fix linter errors, reformat
This commit is contained in:
parent
1ba396bc7c
commit
0982857082
1 changed files with 36 additions and 19 deletions
|
@ -1,27 +1,44 @@
|
||||||
import { CollageModes, CollageModeType, collageModeType } from "../src/common/collages.ts";
|
import { CollageModes } from "../src/common/collages.ts";
|
||||||
import { CanvasRenderingContext2D, createCanvas, Image, ImageBitmap, loadImage } from "https://deno.land/x/canvas/mod.ts";
|
import {
|
||||||
|
CanvasRenderingContext2D,
|
||||||
|
Image,
|
||||||
|
} from "https://deno.land/x/canvas/mod.ts";
|
||||||
import { CollageContext, CollageImage } from "../src/common/types.ts";
|
import { CollageContext, CollageImage } from "../src/common/types.ts";
|
||||||
|
|
||||||
export class ProxyImage implements CollageImage {
|
export class ProxyImage implements CollageImage {
|
||||||
private image: Image;
|
private image: Image;
|
||||||
public readonly height: number;
|
public readonly height: number;
|
||||||
public readonly width: number;
|
public readonly width: number;
|
||||||
|
|
||||||
constructor(image: Image) {
|
constructor(image: Image) {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
this.width = image.width();
|
this.width = image.width();
|
||||||
this.height = image.height();
|
this.height = image.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(): Image {
|
public get(): Image {
|
||||||
return this.image;
|
return this.image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CastCanvasRenderingContext = CanvasRenderingContext2D & CollageContext;
|
export type CastCanvasRenderingContext =
|
||||||
|
& CanvasRenderingContext2D
|
||||||
|
& CollageContext;
|
||||||
|
|
||||||
export default class BrowserCollageModes extends CollageModes<CastCanvasRenderingContext, ProxyImage> {
|
export default class BrowserCollageModes
|
||||||
drawImage(ctx: CastCanvasRenderingContext, image: ProxyImage, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void {
|
extends CollageModes<CastCanvasRenderingContext, ProxyImage> {
|
||||||
ctx.drawImage(image.get(), sx, sy, sw, sh, dx, dy, dw, dh);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue