Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/canvas/mod.ts

Canvas API for Deno, ported from canvaskit-wasm (Skia).
Go to Latest
import * as canvas from "https://deno.land/x/canvas@v1.0.4/mod.ts";

Interfaces

An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient().

An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method.

The CanvasRenderingContext2D export interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects.

The currently supported color spaces. These are all singleton values.

Represents the set of enum values.

Represents a single member of an enum.

CanvasKit is built with Emscripten and Embind. Embind adds the following methods to all objects that are exposed with it.

See GrContext.h for more on this class.

A constructor for making an ImageData that is compatible with the Canvas2D emulation code.

This object is a wrapper around a pointer to some memory on the WASM heap. The type of the pointer was determined at creation time.

TODO(kjlubick) Make this API return Float32Arrays

See SkM44.h for more details.

See Paragraph.h for more information on this class. This is only available if Paragraph has been compiled in.

See SkParticleEffect.h for more details.

A simple wrapper around SkTextBlob and the simple Text Shaper.

This class is an abstraction around SkShaper.h

See SkAnimatedImage.h for more information on this class.

See SkCanvas.h for more information on this class.

See SkColorFilter.h for more.

Represents a blob of memory. See SkData.h for more on this class.

See SkFont.h for more on this class.

See SkFont.h for more.

See SkFontMgr.h for more details

See SkImage.h for more information on this class.

See effects/SkImageFilters.h for more.

See SkMaskFilter.h for more details.

See SkPaint.h for more information on this class.

See SkPath.h for more information on this class.

Contains the ways to create an SkPath.

See SkPathEffect.h for more details.

See SkPicture.h for more information on this class.

See SkRuntimeEffect.h for more details.

See SkRuntimeEffect.h for more details.

For more information, see SkShaders.h. TODO(kjlubick) Rename these to Make* as per the convention

See SkTextBlob.h for more details.

See SkVertices.h for more on this class.

Options used for SkPath.stroke(). If an option is omitted, a sensible default will be used.

Functions for manipulating vectors. It is Loosely based off of SkV3 in SkM44.h but Skia also has SkVec2 and Skv4. This combines them and works on vectors of any length.

Options for configuring a WebGL context. If an option is omitted, a sensible default will be used. These are defined by the WebGL standards.

Type Aliases

Part of the Canvas2D emulation code

FlattenedPointArray represents n points by 2*n float values. In order, the values should be the x, y for each point.

FlattenedRectangleArray represents n rectangles by 4*n float values. In order, the values should be the top, left, right, bottom point for each rectangle.

Regardless of the format we use internally for GlyphID (16 bit unsigned atm), we expose them as 32 bit unsigned.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as colors. Length 4.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as color matrices. Length 20.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as flattened points. Length 2 * n for n points.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as flattened rectangles. Length 4 * n for n rectangles.

This represents n RSXforms by 4*n float values. In order, the values should be scos, ssin, tx, ty for each RSXForm. See RSXForm.h for more details.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as glyph IDs. Length n for n glyph IDs.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as (int) rectangles. Length 4.

CanvasKit APIs accept all of these matrix types. Under the hood, we generally use 4x4 matrices.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as rectangles. Length 4.

CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as rectangles with rounded corners. Length 12.

PathCommand contains a verb and then any arguments needed to fulfill that path verb. Examples: [CanvasKit.MOVE_VERB, 0, 10] [CanvasKit.LINE_VERB, 30, 40] TODO(kjlubick) Make this not be a 2-d array and support typed arrays.

A PosTan is an array of 4 values, representing a position and a tangent vector. In order, the values are [px, py, tx, ty].

An SkColor is represented by 4 floats, typically with values between 0 and 1.0. In order, the floats correspond to red, green, blue, alpha.

See SkColorFilter.h for more on this class. The objects are opaque.

An SkColorMatrix is a 4x4 color matrix that transforms the 4 color channels with a 1x4 matrix that post-translates those 4 channels. For example, the following is the layout with the scale (S) and post-transform (PT) items indicated. RS, 0, 0, 0 | RPT 0, GS, 0, 0 | GPT 0, 0, BS, 0 | BPT 0, 0, 0, AS | APT

See SkImageFilter.h for more on this class. The objects are opaque.

An SkIRect is represented by 4 ints. In order, the ints correspond to left, top, right, bottom. See SkRect.h for more

See SkMaskFilter.h for more on this class. The objects are opaque.

See SkPathEffect.h for more on this class. The objects are opaque.

An SkPoint is represented by 2 floats: (x, y).

An SkRect is represented by 4 floats. In order, the floats correspond to left, top, right, bottom. See SkRect.h for more

An SkRRect (rectangle with rounded corners) is represented by 12 floats. In order, the floats correspond to left, top, right, bottom and then in pairs, the radiusX, radiusY for upper-left, upper-right, lower-right, lower-left. See SkRRect.h for more.

See SkShader.h for more on this class. The objects are opaque.

See SkTextBlob.h for more on this class. The objects are opaque.

See SkTypeface.h for more on this class. The objects are opaque.

Vector3 represents an x, y, z coordinate or vector. It has length 3.

VectorN represents a vector of length n.

VerbList holds verb constants like CanvasKit.MOVE_VERB, CanvasKit.CUBIC_VERB.

WeightList holds weights for conics when making paths.