@tscircuit/pcb-viewer 1.11.306 → 1.11.308
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 +481 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7546,6 +7546,333 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7546
7546
|
});
|
|
7547
7547
|
return primitives;
|
|
7548
7548
|
}
|
|
7549
|
+
case "pcb_plated_hole": {
|
|
7550
|
+
if (element.shape === "circle") {
|
|
7551
|
+
const { x, y, hole_diameter, outer_diameter } = element;
|
|
7552
|
+
return [
|
|
7553
|
+
{
|
|
7554
|
+
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7555
|
+
pcb_drawing_type: "circle",
|
|
7556
|
+
x,
|
|
7557
|
+
y,
|
|
7558
|
+
r: outer_diameter / 2,
|
|
7559
|
+
// TODO support layer on pcb_plated_hole
|
|
7560
|
+
layer: "top",
|
|
7561
|
+
_element: element,
|
|
7562
|
+
_parent_pcb_component,
|
|
7563
|
+
_parent_source_component,
|
|
7564
|
+
_source_port
|
|
7565
|
+
},
|
|
7566
|
+
{
|
|
7567
|
+
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7568
|
+
pcb_drawing_type: "circle",
|
|
7569
|
+
x,
|
|
7570
|
+
y,
|
|
7571
|
+
r: hole_diameter / 2,
|
|
7572
|
+
// TODO support layer on pcb_plated_hole
|
|
7573
|
+
layer: "drill",
|
|
7574
|
+
_element: element
|
|
7575
|
+
// double highlights are annoying
|
|
7576
|
+
// _element: element,
|
|
7577
|
+
}
|
|
7578
|
+
];
|
|
7579
|
+
} else if (element.shape === "oval") {
|
|
7580
|
+
const { x, y, outer_height, outer_width, hole_height, hole_width } = element;
|
|
7581
|
+
return [
|
|
7582
|
+
{
|
|
7583
|
+
_pcb_drawing_object_id: `oval_${globalPcbDrawingObjectCount++}`,
|
|
7584
|
+
pcb_drawing_type: "oval",
|
|
7585
|
+
x,
|
|
7586
|
+
y,
|
|
7587
|
+
rX: outer_width / 2,
|
|
7588
|
+
rY: outer_height / 2,
|
|
7589
|
+
layer: "top",
|
|
7590
|
+
_element: element,
|
|
7591
|
+
_parent_pcb_component,
|
|
7592
|
+
_parent_source_component,
|
|
7593
|
+
_source_port
|
|
7594
|
+
},
|
|
7595
|
+
{
|
|
7596
|
+
_pcb_drawing_object_id: `oval_${globalPcbDrawingObjectCount++}`,
|
|
7597
|
+
_element: element,
|
|
7598
|
+
pcb_drawing_type: "oval",
|
|
7599
|
+
x,
|
|
7600
|
+
y,
|
|
7601
|
+
rX: hole_width / 2,
|
|
7602
|
+
rY: hole_height / 2,
|
|
7603
|
+
layer: "drill"
|
|
7604
|
+
}
|
|
7605
|
+
];
|
|
7606
|
+
} else if (element.shape === "pill") {
|
|
7607
|
+
const { x, y, outer_height, outer_width, hole_height, hole_width } = element;
|
|
7608
|
+
return [
|
|
7609
|
+
{
|
|
7610
|
+
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7611
|
+
pcb_drawing_type: "pill",
|
|
7612
|
+
x,
|
|
7613
|
+
y,
|
|
7614
|
+
w: outer_width,
|
|
7615
|
+
h: outer_height,
|
|
7616
|
+
layer: "top",
|
|
7617
|
+
_element: element,
|
|
7618
|
+
_parent_pcb_component,
|
|
7619
|
+
_parent_source_component,
|
|
7620
|
+
_source_port,
|
|
7621
|
+
ccw_rotation: element.ccw_rotation
|
|
7622
|
+
},
|
|
7623
|
+
{
|
|
7624
|
+
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7625
|
+
_element: element,
|
|
7626
|
+
pcb_drawing_type: "pill",
|
|
7627
|
+
x,
|
|
7628
|
+
y,
|
|
7629
|
+
w: hole_width,
|
|
7630
|
+
h: hole_height,
|
|
7631
|
+
layer: "drill",
|
|
7632
|
+
ccw_rotation: element.ccw_rotation
|
|
7633
|
+
}
|
|
7634
|
+
];
|
|
7635
|
+
} else if (element.shape === "circular_hole_with_rect_pad") {
|
|
7636
|
+
const {
|
|
7637
|
+
x,
|
|
7638
|
+
y,
|
|
7639
|
+
hole_diameter,
|
|
7640
|
+
rect_pad_width,
|
|
7641
|
+
rect_pad_height,
|
|
7642
|
+
rect_border_radius,
|
|
7643
|
+
hole_offset_x,
|
|
7644
|
+
hole_offset_y
|
|
7645
|
+
} = element;
|
|
7646
|
+
const parsed_hole_offset_x = distance2.parse(hole_offset_x ?? 0);
|
|
7647
|
+
const parsed_hole_offset_y = distance2.parse(hole_offset_y ?? 0);
|
|
7648
|
+
return [
|
|
7649
|
+
{
|
|
7650
|
+
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7651
|
+
pcb_drawing_type: "rect",
|
|
7652
|
+
x,
|
|
7653
|
+
y,
|
|
7654
|
+
w: rect_pad_width,
|
|
7655
|
+
h: rect_pad_height,
|
|
7656
|
+
layer: "top",
|
|
7657
|
+
_element: element,
|
|
7658
|
+
_parent_pcb_component,
|
|
7659
|
+
_parent_source_component,
|
|
7660
|
+
_source_port,
|
|
7661
|
+
roundness: rect_border_radius
|
|
7662
|
+
},
|
|
7663
|
+
{
|
|
7664
|
+
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7665
|
+
pcb_drawing_type: "rect",
|
|
7666
|
+
x,
|
|
7667
|
+
y,
|
|
7668
|
+
w: rect_pad_width,
|
|
7669
|
+
h: rect_pad_height,
|
|
7670
|
+
layer: "bottom",
|
|
7671
|
+
_element: element,
|
|
7672
|
+
_parent_pcb_component,
|
|
7673
|
+
_parent_source_component,
|
|
7674
|
+
_source_port,
|
|
7675
|
+
roundness: rect_border_radius
|
|
7676
|
+
},
|
|
7677
|
+
{
|
|
7678
|
+
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7679
|
+
_element: element,
|
|
7680
|
+
pcb_drawing_type: "circle",
|
|
7681
|
+
x: x + parsed_hole_offset_x,
|
|
7682
|
+
y: y + parsed_hole_offset_y,
|
|
7683
|
+
r: hole_diameter / 2,
|
|
7684
|
+
layer: "drill"
|
|
7685
|
+
}
|
|
7686
|
+
];
|
|
7687
|
+
} else if (element.shape === "pill_hole_with_rect_pad") {
|
|
7688
|
+
const {
|
|
7689
|
+
x,
|
|
7690
|
+
y,
|
|
7691
|
+
hole_width,
|
|
7692
|
+
hole_height,
|
|
7693
|
+
rect_pad_width,
|
|
7694
|
+
rect_pad_height,
|
|
7695
|
+
rect_border_radius
|
|
7696
|
+
} = element;
|
|
7697
|
+
return [
|
|
7698
|
+
{
|
|
7699
|
+
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7700
|
+
pcb_drawing_type: "rect",
|
|
7701
|
+
x,
|
|
7702
|
+
y,
|
|
7703
|
+
w: rect_pad_width,
|
|
7704
|
+
h: rect_pad_height,
|
|
7705
|
+
layer: "top",
|
|
7706
|
+
_element: element,
|
|
7707
|
+
_parent_pcb_component,
|
|
7708
|
+
_parent_source_component,
|
|
7709
|
+
_source_port,
|
|
7710
|
+
roundness: rect_border_radius
|
|
7711
|
+
},
|
|
7712
|
+
{
|
|
7713
|
+
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7714
|
+
pcb_drawing_type: "rect",
|
|
7715
|
+
x,
|
|
7716
|
+
y,
|
|
7717
|
+
w: rect_pad_width,
|
|
7718
|
+
h: rect_pad_height,
|
|
7719
|
+
layer: "bottom",
|
|
7720
|
+
_element: element,
|
|
7721
|
+
_parent_pcb_component,
|
|
7722
|
+
_parent_source_component,
|
|
7723
|
+
_source_port,
|
|
7724
|
+
roundness: rect_border_radius
|
|
7725
|
+
},
|
|
7726
|
+
{
|
|
7727
|
+
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7728
|
+
_element: element,
|
|
7729
|
+
pcb_drawing_type: "pill",
|
|
7730
|
+
x,
|
|
7731
|
+
y,
|
|
7732
|
+
w: hole_width,
|
|
7733
|
+
h: hole_height,
|
|
7734
|
+
layer: "drill"
|
|
7735
|
+
}
|
|
7736
|
+
];
|
|
7737
|
+
} else if (element.shape === "rotated_pill_hole_with_rect_pad") {
|
|
7738
|
+
const {
|
|
7739
|
+
x,
|
|
7740
|
+
y,
|
|
7741
|
+
hole_width,
|
|
7742
|
+
hole_height,
|
|
7743
|
+
hole_ccw_rotation,
|
|
7744
|
+
rect_pad_width,
|
|
7745
|
+
rect_pad_height,
|
|
7746
|
+
rect_ccw_rotation,
|
|
7747
|
+
rect_border_radius
|
|
7748
|
+
} = element;
|
|
7749
|
+
return [
|
|
7750
|
+
{
|
|
7751
|
+
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7752
|
+
pcb_drawing_type: "rect",
|
|
7753
|
+
x,
|
|
7754
|
+
y,
|
|
7755
|
+
w: rect_pad_width,
|
|
7756
|
+
h: rect_pad_height,
|
|
7757
|
+
layer: "top",
|
|
7758
|
+
_element: element,
|
|
7759
|
+
_parent_pcb_component,
|
|
7760
|
+
_parent_source_component,
|
|
7761
|
+
_source_port,
|
|
7762
|
+
ccw_rotation: rect_ccw_rotation,
|
|
7763
|
+
roundness: rect_border_radius
|
|
7764
|
+
},
|
|
7765
|
+
{
|
|
7766
|
+
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7767
|
+
pcb_drawing_type: "rect",
|
|
7768
|
+
x,
|
|
7769
|
+
y,
|
|
7770
|
+
w: rect_pad_width,
|
|
7771
|
+
h: rect_pad_height,
|
|
7772
|
+
layer: "bottom",
|
|
7773
|
+
_element: element,
|
|
7774
|
+
_parent_pcb_component,
|
|
7775
|
+
_parent_source_component,
|
|
7776
|
+
_source_port,
|
|
7777
|
+
ccw_rotation: rect_ccw_rotation,
|
|
7778
|
+
roundness: rect_border_radius
|
|
7779
|
+
},
|
|
7780
|
+
{
|
|
7781
|
+
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7782
|
+
_element: element,
|
|
7783
|
+
pcb_drawing_type: "pill",
|
|
7784
|
+
x,
|
|
7785
|
+
y,
|
|
7786
|
+
w: hole_width,
|
|
7787
|
+
h: hole_height,
|
|
7788
|
+
layer: "drill",
|
|
7789
|
+
ccw_rotation: hole_ccw_rotation
|
|
7790
|
+
}
|
|
7791
|
+
];
|
|
7792
|
+
} else if (element.shape === "hole_with_polygon_pad") {
|
|
7793
|
+
const {
|
|
7794
|
+
x,
|
|
7795
|
+
y,
|
|
7796
|
+
pad_outline,
|
|
7797
|
+
hole_shape,
|
|
7798
|
+
hole_diameter,
|
|
7799
|
+
hole_width,
|
|
7800
|
+
hole_height,
|
|
7801
|
+
layers,
|
|
7802
|
+
hole_offset_x,
|
|
7803
|
+
hole_offset_y
|
|
7804
|
+
} = element;
|
|
7805
|
+
const parsed_hole_offset_x = distance2.parse(hole_offset_x ?? 0);
|
|
7806
|
+
const parsed_hole_offset_y = distance2.parse(hole_offset_y ?? 0);
|
|
7807
|
+
const pcb_outline = pad_outline;
|
|
7808
|
+
const padPrimitives = [];
|
|
7809
|
+
if (pcb_outline && Array.isArray(pcb_outline)) {
|
|
7810
|
+
const translatedPoints = normalizePolygonPoints(pcb_outline).map(
|
|
7811
|
+
(p) => ({ x: p.x + x, y: p.y + y })
|
|
7812
|
+
);
|
|
7813
|
+
for (const layer of layers || ["top", "bottom"]) {
|
|
7814
|
+
padPrimitives.push({
|
|
7815
|
+
_pcb_drawing_object_id: `polygon_${globalPcbDrawingObjectCount++}`,
|
|
7816
|
+
pcb_drawing_type: "polygon",
|
|
7817
|
+
points: translatedPoints,
|
|
7818
|
+
layer,
|
|
7819
|
+
_element: element,
|
|
7820
|
+
_parent_pcb_component,
|
|
7821
|
+
_parent_source_component,
|
|
7822
|
+
_source_port
|
|
7823
|
+
});
|
|
7824
|
+
}
|
|
7825
|
+
}
|
|
7826
|
+
const holeCenter = {
|
|
7827
|
+
x: x + parsed_hole_offset_x,
|
|
7828
|
+
y: y + parsed_hole_offset_y
|
|
7829
|
+
};
|
|
7830
|
+
const holePrimitives = [];
|
|
7831
|
+
if (hole_shape === "circle") {
|
|
7832
|
+
holePrimitives.push({
|
|
7833
|
+
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7834
|
+
pcb_drawing_type: "circle",
|
|
7835
|
+
x: holeCenter.x,
|
|
7836
|
+
y: holeCenter.y,
|
|
7837
|
+
r: (hole_diameter ?? 0) / 2,
|
|
7838
|
+
layer: "drill",
|
|
7839
|
+
_element: element,
|
|
7840
|
+
_parent_pcb_component,
|
|
7841
|
+
_parent_source_component
|
|
7842
|
+
});
|
|
7843
|
+
} else if (hole_shape === "oval") {
|
|
7844
|
+
holePrimitives.push({
|
|
7845
|
+
_pcb_drawing_object_id: `oval_${globalPcbDrawingObjectCount++}`,
|
|
7846
|
+
pcb_drawing_type: "oval",
|
|
7847
|
+
x: holeCenter.x,
|
|
7848
|
+
y: holeCenter.y,
|
|
7849
|
+
rX: (hole_width ?? 0) / 2,
|
|
7850
|
+
rY: (hole_height ?? 0) / 2,
|
|
7851
|
+
layer: "drill",
|
|
7852
|
+
_element: element,
|
|
7853
|
+
_parent_pcb_component,
|
|
7854
|
+
_parent_source_component
|
|
7855
|
+
});
|
|
7856
|
+
} else if (hole_shape === "pill" || hole_shape === "rotated_pill") {
|
|
7857
|
+
holePrimitives.push({
|
|
7858
|
+
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7859
|
+
pcb_drawing_type: "pill",
|
|
7860
|
+
x: holeCenter.x,
|
|
7861
|
+
y: holeCenter.y,
|
|
7862
|
+
w: hole_width ?? 0,
|
|
7863
|
+
h: hole_height ?? 0,
|
|
7864
|
+
layer: "drill",
|
|
7865
|
+
_element: element,
|
|
7866
|
+
_parent_pcb_component,
|
|
7867
|
+
_parent_source_component,
|
|
7868
|
+
ccw_rotation: element.ccw_rotation
|
|
7869
|
+
});
|
|
7870
|
+
}
|
|
7871
|
+
return [...padPrimitives, ...holePrimitives];
|
|
7872
|
+
} else {
|
|
7873
|
+
return [];
|
|
7874
|
+
}
|
|
7875
|
+
}
|
|
7549
7876
|
case "pcb_copper_text": {
|
|
7550
7877
|
return convertPcbCopperTextToPrimitive(element, {
|
|
7551
7878
|
_parent_pcb_component,
|
|
@@ -8259,23 +8586,23 @@ var Drawer = class {
|
|
|
8259
8586
|
}
|
|
8260
8587
|
applyAperture() {
|
|
8261
8588
|
const { transform, aperture } = this;
|
|
8262
|
-
let { size, mode, color:
|
|
8589
|
+
let { size, mode, color: color5, fontSize, layer } = aperture;
|
|
8263
8590
|
if (!(layer in this.ctxLayerMap)) this.aperture.layer = "other";
|
|
8264
8591
|
const ctx = this.getLayerCtx();
|
|
8265
8592
|
if (!ctx) {
|
|
8266
8593
|
throw new Error(`No context for layer "${this.foregroundLayer}"`);
|
|
8267
8594
|
}
|
|
8268
|
-
if (!
|
|
8595
|
+
if (!color5) color5 = "undefined";
|
|
8269
8596
|
ctx.lineWidth = scaleOnly(transform, size);
|
|
8270
8597
|
ctx.lineCap = "round";
|
|
8271
8598
|
if (mode === "add") {
|
|
8272
8599
|
ctx.globalCompositeOperation = "source-over";
|
|
8273
|
-
let colorString = LAYER_NAME_TO_COLOR[
|
|
8600
|
+
let colorString = LAYER_NAME_TO_COLOR[color5.toLowerCase()];
|
|
8274
8601
|
if (!colorString)
|
|
8275
8602
|
try {
|
|
8276
|
-
colorString = colorParser(
|
|
8603
|
+
colorString = colorParser(color5).rgb().toString();
|
|
8277
8604
|
} catch (error) {
|
|
8278
|
-
console.warn(`Invalid color format: '${
|
|
8605
|
+
console.warn(`Invalid color format: '${color5}'`);
|
|
8279
8606
|
colorString = "white";
|
|
8280
8607
|
}
|
|
8281
8608
|
ctx.fillStyle = colorString;
|
|
@@ -8804,24 +9131,65 @@ function drawSilkscreenElementsForLayer(canvas, elements, layers, realToCanvasMa
|
|
|
8804
9131
|
}
|
|
8805
9132
|
|
|
8806
9133
|
// src/lib/draw-plated-hole.ts
|
|
8807
|
-
import {
|
|
9134
|
+
import {
|
|
9135
|
+
DEFAULT_PCB_COLOR_MAP as DEFAULT_PCB_COLOR_MAP2,
|
|
9136
|
+
CircuitToCanvasDrawer as CircuitToCanvasDrawer2
|
|
9137
|
+
} from "circuit-to-canvas";
|
|
9138
|
+
import color2 from "color";
|
|
9139
|
+
var HOVER_COLOR_MAP = {
|
|
9140
|
+
...DEFAULT_PCB_COLOR_MAP2,
|
|
9141
|
+
copper: {
|
|
9142
|
+
...DEFAULT_PCB_COLOR_MAP2.copper,
|
|
9143
|
+
top: color2(colors_default.board.pad_front).lighten(0.5).toString(),
|
|
9144
|
+
bottom: color2(colors_default.board.pad_back).lighten(0.5).toString()
|
|
9145
|
+
}
|
|
9146
|
+
};
|
|
8808
9147
|
function isPlatedHole(element) {
|
|
8809
9148
|
return element.type === "pcb_plated_hole";
|
|
8810
9149
|
}
|
|
8811
|
-
function drawPlatedHolePads(
|
|
8812
|
-
|
|
8813
|
-
|
|
9150
|
+
function drawPlatedHolePads({
|
|
9151
|
+
canvas,
|
|
9152
|
+
elements,
|
|
9153
|
+
layers,
|
|
9154
|
+
realToCanvasMat,
|
|
9155
|
+
primitives
|
|
9156
|
+
}) {
|
|
8814
9157
|
const platedHoleElements = elements.filter(isPlatedHole);
|
|
8815
|
-
|
|
9158
|
+
if (platedHoleElements.length === 0) return;
|
|
9159
|
+
const highlightedElementIds = /* @__PURE__ */ new Set();
|
|
9160
|
+
if (primitives) {
|
|
9161
|
+
for (const primitive of primitives) {
|
|
9162
|
+
if ((primitive.is_mouse_over || primitive.is_in_highlighted_net) && primitive._element?.type === "pcb_plated_hole") {
|
|
9163
|
+
highlightedElementIds.add(primitive._element.pcb_plated_hole_id);
|
|
9164
|
+
}
|
|
9165
|
+
}
|
|
9166
|
+
}
|
|
9167
|
+
const highlightedElements = platedHoleElements.filter(
|
|
9168
|
+
(element) => highlightedElementIds.has(element.pcb_plated_hole_id)
|
|
9169
|
+
);
|
|
9170
|
+
const nonHighlightedElements = platedHoleElements.filter(
|
|
9171
|
+
(element) => !highlightedElementIds.has(element.pcb_plated_hole_id)
|
|
9172
|
+
);
|
|
9173
|
+
if (nonHighlightedElements.length > 0) {
|
|
9174
|
+
const drawer = new CircuitToCanvasDrawer2(canvas);
|
|
9175
|
+
drawer.realToCanvasMat = realToCanvasMat;
|
|
9176
|
+
drawer.drawElements(nonHighlightedElements, { layers });
|
|
9177
|
+
}
|
|
9178
|
+
if (highlightedElements.length > 0) {
|
|
9179
|
+
const highlightDrawer = new CircuitToCanvasDrawer2(canvas);
|
|
9180
|
+
highlightDrawer.configure({ colorOverrides: HOVER_COLOR_MAP });
|
|
9181
|
+
highlightDrawer.realToCanvasMat = realToCanvasMat;
|
|
9182
|
+
highlightDrawer.drawElements(highlightedElements, { layers });
|
|
9183
|
+
}
|
|
8816
9184
|
}
|
|
8817
9185
|
|
|
8818
9186
|
// src/lib/draw-fabrication-note.ts
|
|
8819
9187
|
import {
|
|
8820
|
-
DEFAULT_PCB_COLOR_MAP as
|
|
9188
|
+
DEFAULT_PCB_COLOR_MAP as DEFAULT_PCB_COLOR_MAP3,
|
|
8821
9189
|
CircuitToCanvasDrawer as CircuitToCanvasDrawer3
|
|
8822
9190
|
} from "circuit-to-canvas";
|
|
8823
9191
|
var PCB_VIEWER_COLOR_MAP2 = {
|
|
8824
|
-
...
|
|
9192
|
+
...DEFAULT_PCB_COLOR_MAP3,
|
|
8825
9193
|
silkscreen: {
|
|
8826
9194
|
top: colors_default.board.f_fab,
|
|
8827
9195
|
bottom: colors_default.board.b_fab
|
|
@@ -8892,16 +9260,16 @@ function drawPcbCutoutElementsForLayer(canvas, elements, layers, realToCanvasMat
|
|
|
8892
9260
|
|
|
8893
9261
|
// src/lib/draw-pcb-smtpad.ts
|
|
8894
9262
|
import {
|
|
8895
|
-
DEFAULT_PCB_COLOR_MAP as
|
|
9263
|
+
DEFAULT_PCB_COLOR_MAP as DEFAULT_PCB_COLOR_MAP5,
|
|
8896
9264
|
CircuitToCanvasDrawer as CircuitToCanvasDrawer8
|
|
8897
9265
|
} from "circuit-to-canvas";
|
|
8898
|
-
import
|
|
8899
|
-
var
|
|
8900
|
-
...
|
|
9266
|
+
import color3 from "color";
|
|
9267
|
+
var HOVER_COLOR_MAP2 = {
|
|
9268
|
+
...DEFAULT_PCB_COLOR_MAP5,
|
|
8901
9269
|
copper: {
|
|
8902
|
-
...
|
|
8903
|
-
top:
|
|
8904
|
-
bottom:
|
|
9270
|
+
...DEFAULT_PCB_COLOR_MAP5.copper,
|
|
9271
|
+
top: color3(colors_default.board.pad_front).lighten(0.5).toString(),
|
|
9272
|
+
bottom: color3(colors_default.board.pad_back).lighten(0.5).toString()
|
|
8905
9273
|
}
|
|
8906
9274
|
};
|
|
8907
9275
|
function isPcbSmtPad(element) {
|
|
@@ -8944,12 +9312,67 @@ function drawPcbSmtPadElementsForLayer({
|
|
|
8944
9312
|
}
|
|
8945
9313
|
if (highlightedElements.length > 0) {
|
|
8946
9314
|
const highlightDrawer = new CircuitToCanvasDrawer8(canvas);
|
|
8947
|
-
highlightDrawer.configure({ colorOverrides:
|
|
9315
|
+
highlightDrawer.configure({ colorOverrides: HOVER_COLOR_MAP2 });
|
|
8948
9316
|
highlightDrawer.realToCanvasMat = realToCanvasMat;
|
|
8949
9317
|
highlightDrawer.drawElements(highlightedElements, { layers: [] });
|
|
8950
9318
|
}
|
|
8951
9319
|
}
|
|
8952
9320
|
|
|
9321
|
+
// src/lib/draw-via.ts
|
|
9322
|
+
import {
|
|
9323
|
+
DEFAULT_PCB_COLOR_MAP as DEFAULT_PCB_COLOR_MAP6,
|
|
9324
|
+
CircuitToCanvasDrawer as CircuitToCanvasDrawer9
|
|
9325
|
+
} from "circuit-to-canvas";
|
|
9326
|
+
import color4 from "color";
|
|
9327
|
+
var HOVER_COLOR_MAP3 = {
|
|
9328
|
+
...DEFAULT_PCB_COLOR_MAP6,
|
|
9329
|
+
copper: {
|
|
9330
|
+
...DEFAULT_PCB_COLOR_MAP6.copper,
|
|
9331
|
+
top: color4(colors_default.board.pad_front).lighten(0.5).toString(),
|
|
9332
|
+
bottom: color4(colors_default.board.pad_back).lighten(0.5).toString()
|
|
9333
|
+
}
|
|
9334
|
+
};
|
|
9335
|
+
function isPcbVia(element) {
|
|
9336
|
+
return element.type === "pcb_via";
|
|
9337
|
+
}
|
|
9338
|
+
function drawPcbViaElementsForLayer({
|
|
9339
|
+
canvas,
|
|
9340
|
+
elements,
|
|
9341
|
+
layers,
|
|
9342
|
+
realToCanvasMat,
|
|
9343
|
+
primitives
|
|
9344
|
+
}) {
|
|
9345
|
+
const viaElements = elements.filter(isPcbVia).filter((element) => {
|
|
9346
|
+
return layers.some((layer) => layer.includes("copper"));
|
|
9347
|
+
});
|
|
9348
|
+
if (viaElements.length === 0) return;
|
|
9349
|
+
const highlightedElementIds = /* @__PURE__ */ new Set();
|
|
9350
|
+
if (primitives) {
|
|
9351
|
+
for (const primitive of primitives) {
|
|
9352
|
+
if ((primitive.is_mouse_over || primitive.is_in_highlighted_net) && primitive._element?.type === "pcb_via") {
|
|
9353
|
+
highlightedElementIds.add(primitive._element.pcb_via_id);
|
|
9354
|
+
}
|
|
9355
|
+
}
|
|
9356
|
+
}
|
|
9357
|
+
const highlightedElements = viaElements.filter(
|
|
9358
|
+
(element) => highlightedElementIds.has(element.pcb_via_id)
|
|
9359
|
+
);
|
|
9360
|
+
const nonHighlightedElements = viaElements.filter(
|
|
9361
|
+
(element) => !highlightedElementIds.has(element.pcb_via_id)
|
|
9362
|
+
);
|
|
9363
|
+
if (nonHighlightedElements.length > 0) {
|
|
9364
|
+
const drawer = new CircuitToCanvasDrawer9(canvas);
|
|
9365
|
+
drawer.realToCanvasMat = realToCanvasMat;
|
|
9366
|
+
drawer.drawElements(nonHighlightedElements, { layers });
|
|
9367
|
+
}
|
|
9368
|
+
if (highlightedElements.length > 0) {
|
|
9369
|
+
const highlightDrawer = new CircuitToCanvasDrawer9(canvas);
|
|
9370
|
+
highlightDrawer.configure({ colorOverrides: HOVER_COLOR_MAP3 });
|
|
9371
|
+
highlightDrawer.realToCanvasMat = realToCanvasMat;
|
|
9372
|
+
highlightDrawer.drawElements(highlightedElements, { layers });
|
|
9373
|
+
}
|
|
9374
|
+
}
|
|
9375
|
+
|
|
8953
9376
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
8954
9377
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
8955
9378
|
var orderedLayers = [
|
|
@@ -9004,16 +9427,28 @@ var CanvasPrimitiveRenderer = ({
|
|
|
9004
9427
|
if (transform) drawer.transform = transform;
|
|
9005
9428
|
drawer.clear();
|
|
9006
9429
|
drawer.foregroundLayer = selectedLayer;
|
|
9007
|
-
const filteredPrimitives = primitives.filter((p) => isShowingSolderMask || !p.layer?.includes("soldermask")).filter((p) => p.layer !== "board").filter((p) => p._element?.type !== "pcb_smtpad");
|
|
9430
|
+
const filteredPrimitives = primitives.filter((p) => isShowingSolderMask || !p.layer?.includes("soldermask")).filter((p) => p.layer !== "board").filter((p) => p._element?.type !== "pcb_smtpad").filter((p) => p._element?.type !== "pcb_plated_hole").filter((p) => p._element?.type !== "pcb_via");
|
|
9008
9431
|
drawPrimitives(drawer, filteredPrimitives);
|
|
9009
9432
|
if (transform) {
|
|
9010
9433
|
const topCanvas = canvasRefs.current.top;
|
|
9011
9434
|
if (topCanvas) {
|
|
9012
|
-
drawPlatedHolePads(
|
|
9435
|
+
drawPlatedHolePads({
|
|
9436
|
+
canvas: topCanvas,
|
|
9437
|
+
elements,
|
|
9438
|
+
layers: ["top_copper"],
|
|
9439
|
+
realToCanvasMat: transform,
|
|
9440
|
+
primitives
|
|
9441
|
+
});
|
|
9013
9442
|
}
|
|
9014
9443
|
const bottomCanvas = canvasRefs.current.bottom;
|
|
9015
9444
|
if (bottomCanvas) {
|
|
9016
|
-
drawPlatedHolePads(
|
|
9445
|
+
drawPlatedHolePads({
|
|
9446
|
+
canvas: bottomCanvas,
|
|
9447
|
+
elements,
|
|
9448
|
+
layers: ["bottom_copper"],
|
|
9449
|
+
realToCanvasMat: transform,
|
|
9450
|
+
primitives
|
|
9451
|
+
});
|
|
9017
9452
|
}
|
|
9018
9453
|
if (topCanvas) {
|
|
9019
9454
|
drawPcbSmtPadElementsForLayer({
|
|
@@ -9033,6 +9468,24 @@ var CanvasPrimitiveRenderer = ({
|
|
|
9033
9468
|
primitives
|
|
9034
9469
|
});
|
|
9035
9470
|
}
|
|
9471
|
+
if (topCanvas) {
|
|
9472
|
+
drawPcbViaElementsForLayer({
|
|
9473
|
+
canvas: topCanvas,
|
|
9474
|
+
elements,
|
|
9475
|
+
layers: ["top_copper"],
|
|
9476
|
+
realToCanvasMat: transform,
|
|
9477
|
+
primitives
|
|
9478
|
+
});
|
|
9479
|
+
}
|
|
9480
|
+
if (bottomCanvas) {
|
|
9481
|
+
drawPcbViaElementsForLayer({
|
|
9482
|
+
canvas: bottomCanvas,
|
|
9483
|
+
elements,
|
|
9484
|
+
layers: ["bottom_copper"],
|
|
9485
|
+
realToCanvasMat: transform,
|
|
9486
|
+
primitives
|
|
9487
|
+
});
|
|
9488
|
+
}
|
|
9036
9489
|
const topSilkscreenCanvas = canvasRefs.current.top_silkscreen;
|
|
9037
9490
|
if (topSilkscreenCanvas) {
|
|
9038
9491
|
drawSilkscreenElementsForLayer(
|
|
@@ -11704,7 +12157,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11704
12157
|
];
|
|
11705
12158
|
const si = primitive.same_space_index ?? 0;
|
|
11706
12159
|
const sip = 26;
|
|
11707
|
-
const
|
|
12160
|
+
const color5 = layerColorHightlightMap[primitive?._element?.layer] ?? "red";
|
|
11708
12161
|
let rotation = 0;
|
|
11709
12162
|
if (primitiveElement.type === "pcb_smtpad" && primitiveElement?.shape === "rotated_rect") {
|
|
11710
12163
|
rotation = primitiveElement?.ccw_rotation ?? 0;
|
|
@@ -11726,7 +12179,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11726
12179
|
position: "absolute",
|
|
11727
12180
|
left: mousePos.x,
|
|
11728
12181
|
top: yOffset,
|
|
11729
|
-
color:
|
|
12182
|
+
color: color5,
|
|
11730
12183
|
pointerEvents: "none",
|
|
11731
12184
|
transform: "translateX(-50%)"
|
|
11732
12185
|
},
|
|
@@ -11766,7 +12219,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11766
12219
|
top: y - h / 2 - 8,
|
|
11767
12220
|
width: w + 16,
|
|
11768
12221
|
height: h + 16,
|
|
11769
|
-
color:
|
|
12222
|
+
color: color5,
|
|
11770
12223
|
transform: `rotate(${-rotation}deg)`,
|
|
11771
12224
|
transformOrigin: "center center"
|
|
11772
12225
|
},
|
|
@@ -11782,7 +12235,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11782
12235
|
height: finalState ? `calc(100% + ${sip * 2 * si}px)` : "100%",
|
|
11783
12236
|
marginLeft: finalState ? `${-sip * si}px` : 0,
|
|
11784
12237
|
marginTop: finalState ? `${-sip * si}px` : 0,
|
|
11785
|
-
border: `1px solid ${
|
|
12238
|
+
border: `1px solid ${color5}`,
|
|
11786
12239
|
opacity: finalState ? 1 : si === 0 ? 1 : 0,
|
|
11787
12240
|
transition: "width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"
|
|
11788
12241
|
},
|
|
@@ -13141,7 +13594,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13141
13594
|
// package.json
|
|
13142
13595
|
var package_default = {
|
|
13143
13596
|
name: "@tscircuit/pcb-viewer",
|
|
13144
|
-
version: "1.11.
|
|
13597
|
+
version: "1.11.307",
|
|
13145
13598
|
main: "dist/index.js",
|
|
13146
13599
|
type: "module",
|
|
13147
13600
|
repository: "tscircuit/pcb-viewer",
|