Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @svg-drawing/core

Index

Type Aliases

CommandObject: { type: CommandType; value: number[] }

Type declaration

CommandType: "M" | "m" | "L" | "l" | "C" | "c" | "Z" | "H" | "h" | "V" | "v" | "A" | "a" | "Q" | "q"

Command Object

DownloadOption: { extension: "svg" | "png" | "jpg"; filename?: string }

Download options

Type declaration

  • extension: "svg" | "png" | "jpg"
  • Optional filename?: string
DrawEventName: Extract<keyof GlobalEventHandlersEventMap, "pointerdown" | "pointermove" | "pointerleave" | "pointercancel" | "pointerup" | "touchstart" | "touchmove" | "touchend" | "touchcancel" | "mousedown" | "mousemove" | "mouseleave" | "mouseout" | "mouseup">
DrawHandlerCallback: { end: any; move: any; start: any }

DrawHandler callback

Type declaration

  • end:function
    • end(): void
    • Returns void

  • move:function
    • Parameters

      Returns void

  • start:function
    • start(): void
    • Returns void

DrawListenerType: "pointer" | "touch" | "mouse"
DrawingOption: RendererOption & { close?: boolean; curve?: boolean; delay?: number; fill?: string; penColor?: string; penWidth?: number }

SvgDrawing options

ListenerMaps: Record<DrawListenerType, { end: DrawEventName[]; frameout: DrawEventName[]; move: DrawEventName[]; start: DrawEventName[] }>
PathObject: {}

Svg Path JSON TODO: improve key types

Type declaration

  • [camelCase: string]: string | undefined
PointObject: { pressure?: number; x: number; y: number }

Path Object

Type declaration

  • Optional pressure?: number
  • x: number
  • y: number
RendererOption: Pick<SvgOption, "background">

Renderer options

ResizeHandlerCallback: { resize: any }

ResizeHandler callback

Type declaration

  • resize:function
    • resize(rect: DOMRect | { height: number; left: number; top: number; width: number }): void
    • Parameters

      • rect: DOMRect | { height: number; left: number; top: number; width: number }

      Returns void

SvgObject: { background?: string; height: number; paths: PathObject[]; width: number }

Svg JSON

Type declaration

  • Optional background?: string
  • height: number
  • paths: PathObject[]
  • width: number
SvgOption: { background?: string; height: number; width: number }

Svg options

Type declaration

  • Optional background?: string
  • height: number
  • width: number

Variables

COMMAND_TYPE: {} = ...

Type declaration

mimeTypeMap: { [ key in DownloadOption["extension"]]: string } = ...

Functions

  • camel2kebab(str: string): string
  • Parameters

    • str: string

    Returns string

  • createSvgChildElement(elname: string, attrs: Attrs): SVGElement
  • Parameters

    • elname: string
    • attrs: Attrs

    Returns SVGElement

  • createSvgElement(attrs: Attrs, childs: SVGElement[]): SVGSVGElement
  • Parameters

    • attrs: Attrs
    • childs: SVGElement[]

    Returns SVGSVGElement

  • download(svg: Svg, opt?: DownloadOption, dlb?: ((__namedParameters: { data: string; extension: "svg" | "png" | "jpg"; filename?: string }) => void)): void
  • Parameters

    • svg: Svg
    • opt: DownloadOption = defaultOpts
    • dlb: ((__namedParameters: { data: string; extension: "svg" | "png" | "jpg"; filename?: string }) => void) = downloadBlob
        • (__namedParameters: { data: string; extension: "svg" | "png" | "jpg"; filename?: string }): void
        • Parameters

          • __namedParameters: { data: string; extension: "svg" | "png" | "jpg"; filename?: string }
            • data: string
            • extension: "svg" | "png" | "jpg"
            • Optional filename?: string

          Returns void

    Returns void

  • downloadBlob(__namedParameters: { data: string; extension: "svg" | "png" | "jpg"; filename?: string }): void
  • Parameters

    • __namedParameters: { data: string; extension: "svg" | "png" | "jpg"; filename?: string }
      • data: string
      • extension: "svg" | "png" | "jpg"
      • Optional filename?: string

    Returns void

  • getPassiveOptions(passive?: boolean): boolean | { passive: boolean }
  • Parameters

    • passive: boolean = true

    Returns boolean | { passive: boolean }

  • isAlmostSameNumber(a: number, b: number): boolean
  • Parameters

    • a: number
    • b: number

    Returns boolean

  • isNaN(num: number): boolean
  • Parameters

    • num: number

    Returns boolean

  • kebab2camel(str: string): string
  • Parameters

    • str: string

    Returns string

  • Parameters

    Returns SVGElement

  • roundUp(num: number, digits?: number): number
  • Parameters

    • num: number
    • digits: number = 2

    Returns number

  • svg2base64(svg: string): string
  • Parameters

    • svg: string

    Returns string

  • svgObjectToElement(__namedParameters: SvgObject): SVGSVGElement
  • Parameters

    Returns SVGSVGElement

  • throttle<T>(func: T, wait: number, options?: Options): ((...args: Parameters<T>) => ReturnType<T> | null)
  • Type Parameters

    • T extends ((...args: any) => any)

    Parameters

    • func: T
    • wait: number
    • options: Options = {}

    Returns ((...args: Parameters<T>) => ReturnType<T> | null)

      • (...args: Parameters<T>): ReturnType<T> | null
      • Parameters

        • Rest ...args: Parameters<T>

        Returns ReturnType<T> | null

  • Parameters

    Returns string

Generated using TypeDoc