Maker.js, a Microsoft Garage project, is a JavaScript library for creating and sharing modular line drawings for CNC and laser cutters.

View project on GitHub Star

Api - path Module

Index

Variables

Private breakPathFunctionMap

breakPathFunctionMap: IBreakPathFunctionMap

Private distortMap

distortMap: object

Type declaration

  • [pathType: string]: function

Private filletResultMap

filletResultMap: object

Type declaration

  • [pathType: string]: function

Private guidePathMap

guidePathMap: object

Type declaration

  • [pathType: string]: function
      • Parameters

        • pathContext: IPath
        • filletRadius: number
        • nearPoint: IPoint
        • shardPoint: IPoint
        • isStart: boolean

        Returns IPath

Private map

Private mirrorMap

mirrorMap: object

Type declaration

  • [pathType: string]: function
      • (pathToMirror: IPath, origin: IPoint, mirrorX: boolean, mirrorY: boolean): IPath
      • Parameters

        • pathToMirror: IPath
        • origin: IPoint
        • mirrorX: boolean
        • mirrorY: boolean

        Returns IPath

Private moveMap

moveMap: object

Type declaration

  • [pathType: string]: function

Private moveRelativeMap

moveRelativeMap: object

Type declaration

  • [pathType: string]: function
      • (pathToMove: IPath, delta: IPoint, subtract: boolean): void
      • Parameters

        Returns void

Private propertyNamesMap

propertyNamesMap: object

Type declaration

  • [pathType: string]: function
      • (pathToInspect: IPath): string[]
      • Parameters

        Returns string[]

Private rotateMap

rotateMap: object

Type declaration

  • [pathType: string]: function
      • (pathToRotate: IPath, angleInDegrees: number, rotationOrigin: IPoint): void
      • Parameters

        • pathToRotate: IPath
        • angleInDegrees: number
        • rotationOrigin: IPoint

        Returns void

Private scaleMap

scaleMap: object

Type declaration

  • [pathType: string]: function
      • (pathValue: IPath, scaleValue: number): void
      • Parameters

        • pathValue: IPath
        • scaleValue: number

        Returns void

Functions

breakAtPoint

  • Breaks a path in two. The supplied path will end at the supplied pointOfBreak, a new path is returned which begins at the pointOfBreak and ends at the supplied path's initial end point. For Circle, the original path will be converted in place to an Arc, and null is returned.

    Parameters

    • pathToBreak: IPath

      The path to break.

    • pointOfBreak: IPoint

      The point at which to break the path.

    Returns IPath

    A new path of the same type, when path type is line or arc. Returns null for circle.

Private circleToCircle

clone

  • Create a clone of a path. This is faster than cloneObject.

    Parameters

    • pathToClone: IPath

      The path to clone.

    Returns IPath

    Cloned path.

Private cloneAndBreakPath

converge

  • Connect 2 lines at their slope intersection point.

    Parameters

    • lineA: IPathLine

      First line to converge.

    • lineB: IPathLine

      Second line to converge.

    • Optional useOriginA: boolean

      Optional flag to converge the origin point of lineA instead of the end point.

    • Optional useOriginB: boolean

      Optional flag to converge the origin point of lineB instead of the end point.

    Returns IPoint

Private copyLayer

distort

  • Distort a path - scale x and y individually.

    Parameters

    • pathToDistort: IPath

      The path to distort.

    • scaleX: number

      The amount of x scaling.

    • scaleY: number

      The amount of y scaling.

    Returns IModel | IPath

    A new IModel (for circles and arcs) or IPath (for lines and bezier seeds).

dogbone

  • Adds a round corner to the outside angle between 2 lines. The lines must meet at one point.

    Parameters

    • lineA: IPathLine

      First line to fillet, which will be modified to fit the fillet.

    • lineB: IPathLine

      Second line to fillet, which will be modified to fit the fillet.

    • filletRadius: number
    • Optional options: IPointMatchOptions

    Returns IPathArc

    Arc path object of the new fillet.

expand

  • expand(pathToExpand: IPath, expansion: number, isolateCaps?: boolean): IModel
  • Expand path by creating a model which surrounds it.

    Parameters

    • pathToExpand: IPath

      Path to expand.

    • expansion: number

      Distance to expand.

    • Optional isolateCaps: boolean

      Optional flag to put the end caps into a separate model named "caps".

    Returns IModel

    Model which surrounds the path.

fillet

  • Adds a round corner to the inside angle between 2 paths. The paths must meet at one point.

    Parameters

    • pathA: IPath

      First path to fillet, which will be modified to fit the fillet.

    • pathB: IPath

      Second path to fillet, which will be modified to fit the fillet.

    • filletRadius: number
    • Optional options: IPointMatchOptions

    Returns IPathArc

    Arc path object of the new fillet.

Private findCorrespondingAngleIndex

  • findCorrespondingAngleIndex(circleAngles: number[], arcAngle: number[]): number

Private getAnglesWithinArc

Private getDogboneResult

Private getFilletResult

Private getGuidePath

Private getLineRatio

Private getMatchingPointProperties

Private getPointProperties

intersection

  • Find the point(s) where 2 paths intersect.

    Parameters

    • path1: IPath

      First path to find intersection.

    • path2: IPath

      Second path to find intersection.

    • Default value options: IPathIntersectionOptions = {}

      Optional IPathIntersectionOptions.

    Returns IPathIntersection

    IPathIntersection object, with points(s) of intersection (and angles, when a path is an arc or circle); or null if the paths did not intersect.

Private lineToCircle

mirror

  • mirror(pathToMirror: IPath, mirrorX: boolean, mirrorY: boolean): IPath
  • Create a clone of a path, mirrored on either or both x and y axes.

    Parameters

    • pathToMirror: IPath

      The path to mirror.

    • mirrorX: boolean

      Boolean to mirror on the x axis.

    • mirrorY: boolean

      Boolean to mirror on the y axis.

    Returns IPath

    Mirrored path.

move

  • Move a path to an absolute point.

    Parameters

    • pathToMove: IPath

      The path to move.

    • origin: IPoint

      The new origin for the path.

    Returns IPath

    The original path (for chaining).

moveRelative

  • Move a path's origin by a relative amount.

    Parameters

    • pathToMove: IPath

      The path to move.

    • delta: IPoint

      The x & y adjustments as a point object.

    • Optional subtract: boolean

      Optional boolean to subtract instead of add.

    Returns IPath

    The original path (for chaining).

Private moveTemp

moveTemporary

  • moveTemporary(pathsToMove: IPath[], deltas: IPoint[], task: Function): void
  • Move some paths relatively during a task execution, then unmove them.

    Parameters

    • pathsToMove: IPath[]

      The paths to move.

    • deltas: IPoint[]

      The x & y adjustments as a point object array.

    • task: Function

      The function to call while the paths are temporarily moved.

    Returns void

Private pointsFromAnglesOnCircle

Private populateShardPointsFromReferenceCircle

rotate

  • rotate(pathToRotate: IPath, angleInDegrees: number, rotationOrigin: IPoint): IPath
  • Rotate a path.

    Parameters

    • pathToRotate: IPath

      The path to rotate.

    • angleInDegrees: number

      The amount of rotation, in degrees.

    • rotationOrigin: IPoint

      The center point of rotation.

    Returns IPath

    The original path (for chaining).

scale

  • scale(pathToScale: IPath, scaleValue: number): IPath
  • Scale a path.

    Parameters

    • pathToScale: IPath

      The path to scale.

    • scaleValue: number

      The amount of scaling.

    Returns IPath

    The original path (for chaining).

straighten

  • straighten(arc: IPathArc, bevel?: boolean, prefix?: string, close?: boolean): IModel
  • Represent an arc using straight lines.

    Parameters

    • arc: IPathArc

      Arc to straighten.

    • Optional bevel: boolean

      Optional flag to bevel the angle to prevent it from being too sharp.

    • Optional prefix: string

      Optional prefix to apply to path ids.

    • Optional close: boolean

    Returns IModel

    Model of straight lines with same endpoints as the arc.

Private swapAngles

Private testFilletResult

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc