Public
Edited
Apr 10, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
serverUrl = {
let serverName = "machineagency-shopbot-server";
return `wss://${serverName}.herokuapp.com`;
}
Insert cell
Insert cell
Insert cell
receivedInstructions.filter((el) => !el.split)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable test = []
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
render(canvas.ps)
Insert cell
UPSCALE = 20
Insert cell
Insert cell
Insert cell
function drawAnnotations() {
let ps = canvas.ps;
let tpPaths = ps.project.activeLayer.getItems({ name: "toolpathCut" });
let group = new ps.Group(tpPaths);
let boundOffset = 5;
let offsetBounds = group.bounds.expand(boundOffset);
let annotateBounds = new ps.Path.Rectangle(offsetBounds);
annotateBounds.strokeColor = "white";
annotateBounds.strokeWidth = 1;
annotateBounds.dashArray = [3, 2];
let annotateAnchor = new ps.Point(
offsetBounds.x + offsetBounds.width,
offsetBounds.y
);
let depthAnnotation = generateDepthAnnotation(annotateAnchor, ps)();
}
Insert cell
function generateDepthAnnotation(anchor, ps) {
function drawAnnotation() {
let factor = 3;
let mlWidth = 5;
let cutSpan = 40;
let topBottomCutSpan = 20;
let cutWidth = 1;
let mlHeight = mutable machineState.thickness * UPSCALE * factor;
let mlFrom = new ps.Point(anchor.x + mlWidth * 2, anchor.y);
let mlTo = new ps.Point(anchor.x + mlWidth * 2, anchor.y + mlHeight);
let mainline = new ps.Path.Line(mlFrom, mlTo);
mainline.strokeWidth = mlWidth;
mainline.strokeColor = "white";
let drawHorizLine = (depth, spanWidth, isDashed) => {
let dFrom = new ps.Point(
anchor.x + mlWidth * 2,
anchor.y + mlHeight + depth * factor * UPSCALE
);
let dTo = new ps.Point(
anchor.x + mlWidth * 2 + spanWidth,
anchor.y + mlHeight + depth * factor * UPSCALE
);
let cutline = new ps.Path.Line(dFrom, dTo);
cutline.strokeWidth = cutWidth;
cutline.strokeColor = "white";
if (isDashed) {
cutline.dashArray = [2, 1];
}
};
parsedDepths.forEach((depth) => drawHorizLine(depth, cutSpan, true));
drawHorizLine(0, topBottomCutSpan, false);
drawHorizLine(-mutable machineState.thickness, topBottomCutSpan, false);
}
return drawAnnotation;
}
Insert cell
parsedDepths = {
// TODO: for now ignore M3/J3
let zMoves = receivedInstructions.filter((inst) => inst[1] === "Z");
let depths = zMoves.map((inst) => {
let toks = inst.split(",");
return parseFloat(toks[1]);
});
return depths.filter((depth) => depth < 0);
}
Insert cell
Insert cell
Insert cell
mutable homography = PerspT([0, 0, 1, 0, 1, 1, 0, 1], [0, 0, 1, 0, 1, 1, 0, 1])
Insert cell
Insert cell
Insert cell
Insert cell
mutable rangeTest = 0
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
convexHull.makeHull([
{ x: 0, y: 0 },
{ x: 10, y: 0 },
{ x: 10, y: 10 },
{ x: 0, y: 10 },
{ x: 5, y: 5 }
])
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more