Skip to main content
Module

x/skia_canvas/mod.ts>Canvas

Fast HTML Canvas API implementation for Deno using Skia.
Go to Latest
class Canvas
Re-export
import { Canvas } from "https://deno.land/x/skia_canvas@0.2.0/mod.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.

Constructors

new
Canvas(width: number, height: number)

Properties

readonly
_unsafePointer
readonly
height
readonly
pixels

Zero-copy pixels buffer that gets drawn into

readonly
width

Methods

encode(format?: ImageFormat, quality?)

Encode the canvas image into a buffer in specified format and quality.

readPixels(
x?: number,
y?: number,
width?: number,
height?: number,
into?: Uint8Array,
colorSpace?: ColorSpace,
)

Read pixels from the canvas into a buffer.

save(
path: string,
format?: ImageFormat,
quality?,
)

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.