--- layout: posts title: Api - layout Namespace ---
The model containing children to lay out.
The chain on which to lay out.
Numeric percentage value of vertical displacement from the chain. Default is zero.
Flag to travel along the chain in reverse. Default is false.
Flag to contain the children layout within the length of the chain. Default is false.
The parentModel, for cascading.
Layout the children of a model along a path. The x-position of each child will be projected onto the path so that the proportion between children is maintained. Each child will be rotated such that it will be perpendicular to the path at the child's x-center.
The model containing children to lay out.
The path on which to lay out.
Numeric percentage value of vertical displacement from the path. Default is zero.
Flag to travel along the path in reverse. Default is false.
Flag to contain the children layout within the length of the path. Default is false.
Flag to rotate the child to perpendicular. Default is true.
The parentModel, for cascading.
Layout clones in a brick format. Alternating rows will have an additional item in each row.
Examples:
//Brick wall
var m = require('makerjs');
var brick = new m.models.RoundRectangle(50, 30, 4);
var wall = m.layout.cloneToBrick(brick, 8, 6, 3);
document.write(m.exporter.toSVG(wall));
//Fish scales
var m = require('makerjs');
var arc = new m.paths.Arc([0, 0], 50, 20, 160);
var scales = m.layout.cloneToBrick(arc, 8, 20);
document.write(m.exporter.toSVG(scales));
Number of columns in the brick grid.
Number of rows in the brick grid.
Optional numeric distance between each clone. Can also be a 2 dimensional array of numbers, to specify distances in x and y dimensions.
A new model with clones in a brick layout.
Layout clones in a column format.
Example:
//Grooves for a finger joint
var m = require('makerjs');
var dogbone = new m.models.Dogbone(50, 20, 2, -1, false);
var grooves = m.layout.cloneToColumn(dogbone, 5, 20);
document.write(m.exporter.toSVG(grooves));
Number of clones in the column.
Optional distance between each clone.
A new model with clones in a column.
Layout clones in a grid format.
Example:
//Grid of squares
var m = require('makerjs');
var square = new m.models.Square(43);
var grid = m.layout.cloneToGrid(square, 5, 5, 7);
document.write(m.exporter.toSVG(grid));
Number of columns in the grid.
Number of rows in the grid.
Optional numeric distance between each clone. Can also be a 2 dimensional array of numbers, to specify distances in x and y dimensions.
A new model with clones in a grid layout.
Layout clones in a honeycomb format. Alternating rows will have an additional item in each row.
Examples:
//Honeycomb
var m = require('makerjs');
var hex = new m.models.Polygon(6, 50, 30);
var pattern = m.layout.cloneToHoneycomb(hex, 8, 9, 10);
document.write(m.exporter.toSVG(pattern));
Number of columns in the honeycomb grid.
Number of rows in the honeycomb grid.
Optional distance between each clone.
A new model with clones in a honeycomb layout.
Layout clones in a radial format.
Example:
//daisy petals
var makerjs = require('makerjs');
var belt = new makerjs.models.Belt(5, 50, 20);
makerjs.model.move(belt, [25, 0]);
var petals = makerjs.layout.cloneToRadial(belt, 8, 45);
document.write(makerjs.exporter.toSVG(petals));
Number of clones in the radial result.
angle of rotation between clones..
A new model with clones in a radial format.
Layout clones in a row format.
Example:
//Tongue and grooves for a box joint
var m = require('makerjs');
var tongueWidth = 60;
var grooveWidth = 50;
var grooveDepth = 30;
var groove = new m.models.Dogbone(grooveWidth, grooveDepth, 5, 0, true);
groove.paths['leftTongue'] = new m.paths.Line([-tongueWidth / 2, 0], [0, 0]);
groove.paths['rightTongue'] = new m.paths.Line([grooveWidth, 0], [grooveWidth + tongueWidth / 2, 0]);
var tongueAndGrooves = m.layout.cloneToRow(groove, 3);
document.write(m.exporter.toSVG(tongueAndGrooves));
Number of clones in the row.
Optional distance between each clone.
A new model with clones in a row.
Generated using TypeDoc
Layout the children of a model along a chain. The x-position of each child will be projected onto the chain so that the proportion between children is maintained. The projected positions of the children will become an array of points that approximate the chain. Each child will be rotated such that it will be mitered according to the vertex angles formed by this series of points.