copperflow 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/app/assets/{NewPartDialog-ZQ4Y3m45.js → NewPartDialog-PSXlbLR2.js} +1 -1
- package/dist/app/assets/{PackagesDialog-vEzilmpR.js → PackagesDialog-DmIT8b2D.js} +1 -1
- package/dist/app/assets/{VerifyPartDialog-DYr1UIds.js → VerifyPartDialog-KiW1nDnZ.js} +1 -1
- package/dist/app/assets/{footprint-preview-Nyk2poiN.js → footprint-preview-oJ27yBAB.js} +1 -1
- package/dist/app/assets/{index-CF7-tL4t.css → index-CArKmuM_.css} +1 -1
- package/dist/app/assets/index-Yj6ATP2T.js +20 -0
- package/dist/app/assets/texture-worker-e8zKC6dv.js +1 -0
- package/dist/app/index.html +2 -2
- package/dist/cli-commands.d.ts +2 -0
- package/dist/cli-commands.js +24 -0
- package/dist/cli-commands.js.map +1 -1
- package/dist/cli-graphic.d.ts +9 -0
- package/dist/cli-graphic.js +62 -0
- package/dist/cli-graphic.js.map +1 -0
- package/dist/core/annotations.js +2 -2
- package/dist/core/annotations.js.map +1 -1
- package/dist/core/board-edits.d.ts +2 -0
- package/dist/core/board-edits.js +14 -0
- package/dist/core/board-edits.js.map +1 -1
- package/dist/core/board-graphic-edits.d.ts +8 -0
- package/dist/core/board-graphic-edits.js +88 -0
- package/dist/core/board-graphic-edits.js.map +1 -0
- package/dist/core/board-items.d.ts +6 -0
- package/dist/core/board-items.js +8 -3
- package/dist/core/board-items.js.map +1 -1
- package/dist/core/board-shape-edit.js +4 -2
- package/dist/core/board-shape-edit.js.map +1 -1
- package/dist/core/edit.js +17 -1
- package/dist/core/edit.js.map +1 -1
- package/dist/core/graphic-import.d.ts +43 -0
- package/dist/core/graphic-import.js +142 -0
- package/dist/core/graphic-import.js.map +1 -0
- package/dist/core/html-export.d.ts +37 -0
- package/dist/core/html-export.js +139 -0
- package/dist/core/html-export.js.map +1 -0
- package/dist/core/html-page.d.ts +39 -0
- package/dist/core/html-page.js +114 -0
- package/dist/core/html-page.js.map +1 -0
- package/dist/core/html-style.d.ts +3 -0
- package/dist/core/html-style.js +117 -0
- package/dist/core/html-style.js.map +1 -0
- package/dist/core/model-export.js +3 -0
- package/dist/core/model-export.js.map +1 -1
- package/dist/core/out-name.d.ts +5 -0
- package/dist/core/out-name.js +10 -0
- package/dist/core/out-name.js.map +1 -0
- package/dist/core/packages.d.ts +5 -1
- package/dist/core/packages.js +17 -2
- package/dist/core/packages.js.map +1 -1
- package/dist/core/pad-lines.d.ts +7 -0
- package/dist/core/pad-lines.js +15 -0
- package/dist/core/pad-lines.js.map +1 -0
- package/dist/core/pour-edits.d.ts +12 -1
- package/dist/core/pour-edits.js +6 -6
- package/dist/core/pour-edits.js.map +1 -1
- package/dist/core/rules-patch.d.ts +17 -0
- package/dist/core/rules-patch.js +102 -0
- package/dist/core/rules-patch.js.map +1 -0
- package/dist/core/silk-text-edits.d.ts +8 -0
- package/dist/core/silk-text-edits.js +72 -0
- package/dist/core/silk-text-edits.js.map +1 -0
- package/dist/core/step-export.js +3 -0
- package/dist/core/step-export.js.map +1 -1
- package/dist/core/types.d.ts +55 -3
- package/dist/engine/board-graphic.d.ts +49 -0
- package/dist/engine/board-graphic.js +175 -0
- package/dist/engine/board-graphic.js.map +1 -0
- package/dist/engine/checks/copper-clearance.d.ts +1 -1
- package/dist/engine/checks/copper-clearance.js +19 -1
- package/dist/engine/checks/copper-clearance.js.map +1 -1
- package/dist/engine/checks/copper-pieces.d.ts +8 -2
- package/dist/engine/checks/copper-pieces.js +23 -2
- package/dist/engine/checks/copper-pieces.js.map +1 -1
- package/dist/engine/checks/drc-board-graphic.d.ts +10 -0
- package/dist/engine/checks/drc-board-graphic.js +95 -0
- package/dist/engine/checks/drc-board-graphic.js.map +1 -0
- package/dist/engine/checks/drc-parts.js +3 -1
- package/dist/engine/checks/drc-parts.js.map +1 -1
- package/dist/engine/checks/drc-pours.js +3 -3
- package/dist/engine/checks/drc-pours.js.map +1 -1
- package/dist/engine/checks/drc-silk-text.d.ts +15 -0
- package/dist/engine/checks/drc-silk-text.js +65 -0
- package/dist/engine/checks/drc-silk-text.js.map +1 -0
- package/dist/engine/checks/fill-point.d.ts +7 -0
- package/dist/engine/checks/fill-point.js +58 -0
- package/dist/engine/checks/fill-point.js.map +1 -0
- package/dist/engine/checks/stranded-copper.d.ts +14 -0
- package/dist/engine/checks/stranded-copper.js +43 -0
- package/dist/engine/checks/stranded-copper.js.map +1 -0
- package/dist/engine/design.js +1 -1
- package/dist/engine/design.js.map +1 -1
- package/dist/engine/elaborate.d.ts +2 -0
- package/dist/engine/elaborate.js +30 -1
- package/dist/engine/elaborate.js.map +1 -1
- package/dist/engine/engine.d.ts +4 -1
- package/dist/engine/engine.js +5 -2
- package/dist/engine/engine.js.map +1 -1
- package/dist/engine/fab/graphic-objects.d.ts +7 -0
- package/dist/engine/fab/graphic-objects.js +24 -0
- package/dist/engine/fab/graphic-objects.js.map +1 -0
- package/dist/engine/fab/layers.d.ts +9 -0
- package/dist/engine/fab/layers.js +60 -8
- package/dist/engine/fab/layers.js.map +1 -1
- package/dist/engine/fab/silk-text-strokes.d.ts +16 -0
- package/dist/engine/fab/silk-text-strokes.js +28 -0
- package/dist/engine/fab/silk-text-strokes.js.map +1 -0
- package/dist/engine/fab/stroke-font.d.ts +4 -0
- package/dist/engine/fab/stroke-font.js +38 -1
- package/dist/engine/fab/stroke-font.js.map +1 -1
- package/dist/engine/footprints/pad-roles.d.ts +4 -0
- package/dist/engine/footprints/pad-roles.js +32 -0
- package/dist/engine/footprints/pad-roles.js.map +1 -0
- package/dist/engine/graphic-place.d.ts +34 -0
- package/dist/engine/graphic-place.js +132 -0
- package/dist/engine/graphic-place.js.map +1 -0
- package/dist/engine/graphics/curves.d.ts +18 -0
- package/dist/engine/graphics/curves.js +75 -0
- package/dist/engine/graphics/curves.js.map +1 -0
- package/dist/engine/graphics/dxf-entities.d.ts +20 -0
- package/dist/engine/graphics/dxf-entities.js +184 -0
- package/dist/engine/graphics/dxf-entities.js.map +1 -0
- package/dist/engine/graphics/dxf-pairs.d.ts +22 -0
- package/dist/engine/graphics/dxf-pairs.js +77 -0
- package/dist/engine/graphics/dxf-pairs.js.map +1 -0
- package/dist/engine/graphics/dxf.d.ts +5 -0
- package/dist/engine/graphics/dxf.js +110 -0
- package/dist/engine/graphics/dxf.js.map +1 -0
- package/dist/engine/graphics/index.d.ts +9 -0
- package/dist/engine/graphics/index.js +30 -0
- package/dist/engine/graphics/index.js.map +1 -0
- package/dist/engine/graphics/path-data.d.ts +12 -0
- package/dist/engine/graphics/path-data.js +162 -0
- package/dist/engine/graphics/path-data.js.map +1 -0
- package/dist/engine/graphics/rings.d.ts +7 -0
- package/dist/engine/graphics/rings.js +93 -0
- package/dist/engine/graphics/rings.js.map +1 -0
- package/dist/engine/graphics/shapes.d.ts +47 -0
- package/dist/engine/graphics/shapes.js +85 -0
- package/dist/engine/graphics/shapes.js.map +1 -0
- package/dist/engine/graphics/svg-attributes.d.ts +26 -0
- package/dist/engine/graphics/svg-attributes.js +116 -0
- package/dist/engine/graphics/svg-attributes.js.map +1 -0
- package/dist/engine/graphics/svg.d.ts +5 -0
- package/dist/engine/graphics/svg.js +118 -0
- package/dist/engine/graphics/svg.js.map +1 -0
- package/dist/engine/graphics/transform.d.ts +21 -0
- package/dist/engine/graphics/transform.js +88 -0
- package/dist/engine/graphics/transform.js.map +1 -0
- package/dist/engine/graphics/xml.d.ts +10 -0
- package/dist/engine/graphics/xml.js +130 -0
- package/dist/engine/graphics/xml.js.map +1 -0
- package/dist/engine/model.d.ts +55 -0
- package/dist/engine/model.js.map +1 -1
- package/dist/engine/pcb-place/grow.d.ts +12 -0
- package/dist/engine/pcb-place/grow.js +100 -0
- package/dist/engine/pcb-place/grow.js.map +1 -0
- package/dist/engine/pcb.d.ts +5 -1
- package/dist/engine/pcb.js +2 -0
- package/dist/engine/pcb.js.map +1 -1
- package/dist/engine/pour/cache.js +1 -0
- package/dist/engine/pour/cache.js.map +1 -1
- package/dist/engine/pour/obstacles.js +18 -1
- package/dist/engine/pour/obstacles.js.map +1 -1
- package/dist/engine/router/route-board.d.ts +2 -0
- package/dist/engine/router/route-board.js +7 -2
- package/dist/engine/router/route-board.js.map +1 -1
- package/dist/engine/router/unplaced.d.ts +18 -0
- package/dist/engine/router/unplaced.js +27 -0
- package/dist/engine/router/unplaced.js.map +1 -0
- package/dist/engine/silk-text.d.ts +40 -0
- package/dist/engine/silk-text.js +85 -0
- package/dist/engine/silk-text.js.map +1 -0
- package/dist/library/attach-datasheet.d.ts +2 -0
- package/dist/library/attach-datasheet.js +1 -1
- package/dist/library/attach-datasheet.js.map +1 -1
- package/dist/library/part-fields.d.ts +23 -0
- package/dist/library/part-fields.js +55 -0
- package/dist/library/part-fields.js.map +1 -0
- package/dist/mcp/batch-steps.d.ts +33 -0
- package/dist/mcp/batch-steps.js +211 -0
- package/dist/mcp/batch-steps.js.map +1 -0
- package/dist/mcp/batch.d.ts +16 -0
- package/dist/mcp/batch.js +18 -5
- package/dist/mcp/batch.js.map +1 -1
- package/dist/mcp/board-import-tool.d.ts +1 -1
- package/dist/mcp/board-import-tool.js +1 -1
- package/dist/mcp/board-import-tool.js.map +1 -1
- package/dist/mcp/board-summary.d.ts +1 -1
- package/dist/mcp/board-summary.js +32 -1
- package/dist/mcp/board-summary.js.map +1 -1
- package/dist/mcp/board-tool.d.ts +36 -0
- package/dist/mcp/board-tool.js +109 -0
- package/dist/mcp/board-tool.js.map +1 -0
- package/dist/mcp/copper-summary.d.ts +2 -0
- package/dist/mcp/copper-summary.js +10 -2
- package/dist/mcp/copper-summary.js.map +1 -1
- package/dist/mcp/copper-tools.d.ts +1 -1
- package/dist/mcp/copper-tools.js +1 -1
- package/dist/mcp/copper-tools.js.map +1 -1
- package/dist/mcp/create-part.js +2 -2
- package/dist/mcp/create-part.js.map +1 -1
- package/dist/mcp/graphic-tool.d.ts +34 -0
- package/dist/mcp/graphic-tool.js +29 -0
- package/dist/mcp/graphic-tool.js.map +1 -0
- package/dist/mcp/html-tool.d.ts +28 -0
- package/dist/mcp/html-tool.js +21 -0
- package/dist/mcp/html-tool.js.map +1 -0
- package/dist/mcp/new-circuit.d.ts +1 -1
- package/dist/mcp/new-circuit.js +10 -11
- package/dist/mcp/new-circuit.js.map +1 -1
- package/dist/mcp/part-tools.d.ts +20 -0
- package/dist/mcp/part-tools.js +40 -0
- package/dist/mcp/part-tools.js.map +1 -0
- package/dist/mcp/place-tools.d.ts +1 -1
- package/dist/mcp/place-tools.js +11 -5
- package/dist/mcp/place-tools.js.map +1 -1
- package/dist/mcp/project-tools.js +2 -0
- package/dist/mcp/project-tools.js.map +1 -1
- package/dist/mcp/render-tool.d.ts +2 -0
- package/dist/mcp/render-tool.js +32 -1
- package/dist/mcp/render-tool.js.map +1 -1
- package/dist/mcp/route-tools.d.ts +1 -1
- package/dist/mcp/route-tools.js +3 -1
- package/dist/mcp/route-tools.js.map +1 -1
- package/dist/mcp/rules-tool.d.ts +19 -0
- package/dist/mcp/rules-tool.js +73 -0
- package/dist/mcp/rules-tool.js.map +1 -0
- package/dist/mcp/server.js +51 -17
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/text-tool.d.ts +34 -0
- package/dist/mcp/text-tool.js +37 -0
- package/dist/mcp/text-tool.js.map +1 -0
- package/dist/render/render.js +419 -150
- package/dist/studio/server.js +32 -0
- package/dist/studio/server.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/copperflow/SKILL.md +8 -8
- package/skills/copperflow/references/copper.md +9 -1
- package/skills/copperflow/references/design-rules.md +27 -1
- package/skills/copperflow/references/parts-library.md +17 -0
- package/skills/copperflow/references/writing-circuits.md +65 -0
- package/dist/app/assets/index-BUjGdMvr.js +0 -20
- package/dist/app/assets/texture-worker-CyI_g_XZ.js +0 -1
package/dist/render/render.js
CHANGED
|
@@ -5576,6 +5576,37 @@ var GLYPHS = {
|
|
|
5576
5576
|
"(": "3,6 2,5 2,1 3,0",
|
|
5577
5577
|
")": "1,6 2,5 2,1 1,0",
|
|
5578
5578
|
"#": "1,0 1,6;3,0 3,6;0,2 4,2;0,4 4,4",
|
|
5579
|
+
":": "2,1 2,1;2,4 2,4",
|
|
5580
|
+
"%": "0,6 1,6 1,5 0,5 0,6;3,1 4,1 4,0 3,0 3,1;0,0 4,6",
|
|
5581
|
+
"=": "0,2 4,2;0,4 4,4",
|
|
5582
|
+
",": "2,0 1,-1",
|
|
5583
|
+
"!": "2,6 2,2;2,0 2,0",
|
|
5584
|
+
a: "4,4 4,0;4,3 3,4 1,4 0,3 0,1 1,0 3,0 4,1",
|
|
5585
|
+
b: "0,6 0,0;0,1 1,0 3,0 4,1 4,3 3,4 1,4 0,3",
|
|
5586
|
+
c: "4,3 3,4 1,4 0,3 0,1 1,0 3,0 4,1",
|
|
5587
|
+
d: "4,6 4,0;4,1 3,0 1,0 0,1 0,3 1,4 3,4 4,3",
|
|
5588
|
+
e: "0,2 4,2 4,3 3,4 1,4 0,3 0,1 1,0 3,0 4,1",
|
|
5589
|
+
f: "3,6 2,6 1,5 1,0;0,4 3,4",
|
|
5590
|
+
g: "4,4 4,-1 3,-2 1,-2 0,-1;4,3 3,4 1,4 0,3 0,1 1,0 3,0 4,1",
|
|
5591
|
+
h: "0,6 0,0;0,3 1,4 3,4 4,3 4,0",
|
|
5592
|
+
i: "2,4 2,0;2,5.5 2,5.5",
|
|
5593
|
+
j: "3,4 3,-1 2,-2 1,-2 0,-1;3,5.5 3,5.5",
|
|
5594
|
+
k: "0,6 0,0;0,1 3,4;1,2 4,0",
|
|
5595
|
+
l: "1,6 2,6 2,1 3,0",
|
|
5596
|
+
m: "0,4 0,0;0,3 1,4 2,3 2,0;2,3 3,4 4,3 4,0",
|
|
5597
|
+
n: "0,4 0,0;0,3 1,4 3,4 4,3 4,0",
|
|
5598
|
+
o: "1,0 0,1 0,3 1,4 3,4 4,3 4,1 3,0 1,0",
|
|
5599
|
+
p: "0,4 0,-2;0,3 1,4 3,4 4,3 4,1 3,0 1,0 0,1",
|
|
5600
|
+
q: "4,4 4,-2;4,3 3,4 1,4 0,3 0,1 1,0 3,0 4,1",
|
|
5601
|
+
r: "0,4 0,0;0,2 2,4 4,4",
|
|
5602
|
+
s: "4,4 1,4 0,3 1,2 3,2 4,1 3,0 0,0",
|
|
5603
|
+
t: "1,6 1,1 2,0 3,0;0,4 3,4",
|
|
5604
|
+
u: "0,4 0,1 1,0 3,0 4,1;4,4 4,0",
|
|
5605
|
+
v: "0,4 2,0 4,4",
|
|
5606
|
+
w: "0,4 1,0 2,2 3,0 4,4",
|
|
5607
|
+
x: "0,0 4,4;0,4 4,0",
|
|
5608
|
+
y: "0,4 2,0;4,4 1,-2",
|
|
5609
|
+
z: "0,4 4,4 0,0 4,0",
|
|
5579
5610
|
" ": ""
|
|
5580
5611
|
};
|
|
5581
5612
|
var MISSING = "0,0 4,0 4,6 0,6 0,0";
|
|
@@ -5583,7 +5614,7 @@ var GLYPH_WIDTH = 4;
|
|
|
5583
5614
|
var GLYPH_HEIGHT = 6;
|
|
5584
5615
|
var ADVANCE = 6;
|
|
5585
5616
|
function strokesOf(char) {
|
|
5586
|
-
const glyph = GLYPHS[char
|
|
5617
|
+
const glyph = (Object.hasOwn(GLYPHS, char) ? GLYPHS[char] : void 0) ?? MISSING;
|
|
5587
5618
|
if (glyph === "") return [];
|
|
5588
5619
|
return glyph.split(";").map(
|
|
5589
5620
|
(line2) => line2.split(" ").map((pair2) => {
|
|
@@ -5664,8 +5695,8 @@ function sidePlaces(part, clearance, turnFor) {
|
|
|
5664
5695
|
const short = DESIGNATOR_HEIGHT / 2 + SILK_WIDTH / 2;
|
|
5665
5696
|
const found = [];
|
|
5666
5697
|
const along = { flat: slides(halfW, turnFor(true) === 0 ? long : short), upright: slides(halfH, turnFor(false) === 0 ? short : long) };
|
|
5667
|
-
for (const
|
|
5668
|
-
const gap = clearance +
|
|
5698
|
+
for (const ring4 of RINGS) {
|
|
5699
|
+
const gap = clearance + ring4;
|
|
5669
5700
|
for (const side of ["top", "bottom", "left", "right"]) {
|
|
5670
5701
|
const flat = side === "top" || side === "bottom";
|
|
5671
5702
|
const rotation = turnFor(flat);
|
|
@@ -6709,9 +6740,9 @@ function outline(ctx, drawing) {
|
|
|
6709
6740
|
const start = rad(drawing.startAngle);
|
|
6710
6741
|
ctx.arc(drawing.x, drawing.y, drawing.radius, start, start + rad(sweepOf2(drawing.startAngle, drawing.endAngle)));
|
|
6711
6742
|
}
|
|
6712
|
-
function toneOf(drawing,
|
|
6713
|
-
if (
|
|
6714
|
-
return { color: colorOf(drawing), alpha:
|
|
6743
|
+
function toneOf(drawing, paint2) {
|
|
6744
|
+
if (paint2.selected?.includes(drawing.id)) return { color: sheetPalette().selection, alpha: 1 };
|
|
6745
|
+
return { color: colorOf(drawing), alpha: paint2.dim ? HIGHLIGHT_DIM : 1 };
|
|
6715
6746
|
}
|
|
6716
6747
|
function drawJunction(ctx, drawing, color, alpha, selected) {
|
|
6717
6748
|
ctx.globalAlpha = alpha;
|
|
@@ -6722,38 +6753,38 @@ function drawJunction(ctx, drawing, color, alpha, selected) {
|
|
|
6722
6753
|
ctx.fill();
|
|
6723
6754
|
glow(ctx, false);
|
|
6724
6755
|
}
|
|
6725
|
-
function drawDrawings(ctx, drawings, devicePx,
|
|
6756
|
+
function drawDrawings(ctx, drawings, devicePx, paint2) {
|
|
6726
6757
|
for (const drawing of drawings) {
|
|
6727
6758
|
if (drawing.kind === "text") continue;
|
|
6728
|
-
const { color, alpha } = toneOf(drawing,
|
|
6759
|
+
const { color, alpha } = toneOf(drawing, paint2);
|
|
6729
6760
|
if (drawing.kind === "junction") {
|
|
6730
|
-
drawJunction(ctx, drawing, color, alpha,
|
|
6761
|
+
drawJunction(ctx, drawing, color, alpha, paint2.selected?.includes(drawing.id) ?? false);
|
|
6731
6762
|
continue;
|
|
6732
6763
|
}
|
|
6733
6764
|
const width = drawnWidth(strokeWidthOf(drawing), devicePx);
|
|
6734
6765
|
ctx.globalAlpha = alpha;
|
|
6735
6766
|
ctx.lineWidth = width;
|
|
6736
6767
|
ctx.strokeStyle = color;
|
|
6737
|
-
ctx.setLineDash(dashOf(
|
|
6768
|
+
ctx.setLineDash(dashOf(paint2.pending ? "dashed" : lineStyleOf(drawing), width));
|
|
6738
6769
|
outline(ctx, drawing);
|
|
6739
6770
|
if (isFilled(drawing)) {
|
|
6740
6771
|
ctx.fillStyle = fillOf(color);
|
|
6741
6772
|
ctx.fill();
|
|
6742
6773
|
}
|
|
6743
|
-
glow(ctx,
|
|
6774
|
+
glow(ctx, paint2.selected?.includes(drawing.id) ?? false);
|
|
6744
6775
|
ctx.stroke();
|
|
6745
6776
|
glow(ctx, false);
|
|
6746
6777
|
ctx.setLineDash([]);
|
|
6747
6778
|
}
|
|
6748
6779
|
ctx.globalAlpha = 1;
|
|
6749
6780
|
}
|
|
6750
|
-
function drawDrawingTexts(ctx, drawings, camera, size,
|
|
6781
|
+
function drawDrawingTexts(ctx, drawings, camera, size, paint2, ratio) {
|
|
6751
6782
|
for (const drawing of drawings) {
|
|
6752
6783
|
if (drawing.kind !== "text" || drawing.text === "") continue;
|
|
6753
6784
|
const devicePx = devicePxFor(drawing.fontSize, camera.scale, ratio);
|
|
6754
6785
|
if (!textShown("detail", sheetLevelPx(camera.scale, ratio), devicePx)) continue;
|
|
6755
6786
|
const fontPx = devicePx / ratio;
|
|
6756
|
-
const { color, alpha } = toneOf(drawing,
|
|
6787
|
+
const { color, alpha } = toneOf(drawing, paint2);
|
|
6757
6788
|
const at2 = textAnchorAt(worldToScreen(camera, size, drawing), ratio);
|
|
6758
6789
|
const [, horizontal] = anchorAlignment(drawing.anchor);
|
|
6759
6790
|
ctx.globalAlpha = alpha;
|
|
@@ -6858,24 +6889,24 @@ function inkOf(ctx, text2, baseline, size) {
|
|
|
6858
6889
|
descent: metrics.actualBoundingBoxDescent ?? FALLBACK_DESCENT * size + drop
|
|
6859
6890
|
};
|
|
6860
6891
|
}
|
|
6861
|
-
function pinName(ctx, { label, devicePx },
|
|
6892
|
+
function pinName(ctx, { label, devicePx }, paint2) {
|
|
6862
6893
|
const pin = label.pinOf;
|
|
6863
6894
|
if (!pin) return null;
|
|
6864
|
-
const size = devicePx /
|
|
6865
|
-
const p = worldToScreen(
|
|
6895
|
+
const size = devicePx / paint2.ratio;
|
|
6896
|
+
const p = worldToScreen(paint2.camera, paint2.size, label.at);
|
|
6866
6897
|
const [vertical, horizontal] = anchorAlignment(label.anchor);
|
|
6867
|
-
const local = { x: pin.local.x *
|
|
6898
|
+
const local = { x: pin.local.x * paint2.camera.scale, y: pin.local.y * paint2.camera.scale };
|
|
6868
6899
|
const ink = inkOf(ctx, label.text, vertical, size);
|
|
6869
6900
|
return { text: label.text, x: p.x, y: p.y, align: horizontal, size, ...ink, local, side: pin.side, quarter: pin.quarter };
|
|
6870
6901
|
}
|
|
6871
|
-
function fitSymbol(ctx, names,
|
|
6902
|
+
function fitSymbol(ctx, names, paint2) {
|
|
6872
6903
|
const first = names[0];
|
|
6873
6904
|
if (!first) return names;
|
|
6874
|
-
ctx.font = fontOf(first.label, first.devicePx,
|
|
6875
|
-
const onScreen = names.map((sized) => pinName(ctx, sized,
|
|
6905
|
+
ctx.font = fontOf(first.label, first.devicePx, paint2.ratio);
|
|
6906
|
+
const onScreen = names.map((sized) => pinName(ctx, sized, paint2)).filter((name) => name !== null);
|
|
6876
6907
|
if (onScreen.length !== names.length) return names;
|
|
6877
6908
|
const least = Math.ceil(first.devicePx * MIN_NAME_SCALE) / first.devicePx;
|
|
6878
|
-
const fits = fitPinNames(onScreen, (text2) => ctx.measureText(text2).width, first.devicePx /
|
|
6909
|
+
const fits = fitPinNames(onScreen, (text2) => ctx.measureText(text2).width, first.devicePx / paint2.ratio * NAME_GAP, least);
|
|
6879
6910
|
return names.flatMap((sized, i) => {
|
|
6880
6911
|
const fit = fits[i];
|
|
6881
6912
|
if (!fit) return [];
|
|
@@ -6883,36 +6914,36 @@ function fitSymbol(ctx, names, paint) {
|
|
|
6883
6914
|
return [{ label: { ...sized.label, text: fit.text }, devicePx }];
|
|
6884
6915
|
});
|
|
6885
6916
|
}
|
|
6886
|
-
function arrange(ctx, labels,
|
|
6887
|
-
const levelPx = sheetLevelPx(
|
|
6917
|
+
function arrange(ctx, labels, paint2) {
|
|
6918
|
+
const levelPx = sheetLevelPx(paint2.camera.scale, paint2.ratio);
|
|
6888
6919
|
const allowed = ({ label, devicePx }) => textShown(label.kind, levelPx, devicePx);
|
|
6889
|
-
const
|
|
6920
|
+
const shown2 = labels.filter((label) => label.text !== "").map((label) => ({ label, devicePx: sizeOf(ctx, label, paint2) })).filter(allowed);
|
|
6890
6921
|
const bySymbol = /* @__PURE__ */ new Map();
|
|
6891
|
-
for (const sized of
|
|
6922
|
+
for (const sized of shown2) {
|
|
6892
6923
|
const symbol = sized.label.pinOf?.symbol;
|
|
6893
6924
|
if (symbol !== void 0) bySymbol.set(symbol, [...bySymbol.get(symbol) ?? [], sized]);
|
|
6894
6925
|
}
|
|
6895
|
-
const fitted = [...bySymbol.values()].flatMap((names) => fitSymbol(ctx, names,
|
|
6896
|
-
return [...
|
|
6926
|
+
const fitted = [...bySymbol.values()].flatMap((names) => fitSymbol(ctx, names, paint2));
|
|
6927
|
+
return [...shown2.filter(({ label }) => !label.pinOf), ...fitted.filter(allowed)];
|
|
6897
6928
|
}
|
|
6898
|
-
function write(ctx, { label, devicePx },
|
|
6899
|
-
const p = textAnchorAt(worldToScreen(
|
|
6929
|
+
function write(ctx, { label, devicePx }, paint2) {
|
|
6930
|
+
const p = textAnchorAt(worldToScreen(paint2.camera, paint2.size, label.at), paint2.ratio);
|
|
6900
6931
|
const [vertical, horizontal] = anchorAlignment(label.anchor);
|
|
6901
6932
|
ctx.save();
|
|
6902
6933
|
ctx.translate(p.x, p.y);
|
|
6903
6934
|
if (label.rotation) ctx.rotate(-label.rotation * Math.PI / 180);
|
|
6904
6935
|
ctx.globalAlpha = label.alpha ?? 1;
|
|
6905
6936
|
ctx.fillStyle = label.color;
|
|
6906
|
-
ctx.font = fontOf(label, devicePx,
|
|
6937
|
+
ctx.font = fontOf(label, devicePx, paint2.ratio);
|
|
6907
6938
|
ctx.textAlign = horizontal;
|
|
6908
6939
|
ctx.textBaseline = vertical;
|
|
6909
6940
|
ctx.fillText(label.text, 0, 0);
|
|
6910
6941
|
ctx.restore();
|
|
6911
6942
|
}
|
|
6912
6943
|
function drawSheetTexts(ctx, labels, camera, size, ratio) {
|
|
6913
|
-
const
|
|
6944
|
+
const paint2 = { camera, size, ratio };
|
|
6914
6945
|
sharpenText(ctx);
|
|
6915
|
-
for (const sized of arrange(ctx, labels,
|
|
6946
|
+
for (const sized of arrange(ctx, labels, paint2)) write(ctx, sized, paint2);
|
|
6916
6947
|
}
|
|
6917
6948
|
|
|
6918
6949
|
// studio/src/pcb/no-connect-draw.ts
|
|
@@ -6975,12 +7006,12 @@ function drawSchematic(ctx, layout, view, options) {
|
|
|
6975
7006
|
ctx.lineCap = "round";
|
|
6976
7007
|
ctx.lineJoin = "round";
|
|
6977
7008
|
drawWires(ctx, layout, options, px, line2);
|
|
6978
|
-
const
|
|
7009
|
+
const shown2 = shownDrawings(layout.drawings, options.movingDrawings);
|
|
6979
7010
|
const pending = options.pendingDrawings ?? [];
|
|
6980
|
-
const drawings = [...
|
|
6981
|
-
const
|
|
6982
|
-
drawDrawings(ctx,
|
|
6983
|
-
drawDrawings(ctx, pending, px / options.ratio, { pending: true, dim:
|
|
7011
|
+
const drawings = [...shown2, ...pending];
|
|
7012
|
+
const paint2 = { ...options.selectedDrawings ? { selected: options.selectedDrawings } : {}, dim: options.highlight !== void 0 };
|
|
7013
|
+
drawDrawings(ctx, shown2, px / options.ratio, paint2);
|
|
7014
|
+
drawDrawings(ctx, pending, px / options.ratio, { pending: true, dim: paint2.dim });
|
|
6984
7015
|
for (const symbol of layout.symbols) drawSymbol(ctx, symbol, shiftOf(symbol), { line: line2, px, fade: symbolFade(symbol, options.highlight) }, texts);
|
|
6985
7016
|
for (const label of layout.labels) {
|
|
6986
7017
|
const moving = options.movingLabels?.some((m) => m.id === label.id) ?? false;
|
|
@@ -6995,7 +7026,7 @@ function drawSchematic(ctx, layout, view, options) {
|
|
|
6995
7026
|
drawNoConnects(ctx, layout.noConnects ?? [], line2, options.highlight !== void 0);
|
|
6996
7027
|
ctx.setTransform(options.ratio, 0, 0, options.ratio, 0, 0);
|
|
6997
7028
|
drawSheetTexts(ctx, texts, camera, size, options.ratio);
|
|
6998
|
-
drawDrawingTexts(ctx, drawings, camera, size,
|
|
7029
|
+
drawDrawingTexts(ctx, drawings, camera, size, paint2, options.ratio);
|
|
6999
7030
|
drawViolationMarkers(ctx, view, options.violations ?? [], options.activeViolation, false, { error: sheetPalette().markerError, warning: sheetPalette().markerWarning });
|
|
7000
7031
|
ctx.restore();
|
|
7001
7032
|
}
|
|
@@ -7247,9 +7278,9 @@ function disc(ctx, at2, radius, color) {
|
|
|
7247
7278
|
}
|
|
7248
7279
|
function drawTracks(ctx, scene, layers, highlight) {
|
|
7249
7280
|
const active = scene.activeLayer ?? "top";
|
|
7250
|
-
const
|
|
7281
|
+
const shown2 = scene.tracks.filter((track) => trackShown(track, layers));
|
|
7251
7282
|
const isActive = (track) => track.layer === active || track.missingLayer !== void 0;
|
|
7252
|
-
const ordered = [...
|
|
7283
|
+
const ordered = [...shown2.filter((track) => !isActive(track)), ...shown2.filter(isActive)];
|
|
7253
7284
|
for (const track of ordered) {
|
|
7254
7285
|
ctx.globalAlpha = (isActive(track) ? 1 : INACTIVE_COPPER_ALPHA) * litAlpha(highlight, track.net);
|
|
7255
7286
|
strokePath(ctx, track.points, trackColor(track), track.width);
|
|
@@ -7324,8 +7355,8 @@ var MAX_HATCH = 400;
|
|
|
7324
7355
|
var HANDLE_PX = 6;
|
|
7325
7356
|
var OUTLINE_PX2 = 1;
|
|
7326
7357
|
var SELECTED_PX = 1.5;
|
|
7327
|
-
function ringPath(ctx,
|
|
7328
|
-
|
|
7358
|
+
function ringPath(ctx, ring4) {
|
|
7359
|
+
ring4.forEach((p, i) => i === 0 ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y));
|
|
7329
7360
|
ctx.closePath();
|
|
7330
7361
|
}
|
|
7331
7362
|
function fillPath(ctx, fill) {
|
|
@@ -7407,7 +7438,7 @@ function strokeHatch(ctx, fill, px) {
|
|
|
7407
7438
|
}
|
|
7408
7439
|
ctx.stroke();
|
|
7409
7440
|
}
|
|
7410
|
-
function drawFill(ctx, fill, mode, px) {
|
|
7441
|
+
function drawFill(ctx, fill, mode, px, dim) {
|
|
7411
7442
|
const color = LAYER_COLOR[fill.layer] ?? PALETTE.topCopper;
|
|
7412
7443
|
ctx.fillStyle = color;
|
|
7413
7444
|
ctx.strokeStyle = color;
|
|
@@ -7416,21 +7447,21 @@ function drawFill(ctx, fill, mode, px) {
|
|
|
7416
7447
|
strokeRings(ctx, fill, OUTLINE_PX2 * px);
|
|
7417
7448
|
return;
|
|
7418
7449
|
}
|
|
7419
|
-
ctx.globalAlpha = POUR_FILL_ALPHA;
|
|
7450
|
+
ctx.globalAlpha = POUR_FILL_ALPHA * dim;
|
|
7420
7451
|
if (mode === "solid") return fillRings(ctx, fill, "fill");
|
|
7421
7452
|
ctx.save();
|
|
7422
7453
|
fillRings(ctx, fill, "clip");
|
|
7423
7454
|
ctx.lineWidth = OUTLINE_PX2 * px;
|
|
7424
|
-
ctx.globalAlpha =
|
|
7455
|
+
ctx.globalAlpha = dim;
|
|
7425
7456
|
strokeHatch(ctx, fill, px);
|
|
7426
7457
|
ctx.restore();
|
|
7427
7458
|
ctx.globalAlpha = 1;
|
|
7428
7459
|
strokeRings(ctx, fill, OUTLINE_PX2 * px);
|
|
7429
7460
|
}
|
|
7430
7461
|
function drawPourFills(ctx, layout, scene, layers, px) {
|
|
7431
|
-
const
|
|
7432
|
-
const ordered = [...
|
|
7433
|
-
for (const fill of ordered) drawFill(ctx, fill, scene.mode, px);
|
|
7462
|
+
const shown2 = (layout.pours ?? []).filter((fill) => pourShown(fill, layers, scene.hidden));
|
|
7463
|
+
const ordered = [...shown2.filter((fill) => fill.layer !== scene.activeLayer), ...shown2.filter((fill) => fill.layer === scene.activeLayer)];
|
|
7464
|
+
for (const fill of ordered) drawFill(ctx, fill, scene.mode, px, fill.layer === scene.activeLayer ? 1 : INACTIVE_COPPER_ALPHA);
|
|
7434
7465
|
ctx.globalAlpha = 1;
|
|
7435
7466
|
}
|
|
7436
7467
|
function square(ctx, at2, size) {
|
|
@@ -7499,6 +7530,201 @@ function drawHoles(ctx, holes, scene, layers, px, hair) {
|
|
|
7499
7530
|
}
|
|
7500
7531
|
}
|
|
7501
7532
|
|
|
7533
|
+
// src/engine/fab/silk-text-strokes.ts
|
|
7534
|
+
var LINE_SHARE = 0.1;
|
|
7535
|
+
var silkTextLineWidth = (height) => Math.max(SILK_WIDTH, height * LINE_SHARE);
|
|
7536
|
+
function silkTextStrokes(text2) {
|
|
7537
|
+
const radians = text2.rotation * Math.PI / 180;
|
|
7538
|
+
const [cos, sin] = [Math.cos(radians), Math.sin(radians)];
|
|
7539
|
+
const side = text2.layer === "bottom" ? -1 : 1;
|
|
7540
|
+
return textStrokes(text2.text, { x: 0, y: 0 }, text2.height).map(
|
|
7541
|
+
(line2) => line2.map((p) => ({ x: text2.x + side * (p.x * cos - p.y * sin), y: text2.y + p.x * sin + p.y * cos }))
|
|
7542
|
+
);
|
|
7543
|
+
}
|
|
7544
|
+
function silkTextBox(text2) {
|
|
7545
|
+
const points = silkTextStrokes(text2).flat();
|
|
7546
|
+
const half = silkTextLineWidth(text2.height) / 2;
|
|
7547
|
+
if (points.length === 0) return { minX: text2.x, minY: text2.y, maxX: text2.x, maxY: text2.y };
|
|
7548
|
+
const xs = points.map((p) => p.x);
|
|
7549
|
+
const ys = points.map((p) => p.y);
|
|
7550
|
+
return { minX: Math.min(...xs) - half, minY: Math.min(...ys) - half, maxX: Math.max(...xs) + half, maxY: Math.max(...ys) + half };
|
|
7551
|
+
}
|
|
7552
|
+
|
|
7553
|
+
// studio/src/pcb/silk-text-draw.ts
|
|
7554
|
+
var RING_GAP_PX = 3;
|
|
7555
|
+
var RING_PX2 = 1.5;
|
|
7556
|
+
var HOVER_ALPHA = 0.5;
|
|
7557
|
+
var shown = (layers, text2) => layers[text2.layer === "top" ? "topSilk" : "bottomSilk"];
|
|
7558
|
+
function shownText(text2, scene) {
|
|
7559
|
+
const moving = scene?.moving;
|
|
7560
|
+
return moving && moving.id === text2.id ? { ...text2, x: text2.x + moving.by.x, y: text2.y + moving.by.y } : text2;
|
|
7561
|
+
}
|
|
7562
|
+
function drawSilkTexts(ctx, texts, layers, scene, px) {
|
|
7563
|
+
for (const original of texts) {
|
|
7564
|
+
if (!shown(layers, original)) continue;
|
|
7565
|
+
const text2 = shownText(original, scene);
|
|
7566
|
+
const colour = text2.layer === "top" ? PALETTE.topSilk : PALETTE.bottomSilk;
|
|
7567
|
+
ctx.strokeStyle = colour;
|
|
7568
|
+
ctx.fillStyle = colour;
|
|
7569
|
+
ctx.lineWidth = silkTextLineWidth(text2.height);
|
|
7570
|
+
for (const line2 of silkTextStrokes(text2)) strokeLine(ctx, line2);
|
|
7571
|
+
if (scene?.selected.has(text2.id) || scene?.hovered === text2.id) ring2(ctx, text2, scene.selected.has(text2.id), px);
|
|
7572
|
+
}
|
|
7573
|
+
}
|
|
7574
|
+
function strokeLine(ctx, line2) {
|
|
7575
|
+
const first = line2[0];
|
|
7576
|
+
if (!first || line2.length < 2) return;
|
|
7577
|
+
ctx.beginPath();
|
|
7578
|
+
if (line2.every((p) => p.x === first.x && p.y === first.y)) {
|
|
7579
|
+
ctx.arc(first.x, first.y, ctx.lineWidth / 2, 0, 2 * Math.PI);
|
|
7580
|
+
ctx.fill();
|
|
7581
|
+
return;
|
|
7582
|
+
}
|
|
7583
|
+
line2.forEach((p, i) => i === 0 ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y));
|
|
7584
|
+
ctx.stroke();
|
|
7585
|
+
}
|
|
7586
|
+
function ring2(ctx, text2, selected, px) {
|
|
7587
|
+
const box3 = silkTextBox(text2);
|
|
7588
|
+
const gap = RING_GAP_PX * px;
|
|
7589
|
+
ctx.save();
|
|
7590
|
+
ctx.strokeStyle = PALETTE.selection;
|
|
7591
|
+
ctx.globalAlpha = selected ? 1 : HOVER_ALPHA;
|
|
7592
|
+
ctx.lineWidth = RING_PX2 * px;
|
|
7593
|
+
const [left, right, bottom2, top] = [box3.minX - gap, box3.maxX + gap, box3.minY - gap, box3.maxY + gap];
|
|
7594
|
+
ctx.beginPath();
|
|
7595
|
+
ctx.moveTo(left, bottom2);
|
|
7596
|
+
ctx.lineTo(right, bottom2);
|
|
7597
|
+
ctx.lineTo(right, top);
|
|
7598
|
+
ctx.lineTo(left, top);
|
|
7599
|
+
ctx.closePath();
|
|
7600
|
+
ctx.stroke();
|
|
7601
|
+
ctx.restore();
|
|
7602
|
+
}
|
|
7603
|
+
|
|
7604
|
+
// src/engine/graphic-place.ts
|
|
7605
|
+
import earcut from "earcut";
|
|
7606
|
+
|
|
7607
|
+
// src/engine/pour/clip.ts
|
|
7608
|
+
var import_clipper_lib = __toESM(require_clipper(), 1);
|
|
7609
|
+
var UNITS_PER_MM = 1e3;
|
|
7610
|
+
var toUnits = (mm) => Math.round(mm * UNITS_PER_MM);
|
|
7611
|
+
var toPath = (points) => points.map((p) => ({ X: toUnits(p.x), Y: toUnits(p.y) }));
|
|
7612
|
+
var toPoints = (path2) => path2.map((p) => ({ x: p.X / UNITS_PER_MM, y: p.Y / UNITS_PER_MM }));
|
|
7613
|
+
function clipper(subject, clip) {
|
|
7614
|
+
const engine = new import_clipper_lib.default.Clipper();
|
|
7615
|
+
engine.StrictlySimple = true;
|
|
7616
|
+
engine.AddPaths(subject.filter((path2) => path2.length >= 3), import_clipper_lib.default.PolyType.ptSubject, true);
|
|
7617
|
+
engine.AddPaths(clip.filter((path2) => path2.length >= 3), import_clipper_lib.default.PolyType.ptClip, true);
|
|
7618
|
+
return engine;
|
|
7619
|
+
}
|
|
7620
|
+
function regions(paths) {
|
|
7621
|
+
const tree = new import_clipper_lib.default.PolyTree();
|
|
7622
|
+
const fill = import_clipper_lib.default.PolyFillType.pftNonZero;
|
|
7623
|
+
clipper(paths, []).Execute(import_clipper_lib.default.ClipType.ctUnion, tree, fill, fill);
|
|
7624
|
+
return import_clipper_lib.default.JS.PolyTreeToExPolygons(tree).map((piece) => ({ outer: piece.outer, holes: piece.holes }));
|
|
7625
|
+
}
|
|
7626
|
+
var pathArea = (path2) => import_clipper_lib.default.Clipper.Area(path2);
|
|
7627
|
+
|
|
7628
|
+
// src/engine/graphic-place.ts
|
|
7629
|
+
function graphicBox(graphic) {
|
|
7630
|
+
const box3 = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity };
|
|
7631
|
+
const grow = (p, half) => {
|
|
7632
|
+
box3.minX = Math.min(box3.minX, p.x - half);
|
|
7633
|
+
box3.minY = Math.min(box3.minY, p.y - half);
|
|
7634
|
+
box3.maxX = Math.max(box3.maxX, p.x + half);
|
|
7635
|
+
box3.maxY = Math.max(box3.maxY, p.y + half);
|
|
7636
|
+
};
|
|
7637
|
+
for (const area2 of graphic.areas) for (const p of area2.outer) grow(p, 0);
|
|
7638
|
+
for (const line2 of graphic.lines) for (const p of line2.points) grow(p, line2.width / 2);
|
|
7639
|
+
return Number.isFinite(box3.minX) ? box3 : { minX: graphic.x, minY: graphic.y, maxX: graphic.x, maxY: graphic.y };
|
|
7640
|
+
}
|
|
7641
|
+
|
|
7642
|
+
// studio/src/pcb/graphic-draw.ts
|
|
7643
|
+
var RING_GAP_PX2 = 3;
|
|
7644
|
+
var RING_PX3 = 1.5;
|
|
7645
|
+
var HOVER_ALPHA2 = 0.5;
|
|
7646
|
+
var MASK_ALPHA = 0.35;
|
|
7647
|
+
var INACTIVE_COPPER_ALPHA2 = 0.4;
|
|
7648
|
+
var COPPER_COLOURS = { top: PALETTE.topCopper, bottom: PALETTE.bottomCopper, inner1: PALETTE.inner1Copper, inner2: PALETTE.inner2Copper };
|
|
7649
|
+
var bottom = (graphic) => graphic.layer.startsWith("bottom");
|
|
7650
|
+
var isMask = (graphic) => graphic.layer.endsWith("mask");
|
|
7651
|
+
var isCopper = (graphic) => COPPER_COLOURS[graphic.layer] !== void 0;
|
|
7652
|
+
function graphicShown(layers, graphic) {
|
|
7653
|
+
if (graphic.layer === "inner1" || graphic.layer === "inner2") return true;
|
|
7654
|
+
if (isMask(graphic) || isCopper(graphic)) return layers[bottom(graphic) ? "bottom" : "top"];
|
|
7655
|
+
return layers[bottom(graphic) ? "bottomSilk" : "topSilk"];
|
|
7656
|
+
}
|
|
7657
|
+
var colourOf = (graphic) => COPPER_COLOURS[graphic.layer] ?? (isMask(graphic) ? bottom(graphic) ? PALETTE.bottomCopper : PALETTE.topCopper : bottom(graphic) ? PALETTE.bottomSilk : PALETTE.topSilk);
|
|
7658
|
+
function shownGraphic(graphic, scene) {
|
|
7659
|
+
const moving = scene?.moving;
|
|
7660
|
+
if (!moving || moving.id !== graphic.id) return graphic;
|
|
7661
|
+
const by = (p) => ({ x: p.x + moving.by.x, y: p.y + moving.by.y });
|
|
7662
|
+
return {
|
|
7663
|
+
...graphic,
|
|
7664
|
+
x: graphic.x + moving.by.x,
|
|
7665
|
+
y: graphic.y + moving.by.y,
|
|
7666
|
+
areas: graphic.areas.map((area2) => ({ outer: area2.outer.map(by), holes: area2.holes.map((hole) => hole.map(by)) })),
|
|
7667
|
+
lines: graphic.lines.map((line2) => ({ ...line2, points: line2.points.map(by) }))
|
|
7668
|
+
};
|
|
7669
|
+
}
|
|
7670
|
+
function ringPath2(ctx, ring4) {
|
|
7671
|
+
ring4.forEach((p, i) => i === 0 ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y));
|
|
7672
|
+
ctx.closePath();
|
|
7673
|
+
}
|
|
7674
|
+
function paint(ctx, graphic) {
|
|
7675
|
+
ctx.fillStyle = colourOf(graphic);
|
|
7676
|
+
ctx.strokeStyle = colourOf(graphic);
|
|
7677
|
+
ctx.lineCap = "round";
|
|
7678
|
+
ctx.lineJoin = "round";
|
|
7679
|
+
if (graphic.areas.length > 0) {
|
|
7680
|
+
ctx.beginPath();
|
|
7681
|
+
for (const area2 of graphic.areas) for (const ring4 of [area2.outer, ...area2.holes]) ringPath2(ctx, ring4);
|
|
7682
|
+
ctx.fill("evenodd");
|
|
7683
|
+
}
|
|
7684
|
+
for (const line2 of graphic.lines) {
|
|
7685
|
+
const first = line2.points[0];
|
|
7686
|
+
if (!first) continue;
|
|
7687
|
+
ctx.lineWidth = line2.width;
|
|
7688
|
+
ctx.beginPath();
|
|
7689
|
+
if (line2.points.length === 1) {
|
|
7690
|
+
ctx.arc(first.x, first.y, line2.width / 2, 0, 2 * Math.PI);
|
|
7691
|
+
ctx.fill();
|
|
7692
|
+
continue;
|
|
7693
|
+
}
|
|
7694
|
+
line2.points.forEach((p, i) => i === 0 ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y));
|
|
7695
|
+
ctx.stroke();
|
|
7696
|
+
}
|
|
7697
|
+
}
|
|
7698
|
+
function ring3(ctx, graphic, selected, px) {
|
|
7699
|
+
const box3 = graphicBox(graphic);
|
|
7700
|
+
const gap = RING_GAP_PX2 * px;
|
|
7701
|
+
ctx.save();
|
|
7702
|
+
ctx.strokeStyle = PALETTE.selection;
|
|
7703
|
+
ctx.globalAlpha = selected ? 1 : HOVER_ALPHA2;
|
|
7704
|
+
ctx.lineWidth = RING_PX3 * px;
|
|
7705
|
+
ctx.beginPath();
|
|
7706
|
+
ringPath2(ctx, [
|
|
7707
|
+
{ x: box3.minX - gap, y: box3.minY - gap },
|
|
7708
|
+
{ x: box3.maxX + gap, y: box3.minY - gap },
|
|
7709
|
+
{ x: box3.maxX + gap, y: box3.maxY + gap },
|
|
7710
|
+
{ x: box3.minX - gap, y: box3.maxY + gap }
|
|
7711
|
+
]);
|
|
7712
|
+
ctx.stroke();
|
|
7713
|
+
ctx.restore();
|
|
7714
|
+
}
|
|
7715
|
+
function drawGraphics(ctx, graphics, layers, scene, px, activeLayer = "top") {
|
|
7716
|
+
for (const original of graphics) {
|
|
7717
|
+
if (!graphicShown(layers, original)) continue;
|
|
7718
|
+
const graphic = shownGraphic(original, scene);
|
|
7719
|
+
ctx.save();
|
|
7720
|
+
if (isMask(graphic)) ctx.globalAlpha = MASK_ALPHA;
|
|
7721
|
+
if (isCopper(graphic) && graphic.layer !== activeLayer) ctx.globalAlpha = INACTIVE_COPPER_ALPHA2;
|
|
7722
|
+
paint(ctx, graphic);
|
|
7723
|
+
ctx.restore();
|
|
7724
|
+
if (scene?.selected.has(graphic.id) || scene?.hovered === graphic.id) ring3(ctx, graphic, scene.selected.has(graphic.id), px);
|
|
7725
|
+
}
|
|
7726
|
+
}
|
|
7727
|
+
|
|
7502
7728
|
// src/engine/schematic-geometry.ts
|
|
7503
7729
|
var tidy3 = (value) => clean(value) + 0;
|
|
7504
7730
|
var turnsOf = (rotation) => Math.round((rotation % 360 + 360) % 360 / 90) % 4;
|
|
@@ -7567,11 +7793,11 @@ function drawPcb(ctx, layout, view, options) {
|
|
|
7567
7793
|
const px = 1 / camera.scale;
|
|
7568
7794
|
const hair = devicePixelIn(px, options.ratio);
|
|
7569
7795
|
const shiftOf = (part) => options.moving?.components.includes(part.component) ? options.moving.by : NO_SHIFT2;
|
|
7570
|
-
const each = (
|
|
7796
|
+
const each = (paint2) => {
|
|
7571
7797
|
for (const part of layout.parts) {
|
|
7572
7798
|
framed(ctx, shiftOf(part).x, shiftOf(part).y, 0, () => {
|
|
7573
7799
|
ctx.globalAlpha = alphaOf(part);
|
|
7574
|
-
|
|
7800
|
+
paint2(part);
|
|
7575
7801
|
});
|
|
7576
7802
|
}
|
|
7577
7803
|
ctx.globalAlpha = 1;
|
|
@@ -7591,6 +7817,8 @@ function drawPcb(ctx, layout, view, options) {
|
|
|
7591
7817
|
each((part) => {
|
|
7592
7818
|
if (shownOn(layers, part, "Silk")) drawPolylines(ctx, part.silkscreen, part.side === "top" ? PALETTE.topSilk : PALETTE.bottomSilk, Math.max(SILK_WIDTH_MM, hair), false);
|
|
7593
7819
|
});
|
|
7820
|
+
drawGraphics(ctx, layout.graphics ?? [], layers, options.silkTexts, px, options.copper?.activeLayer);
|
|
7821
|
+
drawSilkTexts(ctx, layout.silkTexts ?? [], layers, options.silkTexts, px);
|
|
7594
7822
|
if (layers.courtyard) drawCourtyards(ctx, each, px, hair);
|
|
7595
7823
|
each((part) => {
|
|
7596
7824
|
if (shownOn(layers, part, "Assembly")) drawPolylines(ctx, part.fabrication, assemblyColor(part), hair, false);
|
|
@@ -7642,11 +7870,11 @@ function roundRect(ctx, w, h, r) {
|
|
|
7642
7870
|
ctx.closePath();
|
|
7643
7871
|
}
|
|
7644
7872
|
var stadium = (ctx, w, h) => roundRect(ctx, w, h, Math.min(w, h) / 2);
|
|
7645
|
-
function drawBoard(ctx, layout,
|
|
7873
|
+
function drawBoard(ctx, layout, paint2) {
|
|
7646
7874
|
const outline2 = layout.board?.outline;
|
|
7647
7875
|
if (!outline2 || outline2.length < 3) return;
|
|
7648
7876
|
polygon2(ctx, outline2);
|
|
7649
|
-
|
|
7877
|
+
paint2();
|
|
7650
7878
|
}
|
|
7651
7879
|
function drawKeepouts(ctx, layout, px, hair) {
|
|
7652
7880
|
const keepouts = layout.board?.keepouts ?? [];
|
|
@@ -8031,18 +8259,18 @@ function pcbFrame(design, parts) {
|
|
|
8031
8259
|
}
|
|
8032
8260
|
function schematicFrame(design, page, parts) {
|
|
8033
8261
|
const pages = pageNames(design);
|
|
8034
|
-
const
|
|
8035
|
-
if (!pages.includes(
|
|
8036
|
-
const onPage = designOnPage(design,
|
|
8262
|
+
const shown2 = page ?? pages[0] ?? "Main";
|
|
8263
|
+
if (!pages.includes(shown2)) throw new Error(`No schematic page "${shown2}"; the pages are ${pages.map((name) => `"${name}"`).join(", ")}`);
|
|
8264
|
+
const onPage = designOnPage(design, shown2);
|
|
8037
8265
|
const layout = onPage.schematic;
|
|
8038
|
-
const title = `Schematic page "${
|
|
8266
|
+
const title = `Schematic page "${shown2}"`;
|
|
8039
8267
|
if (parts && parts.length > 0) {
|
|
8040
8268
|
const boxes = new Map(sheetBoxes(layout).map((part) => [part.name, part.box]));
|
|
8041
|
-
return { box: grown2(partBoxes(parts, boxes, `on page "${
|
|
8269
|
+
return { box: grown2(partBoxes(parts, boxes, `on page "${shown2}"`), PART_MARGIN, MIN_PART_MARGIN), what: `${title}, around ${parts.join(", ")}`, page: shown2, design: onPage };
|
|
8042
8270
|
}
|
|
8043
8271
|
const box3 = drawingExtents(layout);
|
|
8044
8272
|
if (!box3) throw new Error(`${title} is empty`);
|
|
8045
|
-
return { box: grown2(box3, WHOLE_MARGIN, 0), what: title, page:
|
|
8273
|
+
return { box: grown2(box3, WHOLE_MARGIN, 0), what: title, page: shown2, design: onPage };
|
|
8046
8274
|
}
|
|
8047
8275
|
function frameFor(design, request) {
|
|
8048
8276
|
if (request.view === "pcb") {
|
|
@@ -8556,8 +8784,8 @@ function partSolid(part, props, footprintText, thickness) {
|
|
|
8556
8784
|
const world = local.map((p) => placed(p, part));
|
|
8557
8785
|
const corners = doubledArea(world) < 0 ? [world[0], world[3], world[2], world[1]] : world;
|
|
8558
8786
|
const { height, source, state, assumed } = partHeight({ ...footprintText === void 0 ? {} : { footprint: footprintText }, props });
|
|
8559
|
-
const [
|
|
8560
|
-
return { name: part.component, side: part.side, corners, bottom, top, height, source, state, assumed };
|
|
8787
|
+
const [bottom2, top] = part.side === "top" ? [thickness, thickness + height] : [-height, 0];
|
|
8788
|
+
return { name: part.component, side: part.side, corners, bottom: bottom2, top, height, source, state, assumed };
|
|
8561
8789
|
}
|
|
8562
8790
|
function solidModel(design) {
|
|
8563
8791
|
const thickness = boardThickness(design);
|
|
@@ -8608,10 +8836,10 @@ function prism(polygon3, z0, z1, colors, material, role, sideColor2) {
|
|
|
8608
8836
|
return [cap, ...sides];
|
|
8609
8837
|
}
|
|
8610
8838
|
function facet(loop, outward, color, material, role) {
|
|
8611
|
-
const
|
|
8612
|
-
const flip =
|
|
8839
|
+
const wound3 = windNormal(loop);
|
|
8840
|
+
const flip = wound3[0] * outward[0] + wound3[1] * outward[1] + wound3[2] * outward[2] < 0;
|
|
8613
8841
|
const turned = flip ? [...loop].reverse() : [...loop];
|
|
8614
|
-
return { loops: [turned], normal: flip ? [-
|
|
8842
|
+
return { loops: [turned], normal: flip ? [-wound3[0], -wound3[1], -wound3[2]] : wound3, color, material, role };
|
|
8615
8843
|
}
|
|
8616
8844
|
function hanging(polygon3, z0, z1, color, material, role) {
|
|
8617
8845
|
if (!(z0 > z1)) return [];
|
|
@@ -8648,20 +8876,20 @@ function windNormal(loop) {
|
|
|
8648
8876
|
function lathe(profile, cx, cy, sides, colors, material, role) {
|
|
8649
8877
|
if (profile.length < 2 || sides < 3) return [];
|
|
8650
8878
|
const { top, side } = colorsOf(colors);
|
|
8651
|
-
const
|
|
8879
|
+
const ring4 = (radius, z, i) => {
|
|
8652
8880
|
const angle = 2 * Math.PI * i / sides;
|
|
8653
8881
|
return [cx + radius * Math.cos(angle), cy + radius * Math.sin(angle), z];
|
|
8654
8882
|
};
|
|
8655
8883
|
const bands = profile.slice(1).flatMap(([r1, z1], k) => {
|
|
8656
8884
|
const [r0, z0] = profile[k];
|
|
8657
8885
|
return Array.from({ length: sides }, (_, i) => {
|
|
8658
|
-
const corners = [
|
|
8886
|
+
const corners = [ring4(r0, z0, i), ring4(r0, z0, i + 1), ring4(r1, z1, i + 1), ring4(r1, z1, i)];
|
|
8659
8887
|
const loop = corners.filter((p, j) => j === 0 || Math.hypot(p[0] - corners[j - 1][0], p[1] - corners[j - 1][1]) > 1e-12 || p[2] !== corners[j - 1][2]);
|
|
8660
8888
|
return loop.length < 3 ? [] : [{ loops: [loop], normal: windNormal(loop), color: side, material, role }];
|
|
8661
8889
|
}).flat();
|
|
8662
8890
|
});
|
|
8663
8891
|
const [lastR, lastZ] = profile[profile.length - 1];
|
|
8664
|
-
const lid2 = lastR > 0 ? [{ loops: [Array.from({ length: sides }, (_, i) =>
|
|
8892
|
+
const lid2 = lastR > 0 ? [{ loops: [Array.from({ length: sides }, (_, i) => ring4(lastR, lastZ, i))], normal: [0, 0, 1], color: top, material, role }] : [];
|
|
8665
8893
|
return [...lid2, ...bands];
|
|
8666
8894
|
}
|
|
8667
8895
|
var rectPolygon = (r) => [
|
|
@@ -8822,14 +9050,14 @@ function ledShape(input) {
|
|
|
8822
9050
|
const outline2 = flangeOutline(radius, cut, sign);
|
|
8823
9051
|
const onFlat = (i) => outline2[i]?.x === cut && outline2[(i + 1) % outline2.length]?.x === cut ? look.mark : void 0;
|
|
8824
9052
|
const flangeColor = wash(look.body);
|
|
8825
|
-
const
|
|
9053
|
+
const ring4 = prism(outline2, 0, flange, flangeColor, "matt", "body", onFlat).map((piece) => Math.abs(piece.normal[0]) > 0.99 && piece.normal[0] * sign > 0 ? { ...piece, role: "cathode" } : piece);
|
|
8826
9054
|
const dome = Array.from({ length: DOME_STEPS }, (_, k) => {
|
|
8827
9055
|
const angle = Math.PI / 2 * ((k + 1) / DOME_STEPS);
|
|
8828
9056
|
return k === DOME_STEPS - 1 ? [0, h] : [lens2 * Math.cos(angle), axis + lens2 * Math.sin(angle)];
|
|
8829
9057
|
});
|
|
8830
9058
|
const profile = [[lens2, flange], [lens2, axis], ...dome];
|
|
8831
9059
|
const lensPieces = lathe(profile, 0, 0, SIDES2, { top: look.top ?? look.body, side: look.body }, "matt", "body");
|
|
8832
|
-
return [...
|
|
9060
|
+
return [...ring4, ...lensPieces, ...leads(input, look.metal, LEAD_HALF)];
|
|
8833
9061
|
}
|
|
8834
9062
|
|
|
8835
9063
|
// studio/src/look/parts/screw.ts
|
|
@@ -9044,12 +9272,12 @@ function pin1Dot(input, body, top, roomy = Infinity) {
|
|
|
9044
9272
|
function gullwingShape(input) {
|
|
9045
9273
|
const body = bodyRect(input);
|
|
9046
9274
|
const h = input.height;
|
|
9047
|
-
const { bottom, top } = bodyBand(h);
|
|
9275
|
+
const { bottom: bottom2, top } = bodyBand(h);
|
|
9048
9276
|
const { look } = input;
|
|
9049
|
-
const pieces = [...box(body,
|
|
9277
|
+
const pieces = [...box(body, bottom2, top, look.body, "matt", "body")];
|
|
9050
9278
|
const legged = legPads(input);
|
|
9051
9279
|
for (const pad of legged) pieces.push(...leg(pad, padSide(pad), body, h, look.metal));
|
|
9052
|
-
for (const pad of input.pads.filter((one) => !legged.includes(one))) pieces.push(...box(clipped(padRect(pad), body), 0, Math.min(PLATE,
|
|
9280
|
+
for (const pad of input.pads.filter((one) => !legged.includes(one))) pieces.push(...box(clipped(padRect(pad), body), 0, Math.min(PLATE, bottom2), look.metal, "metal", "cap"));
|
|
9053
9281
|
pieces.push(...pin1Dot(input, body, top));
|
|
9054
9282
|
return clipPieces(pieces, input.limit);
|
|
9055
9283
|
}
|
|
@@ -9675,13 +9903,13 @@ function tantalumShape(input) {
|
|
|
9675
9903
|
if (axis === void 0) return [];
|
|
9676
9904
|
const [half, across] = [axis.bodyAlong / 2, axis.bodyAcross / 2];
|
|
9677
9905
|
const h = input.height;
|
|
9678
|
-
const { bottom, top } = bodyBand(h);
|
|
9906
|
+
const { bottom: bottom2, top } = bodyBand(h);
|
|
9679
9907
|
const { look } = input;
|
|
9680
9908
|
const local = (minX, maxX, y) => ({ minX, maxX, minY: -y, maxY: y });
|
|
9681
9909
|
const stripe = Math.max(axis.bodyAlong * STRIPE_SHARE, STRIPE_LEAST);
|
|
9682
9910
|
const wide = Math.min(across, axis.padAcross / 2) * 0.9;
|
|
9683
9911
|
const pieces = [
|
|
9684
|
-
...box(local(-half, half, across),
|
|
9912
|
+
...box(local(-half, half, across), bottom2, top, look.body, "matt", "body"),
|
|
9685
9913
|
...box(local(-half + stripe * 0.5, -half + stripe * 1.5, across), top, h, look.mark, "matt", "pin1"),
|
|
9686
9914
|
...box(local(-half - THICK, -half + TUCK3, wide), 0, h * WRAP, look.metal, "metal", "cap"),
|
|
9687
9915
|
...box(local(half - TUCK3, half + THICK, wide), 0, h * WRAP, look.metal, "metal", "cap")
|
|
@@ -9808,8 +10036,8 @@ var PIN_LENGTH_SHARE = 0.72;
|
|
|
9808
10036
|
var FOLD = 3;
|
|
9809
10037
|
var FOLD_SHARE = 0.3;
|
|
9810
10038
|
function face(x0, x1, y, h, cx, cz, radius, color) {
|
|
9811
|
-
const
|
|
9812
|
-
return { loops: [[[x0, y, 0], [x1, y, 0], [x1, y, h], [x0, y, h]], [...
|
|
10039
|
+
const ring4 = Array.from({ length: SIDES7 }, (_, i) => [cx + radius * Math.cos(2 * Math.PI * i / SIDES7), y, cz + radius * Math.sin(2 * Math.PI * i / SIDES7)]);
|
|
10040
|
+
return { loops: [[[x0, y, 0], [x1, y, 0], [x1, y, h], [x0, y, h]], [...ring4].reverse()], normal: [0, -1, 0], color, material: "matt", role: "body" };
|
|
9813
10041
|
}
|
|
9814
10042
|
function dcJackShape(input) {
|
|
9815
10043
|
const body = clipped(input.body ?? grown3(input.limit, -0.25), input.limit);
|
|
@@ -9914,8 +10142,8 @@ function resonatorShape(input) {
|
|
|
9914
10142
|
const x = { minX: Math.max(r.minX, pad.x - TERMINAL_HALF), maxX: Math.min(r.maxX, pad.x + TERMINAL_HALF) };
|
|
9915
10143
|
const height = Math.min(TERMINAL_HEIGHT3, split * TERMINAL_SHARE2);
|
|
9916
10144
|
const top = { ...x, minY: Math.max(r.minY, body.maxY - TUCK5), maxY: Math.min(r.maxY, body.maxY + OUT) };
|
|
9917
|
-
const
|
|
9918
|
-
pieces.push(...box(top, 0, height, look.metal, "metal", "leg"), ...box(
|
|
10145
|
+
const bottom2 = { ...x, minY: Math.max(r.minY, body.minY - OUT), maxY: Math.min(r.maxY, body.minY + TUCK5) };
|
|
10146
|
+
pieces.push(...box(top, 0, height, look.metal, "metal", "leg"), ...box(bottom2, 0, height, look.metal, "metal", "leg"));
|
|
9919
10147
|
}
|
|
9920
10148
|
return pieces;
|
|
9921
10149
|
}
|
|
@@ -10085,9 +10313,9 @@ function tabShape(input) {
|
|
|
10085
10313
|
const outline2 = input.outlines !== void 0 && input.outlines.length > 1 ? rectOf(input.outlines[0]) : input.body;
|
|
10086
10314
|
const body = outline2 ? clipped(outline2, input.limit) : bodyRect({ ...input, pads: narrow });
|
|
10087
10315
|
const h = input.height;
|
|
10088
|
-
const { bottom, top } = bodyBand(h);
|
|
10316
|
+
const { bottom: bottom2, top } = bodyBand(h);
|
|
10089
10317
|
const { look } = input;
|
|
10090
|
-
const pieces = [...box(body,
|
|
10318
|
+
const pieces = [...box(body, bottom2, top, look.body, "matt", "body")];
|
|
10091
10319
|
for (const pad of narrow) pieces.push(...leg(pad, padSide(pad), body, h, look.metal));
|
|
10092
10320
|
if (wide !== void 0) pieces.push(...tab(wide, body, h, look.metal));
|
|
10093
10321
|
pieces.push(...pin1Dot(input, body, top));
|
|
@@ -10235,14 +10463,14 @@ var FALLBACK = { minX: -0.5, minY: -0.5, maxX: 0.5, maxY: 0.5 };
|
|
|
10235
10463
|
function placer(part, thickness) {
|
|
10236
10464
|
const r = part.rotation * Math.PI / 180;
|
|
10237
10465
|
const [c, s] = [Math.cos(r), Math.sin(r)];
|
|
10238
|
-
const
|
|
10466
|
+
const bottom2 = part.side === "bottom";
|
|
10239
10467
|
const point = (p) => {
|
|
10240
10468
|
const [x, y] = [p[0] * c - p[1] * s, p[0] * s + p[1] * c];
|
|
10241
|
-
return [part.x + (
|
|
10469
|
+
return [part.x + (bottom2 ? -x : x), part.y + y, bottom2 ? -p[2] : thickness + p[2]];
|
|
10242
10470
|
};
|
|
10243
10471
|
const normal = (n) => {
|
|
10244
10472
|
const [x, y] = [n[0] * c - n[1] * s, n[0] * s + n[1] * c];
|
|
10245
|
-
return [
|
|
10473
|
+
return [bottom2 ? -x : x, y, bottom2 ? -n[2] : n[2]];
|
|
10246
10474
|
};
|
|
10247
10475
|
return { point, normal };
|
|
10248
10476
|
}
|
|
@@ -10261,8 +10489,8 @@ function partFaces(design, model) {
|
|
|
10261
10489
|
const component = components.get(part.component);
|
|
10262
10490
|
const through2 = part.pads.some((pad) => pad.layers === "through");
|
|
10263
10491
|
const { family, look, parsed: parsed2 } = familyOf(component?.kind ?? "", component?.footprint, through2, part.component);
|
|
10264
|
-
const
|
|
10265
|
-
const input = shapeInput(part, solid.height,
|
|
10492
|
+
const paint2 = family === "ledth" ? ledLook(FAMILY_LOOKS[look], component?.props) : FAMILY_LOOKS[look];
|
|
10493
|
+
const input = shapeInput(part, solid.height, paint2, parsed2, thickness, look);
|
|
10266
10494
|
const shaped = part.footprint === void 0 ? [] : SHAPES[family](input);
|
|
10267
10495
|
const pieces = shaped.length === 0 ? plainBox(input) : shaped;
|
|
10268
10496
|
const place3 = placer(part, thickness);
|
|
@@ -10329,10 +10557,10 @@ function projectFace(face2, view) {
|
|
|
10329
10557
|
return { loops, a, b, c };
|
|
10330
10558
|
}
|
|
10331
10559
|
function scan(face2, width, height, fill) {
|
|
10332
|
-
let [top,
|
|
10333
|
-
for (const loop of face2.loops) for (const p of loop) [top,
|
|
10560
|
+
let [top, bottom2] = [Infinity, -Infinity];
|
|
10561
|
+
for (const loop of face2.loops) for (const p of loop) [top, bottom2] = [Math.min(top, p.y), Math.max(bottom2, p.y)];
|
|
10334
10562
|
const first = Math.max(0, Math.ceil(top - 0.5));
|
|
10335
|
-
const last = Math.min(height - 1, Math.floor(
|
|
10563
|
+
const last = Math.min(height - 1, Math.floor(bottom2 - 0.5));
|
|
10336
10564
|
const crossings = [];
|
|
10337
10565
|
for (let row3 = first; row3 <= last; row3++) {
|
|
10338
10566
|
const y = row3 + 0.5;
|
|
@@ -10412,8 +10640,8 @@ function drawLit(scene, view, frame, options) {
|
|
|
10412
10640
|
const { scale, add } = lightFace(face2.normal, view.eye, key, face2.material);
|
|
10413
10641
|
const lift = face2.part >= 0 && face2.part === options.highlight ? HIGHLIGHT : 0;
|
|
10414
10642
|
const tone = (c2) => Math.min(255, c2 * scale + add) * (1 - lift) + 255 * lift;
|
|
10415
|
-
const
|
|
10416
|
-
if (!
|
|
10643
|
+
const paint2 = face2.paint;
|
|
10644
|
+
if (!paint2) {
|
|
10417
10645
|
const [r, g, b2] = [tone(face2.color[0]), tone(face2.color[1]), tone(face2.color[2])];
|
|
10418
10646
|
scan(projected, width, height, (i, depth) => {
|
|
10419
10647
|
if (depth >= frame.depth[i]) return;
|
|
@@ -10435,7 +10663,7 @@ function drawLit(scene, view, frame, options) {
|
|
|
10435
10663
|
});
|
|
10436
10664
|
const [X, Y, Z] = [axis(0), axis(1), axis(2)];
|
|
10437
10665
|
const fine = options.fine ?? false;
|
|
10438
|
-
const texture =
|
|
10666
|
+
const texture = paint2.texture;
|
|
10439
10667
|
if (texture && !fine) {
|
|
10440
10668
|
const sign = texture.mirrored ? -1 : 1;
|
|
10441
10669
|
const p = texture.pxPerMm;
|
|
@@ -10467,7 +10695,7 @@ function drawLit(scene, view, frame, options) {
|
|
|
10467
10695
|
const x = X.A * col + X.B * row3 + X.C;
|
|
10468
10696
|
const y = Y.A * col + Y.B * row3 + Y.C;
|
|
10469
10697
|
const z = Z.A * col + Z.B * row3 + Z.C;
|
|
10470
|
-
if (
|
|
10698
|
+
if (paint2.at(x, y, z, sample, fine) < 0.5) return;
|
|
10471
10699
|
frame.depth[i] = depth;
|
|
10472
10700
|
frame.ids[i] = face2.part;
|
|
10473
10701
|
frame.faces[i] = index;
|
|
@@ -10622,7 +10850,7 @@ function loopPoints(loop) {
|
|
|
10622
10850
|
function prismFaces(loops, z0, z1, color, alpha, part) {
|
|
10623
10851
|
const at2 = (z) => (p) => [p.x, p.y, z];
|
|
10624
10852
|
const top = { loops: loops.map((loop) => loop.map(at2(z1))), normal: [0, 0, 1], color, alpha, part };
|
|
10625
|
-
const
|
|
10853
|
+
const bottom2 = { loops: loops.map((loop) => [...loop].reverse().map(at2(z0))), normal: [0, 0, -1], color, alpha, part };
|
|
10626
10854
|
const sides = loops.flatMap(
|
|
10627
10855
|
(loop) => loop.map((p, i) => {
|
|
10628
10856
|
const q = loop[(i + 1) % loop.length];
|
|
@@ -10630,7 +10858,7 @@ function prismFaces(loops, z0, z1, color, alpha, part) {
|
|
|
10630
10858
|
return { loops: [[at2(z0)(p), at2(z0)(q), at2(z1)(q), at2(z1)(p)]], normal: [(q.y - p.y) / length2, -(q.x - p.x) / length2, 0], color, alpha, part };
|
|
10631
10859
|
})
|
|
10632
10860
|
);
|
|
10633
|
-
return [top,
|
|
10861
|
+
return [top, bottom2, ...sides];
|
|
10634
10862
|
}
|
|
10635
10863
|
function litBoard(board, options) {
|
|
10636
10864
|
const colours = plainBoardColours(options.look ?? {});
|
|
@@ -10639,7 +10867,7 @@ function litBoard(board, options) {
|
|
|
10639
10867
|
const at2 = (z) => (p) => [p.x, p.y, z];
|
|
10640
10868
|
const faceLoops = (texture) => texture ? loops.slice(0, 1) : loops;
|
|
10641
10869
|
const top = { loops: faceLoops(options.textures?.top).map((loop) => loop.map(at2(t))), normal: [0, 0, 1], color: colours.mask, alpha: 1, part: -1, material: "matt", role: "board", ...options.textures?.top ? { paint: texturePaint(options.textures.top) } : {} };
|
|
10642
|
-
const
|
|
10870
|
+
const bottom2 = { loops: faceLoops(options.textures?.bottom).map((loop) => [...loop].reverse().map(at2(0))), normal: [0, 0, -1], color: colours.mask, alpha: 1, part: -1, material: "matt", role: "board", ...options.textures?.bottom ? { paint: texturePaint(options.textures.bottom) } : {} };
|
|
10643
10871
|
const edge = edgePaint(t, options.layers ?? 2, colours.mask);
|
|
10644
10872
|
const mounting = options.mounting ?? 0;
|
|
10645
10873
|
const walls = loops.flatMap(
|
|
@@ -10660,7 +10888,7 @@ function litBoard(board, options) {
|
|
|
10660
10888
|
};
|
|
10661
10889
|
})
|
|
10662
10890
|
);
|
|
10663
|
-
return [top,
|
|
10891
|
+
return [top, bottom2, ...walls];
|
|
10664
10892
|
}
|
|
10665
10893
|
function buildScene(model, options) {
|
|
10666
10894
|
const board = model.board;
|
|
@@ -10714,26 +10942,27 @@ function viaSpan(via) {
|
|
|
10714
10942
|
return new Set(STACK.slice(Math.min(...indices), Math.max(...indices) + 1));
|
|
10715
10943
|
}
|
|
10716
10944
|
|
|
10717
|
-
// src/engine/
|
|
10718
|
-
var
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
const
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10945
|
+
// src/engine/fab/graphic-objects.ts
|
|
10946
|
+
var wound = (ring4, counterClockwise) => {
|
|
10947
|
+
const area2 = ring4.reduce((sum, a, i) => {
|
|
10948
|
+
const b = ring4[(i + 1) % ring4.length];
|
|
10949
|
+
return sum + a.x * b.y - b.x * a.y;
|
|
10950
|
+
}, 0);
|
|
10951
|
+
return area2 > 0 === counterClockwise ? [...ring4] : [...ring4].reverse();
|
|
10952
|
+
};
|
|
10953
|
+
function graphicObjects(graphics, layer, fn) {
|
|
10954
|
+
const here = (graphics ?? []).filter((graphic) => graphic.layer === layer);
|
|
10955
|
+
if (here.length === 0) return { areas: [], lines: [] };
|
|
10956
|
+
const extra = fn === void 0 ? {} : { function: fn };
|
|
10957
|
+
const paths = here.flatMap((graphic) => graphic.areas.flatMap((area2) => [toPath(wound(area2.outer, true)), ...area2.holes.map((hole) => toPath(wound(hole, false)))]));
|
|
10958
|
+
const pieces = paths.length === 0 ? [] : regions(paths).sort((a, b) => Math.abs(pathArea(b.outer)) - Math.abs(pathArea(a.outer)));
|
|
10959
|
+
const areas = pieces.flatMap((piece) => [
|
|
10960
|
+
{ kind: "region", points: toPoints(piece.outer), ...extra },
|
|
10961
|
+
...piece.holes.map((hole) => ({ kind: "region", points: toPoints(hole), polarity: "clear" }))
|
|
10962
|
+
]);
|
|
10963
|
+
const lines2 = here.flatMap((graphic) => graphic.lines.filter((line2) => line2.points.length > 0).map((line2) => ({ kind: "draw", points: line2.points, width: line2.width, ...extra })));
|
|
10964
|
+
return { areas, lines: lines2 };
|
|
10735
10965
|
}
|
|
10736
|
-
var pathArea = (path2) => import_clipper_lib.default.Clipper.Area(path2);
|
|
10737
10966
|
|
|
10738
10967
|
// src/engine/fab/layers.ts
|
|
10739
10968
|
var DEFAULT_PASTE_REDUCTION = 0;
|
|
@@ -10807,18 +11036,58 @@ function pourObjects(pcb, layer) {
|
|
|
10807
11036
|
...piece.holes.map((hole) => ({ kind: "region", points: toPoints(hole), polarity: "clear" }))
|
|
10808
11037
|
]);
|
|
10809
11038
|
}
|
|
11039
|
+
function drawingCopper(pcb, layer) {
|
|
11040
|
+
const here = (pcb.graphics ?? []).filter((graphic) => graphic.layer === layer);
|
|
11041
|
+
return here.flatMap((graphic) => [
|
|
11042
|
+
...graphic.areas.map((area2) => ({ kind: "region", points: withCutIns(area2), function: "Conductor" })),
|
|
11043
|
+
...graphic.lines.filter((line2) => line2.points.length > 0).map((line2) => ({ kind: "draw", points: line2.points, width: line2.width, function: "Conductor" }))
|
|
11044
|
+
]);
|
|
11045
|
+
}
|
|
11046
|
+
var wound2 = (ring4, counterClockwise) => {
|
|
11047
|
+
const twice = ring4.reduce((sum, a, i) => {
|
|
11048
|
+
const b = ring4[(i + 1) % ring4.length];
|
|
11049
|
+
return sum + a.x * b.y - b.x * a.y;
|
|
11050
|
+
}, 0);
|
|
11051
|
+
return twice > 0 === counterClockwise ? [...ring4] : [...ring4].reverse();
|
|
11052
|
+
};
|
|
11053
|
+
function withCutIns(area2) {
|
|
11054
|
+
return area2.holes.reduce((ring4, raw) => {
|
|
11055
|
+
const hole = wound2(raw, false);
|
|
11056
|
+
let [best, at2, from] = [Infinity, 0, 0];
|
|
11057
|
+
hole.forEach(
|
|
11058
|
+
(h, j) => ring4.forEach((o, i) => {
|
|
11059
|
+
const d = (o.x - h.x) ** 2 + (o.y - h.y) ** 2;
|
|
11060
|
+
if (d < best) [best, at2, from] = [d, i, j];
|
|
11061
|
+
})
|
|
11062
|
+
);
|
|
11063
|
+
const loop = [...hole.slice(from), ...hole.slice(0, from), hole[from]];
|
|
11064
|
+
return [...ring4.slice(0, at2 + 1), ...loop, ...ring4.slice(at2)];
|
|
11065
|
+
}, wound2(area2.outer, true));
|
|
11066
|
+
}
|
|
10810
11067
|
function copperObjects(pcb, layer) {
|
|
10811
11068
|
const padCopper = pads(pcb.parts).filter((pad) => pad.layers === "through" || pad.layers === layer).map((pad) => padObject(pad, 0, padFunction(pad)));
|
|
10812
11069
|
const tracks = pcb.tracks.filter((track) => track.layer === layer && track.missingLayer === void 0).map((track) => ({ kind: "draw", points: track.points, width: track.width, function: "Conductor" }));
|
|
10813
11070
|
const vias = pcb.vias.filter((via) => via.missingLayer === void 0 && viaSpan(via).has(layer)).map((via) => ({ kind: "flash", at: via.at, aperture: { shape: "circle", diameter: via.diameter }, function: "ViaPad" }));
|
|
10814
|
-
return [...pourObjects(pcb, layer), ...padCopper.filter(present), ...tracks, ...vias];
|
|
11071
|
+
return [...pourObjects(pcb, layer), ...drawingCopper(pcb, layer), ...padCopper.filter(present), ...tracks, ...vias];
|
|
10815
11072
|
}
|
|
10816
11073
|
function silkObjects(pcb, side, expansion, clearance) {
|
|
10817
11074
|
const designators = designatorPlacements(pcb, expansion, clearance).filter((placed2) => placed2.side === side);
|
|
11075
|
+
const draw2 = (width) => (points) => ({ kind: "draw", points, width, function: LEGEND_FUNCTION });
|
|
11076
|
+
const texts = (pcb.silkTexts ?? []).filter((text2) => text2.layer === side).flatMap((text2) => silkTextStrokes(text2).map(draw2(silkTextLineWidth(text2.height))));
|
|
11077
|
+
const drawings = graphicObjects(pcb.graphics, `${side}-silkscreen`, LEGEND_FUNCTION);
|
|
10818
11078
|
return [
|
|
10819
|
-
...
|
|
10820
|
-
...
|
|
10821
|
-
|
|
11079
|
+
...drawings.areas,
|
|
11080
|
+
...[
|
|
11081
|
+
...pcb.parts.filter((part) => part.side === side).flatMap((part) => part.silkscreen),
|
|
11082
|
+
...designators.flatMap((placed2) => textStrokes(placed2.component, placed2.at, DESIGNATOR_HEIGHT, side === "bottom", placed2.rotation === 90))
|
|
11083
|
+
].filter((line2) => line2.length > 0).map(draw2(SILK_WIDTH)),
|
|
11084
|
+
...texts,
|
|
11085
|
+
...drawings.lines
|
|
11086
|
+
];
|
|
11087
|
+
}
|
|
11088
|
+
function maskObjects(pcb, side, onSide, expansion) {
|
|
11089
|
+
const drawings = graphicObjects(pcb.graphics, `${side}-mask`);
|
|
11090
|
+
return [...drawings.areas, ...onSide.map((pad) => padObject(pad, expansion, padFunction(pad))).filter(present), ...drawings.lines];
|
|
10822
11091
|
}
|
|
10823
11092
|
function outlineObjects(pcb) {
|
|
10824
11093
|
const outline2 = pcb.board?.outline ?? [];
|
|
@@ -10838,7 +11107,7 @@ function gerberLayers(pcb, fabrication) {
|
|
|
10838
11107
|
});
|
|
10839
11108
|
for (const side of SIDES8) {
|
|
10840
11109
|
const onSide = pads(pcb.parts).filter((pad) => padOnSide(pad, side));
|
|
10841
|
-
const mask =
|
|
11110
|
+
const mask = maskObjects(pcb, side, onSide, expansion);
|
|
10842
11111
|
const paste = onSide.filter(isSmd).map((pad) => padObject(pad, -reduction, padFunction(pad))).filter(present);
|
|
10843
11112
|
layers.set(`${SIDE_KEY[side]}_Mask`, { fileFunction: `Soldermask,${SIDE_X2[side]}`, polarity: "Negative", objects: mask });
|
|
10844
11113
|
layers.set(`${SIDE_KEY[side]}_Paste`, { fileFunction: `Paste,${SIDE_X2[side]}`, polarity: "Positive", objects: paste });
|
|
@@ -11048,32 +11317,32 @@ function band2(d, half) {
|
|
|
11048
11317
|
}
|
|
11049
11318
|
var length = (x, y) => Math.sqrt(x * x + y * y);
|
|
11050
11319
|
var clamp012 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
11051
|
-
function put(data, i, c,
|
|
11320
|
+
function put(data, i, c, paint2) {
|
|
11052
11321
|
if (c <= 0) return;
|
|
11053
|
-
if (
|
|
11322
|
+
if (paint2 === "dark") {
|
|
11054
11323
|
if (c > data[i]) data[i] = c;
|
|
11055
11324
|
} else {
|
|
11056
11325
|
const left = 1 - c;
|
|
11057
11326
|
if (left < data[i]) data[i] = left;
|
|
11058
11327
|
}
|
|
11059
11328
|
}
|
|
11060
|
-
function eachPixel(layer, a, b, reach, cover,
|
|
11329
|
+
function eachPixel(layer, a, b, reach, cover, paint2) {
|
|
11061
11330
|
const x0 = Math.max(0, Math.floor(Math.min(a.x, b.x) - reach));
|
|
11062
11331
|
const x1 = Math.min(layer.width, Math.ceil(Math.max(a.x, b.x) + reach));
|
|
11063
11332
|
const y0 = Math.max(0, Math.floor(Math.min(a.y, b.y) - reach));
|
|
11064
11333
|
const y1 = Math.min(layer.height, Math.ceil(Math.max(a.y, b.y) + reach));
|
|
11065
11334
|
for (let y = y0; y < y1; y += 1) {
|
|
11066
11335
|
const row3 = y * layer.width;
|
|
11067
|
-
for (let x = x0; x < x1; x += 1) put(layer.data, row3 + x, cover(x + 0.5, y + 0.5),
|
|
11336
|
+
for (let x = x0; x < x1; x += 1) put(layer.data, row3 + x, cover(x + 0.5, y + 0.5), paint2);
|
|
11068
11337
|
}
|
|
11069
11338
|
}
|
|
11070
|
-
function disc2(layer, c, r,
|
|
11071
|
-
eachPixel(layer, c, c, r + 1, (x, y) => band2(length(x - c.x, y - c.y), r),
|
|
11339
|
+
function disc2(layer, c, r, paint2 = "dark") {
|
|
11340
|
+
eachPixel(layer, c, c, r + 1, (x, y) => band2(length(x - c.x, y - c.y), r), paint2);
|
|
11072
11341
|
}
|
|
11073
|
-
function capsule(layer, a, b, r,
|
|
11342
|
+
function capsule(layer, a, b, r, paint2 = "dark") {
|
|
11074
11343
|
const [dx, dy] = [b.x - a.x, b.y - a.y];
|
|
11075
11344
|
const length2 = dx * dx + dy * dy;
|
|
11076
|
-
if (length2 === 0) return disc2(layer, a, r,
|
|
11345
|
+
if (length2 === 0) return disc2(layer, a, r, paint2);
|
|
11077
11346
|
eachPixel(
|
|
11078
11347
|
layer,
|
|
11079
11348
|
a,
|
|
@@ -11083,10 +11352,10 @@ function capsule(layer, a, b, r, paint = "dark") {
|
|
|
11083
11352
|
const t = clamp012(((x - a.x) * dx + (y - a.y) * dy) / length2);
|
|
11084
11353
|
return band2(length(x - a.x - t * dx, y - a.y - t * dy), r);
|
|
11085
11354
|
},
|
|
11086
|
-
|
|
11355
|
+
paint2
|
|
11087
11356
|
);
|
|
11088
11357
|
}
|
|
11089
|
-
function box2(layer, c, hw, hh, angle, radius,
|
|
11358
|
+
function box2(layer, c, hw, hh, angle, radius, paint2 = "dark") {
|
|
11090
11359
|
const [cos, sin] = [Math.cos(angle), Math.sin(angle)];
|
|
11091
11360
|
const reach = Math.hypot(hw, hh) + 1;
|
|
11092
11361
|
const rounded = Math.min(radius, hw, hh);
|
|
@@ -11105,7 +11374,7 @@ function box2(layer, c, hw, hh, angle, radius, paint = "dark") {
|
|
|
11105
11374
|
const distance = outside + Math.min(Math.max(qx, qy), 0) - rounded;
|
|
11106
11375
|
return clamp012(0.5 - distance);
|
|
11107
11376
|
},
|
|
11108
|
-
|
|
11377
|
+
paint2
|
|
11109
11378
|
);
|
|
11110
11379
|
}
|
|
11111
11380
|
function edgesOf(paths) {
|
|
@@ -11115,8 +11384,8 @@ function edgesOf(paths) {
|
|
|
11115
11384
|
const a = path2[i];
|
|
11116
11385
|
const b = path2[(i + 1) % path2.length];
|
|
11117
11386
|
if (a.y === b.y) continue;
|
|
11118
|
-
const [top,
|
|
11119
|
-
edges.push({ x0: top.x, y0: top.y, y1:
|
|
11387
|
+
const [top, bottom2, dir] = a.y < b.y ? [a, b, 1] : [b, a, -1];
|
|
11388
|
+
edges.push({ x0: top.x, y0: top.y, y1: bottom2.y, slope: (bottom2.x - top.x) / (bottom2.y - top.y), dir });
|
|
11120
11389
|
}
|
|
11121
11390
|
}
|
|
11122
11391
|
return edges.sort((a, b) => a.y0 - b.y0);
|
|
@@ -11133,18 +11402,18 @@ function addSpan(parts, steps, a, b, weight) {
|
|
|
11133
11402
|
steps[ib] = steps[ib] - weight;
|
|
11134
11403
|
parts[ib] = parts[ib] + (b - ib) * weight;
|
|
11135
11404
|
}
|
|
11136
|
-
function polygons(layer, paths, rule,
|
|
11405
|
+
function polygons(layer, paths, rule, paint2 = "dark") {
|
|
11137
11406
|
const edges = edgesOf(paths);
|
|
11138
11407
|
if (edges.length === 0) return;
|
|
11139
11408
|
const top = Math.max(0, Math.floor(edges[0]?.y0 ?? 0));
|
|
11140
|
-
const
|
|
11409
|
+
const bottom2 = Math.min(layer.height, Math.ceil(Math.max(...edges.map((edge) => edge.y1))));
|
|
11141
11410
|
const parts = new Float32Array(layer.width + 2);
|
|
11142
11411
|
const steps = new Float32Array(layer.width + 2);
|
|
11143
11412
|
const crossings = [];
|
|
11144
11413
|
let next = 0;
|
|
11145
11414
|
let active = [];
|
|
11146
11415
|
const weight = 1 / SUBROWS;
|
|
11147
|
-
for (let y = top; y <
|
|
11416
|
+
for (let y = top; y < bottom2; y += 1) {
|
|
11148
11417
|
while (next < edges.length && edges[next].y0 < y + 1) active.push(edges[next++]);
|
|
11149
11418
|
active = active.filter((edge) => edge.y1 > y);
|
|
11150
11419
|
if (active.length === 0) continue;
|
|
@@ -11173,7 +11442,7 @@ function polygons(layer, paths, rule, paint = "dark") {
|
|
|
11173
11442
|
const row3 = y * layer.width;
|
|
11174
11443
|
for (let x = from; x < to; x += 1) {
|
|
11175
11444
|
run += steps[x];
|
|
11176
|
-
put(layer.data, row3 + x, Math.min(run + parts[x], 1),
|
|
11445
|
+
put(layer.data, row3 + x, Math.min(run + parts[x], 1), paint2);
|
|
11177
11446
|
parts[x] = 0;
|
|
11178
11447
|
steps[x] = 0;
|
|
11179
11448
|
}
|
|
@@ -11186,22 +11455,22 @@ function pictureAngle(grid, degrees) {
|
|
|
11186
11455
|
const radians = degrees * Math.PI / 180;
|
|
11187
11456
|
return Math.atan2(-Math.sin(radians), (grid.mirrored ? -1 : 1) * Math.cos(radians));
|
|
11188
11457
|
}
|
|
11189
|
-
function flash(layer, grid, at2, aperture,
|
|
11458
|
+
function flash(layer, grid, at2, aperture, paint2) {
|
|
11190
11459
|
const s = grid.pxPerMm;
|
|
11191
11460
|
const c = toPixel(grid, at2);
|
|
11192
11461
|
switch (aperture.shape) {
|
|
11193
11462
|
case "circle":
|
|
11194
|
-
return disc2(layer, c, aperture.diameter / 2 * s,
|
|
11463
|
+
return disc2(layer, c, aperture.diameter / 2 * s, paint2);
|
|
11195
11464
|
case "rect":
|
|
11196
|
-
return box2(layer, c, aperture.width / 2 * s, aperture.height / 2 * s, 0, 0,
|
|
11465
|
+
return box2(layer, c, aperture.width / 2 * s, aperture.height / 2 * s, 0, 0, paint2);
|
|
11197
11466
|
case "obround": {
|
|
11198
11467
|
const along = aperture.width >= aperture.height;
|
|
11199
11468
|
const half = Math.abs(aperture.width - aperture.height) / 2 * s;
|
|
11200
11469
|
const [dx, dy] = along ? [half, 0] : [0, half];
|
|
11201
|
-
return capsule(layer, { x: c.x - dx, y: c.y - dy }, { x: c.x + dx, y: c.y + dy }, Math.min(aperture.width, aperture.height) / 2 * s,
|
|
11470
|
+
return capsule(layer, { x: c.x - dx, y: c.y - dy }, { x: c.x + dx, y: c.y + dy }, Math.min(aperture.width, aperture.height) / 2 * s, paint2);
|
|
11202
11471
|
}
|
|
11203
11472
|
case "roundrect":
|
|
11204
|
-
return box2(layer, c, aperture.width / 2 * s, aperture.height / 2 * s, pictureAngle(grid, aperture.rotation), aperture.radius * s,
|
|
11473
|
+
return box2(layer, c, aperture.width / 2 * s, aperture.height / 2 * s, pictureAngle(grid, aperture.rotation), aperture.radius * s, paint2);
|
|
11205
11474
|
}
|
|
11206
11475
|
}
|
|
11207
11476
|
function draw(layer, grid, object) {
|
|
@@ -11470,7 +11739,7 @@ async function renderLook(design, request) {
|
|
|
11470
11739
|
}
|
|
11471
11740
|
|
|
11472
11741
|
// studio/src/look/glb.ts
|
|
11473
|
-
import
|
|
11742
|
+
import earcut2 from "earcut";
|
|
11474
11743
|
var FLOAT = 5126;
|
|
11475
11744
|
var UINT = 5125;
|
|
11476
11745
|
var ARRAY_BUFFER = 34962;
|
|
@@ -11499,7 +11768,7 @@ function triangles(face2) {
|
|
|
11499
11768
|
const flat = corners.flatMap((corner) => [corner[a], corner[b]]);
|
|
11500
11769
|
const holes = [];
|
|
11501
11770
|
face2.loops.slice(0, -1).reduce((count, loop) => (holes.push(count + loop.length), count + loop.length), 0);
|
|
11502
|
-
const cut =
|
|
11771
|
+
const cut = earcut2(flat, holes, 2);
|
|
11503
11772
|
const indices = [];
|
|
11504
11773
|
for (let i = 0; i < cut.length; i += 3) {
|
|
11505
11774
|
const [p, q, r] = [cut[i], cut[i + 1], cut[i + 2]];
|
|
@@ -11546,29 +11815,29 @@ function sceneGlb(scene, options) {
|
|
|
11546
11815
|
const images = [];
|
|
11547
11816
|
const pictures = /* @__PURE__ */ new Map();
|
|
11548
11817
|
const painted = scene.faces.filter((face2) => face2.paint !== void 0);
|
|
11549
|
-
for (const
|
|
11550
|
-
const texture =
|
|
11818
|
+
for (const paint2 of new Set(painted.map((face2) => face2.paint))) {
|
|
11819
|
+
const texture = paint2.texture;
|
|
11551
11820
|
if (texture) {
|
|
11552
11821
|
const sign = texture.mirrored ? -1 : 1;
|
|
11553
11822
|
images.push({ bufferView: addView(options.png(texture)), mimeType: "image/png", name: texture.mirrored ? "board bottom" : "board top" });
|
|
11554
|
-
pictures.set(
|
|
11823
|
+
pictures.set(paint2, { image: images.length - 1, map: (p) => [(texture.origin.x + sign * p[0] * texture.pxPerMm) / texture.width, (texture.origin.y - p[1] * texture.pxPerMm) / texture.height] });
|
|
11555
11824
|
continue;
|
|
11556
11825
|
}
|
|
11557
11826
|
let [low, high] = [Infinity, -Infinity];
|
|
11558
11827
|
for (const face2 of painted) {
|
|
11559
|
-
if (face2.paint !==
|
|
11828
|
+
if (face2.paint !== paint2) continue;
|
|
11560
11829
|
for (const point of face2.loops.flat()) [low, high] = [Math.min(low, point[2]), Math.max(high, point[2])];
|
|
11561
11830
|
}
|
|
11562
11831
|
const span = high - low || 1;
|
|
11563
|
-
const [x, y] = painted.find((face2) => face2.paint ===
|
|
11832
|
+
const [x, y] = painted.find((face2) => face2.paint === paint2).loops[0]?.[0] ?? [0, 0];
|
|
11564
11833
|
const rgba = new Uint8ClampedArray(STRIP_WIDTH * STRIP_HEIGHT * 4);
|
|
11565
11834
|
const colour = new Float32Array(3);
|
|
11566
11835
|
for (let row3 = 0; row3 < STRIP_HEIGHT; row3++) {
|
|
11567
|
-
const alpha =
|
|
11836
|
+
const alpha = paint2.at(x, y, high - (row3 + 0.5) / STRIP_HEIGHT * span, colour, true);
|
|
11568
11837
|
for (let column = 0; column < STRIP_WIDTH; column++) rgba.set([colour[0], colour[1], colour[2], alpha * 255], (row3 * STRIP_WIDTH + column) * 4);
|
|
11569
11838
|
}
|
|
11570
11839
|
images.push({ bufferView: addView(options.png({ rgba, width: STRIP_WIDTH, height: STRIP_HEIGHT })), mimeType: "image/png", name: "board edge" });
|
|
11571
|
-
pictures.set(
|
|
11840
|
+
pictures.set(paint2, { image: images.length - 1, map: (p) => [0.5, (high - p[2]) / span] });
|
|
11572
11841
|
}
|
|
11573
11842
|
const materials = [];
|
|
11574
11843
|
const materialOf = /* @__PURE__ */ new Map();
|