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

Index

Variables

Private middleMap

middleMap: object

Type declaration

  • [type: string]: function

Private pathEndsMap

pathEndsMap: object

Type declaration

  • [type: string]: function
      • (pathValue: IPath): IPoint[]
      • Parameters

        Returns IPoint[]

Private Const zero_cos

zero_cos: object

Type declaration

  • [index: number]: boolean

Private Const zero_sin

zero_sin: object

Type declaration

  • [index: number]: boolean

Functions

add

  • Add two points together and return the result as a new point object.

    Parameters

    • a: IPoint

      First point.

    • b: IPoint

      Second point.

    • Optional subtract: boolean

      Optional boolean to subtract instead of add.

    Returns IPoint

    A new point object.

average

  • Get the average of two points.

    Parameters

    Returns IPoint

    New point object which is the average of a and b.

clone

  • Clone a point into a new point.

    Parameters

    • pointToClone: IPoint

      The point to clone.

    Returns IPoint

    A new point with same values as the original.

closest

  • closest(referencePoint: IPoint, pointOptions: IPoint[]): IPoint
  • From an array of points, find the closest point to a given reference point.

    Parameters

    • referencePoint: IPoint

      The reference point.

    • pointOptions: IPoint[]

      Array of points to choose from.

    Returns IPoint

    The first closest point from the pointOptions.

distort

  • distort(pointToDistort: IPoint, scaleX: number, scaleY: number): IPoint
  • Distort a point's coordinates.

    Parameters

    • pointToDistort: IPoint

      The point to distort.

    • scaleX: number

      The amount of x scaling.

    • scaleY: number

      The amount of y scaling.

    Returns IPoint

    A new point.

fromAngleOnCircle

  • Get a point on a circle or arc path, at a given angle.

    Parameters

    • angleInDegrees: number

      The angle at which you want to find the point, in degrees.

    • circle: IPathCircle

      A circle or arc.

    Returns IPoint

    A new point object.

fromArc

  • Get the two end points of an arc path.

    Parameters

    Returns IPoint[]

    Array with 2 elements: [0] is the point object corresponding to the start angle, [1] is the point object corresponding to the end angle.

fromPathEnds

  • fromPathEnds(pathContext: IPath, pathOffset?: IPoint): IPoint[]
  • Get the two end points of a path.

    Parameters

    • pathContext: IPath

      The path object.

    • Optional pathOffset: IPoint

    Returns IPoint[]

    Array with 2 elements: [0] is the point object corresponding to the origin, [1] is the point object corresponding to the end.

fromPolar

  • fromPolar(angleInRadians: number, radius: number): IPoint
  • Get a point from its polar coordinates.

    Parameters

    • angleInRadians: number

      The angle of the polar coordinate, in radians.

    • radius: number

      The radius of the polar coordinate.

    Returns IPoint

    A new point object.

fromSlopeIntersection

  • Calculates the intersection of slopes of two lines.

    Parameters

    Returns IPoint

    point of intersection of the two slopes, or null if the slopes did not intersect.

Private midCircle

middle

  • Get the middle point of a path.

    Parameters

    • pathContext: IPath

      The path object.

    • Default value ratio: number = 0.5

      Optional ratio (between 0 and 1) of point along the path. Default is .5 for middle.

    Returns IPoint

    Point on the path, in the middle of the path.

mirror

  • mirror(pointToMirror: IPoint, mirrorX: boolean, mirrorY: boolean): IPoint
  • Create a clone of a point, mirrored on either or both x and y axes.

    Parameters

    • pointToMirror: IPoint

      The point to mirror.

    • mirrorX: boolean

      Boolean to mirror on the x axis.

    • mirrorY: boolean

      Boolean to mirror on the y axis.

    Returns IPoint

    Mirrored point.

rotate

  • Rotate a point.

    Parameters

    • pointToRotate: IPoint

      The point to rotate.

    • angleInDegrees: number

      The amount of rotation, in degrees.

    • Default value rotationOrigin: IPoint = [0, 0]

      The center point of rotation.

    Returns IPoint

    A new point.

rounded

  • Round the values of a point.

    Parameters

    • pointContext: IPoint

      The point to serialize.

    • Optional accuracy: number

      Optional exemplar number of decimal places.

    Returns IPoint

    A new point with the values rounded.

scale

  • Scale a point's coordinates.

    Parameters

    • pointToScale: IPoint

      The point to scale.

    • scaleValue: number

      The amount of scaling.

    Returns IPoint

    A new point.

subtract

  • Subtract a point from another point, and return the result as a new point. Shortcut to Add(a, b, subtract = true).

    Parameters

    Returns IPoint

    A new point object.

Private verticalIntersectionPoint

zero

  • A point at 0,0 coordinates. NOTE: It is important to call this as a method, with the empty parentheses.

    Returns IPoint

    A new point.

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