@tscircuit/pcb-viewer 1.11.305 → 1.11.306
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 +89 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8259,23 +8259,23 @@ var Drawer = class {
|
|
|
8259
8259
|
}
|
|
8260
8260
|
applyAperture() {
|
|
8261
8261
|
const { transform, aperture } = this;
|
|
8262
|
-
let { size, mode, color:
|
|
8262
|
+
let { size, mode, color: color3, fontSize, layer } = aperture;
|
|
8263
8263
|
if (!(layer in this.ctxLayerMap)) this.aperture.layer = "other";
|
|
8264
8264
|
const ctx = this.getLayerCtx();
|
|
8265
8265
|
if (!ctx) {
|
|
8266
8266
|
throw new Error(`No context for layer "${this.foregroundLayer}"`);
|
|
8267
8267
|
}
|
|
8268
|
-
if (!
|
|
8268
|
+
if (!color3) color3 = "undefined";
|
|
8269
8269
|
ctx.lineWidth = scaleOnly(transform, size);
|
|
8270
8270
|
ctx.lineCap = "round";
|
|
8271
8271
|
if (mode === "add") {
|
|
8272
8272
|
ctx.globalCompositeOperation = "source-over";
|
|
8273
|
-
let colorString = LAYER_NAME_TO_COLOR[
|
|
8273
|
+
let colorString = LAYER_NAME_TO_COLOR[color3.toLowerCase()];
|
|
8274
8274
|
if (!colorString)
|
|
8275
8275
|
try {
|
|
8276
|
-
colorString = colorParser(
|
|
8276
|
+
colorString = colorParser(color3).rgb().toString();
|
|
8277
8277
|
} catch (error) {
|
|
8278
|
-
console.warn(`Invalid color format: '${
|
|
8278
|
+
console.warn(`Invalid color format: '${color3}'`);
|
|
8279
8279
|
colorString = "white";
|
|
8280
8280
|
}
|
|
8281
8281
|
ctx.fillStyle = colorString;
|
|
@@ -8890,6 +8890,66 @@ function drawPcbCutoutElementsForLayer(canvas, elements, layers, realToCanvasMat
|
|
|
8890
8890
|
drawer.drawElements(cutoutElements, { layers });
|
|
8891
8891
|
}
|
|
8892
8892
|
|
|
8893
|
+
// src/lib/draw-pcb-smtpad.ts
|
|
8894
|
+
import {
|
|
8895
|
+
DEFAULT_PCB_COLOR_MAP as DEFAULT_PCB_COLOR_MAP4,
|
|
8896
|
+
CircuitToCanvasDrawer as CircuitToCanvasDrawer8
|
|
8897
|
+
} from "circuit-to-canvas";
|
|
8898
|
+
import color2 from "color";
|
|
8899
|
+
var HOVER_COLOR_MAP = {
|
|
8900
|
+
...DEFAULT_PCB_COLOR_MAP4,
|
|
8901
|
+
copper: {
|
|
8902
|
+
...DEFAULT_PCB_COLOR_MAP4.copper,
|
|
8903
|
+
top: color2(colors_default.board.pad_front).lighten(0.5).toString(),
|
|
8904
|
+
bottom: color2(colors_default.board.pad_back).lighten(0.5).toString()
|
|
8905
|
+
}
|
|
8906
|
+
};
|
|
8907
|
+
function isPcbSmtPad(element) {
|
|
8908
|
+
return element.type === "pcb_smtpad";
|
|
8909
|
+
}
|
|
8910
|
+
function drawPcbSmtPadElementsForLayer({
|
|
8911
|
+
canvas,
|
|
8912
|
+
elements,
|
|
8913
|
+
layers,
|
|
8914
|
+
realToCanvasMat,
|
|
8915
|
+
primitives
|
|
8916
|
+
}) {
|
|
8917
|
+
const smtPadElements = elements.filter(isPcbSmtPad).filter((element) => {
|
|
8918
|
+
const elementLayer = element.layer;
|
|
8919
|
+
return layers.some((layer) => {
|
|
8920
|
+
if (layer === "top_copper" && elementLayer === "top") return true;
|
|
8921
|
+
if (layer === "bottom_copper" && elementLayer === "bottom") return true;
|
|
8922
|
+
return false;
|
|
8923
|
+
});
|
|
8924
|
+
});
|
|
8925
|
+
if (smtPadElements.length === 0) return;
|
|
8926
|
+
const highlightedElementIds = /* @__PURE__ */ new Set();
|
|
8927
|
+
if (primitives) {
|
|
8928
|
+
for (const primitive of primitives) {
|
|
8929
|
+
if ((primitive.is_mouse_over || primitive.is_in_highlighted_net) && primitive._element?.type === "pcb_smtpad") {
|
|
8930
|
+
highlightedElementIds.add(primitive._element.pcb_smtpad_id);
|
|
8931
|
+
}
|
|
8932
|
+
}
|
|
8933
|
+
}
|
|
8934
|
+
const highlightedElements = smtPadElements.filter(
|
|
8935
|
+
(element) => highlightedElementIds.has(element.pcb_smtpad_id)
|
|
8936
|
+
);
|
|
8937
|
+
const nonHighlightedElements = smtPadElements.filter(
|
|
8938
|
+
(element) => !highlightedElementIds.has(element.pcb_smtpad_id)
|
|
8939
|
+
);
|
|
8940
|
+
if (nonHighlightedElements.length > 0) {
|
|
8941
|
+
const drawer = new CircuitToCanvasDrawer8(canvas);
|
|
8942
|
+
drawer.realToCanvasMat = realToCanvasMat;
|
|
8943
|
+
drawer.drawElements(nonHighlightedElements, { layers: [] });
|
|
8944
|
+
}
|
|
8945
|
+
if (highlightedElements.length > 0) {
|
|
8946
|
+
const highlightDrawer = new CircuitToCanvasDrawer8(canvas);
|
|
8947
|
+
highlightDrawer.configure({ colorOverrides: HOVER_COLOR_MAP });
|
|
8948
|
+
highlightDrawer.realToCanvasMat = realToCanvasMat;
|
|
8949
|
+
highlightDrawer.drawElements(highlightedElements, { layers: [] });
|
|
8950
|
+
}
|
|
8951
|
+
}
|
|
8952
|
+
|
|
8893
8953
|
// src/components/CanvasPrimitiveRenderer.tsx
|
|
8894
8954
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
8895
8955
|
var orderedLayers = [
|
|
@@ -8944,7 +9004,7 @@ var CanvasPrimitiveRenderer = ({
|
|
|
8944
9004
|
if (transform) drawer.transform = transform;
|
|
8945
9005
|
drawer.clear();
|
|
8946
9006
|
drawer.foregroundLayer = selectedLayer;
|
|
8947
|
-
const filteredPrimitives = primitives.filter((p) => isShowingSolderMask || !p.layer?.includes("soldermask")).filter((p) => p.layer !== "board");
|
|
9007
|
+
const filteredPrimitives = primitives.filter((p) => isShowingSolderMask || !p.layer?.includes("soldermask")).filter((p) => p.layer !== "board").filter((p) => p._element?.type !== "pcb_smtpad");
|
|
8948
9008
|
drawPrimitives(drawer, filteredPrimitives);
|
|
8949
9009
|
if (transform) {
|
|
8950
9010
|
const topCanvas = canvasRefs.current.top;
|
|
@@ -8955,6 +9015,24 @@ var CanvasPrimitiveRenderer = ({
|
|
|
8955
9015
|
if (bottomCanvas) {
|
|
8956
9016
|
drawPlatedHolePads(bottomCanvas, elements, ["bottom_copper"], transform);
|
|
8957
9017
|
}
|
|
9018
|
+
if (topCanvas) {
|
|
9019
|
+
drawPcbSmtPadElementsForLayer({
|
|
9020
|
+
canvas: topCanvas,
|
|
9021
|
+
elements,
|
|
9022
|
+
layers: ["top_copper"],
|
|
9023
|
+
realToCanvasMat: transform,
|
|
9024
|
+
primitives
|
|
9025
|
+
});
|
|
9026
|
+
}
|
|
9027
|
+
if (bottomCanvas) {
|
|
9028
|
+
drawPcbSmtPadElementsForLayer({
|
|
9029
|
+
canvas: bottomCanvas,
|
|
9030
|
+
elements,
|
|
9031
|
+
layers: ["bottom_copper"],
|
|
9032
|
+
realToCanvasMat: transform,
|
|
9033
|
+
primitives
|
|
9034
|
+
});
|
|
9035
|
+
}
|
|
8958
9036
|
const topSilkscreenCanvas = canvasRefs.current.top_silkscreen;
|
|
8959
9037
|
if (topSilkscreenCanvas) {
|
|
8960
9038
|
drawSilkscreenElementsForLayer(
|
|
@@ -11626,7 +11704,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11626
11704
|
];
|
|
11627
11705
|
const si = primitive.same_space_index ?? 0;
|
|
11628
11706
|
const sip = 26;
|
|
11629
|
-
const
|
|
11707
|
+
const color3 = layerColorHightlightMap[primitive?._element?.layer] ?? "red";
|
|
11630
11708
|
let rotation = 0;
|
|
11631
11709
|
if (primitiveElement.type === "pcb_smtpad" && primitiveElement?.shape === "rotated_rect") {
|
|
11632
11710
|
rotation = primitiveElement?.ccw_rotation ?? 0;
|
|
@@ -11648,7 +11726,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11648
11726
|
position: "absolute",
|
|
11649
11727
|
left: mousePos.x,
|
|
11650
11728
|
top: yOffset,
|
|
11651
|
-
color:
|
|
11729
|
+
color: color3,
|
|
11652
11730
|
pointerEvents: "none",
|
|
11653
11731
|
transform: "translateX(-50%)"
|
|
11654
11732
|
},
|
|
@@ -11688,7 +11766,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11688
11766
|
top: y - h / 2 - 8,
|
|
11689
11767
|
width: w + 16,
|
|
11690
11768
|
height: h + 16,
|
|
11691
|
-
color:
|
|
11769
|
+
color: color3,
|
|
11692
11770
|
transform: `rotate(${-rotation}deg)`,
|
|
11693
11771
|
transformOrigin: "center center"
|
|
11694
11772
|
},
|
|
@@ -11704,7 +11782,7 @@ var HighlightedPrimitiveBoxWithText = ({
|
|
|
11704
11782
|
height: finalState ? `calc(100% + ${sip * 2 * si}px)` : "100%",
|
|
11705
11783
|
marginLeft: finalState ? `${-sip * si}px` : 0,
|
|
11706
11784
|
marginTop: finalState ? `${-sip * si}px` : 0,
|
|
11707
|
-
border: `1px solid ${
|
|
11785
|
+
border: `1px solid ${color3}`,
|
|
11708
11786
|
opacity: finalState ? 1 : si === 0 ? 1 : 0,
|
|
11709
11787
|
transition: "width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"
|
|
11710
11788
|
},
|
|
@@ -13063,7 +13141,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13063
13141
|
// package.json
|
|
13064
13142
|
var package_default = {
|
|
13065
13143
|
name: "@tscircuit/pcb-viewer",
|
|
13066
|
-
version: "1.11.
|
|
13144
|
+
version: "1.11.305",
|
|
13067
13145
|
main: "dist/index.js",
|
|
13068
13146
|
type: "module",
|
|
13069
13147
|
repository: "tscircuit/pcb-viewer",
|