cli - reformat & lint
This commit is contained in:
parent
4d8b0b85dd
commit
85881f877c
2 changed files with 16 additions and 18 deletions
|
@ -4,9 +4,7 @@ import {
|
|||
EmulatedCanvas2D,
|
||||
Image,
|
||||
} from "https://deno.land/x/canvas/mod.ts";
|
||||
import {
|
||||
CollageImage,
|
||||
} from "../src/common/types.ts";
|
||||
import { CollageImage } from "../src/common/types.ts";
|
||||
import { init } from "https://deno.land/x/canvas@v1.3.0/mod.ts";
|
||||
|
||||
const canvasKit = await init();
|
||||
|
@ -50,17 +48,15 @@ declare module "https://deno.land/x/canvas/mod.ts" {
|
|||
interface HTMLCanvasElement {
|
||||
width: number;
|
||||
height: number;
|
||||
getContext(x: '2d'): CanvasRenderingContext2D
|
||||
getContext(x: "2d"): CanvasRenderingContext2D;
|
||||
}
|
||||
}
|
||||
|
||||
export class DenoCollageModes
|
||||
extends CollageModes<
|
||||
export class DenoCollageModes extends CollageModes<
|
||||
CanvasRenderingContext2D,
|
||||
ProxyImage,
|
||||
EmulatedCanvas2D
|
||||
> {
|
||||
|
||||
> {
|
||||
createCanvas(w: number, h: number): EmulatedCanvas2D {
|
||||
const canvas = canvasKit.MakeCanvas(Math.round(w), Math.round(h));
|
||||
if (!canvas) {
|
||||
|
|
22
cli/main.ts
22
cli/main.ts
|
@ -1,10 +1,12 @@
|
|||
import { parse } from "https://deno.land/std@0.106.0/flags/mod.ts";
|
||||
import { createCanvas } from "https://deno.land/x/canvas@v1.3.0/mod.ts";
|
||||
import { collageModeType, DisplayCollageModeType, displayCollageModeType, isCollageModeType, isDisplayCollageModeType } from "../src/common/collages.ts";
|
||||
import {
|
||||
denoCollageModes,
|
||||
ProxyImage,
|
||||
} from "./collages.ts";
|
||||
collageModeType,
|
||||
DisplayCollageModeType,
|
||||
displayCollageModeType,
|
||||
isDisplayCollageModeType,
|
||||
} from "../src/common/collages.ts";
|
||||
import { denoCollageModes, ProxyImage } from "./collages.ts";
|
||||
import { CollageConfig } from "../src/common/types.ts";
|
||||
import { choice, shuffle } from "../src/common/utils.ts";
|
||||
import { walkSync } from "https://deno.land/std@0.107.0/fs/mod.ts";
|
||||
|
@ -22,8 +24,8 @@ const args = parse(Deno.args, {
|
|||
w: 640,
|
||||
h: 640,
|
||||
include: "*.png, *.jpg",
|
||||
output: "collage.png"
|
||||
}
|
||||
output: "collage.png",
|
||||
},
|
||||
});
|
||||
|
||||
if (args["mode"] === true) {
|
||||
|
@ -65,11 +67,11 @@ const allModeKeys: DisplayCollageModeType[] = [];
|
|||
if (args["mode"]) {
|
||||
(args["mode"] as string).split(",").map((m) => m.trim()).forEach((m) => {
|
||||
if (isDisplayCollageModeType(m)) {
|
||||
allModeKeys.push(m)
|
||||
allModeKeys.push(m);
|
||||
} else {
|
||||
throw Error(`"${m}" is not a valid collage mode.`);
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
allModeKeys.push(...displayCollageModeType);
|
||||
}
|
||||
|
@ -89,8 +91,8 @@ if (modeKey === "recursive") {
|
|||
await denoCollageModes.recursiveDraw(context, images, {
|
||||
modes: collageModeType,
|
||||
repeat: true,
|
||||
level: 3
|
||||
})
|
||||
level: 3,
|
||||
});
|
||||
} else {
|
||||
const mode = denoCollageModes.modes[modeKey];
|
||||
console.log(
|
||||
|
|
Loading…
Reference in a new issue