import { CollageModes, CollageModeType, collageModeType } from "../src/common/collages.ts"; import { CanvasRenderingContext2D, createCanvas, Image, ImageBitmap, loadImage } 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; constructor(image: Image) { this.image = image; this.width = image.width(); this.height = image.height(); } public get(): Image { return this.image; } } export type CastCanvasRenderingContext = CanvasRenderingContext2D & CollageContext; export default class BrowserCollageModes extends CollageModes { 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); } }