A 2D context that writes SVG. Construct one at the document's media size, hand it (cast) to whatever paints, and read toString().

Constructors

Properties

canvas: undefined = undefined

Deliberately undefined: a primitive that wants an offscreen canvas asks the context for its element, and the honest answer is that there is none.

fillStyle: string | SvgLinearGradient = '#000'
font: string = '10px sans-serif'
globalAlpha: number = 1
globalCompositeOperation: string = 'source-over'
height: number
imageSmoothingEnabled: boolean = true
lineCap: CanvasLineCap = 'butt'
lineJoin: CanvasLineJoin = 'miter'
lineWidth: number = 1
miterLimit: number = 10
shadowBlur: number = 0
shadowColor: string = 'rgba(0, 0, 0, 0)'
shadowOffsetX: number = 0
shadowOffsetY: number = 0
strokeStyle: string | SvgLinearGradient = '#000'
textAlign: CanvasTextAlign = 'start'
textBaseline: CanvasTextBaseline = 'alphabetic'
unsupported: string[] = []

Names of the calls that could not be exported, first occurrence only.

width: number

Methods

  • Parameters

    • x: number
    • y: number
    • r: number
    • a0: number
    • a1: number
    • ccw: boolean = false

    Returns void

  • This context typed as the canvas one the paint code is written against.

    Returns CanvasRenderingContext2D

  • Parameters

    • c1x: number
    • c1y: number
    • c2x: number
    • c2y: number
    • x: number
    • y: number

    Returns void

  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • Parameters

    • Optionalrule: CanvasFillRule | Path2D

    Returns void

  • An <img> becomes an <image> of its src; a canvas becomes one of its data URL. The nine-argument crop is a nested <svg> whose viewBox is the source rectangle. Anything else (an ImageBitmap, a video frame) has no URL to point at and is skipped.

    Parameters

    • source: CanvasImageSource
    • ...args: number[]

    Returns void

  • Parameters

    • x: number
    • y: number
    • rx: number
    • ry: number
    • rotation: number
    • a0: number
    • a1: number
    • ccw: boolean = false

    Returns void

  • Parameters

    • Optionalrule: CanvasFillRule | Path2D
    • Optional_rule: CanvasFillRule

    Returns void

  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • Parameters

    • text: string
    • x: number
    • y: number

    Returns void

  • Open an explicit <g> with the given attributes, optionally translated and clipped to a rectangle in the group's own coordinates. The chart wraps each pane in one so the export carries the same per-pane offset and clip the DOM stacking gives the canvases. Balanced by popGroup.

    Parameters

    • attrs: Record<string, string | number>
    • options: {
          clip?: { height: number; width: number; x: number; y: number };
          translate?: { x: number; y: number };
      } = {}

    Returns void

  • Parameters

    • cx: number
    • cy: number
    • x: number
    • y: number

    Returns void

  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • The radii argument takes the forms the paint code uses: one number, or an array of up to four (top-left, top-right, bottom-right, bottom-left, the CSS order). Radii are scaled down together when they would overlap, as the canvas does, so a pill shorter than its radius stays a pill.

    Parameters

    • x: number
    • y: number
    • w: number
    • h: number
    • radii: number | number[] = 0

    Returns void

  • Parameters

    • x: number
    • y: number
    • w: number
    • h: number

    Returns void

  • The document. Groups still open (a paint that ended inside a save) are closed here without being popped, so the string is the same however many times it is read.

    Returns string