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

Hierarchy

  • Rectangle

Implements

Index

Constructors

Properties

Constructors

constructor

  • Create a rectangle from width and height.

    Example:

    //Create a rectangle from width and height
    var makerjs = require('makerjs');
    var model = new makerjs.models.Rectangle(50, 100);
    var svg = makerjs.exporter.toSVG(model);
    document.write(svg);
    

    Parameters

    • width: number

      Width of the rectangle.

    • height: number

      Height of the rectangle.

    Returns Rectangle

  • Create a rectangle which will surround a model.

    Example:

    //Create a rectangle which will surround a model
    var makerjs = require('makerjs');
    var e = new makerjs.models.Ellipse(17, 10); // draw an ellipse so we have something to surround.
    var r = new makerjs.models.Rectangle(e, 3); // draws a rectangle surrounding the ellipse by 3 units.
    var svg = makerjs.exporter.toSVG({ models: { e: e, r: r }});
    document.write(svg);
    

    Parameters

    • modelToSurround: IModel

      IModel object.

    • Optional margin: number

      Optional distance from the model.

    Returns Rectangle

  • Create a rectangle from a measurement.

    Example:

    //Create a rectangle from a measurement.
    var makerjs = require('makerjs');
    var e = new makerjs.models.Ellipse(17, 10); // draw an ellipse so we have something to measure.
    var m = makerjs.measure.modelExtents(e);    // measure the ellipse.
    var r = new makerjs.models.Rectangle(m);    // draws a rectangle surrounding the ellipse.
    var svg = makerjs.exporter.toSVG({ models: { e: e, r: r }});
    document.write(svg);
    

    Parameters

    Returns Rectangle

Properties

origin

origin: IPoint

paths

paths: IPathMap

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