Dynamic Icons Scripting Reference - v1.3.0
    Preparing search index...

    Class FreeformPath

    An element for drawing paths/shapes, eg. for styled drawing or for clipping. A path can be specified with either an array of points or an SVG syntax path. When using arrays of points, multiple line segments can be specified by wrapping each segment in its own array.

    Hierarchy (View Summary)

    Implements

    • ILayerElement
    • IPathProducer
    • IValuedElement
    Index

    Accessors

    • get isEmpty(): boolean

      Returns true if there are fewer than 2 points to draw and has no SVG path.

      Returns boolean

    • get path(): null | Path2D

      Returns the currently cached Path2D object, if any, or null otherwise.

      Returns null | Path2D

    • set path(path: null | Path2D): void

      Explicitly sets the cached Path3D object to path. A new path will not be re-generated unless svgPath or lines properties are set, or cache is explicitly cleared with clearCache(). The path will still be scaled and aligned in (), if needed, and the new scaled/aligned path will then be cached.

      Parameters

      Returns void

    • get svgPath(): string

      Set or get the path definition as an SVG path string. Reading the property returns empty unless the property was explicitly set previously.

      Returns string

    • set svgPath(path: string): void

      Parameters

      • path: string

      Returns void

    • get lines(): PointType[][]

      Set or get the path definition as an array or line coordinates. Reading the property returns an empty array unless the property was explicitly set previously.

      Returns PointType[][]

    • set lines(lines: PointType[][]): void

      Parameters

      Returns void

    • get align(): string

      Alignment value as two string values, first for vertical and second for horizontal. Eg. "top left" or "center middle". Setting the property can be done with either a single direction or both (separated by space or comma) in either order.

      Returns string

    • set align(value: string | Alignment): void

      Parameters

      Returns void

    Constructors

    • Parameters

      • Optionalinit: FreeformPathInit

      Returns FreeformPath

    Methods

    • Appends an array of points to the current lines array.

      Parameters

      Returns void

    • Clears all coordinates in the current lines array.

      Returns void

    • Parses and sets the path from an evaluated string value, with minimal validation. First checks value against the cached last value. Returns false if the path hasn't changed or couldn't be loaded.

      Accepted path values:

          "x,y" || "[x,y]" - single point (<pt>), y is optional (defaults to x)
      "<pt>, <pt>, ..." - Multiple points on one path; at least 2 points are required
      "[ <pt>, <pt>, ...], [ <pt>, <pt>, ...], ..." - Multiple paths
      "M..." or "m..." - An SVG path; The action data is evaluated as an interpolated string for embedded JS ('${...}')
      "() => {...}" - A function returning either a points array or an SVG path string.

      Parameters

      • value: string

      Returns boolean

    • Returns the defined path as a Path2D object, scaled to fit into rect bounds (if size units are relative), and combined with any paths in the pathStack according to value of the operation property.

      Parameters

      Returns Path2D

    • Clears the generated & cached Path2D object (if any). Some Path subclasses my not use the cache. Typically the cache management is handled automatically when relevant properties are modified.

      Returns void

    • Sets element width and height property values with optional unit type specifier to use for both dimensions. If unit is undefined then the current unit types for each dimension remain unchanged.

      Parameters

      • size: SizeType
      • Optionalunit: string
      • OptionalunitY: string

      Returns void

    • Returns actual pixel width of this element, either scaled to viewWidth if width unit is % or actual width value if it is in pixels already. If this element's width value is zero then return viewWidth.

      Parameters

      • viewWidth: number

      Returns number

    • Returns actual pixel height of this element, either scaled to viewHeight if height unit is % or actual height value if it is in pixels already. If this element's height value is zero then return viewHeight.

      Parameters

      • viewHeight: number

      Returns number

    Properties

    relativeUnits: boolean = false

    When true, path is scaled to size of drawing rectangle.

    closePath: boolean = false

    true if a closePath() should be used at the of each line segment when crating paths from arrays of points (ignored for SVG paths, use 'Z'/'z' instead).

    operation: PathBoolOperation = PathBoolOperation.None

    Boolean operation to perform with previous path, if any. May be used by subclasses in their IPathProducer#getPath method to automatically combine with other paths.

    layerRole: LayerRole = LayerRole.PathProducer
    width: UnitValue = ...

    A zero width/height (default) indicates to draw into the full available image area (eg. passed to render() in rect argument). Negative values are not allowed.

    height: UnitValue = ...
    alignment: Alignment = Alignment.CENTER

    How to align within drawing area if/when width/height doesn't fill it completely.

    offset: Vect2d = ...

    Extra position offset to apply after alignment. Expressed as a percentage of overall drawing area size.