fix linter errors, reformat

This commit is contained in:
Tomáš Mládek 2021-09-15 21:19:03 +02:00
parent 1ba396bc7c
commit 0982857082

View file

@ -1,27 +1,44 @@
import { CollageModes, CollageModeType, collageModeType } from "../src/common/collages.ts";
import { CanvasRenderingContext2D, createCanvas, Image, ImageBitmap, loadImage } from "https://deno.land/x/canvas/mod.ts";
import { CollageModes } from "../src/common/collages.ts";
import {
CanvasRenderingContext2D,
Image,
} from "https://deno.land/x/canvas/mod.ts";
import { CollageContext, CollageImage } from "../src/common/types.ts";
export class ProxyImage implements CollageImage {
private image: Image;
public readonly height: number;
public readonly width: number;
private image: Image;
public readonly height: number;
public readonly width: number;
constructor(image: Image) {
this.image = image;
this.width = image.width();
this.height = image.height();
}
constructor(image: Image) {
this.image = image;
this.width = image.width();
this.height = image.height();
}
public get(): Image {
return this.image;
}
public get(): Image {
return this.image;
}
}
export type CastCanvasRenderingContext = CanvasRenderingContext2D & CollageContext;
export type CastCanvasRenderingContext =
& CanvasRenderingContext2D
& CollageContext;
export default class BrowserCollageModes extends CollageModes<CastCanvasRenderingContext, ProxyImage> {
drawImage(ctx: CastCanvasRenderingContext, image: ProxyImage, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void {
ctx.drawImage(image.get(), sx, sy, sw, sh, dx, dy, dw, dh);
}
}
export default class BrowserCollageModes
extends CollageModes<CastCanvasRenderingContext, ProxyImage> {
drawImage(
ctx: CastCanvasRenderingContext,
image: ProxyImage,
sx: number,
sy: number,
sw: number,
sh: number,
dx: number,
dy: number,
dw: number,
dh: number,
): void {
ctx.drawImage(image.get(), sx, sy, sw, sh, dx, dy, dw, dh);
}
}