cli - reformat & lint

This commit is contained in:
Tomáš Mládek 2021-09-20 22:41:00 +02:00
parent 4d8b0b85dd
commit 85881f877c
2 changed files with 16 additions and 18 deletions

View file

@ -4,9 +4,7 @@ import {
EmulatedCanvas2D, EmulatedCanvas2D,
Image, Image,
} from "https://deno.land/x/canvas/mod.ts"; } from "https://deno.land/x/canvas/mod.ts";
import { import { CollageImage } from "../src/common/types.ts";
CollageImage,
} from "../src/common/types.ts";
import { init } from "https://deno.land/x/canvas@v1.3.0/mod.ts"; import { init } from "https://deno.land/x/canvas@v1.3.0/mod.ts";
const canvasKit = await init(); const canvasKit = await init();
@ -50,17 +48,15 @@ declare module "https://deno.land/x/canvas/mod.ts" {
interface HTMLCanvasElement { interface HTMLCanvasElement {
width: number; width: number;
height: number; height: number;
getContext(x: '2d'): CanvasRenderingContext2D getContext(x: "2d"): CanvasRenderingContext2D;
} }
} }
export class DenoCollageModes export class DenoCollageModes extends CollageModes<
extends CollageModes<
CanvasRenderingContext2D, CanvasRenderingContext2D,
ProxyImage, ProxyImage,
EmulatedCanvas2D EmulatedCanvas2D
> { > {
createCanvas(w: number, h: number): EmulatedCanvas2D { createCanvas(w: number, h: number): EmulatedCanvas2D {
const canvas = canvasKit.MakeCanvas(Math.round(w), Math.round(h)); const canvas = canvasKit.MakeCanvas(Math.round(w), Math.round(h));
if (!canvas) { if (!canvas) {

View file

@ -1,10 +1,12 @@
import { parse } from "https://deno.land/std@0.106.0/flags/mod.ts"; 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 { createCanvas } from "https://deno.land/x/canvas@v1.3.0/mod.ts";
import { collageModeType, DisplayCollageModeType, displayCollageModeType, isCollageModeType, isDisplayCollageModeType } from "../src/common/collages.ts";
import { import {
denoCollageModes, collageModeType,
ProxyImage, DisplayCollageModeType,
} from "./collages.ts"; displayCollageModeType,
isDisplayCollageModeType,
} from "../src/common/collages.ts";
import { denoCollageModes, ProxyImage } from "./collages.ts";
import { CollageConfig } from "../src/common/types.ts"; import { CollageConfig } from "../src/common/types.ts";
import { choice, shuffle } from "../src/common/utils.ts"; import { choice, shuffle } from "../src/common/utils.ts";
import { walkSync } from "https://deno.land/std@0.107.0/fs/mod.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, w: 640,
h: 640, h: 640,
include: "*.png, *.jpg", include: "*.png, *.jpg",
output: "collage.png" output: "collage.png",
} },
}); });
if (args["mode"] === true) { if (args["mode"] === true) {
@ -65,11 +67,11 @@ const allModeKeys: DisplayCollageModeType[] = [];
if (args["mode"]) { if (args["mode"]) {
(args["mode"] as string).split(",").map((m) => m.trim()).forEach((m) => { (args["mode"] as string).split(",").map((m) => m.trim()).forEach((m) => {
if (isDisplayCollageModeType(m)) { if (isDisplayCollageModeType(m)) {
allModeKeys.push(m) allModeKeys.push(m);
} else { } else {
throw Error(`"${m}" is not a valid collage mode.`); throw Error(`"${m}" is not a valid collage mode.`);
} }
}) });
} else { } else {
allModeKeys.push(...displayCollageModeType); allModeKeys.push(...displayCollageModeType);
} }
@ -89,8 +91,8 @@ if (modeKey === "recursive") {
await denoCollageModes.recursiveDraw(context, images, { await denoCollageModes.recursiveDraw(context, images, {
modes: collageModeType, modes: collageModeType,
repeat: true, repeat: true,
level: 3 level: 3,
}) });
} else { } else {
const mode = denoCollageModes.modes[modeKey]; const mode = denoCollageModes.modes[modeKey];
console.log( console.log(