Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
///
var makerjs = require('makerjs');
var arc = makerjs.paths.Arc;
var line = makerjs.paths.Line;
var point = makerjs.point;
var PolygonStackBoxInside = (function () {
function PolygonStackBoxInside(angle, radius, holeRadius, rimThickness) {
var rim = Math.min(rimThickness, holeRadius);
var a2 = angle * 2;
var innerFilletCenter = point.rotate([radius + 2 * holeRadius + rim, 0], 90 + angle, [radius, 0]);
var innerFilletTop = new arc(innerFilletCenter, holeRadius, 270 + angle, angle);
var innerFilletTopPoints = point.fromArc(innerFilletTop);
var innerFilletBottomPoint = [innerFilletTopPoints[1][0], -innerFilletTopPoints[1][1]];
this.paths = {
innerFilletTop: innerFilletTop,
innerFilletBottom: makerjs.path.mirror(innerFilletTop, false, true),
innerLine: new line(innerFilletTopPoints[1], point.rotate(innerFilletBottomPoint, a2, [0, 0])),
innerFillet: new arc([radius, 0], holeRadius + rim, 90 + angle, 270 - angle)
};
}
function starboxInner(width, height, holeRadius, rimThickness) {
var mm = makerjs.model;
var corner = new starboxCorner(holeRadius, rimThickness);
this.models = {
bottomLeft: corner,
bottomRight: mm.move(mm.mirror(corner, true, false), [width, 0]),
topLeft: mm.move(mm.mirror(corner, false, true), [0, height]),
topRight: mm.move(mm.mirror(corner, true, true), [width, height])
};
var line = makerjs.paths.Line;
var rim = Math.min(rimThickness, holeRadius);
var d = 2 * holeRadius + rim;
this.paths = {
bottom: new line([d, -holeRadius], [width - d, -holeRadius]),
top: new line([d, height + holeRadius], [width - d, height + holeRadius]),
left: new line([-holeRadius, d], [-holeRadius, height - d]),
right: new line([width + holeRadius, d], [width + holeRadius, height - d])
};
}
return starboxInner;
function Spines(spines, innerRadius, outerRadius) {
this.paths = {};
if (innerRadius === outerRadius) innerRadius = 0;
for (var i = 1; i < spines; i++) {
var a = (180 / spines) * i;
var line = new makerjs.paths.Line([innerRadius, 0], [outerRadius, 0]);
makerjs.path.rotate(line, a);
this.paths["spine" + i] = line;
}
}
function Wireframe(columns, column, extra, radius, split) {
this.paths = {
bottom: new makerjs.paths.Line([-radius, 0], [radius, 0])
};
this.models = {
bows: new Bows(columns, column),
spines: new Spines(columns + (+extra), columns % 2 ? column / 2 : column, radius)
};
if (split && columns > 3 && columns % 2 === 0) {
this.paths.split = new makerjs.paths.Line([0, 0], [0, column]);
}
}
function TongueAndGroove(count, tongueWidth, grooveWidth, grooveDepth, dogbone) {
//Tongue and grooves for a box joint
var groove = new m.models.Dogbone(grooveWidth, grooveDepth, dogbone, 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]);
this.models = {
tng: m.layout.cloneToRow(groove, count)
};
this.origin = [tongueWidth / 2, 0];
}
function Heart(r, a2) {
var a = a2 / 2;
var a_radians = makerjs.angle.toRadians(a);
var x = Math.cos(a_radians) * r;
var y = Math.sin(a_radians) * r;
var z = makerjs.solvers.solveTriangleASA(90, 2 * r, 90 - a);
this.paths = {
arc1: new makerjs.paths.Arc([x , 0], r, -a, 180 - a),
line1: new makerjs.paths.Line([x * 2, -y], [0, -z + y])
};
this.paths.arc2 = makerjs.path.mirror(this.paths.arc1, true, false);
this.paths.line2 = makerjs.path.mirror(this.paths.line1, true, false);
}
function TongueAndGroove(count, tongueWidth, grooveWidth, grooveDepth, dogbone) {
//Tongue and grooves for a box joint
var groove = new m.models.Dogbone(grooveWidth, grooveDepth, dogbone, 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]);
this.models = {
tng: m.layout.cloneToRow(groove, count)
};
this.origin = [tongueWidth / 2, 0];
}
function TextOnPath(font, fontSize, topText, topSpan, bottomText, bottomSpan, baseline, contain, rotate, showPath) {
var topTextModel = new makerjs.models.Text(font, topText, fontSize);
var bottomTextModel = new makerjs.models.Text(font, bottomText, fontSize);
var topArc = new makerjs.paths.Arc([0, 0], 100, 90 - topSpan / 2, 90 + topSpan / 2);
var bottomArc = new makerjs.paths.Arc([0, 0], 100, 270 - bottomSpan / 2, 270 + bottomSpan / 2);
makerjs.layout.childrenOnPath(topTextModel, topArc, baseline, true, contain, rotate);
makerjs.layout.childrenOnPath(bottomTextModel, bottomArc, baseline, false, contain, rotate);
this.models = {
topText: topTextModel,
bottomText: bottomTextModel
};
if (showPath) {
this.paths = {
topArc: topArc,
bottomArc: bottomArc
};
}
function Heart(r, a2) {
var a = a2 / 2;
var a_radians = makerjs.angle.toRadians(a);
var x = Math.cos(a_radians) * r;
var y = Math.sin(a_radians) * r;
var z = makerjs.solvers.solveTriangleASA(90, 2 * r, 90 - a);
this.paths = {
arc1: new makerjs.paths.Arc([x , 0], r, -a, 180 - a),
line1: new makerjs.paths.Line([x * 2, -y], [0, -z + y])
};
this.paths.arc2 = makerjs.path.mirror(this.paths.arc1, true, false);
this.paths.line2 = makerjs.path.mirror(this.paths.line1, true, false);
}
function monotext() {
var mv = makerjs.model.move;
var arc = makerjs.paths.Arc;
var line = makerjs.paths.Line;
var u = 50;
var u2 = u * 2;
var u3 = u * 3;
var u4 = u * 4;
var up = u / 3;
var c1 = [u, u];
var c2 = [u, u3];
var pne = [u2, u4];
var pnw = [0, u4];
var k = u2 + u * .75;
var gap = 15;
var gc = [gap, u2];
var gc2 = [u2 - gap, u2];
var sa = 10;