Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Canvg

SVG renderer on canvas.

Hierarchy

  • Canvg

Index

Constructors

constructor

  • Main constructor.

    Parameters

    • ctx: RenderingContext2D

      Rendering context.

    • svg: DOMDocument

      SVG Document.

    • Default value options: IOptions = {}

      Rendering options.

    Returns Canvg

Properties

document

document: Document

Canvg Document.

Private documentElement

documentElement: SVGElement

Private options

options: IOptions

parser

parser: Parser

XML/HTML parser isntance.

screen

screen: Screen

Screen instance.

Methods

fork

  • fork(ctx: RenderingContext2D, svg: string, options?: IOptions): Promise<Canvg>
  • Create new Canvg instance with inherited options.

    Parameters

    • ctx: RenderingContext2D

      Rendering context.

    • svg: string

      SVG source string or URL.

    • Default value options: IOptions = {}

      Rendering options.

    Returns Promise<Canvg>

forkString

  • forkString(ctx: RenderingContext2D, svg: string, options?: IOptions): Canvg
  • Create new Canvg instance with inherited options.

    Parameters

    • ctx: RenderingContext2D

      Rendering context.

    • svg: string

      SVG source string.

    • Default value options: IOptions = {}

      Rendering options.

    Returns Canvg

isReady

  • isReady(): boolean
  • Document is ready value.

    Returns boolean

ready

  • ready(): Promise<void>
  • Document is ready promise.

    Returns Promise<void>

render

  • Render only first frame, ignoring animations and mouse.

    Parameters

    Returns Promise<void>

resize

  • resize(width: number, height?: number, preserveAspectRatio?: boolean | string): void
  • Resize SVG to fit in given size.

    Parameters

    • width: number
    • Default value height: number = width
    • Default value preserveAspectRatio: boolean | string = false

    Returns void

start

stop

  • stop(): void

Static from

  • from(ctx: RenderingContext2D, svg: string, options?: IOptions): Promise<Canvg>
  • Create Canvg isntance from SVG source string or URL.

    Parameters

    • ctx: RenderingContext2D

      Rendering context.

    • svg: string

      SVG source string or URL.

    • Default value options: IOptions = {}

      Rendering options.

    Returns Promise<Canvg>

Static fromString

  • fromString(ctx: RenderingContext2D, svg: string, options?: IOptions): Canvg
  • Create Canvg isntance from SVG source string.

    Parameters

    • ctx: RenderingContext2D

      Rendering context.

    • svg: string

      SVG source string.

    • Default value options: IOptions = {}

      Rendering options.

    Returns Canvg

Generated using TypeDoc