@tscircuit/pcb-viewer 1.11.218 → 1.11.219
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/dist/index.js +107 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13242,31 +13242,47 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
13242
13242
|
const pour = element;
|
|
13243
13243
|
switch (pour.shape) {
|
|
13244
13244
|
case "rect": {
|
|
13245
|
+
const { center, width, height, layer, rotation: rotation2 } = pour;
|
|
13245
13246
|
return [
|
|
13246
13247
|
{
|
|
13247
13248
|
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
13248
13249
|
"pcb_copper_pour_rect"
|
|
13249
13250
|
),
|
|
13250
13251
|
pcb_drawing_type: "rect",
|
|
13251
|
-
x:
|
|
13252
|
-
y:
|
|
13253
|
-
w:
|
|
13254
|
-
h:
|
|
13255
|
-
layer
|
|
13252
|
+
x: center.x,
|
|
13253
|
+
y: center.y,
|
|
13254
|
+
w: width,
|
|
13255
|
+
h: height,
|
|
13256
|
+
layer,
|
|
13256
13257
|
_element: element,
|
|
13257
|
-
ccw_rotation:
|
|
13258
|
+
ccw_rotation: rotation2
|
|
13258
13259
|
}
|
|
13259
13260
|
];
|
|
13260
13261
|
}
|
|
13261
13262
|
case "polygon": {
|
|
13263
|
+
const { points, layer } = pour;
|
|
13262
13264
|
return [
|
|
13263
13265
|
{
|
|
13264
13266
|
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
13265
13267
|
"pcb_copper_pour_polygon"
|
|
13266
13268
|
),
|
|
13267
13269
|
pcb_drawing_type: "polygon",
|
|
13268
|
-
points
|
|
13269
|
-
layer
|
|
13270
|
+
points,
|
|
13271
|
+
layer,
|
|
13272
|
+
_element: element
|
|
13273
|
+
}
|
|
13274
|
+
];
|
|
13275
|
+
}
|
|
13276
|
+
case "brep": {
|
|
13277
|
+
const { brep_shape: brep_shape2, layer } = pour;
|
|
13278
|
+
return [
|
|
13279
|
+
{
|
|
13280
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId(
|
|
13281
|
+
"pcb_copper_pour_brep"
|
|
13282
|
+
),
|
|
13283
|
+
pcb_drawing_type: "polygon_with_arcs",
|
|
13284
|
+
brep_shape: brep_shape2,
|
|
13285
|
+
layer,
|
|
13270
13286
|
_element: element
|
|
13271
13287
|
}
|
|
13272
13288
|
];
|
|
@@ -13912,7 +13928,7 @@ var Drawer = class {
|
|
|
13912
13928
|
ctx.lineTo(transformedPoints[i][0], transformedPoints[i][1]);
|
|
13913
13929
|
}
|
|
13914
13930
|
ctx.closePath();
|
|
13915
|
-
ctx.fill();
|
|
13931
|
+
ctx.fill("evenodd");
|
|
13916
13932
|
const lineWidth = scaleOnly(this.transform, this.aperture.size);
|
|
13917
13933
|
ctx.lineWidth = lineWidth;
|
|
13918
13934
|
ctx.stroke();
|
|
@@ -13976,6 +13992,7 @@ var Drawer = class {
|
|
|
13976
13992
|
ctx.lineWidth = scaleOnly(transform, size2);
|
|
13977
13993
|
ctx.lineCap = "round";
|
|
13978
13994
|
if (mode === "add") {
|
|
13995
|
+
ctx.globalCompositeOperation = "source-over";
|
|
13979
13996
|
let colorString = color2?.[0] === "#" || color2?.startsWith("rgb") ? color2 : LAYER_NAME_TO_COLOR[color2?.toLowerCase()] ? LAYER_NAME_TO_COLOR[color2?.toLowerCase()] : null;
|
|
13980
13997
|
if (colorString === null) {
|
|
13981
13998
|
console.warn(`Color mapping for "${color2}" not found`);
|
|
@@ -14017,6 +14034,75 @@ var Drawer = class {
|
|
|
14017
14034
|
ctx.fillRect(x$ - size$ / 2, y$ - size$ / 2, size$, size$);
|
|
14018
14035
|
this.lastPoint = { x, y };
|
|
14019
14036
|
}
|
|
14037
|
+
polygonWithArcs(brep) {
|
|
14038
|
+
const ctx = this.getLayerCtx();
|
|
14039
|
+
const processRing = (ring2) => {
|
|
14040
|
+
if (ring2.vertices.length === 0) return;
|
|
14041
|
+
const startPoint = ring2.vertices[0];
|
|
14042
|
+
const t_start_point = applyToPoint3(this.transform, [
|
|
14043
|
+
startPoint.x,
|
|
14044
|
+
startPoint.y
|
|
14045
|
+
]);
|
|
14046
|
+
ctx.moveTo(t_start_point[0], t_start_point[1]);
|
|
14047
|
+
for (let i = 0; i < ring2.vertices.length; i++) {
|
|
14048
|
+
const p1 = ring2.vertices[i];
|
|
14049
|
+
const p2 = ring2.vertices[(i + 1) % ring2.vertices.length];
|
|
14050
|
+
if (p1.bulge && p1.bulge !== 0) {
|
|
14051
|
+
const bulge = p1.bulge;
|
|
14052
|
+
const dx = p2.x - p1.x;
|
|
14053
|
+
const dy = p2.y - p1.y;
|
|
14054
|
+
const chord = Math.sqrt(dx * dx + dy * dy);
|
|
14055
|
+
if (chord < 1e-9) {
|
|
14056
|
+
const t_p2 = applyToPoint3(this.transform, [p2.x, p2.y]);
|
|
14057
|
+
ctx.lineTo(t_p2[0], t_p2[1]);
|
|
14058
|
+
continue;
|
|
14059
|
+
}
|
|
14060
|
+
const angle = 4 * Math.atan(bulge);
|
|
14061
|
+
const radius = Math.abs(chord / (2 * Math.sin(angle / 2)));
|
|
14062
|
+
const mx = (p1.x + p2.x) / 2;
|
|
14063
|
+
const my = (p1.y + p2.y) / 2;
|
|
14064
|
+
const norm_dx = dx / chord;
|
|
14065
|
+
const norm_dy = dy / chord;
|
|
14066
|
+
const perp_vx = -norm_dy;
|
|
14067
|
+
const perp_vy = norm_dx;
|
|
14068
|
+
const dist_to_center = Math.sqrt(
|
|
14069
|
+
Math.max(0, radius * radius - (chord / 2) ** 2)
|
|
14070
|
+
);
|
|
14071
|
+
const cx = mx + dist_to_center * perp_vx * Math.sign(bulge);
|
|
14072
|
+
const cy = my + dist_to_center * perp_vy * Math.sign(bulge);
|
|
14073
|
+
const startAngle = Math.atan2(p1.y - cy, p1.x - cx);
|
|
14074
|
+
let endAngle = Math.atan2(p2.y - cy, p2.x - cx);
|
|
14075
|
+
if (bulge > 0 && endAngle < startAngle) {
|
|
14076
|
+
endAngle += 2 * Math.PI;
|
|
14077
|
+
} else if (bulge < 0 && endAngle > startAngle) {
|
|
14078
|
+
endAngle -= 2 * Math.PI;
|
|
14079
|
+
}
|
|
14080
|
+
const t_center = applyToPoint3(this.transform, [cx, cy]);
|
|
14081
|
+
const t_radius = scaleOnly(this.transform, radius);
|
|
14082
|
+
ctx.arc(
|
|
14083
|
+
t_center[0],
|
|
14084
|
+
t_center[1],
|
|
14085
|
+
t_radius,
|
|
14086
|
+
-startAngle,
|
|
14087
|
+
-endAngle,
|
|
14088
|
+
bulge > 0
|
|
14089
|
+
);
|
|
14090
|
+
} else {
|
|
14091
|
+
const t_p2 = applyToPoint3(this.transform, [p2.x, p2.y]);
|
|
14092
|
+
ctx.lineTo(t_p2[0], t_p2[1]);
|
|
14093
|
+
}
|
|
14094
|
+
}
|
|
14095
|
+
ctx.closePath();
|
|
14096
|
+
};
|
|
14097
|
+
ctx.beginPath();
|
|
14098
|
+
processRing(brep.outer_ring);
|
|
14099
|
+
if (brep.inner_rings) {
|
|
14100
|
+
for (const inner_ring of brep.inner_rings) {
|
|
14101
|
+
processRing(inner_ring);
|
|
14102
|
+
}
|
|
14103
|
+
}
|
|
14104
|
+
ctx.fill("evenodd");
|
|
14105
|
+
}
|
|
14020
14106
|
};
|
|
14021
14107
|
|
|
14022
14108
|
// src/lib/util/rotate-text.ts
|
|
@@ -14334,17 +14420,25 @@ var drawPolygon = (drawer, polygon) => {
|
|
|
14334
14420
|
});
|
|
14335
14421
|
drawer.polygon(polygon.points);
|
|
14336
14422
|
};
|
|
14423
|
+
var drawPolygonWithArcs = (drawer, p) => {
|
|
14424
|
+
drawer.equip({
|
|
14425
|
+
color: getColor(p),
|
|
14426
|
+
layer: p.layer
|
|
14427
|
+
});
|
|
14428
|
+
drawer.polygonWithArcs(p.brep_shape);
|
|
14429
|
+
};
|
|
14337
14430
|
var drawPrimitive = (drawer, primitive) => {
|
|
14338
14431
|
switch (primitive.pcb_drawing_type) {
|
|
14339
14432
|
case "line":
|
|
14340
14433
|
return drawLine(drawer, primitive);
|
|
14341
14434
|
case "text":
|
|
14342
14435
|
return drawText(drawer, primitive);
|
|
14343
|
-
case "rect":
|
|
14436
|
+
case "rect": {
|
|
14344
14437
|
if (primitive.ccw_rotation) {
|
|
14345
14438
|
return drawRotatedRect(drawer, primitive);
|
|
14346
14439
|
}
|
|
14347
14440
|
return drawRect(drawer, primitive);
|
|
14441
|
+
}
|
|
14348
14442
|
case "circle":
|
|
14349
14443
|
return drawCircle(drawer, primitive);
|
|
14350
14444
|
case "oval":
|
|
@@ -14356,6 +14450,8 @@ var drawPrimitive = (drawer, primitive) => {
|
|
|
14356
14450
|
return drawPill(drawer, primitive);
|
|
14357
14451
|
case "polygon":
|
|
14358
14452
|
return drawPolygon(drawer, primitive);
|
|
14453
|
+
case "polygon_with_arcs":
|
|
14454
|
+
return drawPolygonWithArcs(drawer, primitive);
|
|
14359
14455
|
}
|
|
14360
14456
|
};
|
|
14361
14457
|
var drawPrimitives = (drawer, primitives) => {
|
|
@@ -16983,7 +17079,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
16983
17079
|
// package.json
|
|
16984
17080
|
var package_default = {
|
|
16985
17081
|
name: "@tscircuit/pcb-viewer",
|
|
16986
|
-
version: "1.11.
|
|
17082
|
+
version: "1.11.218",
|
|
16987
17083
|
main: "dist/index.js",
|
|
16988
17084
|
type: "module",
|
|
16989
17085
|
repository: "tscircuit/pcb-viewer",
|