Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const poly = (arr) => {
let counter = 0
let prev = arr[arr.length - 1]
const res = {
paths: {}
}
for (const p of arr) {
res.paths['p' + (++counter)] = line(prev, p)
prev = p
}
return res
}
const deepcopy = obj => JSON.parse(JSON.stringify(obj))
const measure = m.measure.modelExtents
// #endregion
// #region Positioning
const column = (func, col) => ({
models: {
bottom: up(func(col, 'bottom'), 0 * (side + padding)),
middle: up(func(col, 'middle'), 1 * (side + padding)),
top: up(func(col, 'top'), 2 * (side + padding))
}
})
const matrix = (func) => {
function hCenter(model, y) {
var measure = makerjs.measure.modelExtents(model);
var mw = measure.high[0];
model.origin = [(w - mw) / 2, y];
return mw;
}
const furthest = (arr, control) => {
let max
let max_dist = 0
for (const point of arr) {
const d = m.measure.pointDistance(point, control)
if (d > max_dist) {
max_dist = d
max = point
}
}
return max
}
parameters = [
opentypeLib.loadSync('../fonts/stardosstencil/StardosStencil-Regular.ttf'),
'A'
];
}
else {
if (kit.ctor.metaParameters) {
kit.ctor.metaParameters.forEach(function (metaParameter, i) {
if (metaParameter.type === 'font') {
parameters[i] = opentypeLib.loadSync('../fonts/allertastencil/AllertaStencil-Regular.ttf');
}
});
}
}
var model = makerjs.kit.construct(kit.ctor, parameters);
var measurement = makerjs.measure.modelExtents(model);
var scaleX = measurement.high[0] - measurement.low[0];
var scaleY = measurement.high[1] - measurement.low[1];
var scale = Math.max(scaleX, scaleY);
makerjs.model.scale(model, 100 / scale);
var svg = makerjs.exporter.toSVG(model);
var div = new makerjs.exporter.XmlTag('div', { "class": 'thumb' });
div.innerText = svg;
div.innerTextEscaped = true;
return anchor(div.toString(), baseUrl + 'playground/?script=' + key, key, true, 'thumb-link');
}
function jekyll(layout, title) {
VentgridCircle.prototype.checkCircle = function (id, circle) {
var distanceToCenter = makerjs.measure.pointDistance([0, 0], circle.origin);
if (makerjs.round(distanceToCenter + circle.radius) <= this.radius) {
//inside
this.paths[id] = circle;
}
else if (makerjs.round(distanceToCenter - circle.radius) > this.radius) {
}
else {
//border
var arcIntersection = makerjs.path.intersection(circle, this.rim);
if (arcIntersection && arcIntersection.path1Angles.length == 2) {
var filterArc = new makerjs.paths.Arc(circle.origin, circle.radius, arcIntersection.path1Angles[1], arcIntersection.path1Angles[0]);
this.paths[id] = filterArc;
var rimArc = new makerjs.paths.Arc([0, 0], this.radius, arcIntersection.path2Angles[0], arcIntersection.path2Angles[1]);
this.paths[id + '_rim'] = rimArc;
}
}
function Nameplate(font, text, fontSize, fontMargin, boltMargin, boltRadius, rounded) {
//generate the text using a font
var textModel = new makerjs.models.Text(font, text, fontSize);
//move text to [0, 0]
makerjs.model.zero(textModel);
//measure the text
var measure = makerjs.measure.modelExtents(textModel);
//create a bolt rectangle larger than the text
var bolts = new makerjs.models.BoltRectangle(measure.high[0] + fontMargin, measure.high[1] + fontMargin, boltRadius);
//center the text and the bolts
makerjs.model.center(textModel);
makerjs.model.center(bolts);
//make a rectangle around the bolts
var Rect = rounded ? makerjs.models.RoundRectangle : makerjs.models.Rectangle;
var rect = new Rect(bolts, boltMargin);
//save all of these in the model
this.models = {
text: textModel,
rect: rect,
function ArcText(font, text, fontSize, arcRadius, startAngle, endAngle, onTop, showCircle) {
var arc = new makerjs.paths.Arc([0, 0], arcRadius, startAngle, endAngle);
//generate the text using a font
var textModel = new makerjs.models.Text(font, text, fontSize, false, true);
//save all of these in the model
this.models = {
text: textModel,
};
//measure height of the text from the baseline
var measure = makerjs.measure.modelExtents(textModel);
var height = measure.high[1];
var h2 = height / 2;
var left = measure.low[0];
var right = measure.high[0];
var textWidth = right - left;
if (showCircle) {
this.paths = {
arc: arc,
circleT: new makerjs.paths.Circle(arcRadius + h2),
circleB: new makerjs.paths.Circle(arcRadius - h2)
};
}
//move each character to a percentage of the total arc
var span = makerjs.angle.ofArcSpan(arc);