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 - PointGraph Class

A graph of items which may be located on the same points.

Type parameters

  • T

Hierarchy

  • PointGraph

Index

Constructors

constructor

Properties

graph

graph: object

Map of unique points by x, then y, to a point id. This will remain intact even after merging.

Type declaration

  • [x: number]: object
    • [y: number]: number

index

index: object

Index of points by id.

Type declaration

insertedCount

insertedCount: number

Number of points inserted

merged

merged: object

Map of point ids which once existed but have been merged into another id due to close proximity.

Type declaration

  • [pointId: number]: number

values

values: T[]

List of values inserted at points.

Methods

forEachPoint

  • forEachPoint(cb: function): void

getElementAtPoint

getIdOfPoint

  • getIdOfPoint(p: IPoint): number
  • Gets the id of a point, after merging.

    Parameters

    • p: IPoint

      Point to look up id.

    Returns number

insertValue

  • insertValue(value: T): number
  • Insert a value.

    Parameters

    • value: T

      Value associated with this point.

    Returns number

    valueId of the inserted value.

insertValueIdAtPoint

  • insertValueIdAtPoint(valueId: number, p: IPoint): object
  • Insert a value at a point.

    Parameters

    • valueId: number
    • p: IPoint

      Point.

    Returns object

    • existed: boolean
    • pointId: number

mergeNearestSinglePoints

  • mergeNearestSinglePoints(withinDistance: number): void
  • Finds all points which have only one value associated. Then, merge to the nearest other point within this set. Call this after inserting values.

    Parameters

    • withinDistance: number

      Distance to consider points equal.

    Returns void

mergePoints

  • mergePoints(withinDistance: number): void
  • Merge points within a given distance from each other. Call this after inserting values.

    Parameters

    • withinDistance: number

      Distance to consider points equal.

    Returns void

reset

  • reset(): void
  • Reset the stored points, graphs, lists, to initial state.

    Returns void

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