--- title: Measuring ---

Browse to the makerjs.measure module documentation to see all functions related to measuring.

To get the bounding rectangle of a path or a model, use:

These functions return a measurement object with high and low points.

Measure path example:

{% highlight javascript %} //render an arc, and a measurement reactangle around it var makerjs = require('makerjs'); var arc = new makerjs.paths.Arc([0, 0], 100, 45, 135); var m = makerjs.measure.pathExtents(arc); console.log('measurement:'); console.log(m); var totalWidth = m.high[0] - m.low[0]; var totalHeight = m.high[1] - m.low[1]; var measureRect = new makerjs.models.Rectangle(totalWidth, totalHeight); measureRect.origin = m.low; var model = { paths: { arc: arc }, models: { measureRect: measureRect } }; var svg = makerjs.exporter.toSVG(model, {useSvgPathOnly: false}); document.write(svg); {% endhighlight %}

Measure model example:

{% highlight javascript %} //render an oval, and a measurement reactangle around it var makerjs = require('makerjs'); var oval = new makerjs.models.Oval(100, 20); makerjs.model.rotate(oval, 30); var m = makerjs.measure.modelExtents(oval); console.log('measurement:'); console.log(m); var totalWidth = m.high[0] - m.low[0]; var totalHeight = m.high[1] - m.low[1]; var measureRect = new makerjs.models.Rectangle(totalWidth, totalHeight); measureRect.origin = m.low; var model = { models: { measureRect: measureRect, oval: oval } }; var svg = makerjs.exporter.toSVG(model, {useSvgPathOnly: false}); document.write(svg); {% endhighlight %}