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 - ICascadeModel Interface

Hierarchy

Index

Properties

$initial

$initial: any

The initial context object of the cascade.

$reset

$reset: function

Use the $original as the $result.

Type declaration

    • (): this
    • Returns this

$result

$result: any

The current final value of the cascade.

Methods

addCaption

  • Add a Caption object to a model.

    Parameters

    • text: string

      Text to add.

    • Optional leftAnchorPoint: IPoint

      Optional Point on left side middle of text.

    • Optional rightAnchorPoint: IPoint

      Optional Point on right side middle of text.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

addModel

  • Add a model as a child. This is basically equivalent to:

    parentModel.models[childModelId] = childModel;
    

    with additional checks to make it safe for cascading.

    Parameters

    • childModel: IModel

      The model to add.

    • childModelId: string

      The id of the child model.

    • Optional overWrite: boolean

      (default false) Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

addPath

  • Add a path as a child. This is basically equivalent to:

    parentModel.paths[childPathId] = childPath;
    

    with additional checks to make it safe for cascading.

    Parameters

    • pathContext: IPath

      The path to add.

    • pathId: string

      The id of the path.

    • Optional overWrite: boolean

      (default false) Optional flag to overwrite any path referenced by pathId. Default is false, which will create an id similar to pathId.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

addTo

  • Add a model as a child of another model. This is basically equivalent to:

    parentModel.models[childModelId] = childModel;
    

    with additional checks to make it safe for cascading.

    Parameters

    • parentModel: IModel

      The model to add to.

    • childModelId: string

      The id of the child model.

    • Optional overWrite: boolean

      (default false) Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

breakPathsAtIntersections

  • DEPRECATED Break a model's paths everywhere they intersect with another path.

    Parameters

    • Optional modelToIntersect: IModel

      Optional model containing paths to look for intersection, or else the modelToBreak will be used.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

center

  • Center a model at [0, 0].

    Parameters

    • Optional centerX: boolean

      (default true) Boolean to center on the x axis. Default is true.

    • Optional centerY: boolean

      (default true) Boolean to center on the y axis. Default is true.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

clone

combine

  • combine(modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, options?: ICombineOptions): ICascadeModel
  • Combine 2 models. Each model will be modified accordingly.

    Parameters

    • modelB: IModel

      Second model to combine.

    • Optional includeAInsideB: boolean

      (default false) Flag to include paths from modelA which are inside of modelB.

    • Optional includeAOutsideB: boolean

      (default true) Flag to include paths from modelA which are outside of modelB.

    • Optional includeBInsideA: boolean

      (default false) Flag to include paths from modelB which are inside of modelA.

    • Optional includeBOutsideA: boolean

      (default true) Flag to include paths from modelB which are outside of modelA.

    • Optional options: ICombineOptions

      Optional ICombineOptions object.

    Returns ICascadeModel

    this cascade container, this.$result will be A new model containing both of the input models as "a" and "b".

combineIntersection

combineSubtraction

combineUnion

convertUnits

distort

  • distort(scaleX: number, scaleY: number, scaleOrigin?: boolean, bezierAccuracy?: number): ICascadeModel
  • Create a distorted copy of a model - scale x and y individually.

    Parameters

    • scaleX: number

      The amount of x scaling.

    • scaleY: number

      The amount of y scaling.

    • Optional scaleOrigin: boolean

      (default false) Optional boolean to scale the origin point. Typically false for the root model.

    • Optional bezierAccuracy: number

      Optional accuracy of Bezier curves.

    Returns ICascadeModel

    this cascade container, this.$result will be New model (for cascading).

expandPaths

  • Expand all paths in a model, then combine the resulting expansions.

    Parameters

    • distance: number

      Distance to expand.

    • Optional joints: number

      (default 0) Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.

    • Optional combineOptions: ICombineOptions

      (default {}) Optional object containing combine options.

    Returns ICascadeModel

    this cascade container, this.$result will be Model which surrounds the paths of the original model.

layer

mirror

move

  • Move a model to an absolute point. Note that this is also accomplished by directly setting the origin property. This function exists for cascading.

    Parameters

    • origin: IPoint

      The new position of the model.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

moveRelative

originate

  • Moves all of a model's children (models and paths, recursively) in reference to a single common origin. Useful when points between children need to connect to each other.

    Parameters

    • Optional origin: IPoint

      Optional offset reference point.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

outline

  • Outline a model by a specified distance. Useful for accommodating for kerf.

    Parameters

    • distance: number

      Distance to outline.

    • Optional joints: number

      (default 0) Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.

    • Optional inside: boolean

      (default false) Optional boolean to draw lines inside the model instead of outside.

    • Optional options: ICombineOptions

      (default {}) Options to send to combine() function.

    Returns ICascadeModel

    this cascade container, this.$result will be Model which surrounds the paths outside of the original model.

prefixPathIds

removeDeadEnds

  • Remove paths from a model which have endpoints that do not connect to other paths.

    Parameters

    • Optional pointMatchingDistance: number

      Optional max distance to consider two points as the same.

    • Optional keep: IWalkPathBooleanCallback

      Optional callback function (which should return a boolean) to decide if a dead end path should be kept instead.

    • Optional trackDeleted: undefined

      Optional callback function which will log discarded paths and the reason they were discarded.

    Returns ICascadeModel

    this cascade container, this.$result will be The input model (for cascading).

rotate

scale

  • scale(scaleValue: number, scaleOrigin?: boolean): ICascadeModel
  • Scale a model.

    Parameters

    • scaleValue: number

      The amount of scaling.

    • Optional scaleOrigin: boolean

      (default false) Optional boolean to scale the origin point. Typically false for the root model.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

simplify

walk

zero

  • Move a model so its bounding box begins at [0, 0].

    Parameters

    • Optional zeroX: boolean

      (default true) Boolean to zero on the x axis. Default is true.

    • Optional zeroY: boolean

      (default true) Boolean to zero on the y axis. Default is true.

    Returns ICascadeModel

    this cascade container, this.$result will be The original model (for cascading).

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