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 - model Module

Index

Functions

Private addOrDeleteSegments

  • addOrDeleteSegments(crossedPath: ICrossedPath, includeInside: boolean, includeOutside: boolean, keepDuplicates: boolean, atlas: Atlas): void

Private addUniquePoints

  • addUniquePoints(pointArray: IPoint[], pointsToAdd: IPoint[]): number

Private breakAllPathsAtIntersections

Private breakAlongForeignPath

breakPathsAtIntersections

  • breakPathsAtIntersections(modelToBreak: IModel, modelToIntersect?: IModel): void
  • Break a model's paths everywhere they intersect with another path.

    Parameters

    • modelToBreak: IModel

      The model containing paths to be broken.

    • Optional modelToIntersect: IModel

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

    Returns void

center

Private checkForEqualOverlaps

Private checkForOverlaps

  • checkForOverlaps(refPaths: IWalkPath[], isOverlapping: function, overlapUnion: function): void
  • Parameters

    • refPaths: IWalkPath[]
    • isOverlapping: function
        • (pathA: IPath, pathB: IPath, excludeTangents: boolean): boolean
        • Parameters

          • pathA: IPath
          • pathB: IPath
          • excludeTangents: boolean

          Returns boolean

    • overlapUnion: function

    Returns void

Private checkInsideForeignModel

Private collectLoop

combine

  • combine(modelA: IModel, modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, options?: ICombineOptions): void
  • Combine 2 models.

    Parameters

    • modelA: IModel

      First model to combine.

    • modelB: IModel

      Second model to combine.

    • Default value includeAInsideB: boolean = false

      Flag to include paths from modelA which are inside of modelB.

    • Default value includeAOutsideB: boolean = true

      Flag to include paths from modelA which are outside of modelB.

    • Default value includeBInsideA: boolean = false

      Flag to include paths from modelB which are inside of modelA.

    • Default value includeBOutsideA: boolean = true

      Flag to include paths from modelB which are outside of modelA.

    • Optional options: ICombineOptions

    Returns void

combineIntersection

  • Combine 2 models, resulting in a intersection.

    Parameters

    • modelA: IModel

      First model to combine.

    • modelB: IModel

      Second model to combine.

    Returns void

combineSubtraction

  • Combine 2 models, resulting in a subtraction of B from A.

    Parameters

    • modelA: IModel

      First model to combine.

    • modelB: IModel

      Second model to combine.

    Returns void

combineUnion

  • Combine 2 models, resulting in a union.

    Parameters

    • modelA: IModel

      First model to combine.

    • modelB: IModel

      Second model to combine.

    Returns void

convertUnits

  • convertUnits(modeltoConvert: IModel, destUnitType: string): IModel
  • Convert a model to match a different unit system.

    Parameters

    • modeltoConvert: IModel

      The model to convert.

    • destUnitType: string

      The unit system.

    Returns IModel

    The scaled model (for chaining).

countChildModels

  • countChildModels(modelContext: IModel): number
  • Count the number of child models within a given model.

    Parameters

    • modelContext: IModel

      The model containing other models.

    Returns number

    Number of child models.

detachLoop

  • detachLoop(loopToDetach: IModel): void
  • Remove all paths in a loop model from the model(s) which contained them.

    Parameters

    • loopToDetach: IModel

      The model to search for loops.

    Returns void

expandPaths

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

    Parameters

    • modelToExpand: IModel

      Model to expand.

    • distance: number

      Distance to expand.

    • Default value joints: number = 0

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

    • Default value combineOptions: ICombineOptions = {}

    Returns IModel

    Model which surrounds the paths of the original model.

findChains

findLoops

  • Find paths that have common endpoints and form loops.

    Parameters

    Returns IModel

    A new model with child models ranked according to their containment within other found loops. The paths of models will be IPathDirectionalWithPrimeContext.

Private follow

Private followLinks

Private getFirstPathFromModel

Private getNonZeroSegments

Private getOpposedLink

getSimilarModelId

  • getSimilarModelId(modelContext: IModel, modelId: string): string
  • Get an unused id in the models map with the same prefix.

    Parameters

    • modelContext: IModel

      The model containing the models map.

    • modelId: string

      The id to use directly (if unused), or as a prefix.

    Returns string

getSimilarPathId

  • getSimilarPathId(modelContext: IModel, pathId: string): string
  • Get an unused id in the paths map with the same prefix.

    Parameters

    • modelContext: IModel

      The model containing the paths map.

    • pathId: string

      The id to use directly (if unused), or as a prefix.

    Returns string

isPathInsideModel

  • Check to see if a path is inside of a model.

    Parameters

    • pathContext: IPath

      The path to check.

    • modelContext: IModel

      The model to check against.

    • Optional pathOffset: IPoint
    • Optional farPoint: IPoint

      Optional point of reference which is outside the bounds of the modelContext.

    • Optional measureAtlas: Atlas

    Returns boolean

    Boolean true if the path is inside of the modelContext.

mirror

  • mirror(modelToMirror: IModel, mirrorX: boolean, mirrorY: boolean): IModel
  • Create a clone of a model, mirrored on either or both x and y axes.

    Parameters

    • modelToMirror: IModel

      The model to mirror.

    • mirrorX: boolean

      Boolean to mirror on the x axis.

    • mirrorY: boolean

      Boolean to mirror on the y axis.

    Returns IModel

    Mirrored model.

move

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

    Parameters

    • modelToMove: IModel

      The model to move.

    • origin: IPoint

      The new position of the model.

    Returns IModel

    The original model (for chaining).

moveRelative

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

    Parameters

    • modelToMove: IModel

      The model to move.

    • delta: IPoint

      The x & y adjustments as a point object.

    Returns IModel

    The original model (for chaining).

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

    • modelToOriginate: IModel

      The model to originate.

    • Optional origin: IPoint

      Optional offset reference point.

    Returns IModel

outline

  • outline(modelToOutline: IModel, distance: number, joints?: number, inside?: boolean): IModel
  • Outline a model by a specified distance. Useful for accommodating for kerf.

    Parameters

    • modelToOutline: IModel

      Model to outline.

    • distance: number

      Distance to outline.

    • Default value joints: number = 0

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

    • Default value inside: boolean = false

      Optional boolean to draw lines inside the model instead of outside.

    Returns IModel

    Model which surrounds the paths outside of the original model.

prefixPathIds

  • prefixPathIds(modelToPrefix: IModel, prefix: string): IModel
  • Prefix the ids of paths in a model.

    Parameters

    • modelToPrefix: IModel

      The model to prefix.

    • prefix: string

      The prefix to prepend on paths ids.

    Returns IModel

    The original model (for chaining).

removeDeadEnds

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

    Parameters

    Returns IModel

    The input model (for chaining).

rotate

  • Rotate a model.

    Parameters

    • modelToRotate: IModel

      The model to rotate.

    • angleInDegrees: number

      The amount of rotation, in degrees.

    • rotationOrigin: IPoint

      The center point of rotation.

    Returns IModel

    The original model (for chaining).

scale

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

    Parameters

    • modelToScale: IModel

      The model to scale.

    • scaleValue: number

      The amount of scaling.

    • Default value scaleOrigin: boolean = false

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

    Returns IModel

    The original model (for chaining).

simplify

  • Simplify a model's paths by reducing redundancy: combine multiple overlapping paths into a single path. The model must be originated.

    Parameters

    Returns IModel

    The simplified model (for chaining).

walk

walkPaths

zero

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

    Parameters

    • modelToZero: IModel

      The model to zero.

    Returns IModel

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