This commit is contained in:
parent
11fa3d1558
commit
ad01868a9f
23 changed files with 328 additions and 97 deletions
|
|
@ -1,5 +1,13 @@
|
|||
import { asInt } from "@thi.ng/color-palettes";
|
||||
import { ARGB8888, canvasFromPixelBuffer, defIndexed, imageFromURL, intBufferFromImage } from "@thi.ng/pixel";
|
||||
import {
|
||||
ARGB8888,
|
||||
canvasFromPixelBuffer,
|
||||
defIndexed,
|
||||
imageFromURL,
|
||||
IntBuffer,
|
||||
intBufferFromImage,
|
||||
type IntFormat,
|
||||
} from "@thi.ng/pixel";
|
||||
import { ATKINSON, ditherWith } from "@thi.ng/pixel-dither";
|
||||
import { Data, Effect, pipe } from "effect";
|
||||
|
||||
|
|
@ -10,12 +18,12 @@ export class Images extends Effect.Service<Images>()("Images", {
|
|||
return {
|
||||
ditherImage: (image: HTMLImageElement, parent?: HTMLElement) =>
|
||||
Effect.gen(function*() {
|
||||
const buf = intBufferFromImage(image, ARGB8888).scale(0.8, "cubic");
|
||||
const theme = defIndexed(asInt(["salmon", "black"]));
|
||||
const ditheredBuf = ditherWith(ATKINSON, buf.copy(), {}).as(theme);
|
||||
const buf: IntBuffer = intBufferFromImage(image, ARGB8888).scale(0.8, "cubic");
|
||||
const theme: IntFormat = defIndexed(asInt(["salmon", "black"]));
|
||||
const ditheredBuffer: IntBuffer = ditherWith(ATKINSON, buf.copy(), {}).as(theme);
|
||||
|
||||
const canvas = canvasFromPixelBuffer(ditheredBuf, parent, { pixelated: true });
|
||||
return canvas;
|
||||
const canvas = canvasFromPixelBuffer(ditheredBuffer, parent, { pixelated: true });
|
||||
return { buffer: ditheredBuffer, canvas: canvas };
|
||||
}),
|
||||
imageFromUrl: (url: URL) =>
|
||||
pipe(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { SQLocalDrizzle } from "sqlocal/drizzle";
|
||||
|
||||
import v0000 from "@/db/drizzle/0000_unusual_karen_page.sql?raw";
|
||||
import v0000 from "@/db/drizzle/0000_goofy_vanisher.sql?raw";
|
||||
import { Data, Effect } from "effect";
|
||||
|
||||
import { LocalSqlite } from "./db";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue