Class ShapePath

A Path builder that incrementally converts a series of shapes into an array of Paths. For example an SVG shape to a path.

Hierarchy

  • ShapePath

Constructors

  • Creates a new ShapePath. Unlike a Path, no points are passed in as the ShapePath is designed to be generated after creation.

    Returns ShapePath

Properties

color: Color

Color of the shape, by default set to white (0xffffff).

Default Value

new Color()

currentPath: Path

The current Path that is being generated.

Default Value

null

subPaths: Path[]

Array of Paths.

Defaultvalue

[]

type: string

Default Value

'ShapePath'

Methods

  • Create a bezier curve from the currentPath offset to x and y with cp1X, cp1Y and cp2X, cp2Y as control points and updates the currentPath offset to x and y.

    Returns

    This instance.

    Parameters

    • cp1x: number

      Control point1, x coordinate

    • cp1y: number

      Control point1, y coordinate

    • cp2x: number

      Control point2, x coordinate

    • cp2y: number

      Control point2, y coordinate

    • x: number

      end point, x coordinate

    • y: number

      end point, y coordinate

    Returns ShapePath

  • Add a line from the currentPath offset to X and Y and update the offset to X and Y.

    Returns

    This instance.

    Parameters

    • x: number

      The target position x coordinate

    • y: number

      The target position y coordinate

    Returns ShapePath

  • Starts a new Path and calls Path.moveTo( x, y ) on that Path. Also points currentPath to that Path.

    Returns

    This instance.

    Parameters

    • x: number

      The target position x coordinate

    • y: number

      The target position y coordinate

    Returns ShapePath

  • Create a quadratic curve from the currentPath's offset to x and y with cpX and cpY as control point and update the currentPath offset to x and y.

    Returns

    This instance.

    Parameters

    • cpx: number

      The control point x coordinate

    • cpy: number

      The control point y coordinate

    • x: number

      The end point x coordinate

    • y: number

      The end point y coordinate

    Returns ShapePath

  • Connects a new SplineCurve onto the currentPath.

    Returns

    This instance.

    Parameters

    • pts: Vector2[]

      An array of Vector2s

    Returns ShapePath

  • Converts the subPaths array into an array of Shapes. By default solid shapes are defined clockwise (CW) and holes are defined counterclockwise (CCW). If isCCW is set to true, then those are flipped. If the parameter noHoles is set to true then all paths are set as solid shapes and isCCW is ignored.

    Returns

    Array of shapes.

    Parameters

    • isCCW: boolean

      Changes how solids and holes are generated

    • Optional noHoles: boolean

      Whether or not to generate holes

    Returns Shape[]