in packages/maker.js/src/core/layout.ts [183:226]
export function childrenOnChain(parentModel: IModel, onChain: IChain, baseline = 0, reversed = false, contain = false, rotated = true) {
var result = getChildPlacement(parentModel, baseline);
var cpa = result.cpa;
var chainLength = onChain.pathLength;
if (contain) chainLength -= result.firstX + result.lastX;
var absolutes = cpa.map(cp => (reversed ? 1 - cp.xRatio : cp.xRatio) * chainLength);
var relatives: number[];
if (reversed) absolutes.reverse();
relatives = absolutes.map((ab, i) => Math.abs(ab - (i == 0 ? 0 : absolutes[i - 1])));
if (contain) {
relatives[0] += reversed ? result.lastX : result.firstX;
} else {
relatives.shift();
}
//chain.toPoints always follows the chain in its order, from beginning to end. This is why we needed to contort the points input
var points = chain.toPoints(onChain, relatives);
if (points.length < cpa.length) {
//add last point of chain, since our distances exceeded the chain
var endLink = onChain.links[onChain.links.length - 1];
points.push(endLink.endPoints[endLink.reversed ? 0 : 1]);
}
if (contain) points.shift(); //delete the first point which is the beginning of the chain
if (reversed) points.reverse();
var angles = miterAngles(points, -90);
cpa.forEach((cp, i) => {
cp.angle = angles[i];
cp.origin = points[i];
});
moveAndRotate(parentModel, cpa, rotated);
return parentModel;
}