import { Canvas } from "https://deno.land/x/skia_canvas@0.5.1/src/canvas.ts";
Canvas is an offscreen surface that can be drawn to.
Internally it uses Skia's SkSurface
and raster backend.
API is mostly compatible with the Web's OffscreenCanvas
API,
however we also have some non-standard methods such as save
.
Methods
encode(format?: ImageFormat, quality?)
Encode the canvas image into a buffer in specified format and quality.
flush()
Only for GPU backed: Flushes all draw calls, call before swap
getContext(type: "2d"): CanvasRenderingContext2D
Read pixels from the canvas into a buffer.
resize(width: number, height: number)
save()
Save the canvas image to a file encoded in specified format and quality.
Quality is a factor between 0 and 100, where 100 is the best quality. It represents different factors for different formats.
toDataURL(format?: ImageFormat, quality?)