v5.0.0
    Preparing search index...

    Class SVGContext

    SVG rendering context with an API similar to CanvasRenderingContext2D.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    attributes: Attributes
    backgroundFillStyle: string = 'white'
    element: HTMLElement
    fontCSSString: string = ''

    Formatted as CSS font shorthand (e.g., 'italic bold 12pt Arial')

    groupAttributes: Attributes[]
    groups: SVGGElement[]
    height: number = 0
    parent: SVGGElement
    path: string
    pen: { x: number; y: number }
    precision: number = 1
    state: Attributes
    stateStack: State[]
    svg: SVGSVGElement
    width: number = 0
    measureTextElement: Element = ...

    Accessors

    • get fillStyle(): string | CanvasGradient | CanvasPattern

      Returns string | CanvasGradient | CanvasPattern

    • set fillStyle(style: string | CanvasGradient | CanvasPattern): void

      Parameters

      • style: string | CanvasGradient | CanvasPattern

      Returns void

    • get strokeStyle(): string | CanvasGradient | CanvasPattern

      Returns string | CanvasGradient | CanvasPattern

    • set strokeStyle(style: string | CanvasGradient | CanvasPattern): void

      Parameters

      • style: string | CanvasGradient | CanvasPattern

      Returns void

    Methods

    • Parameters

      • x: number
      • y: number
      • radius: number
      • startAngle: number
      • endAngle: number
      • counterclockwise: boolean

      Returns this

    • Parameters

      • x1: number
      • y1: number
      • x2: number
      • y2: number
      • x: number
      • y: number

      Returns this

    • Use one of the overload signatures to create an SVG element of a specific type. The last overload accepts an arbitrary string, and is identical to the implementation signature. Feel free to add new overloads for other SVG element types as required.

      Parameters

      • svgElementType: "g"

      Returns SVGGElement

    • Use one of the overload signatures to create an SVG element of a specific type. The last overload accepts an arbitrary string, and is identical to the implementation signature. Feel free to add new overloads for other SVG element types as required.

      Parameters

      • svgElementType: "path"

      Returns SVGPathElement

    • Use one of the overload signatures to create an SVG element of a specific type. The last overload accepts an arbitrary string, and is identical to the implementation signature. Feel free to add new overloads for other SVG element types as required.

      Parameters

      • svgElementType: "rect"

      Returns SVGRectElement

    • Use one of the overload signatures to create an SVG element of a specific type. The last overload accepts an arbitrary string, and is identical to the implementation signature. Feel free to add new overloads for other SVG element types as required.

      Parameters

      • svgElementType: "svg"

      Returns SVGSVGElement

    • Use one of the overload signatures to create an SVG element of a specific type. The last overload accepts an arbitrary string, and is identical to the implementation signature. Feel free to add new overloads for other SVG element types as required.

      Parameters

      • svgElementType: "text"

      Returns SVGTextElement

    • Use one of the overload signatures to create an SVG element of a specific type. The last overload accepts an arbitrary string, and is identical to the implementation signature. Feel free to add new overloads for other SVG element types as required.

      Parameters

      • svgElementType: string

      Returns SVGElement

    • Parameters

      • Optionalf: string | FontInfo

        is 1) a FontInfo object or 2) a string formatted as CSS font shorthand (e.g., 'bold 10pt Arial') or 3) a string representing the font family (one of size, weight, or style must also be provided).

      • Optionalsize: string | number

        a string specifying the font size and unit (e.g., '16pt'), or a number (the unit is assumed to be 'pt').

      • Optionalweight: string | number

        is a string (e.g., 'bold', 'normal') or a number (100, 200, ... 900). It is inserted into the font-weight attribute (e.g., font-weight="bold")

      • Optionalstyle: string

        is a string (e.g., 'italic', 'normal') that is inserted into the font-style attribute (e.g., font-style="italic")

      Returns this

    • Parameters

      • blur: number

        A non-negative float specifying the level of shadow blur, where 0 represents no blur and larger numbers represent increasingly more blur.

      Returns this

      this

    • 1 arg: string in the "x y w h" format 4 args: x:number, y:number, w:number, h:number

      Parameters

      • viewBoxOrMinX: string | number
      • OptionalminY: number
      • Optionalwidth: number
      • Optionalheight: number

      Returns void