Api - layout Namespace
Index
Functions
childrenOnChain
-
Parameters
-
parentModel: IModel
The model containing children to lay out.
-
onChain: IChain
The chain on which to lay out.
-
Default value baseline: number = 0
Numeric percentage value of vertical displacement from the chain. Default is zero.
-
Default value reversed: boolean = false
Flag to travel along the chain in reverse. Default is false.
-
Default value contain: boolean = false
Flag to contain the children layout within the length of the chain. Default is false.
-
Default value rotated: boolean = true
Returns IModel
The parentModel, for cascading.
-
childrenOnPath
-
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.
Parameters
-
parentModel: IModel
The model containing children to lay out.
-
onPath: IPath
The path on which to lay out.
-
Default value baseline: number = 0
Numeric percentage value of vertical displacement from the path. Default is zero.
-
Default value reversed: boolean = false
Flag to travel along the path in reverse. Default is false.
-
Default value contain: boolean = false
Flag to contain the children layout within the length of the path. Default is false.
-
Default value rotate: boolean = true
Flag to rotate the child to perpendicular. Default is true.
Returns IModel
The parentModel, for cascading.
-
cloneToBrick
-
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));
Parameters
-
itemToClone: IModel | IPath
-
xCount: number
Number of columns in the brick grid.
-
yCount: number
Number of rows in the brick grid.
-
Optional margin: number | IPoint
Optional numeric distance between each clone. Can also be a 2 dimensional array of numbers, to specify distances in x and y dimensions.
Returns IModel
A new model with clones in a brick layout.
-
cloneToColumn
-
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));
Parameters
-
itemToClone: IModel | IPath
-
count: number
Number of clones in the column.
-
Default value margin: number = 0
Optional distance between each clone.
Returns IModel
A new model with clones in a column.
-
cloneToGrid
-
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));
Parameters
-
itemToClone: IModel | IPath
-
xCount: number
Number of columns in the grid.
-
yCount: number
Number of rows in the grid.
-
Optional margin: number | IPoint
Optional numeric distance between each clone. Can also be a 2 dimensional array of numbers, to specify distances in x and y dimensions.
Returns IModel
A new model with clones in a grid layout.
-
cloneToHoneycomb
-
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));
Parameters
-
itemToClone: IModel | IPath
-
xCount: number
Number of columns in the honeycomb grid.
-
yCount: number
Number of rows in the honeycomb grid.
-
Default value margin: number = 0
Optional distance between each clone.
Returns IModel
A new model with clones in a honeycomb layout.
-
cloneToRadial
-
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));
Parameters
-
itemToClone: IModel | IPath
-
count: number
Number of clones in the radial result.
-
angleInDegrees: number
angle of rotation between clones..
-
Optional rotationOrigin: IPoint
Returns IModel
A new model with clones in a radial format.
-
cloneToRow
-
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));
Parameters
-
itemToClone: IModel | IPath
-
count: number
Number of clones in the row.
-
Default value margin: number = 0
Optional distance between each clone.
Returns IModel
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.