Api - Rectangle Class
Hierarchy
- Rectangle
Implements
Index
Constructors
Properties
Constructors
constructor
-
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
-
measurement: IMeasure
IMeasure object. See http://maker.js.org/docs/api/modules/makerjs.measure.html#pathextents and http://maker.js.org/docs/api/modules/makerjs.measure.html#modelextents to get measurements of paths and models.
Returns Rectangle
-
Properties
origin
paths
Generated using TypeDoc
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);