Class SVGRenderer

Renders onto an SVGElement.

Hierarchy (View Summary)

Constructors

Properties

objectLevel: number = 0

Methods

  • Adds a copy of the given element directly to the container SVG element, without applying transforms.

    If sanitize is enabled, this does nothing.

    Parameters

    • elem: SVGElement

    Returns void

  • Allows rendering directly to the underlying SVG element. Rendered content is added to a <g> element that's passed as parent to callback.

    Note: Unlike drawSVGElem, this method can be used even if sanitize is true. In this case, it's the responsibility of callback to ensure that everything added to parent is safe to render.

    Parameters

    • callback: (parent: SVGGElement, context: DrawWithSVGParentContext) => void

    Returns void

  • Notes the end of an object.

    Parameters

    • OptionalloaderData: LoadSaveDataTable

      a map from strings to JSON-ifyable objects and contains properties attached to the object by whatever loader loaded the image. This is used to preserve attributes not supported by js-draw when loading/saving an image. Renderers may ignore this.

    • OptionalelemClassNames: string[]

      a list of labels (e.g. classNames) to be attached to the object. Renderers may ignore this.

    Returns void

  • Creates a new SVG element and SVGRenerer with width, height, viewBox, and other metadata attributes set for the given Viewport.

    If options is a boolean, it is interpreted as whether to sanitize (not add unknown SVG entities to) the output.

    Parameters

    • viewport: Viewport
    • options: boolean | FromViewportOptions = true

    Returns { element: SVGSVGElement; renderer: SVGRenderer }

OpenSource licenses