circuit-to-svg 0.0.284 → 0.0.285
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 +626 -359
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// lib/pcb/convert-circuit-json-to-pcb-svg.ts
|
|
2
|
-
import { distance } from "circuit-json";
|
|
2
|
+
import { distance as distance2 } from "circuit-json";
|
|
3
3
|
import { stringify } from "svgson";
|
|
4
4
|
import {
|
|
5
|
-
applyToPoint as
|
|
6
|
-
compose as
|
|
7
|
-
scale as
|
|
8
|
-
translate as
|
|
5
|
+
applyToPoint as applyToPoint33,
|
|
6
|
+
compose as compose6,
|
|
7
|
+
scale as scale3,
|
|
8
|
+
translate as translate6
|
|
9
9
|
} from "transformation-matrix";
|
|
10
10
|
|
|
11
11
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace-error.ts
|
|
@@ -2677,8 +2677,326 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
2677
2677
|
return [svgObject];
|
|
2678
2678
|
}
|
|
2679
2679
|
|
|
2680
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-text.ts
|
|
2681
|
+
import {
|
|
2682
|
+
applyToPoint as applyToPoint16,
|
|
2683
|
+
compose as compose3,
|
|
2684
|
+
rotate as rotate3,
|
|
2685
|
+
translate as translate3,
|
|
2686
|
+
scale as scale2,
|
|
2687
|
+
toString as matrixToString4
|
|
2688
|
+
} from "transformation-matrix";
|
|
2689
|
+
|
|
2690
|
+
// lib/pcb/colors.ts
|
|
2691
|
+
var DEFAULT_PCB_COLOR_MAP = {
|
|
2692
|
+
copper: {
|
|
2693
|
+
top: "rgb(200, 52, 52)",
|
|
2694
|
+
inner1: "rgb(255, 140, 0)",
|
|
2695
|
+
inner2: "rgb(255, 215, 0)",
|
|
2696
|
+
inner3: "rgb(50, 205, 50)",
|
|
2697
|
+
inner4: "rgb(64, 224, 208)",
|
|
2698
|
+
inner5: "rgb(138, 43, 226)",
|
|
2699
|
+
inner6: "rgb(255, 105, 180)",
|
|
2700
|
+
bottom: "rgb(77, 127, 196)"
|
|
2701
|
+
},
|
|
2702
|
+
soldermaskWithCopperUnderneath: {
|
|
2703
|
+
top: "rgb(18, 82, 50)",
|
|
2704
|
+
bottom: "rgb(77, 127, 196)"
|
|
2705
|
+
},
|
|
2706
|
+
soldermask: {
|
|
2707
|
+
top: "rgb(12, 55, 33)",
|
|
2708
|
+
bottom: "rgb(12, 55, 33)"
|
|
2709
|
+
},
|
|
2710
|
+
soldermaskOverCopper: {
|
|
2711
|
+
top: "rgb(52, 135, 73)",
|
|
2712
|
+
bottom: "rgb(52, 135, 73)"
|
|
2713
|
+
},
|
|
2714
|
+
substrate: "rgb(201, 162, 110)",
|
|
2715
|
+
// FR4 substrate color (tan/beige)
|
|
2716
|
+
drill: "#FF26E2",
|
|
2717
|
+
silkscreen: {
|
|
2718
|
+
top: "#f2eda1",
|
|
2719
|
+
bottom: "#5da9e9"
|
|
2720
|
+
},
|
|
2721
|
+
boardOutline: "rgba(255, 255, 255, 0.5)",
|
|
2722
|
+
courtyard: "#FF00FF",
|
|
2723
|
+
debugComponent: {
|
|
2724
|
+
fill: null,
|
|
2725
|
+
stroke: null
|
|
2726
|
+
}
|
|
2727
|
+
};
|
|
2728
|
+
var HOLE_COLOR = DEFAULT_PCB_COLOR_MAP.drill;
|
|
2729
|
+
var SILKSCREEN_TOP_COLOR = DEFAULT_PCB_COLOR_MAP.silkscreen.top;
|
|
2730
|
+
var SILKSCREEN_BOTTOM_COLOR = DEFAULT_PCB_COLOR_MAP.silkscreen.bottom;
|
|
2731
|
+
|
|
2732
|
+
// lib/pcb/layer-name-to-color.ts
|
|
2733
|
+
var LAYER_NAME_TO_COLOR = {
|
|
2734
|
+
...DEFAULT_PCB_COLOR_MAP.copper
|
|
2735
|
+
};
|
|
2736
|
+
function layerNameToColor(layerName, colorMap2 = DEFAULT_PCB_COLOR_MAP) {
|
|
2737
|
+
return colorMap2.copper[layerName] ?? "white";
|
|
2738
|
+
}
|
|
2739
|
+
var SOLDER_PASTE_LAYER_NAME_TO_COLOR = {
|
|
2740
|
+
bottom: "rgb(105, 105, 105)",
|
|
2741
|
+
top: "rgb(105, 105, 105)"
|
|
2742
|
+
};
|
|
2743
|
+
function solderPasteLayerNameToColor(layerName) {
|
|
2744
|
+
return SOLDER_PASTE_LAYER_NAME_TO_COLOR[layerName] ?? "rgb(105, 105, 105)";
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-text.ts
|
|
2748
|
+
import { distance } from "circuit-json";
|
|
2749
|
+
import { lineAlphabet } from "@tscircuit/alphabet";
|
|
2750
|
+
var CHAR_WIDTH = 1;
|
|
2751
|
+
var CHAR_SPACING = 0.2;
|
|
2752
|
+
var LINE_HEIGHT = 1.4;
|
|
2753
|
+
function linesToPathData(lines, offsetX, offsetY, charScale) {
|
|
2754
|
+
return lines.map((line) => {
|
|
2755
|
+
const x1 = offsetX + line.x1 * charScale;
|
|
2756
|
+
const y1 = offsetY + (1 - line.y1) * charScale;
|
|
2757
|
+
const x2 = offsetX + line.x2 * charScale;
|
|
2758
|
+
const y2 = offsetY + (1 - line.y2) * charScale;
|
|
2759
|
+
return `M${x1} ${y1}L${x2} ${y2}`;
|
|
2760
|
+
}).join(" ");
|
|
2761
|
+
}
|
|
2762
|
+
function textToAlphabetPath(text, fontSize) {
|
|
2763
|
+
const paths = [];
|
|
2764
|
+
const charAdvance = (CHAR_WIDTH + CHAR_SPACING) * fontSize;
|
|
2765
|
+
let x = 0;
|
|
2766
|
+
for (const char of text) {
|
|
2767
|
+
if (char === " ") {
|
|
2768
|
+
x += charAdvance * 0.6;
|
|
2769
|
+
continue;
|
|
2770
|
+
}
|
|
2771
|
+
const lines = lineAlphabet[char];
|
|
2772
|
+
if (lines) {
|
|
2773
|
+
paths.push(linesToPathData(lines, x, 0, fontSize));
|
|
2774
|
+
}
|
|
2775
|
+
x += charAdvance;
|
|
2776
|
+
}
|
|
2777
|
+
const width = x > 0 ? x - CHAR_SPACING * fontSize : 0;
|
|
2778
|
+
return { pathData: paths.join(" "), width };
|
|
2779
|
+
}
|
|
2780
|
+
var maskIdCounter = 0;
|
|
2781
|
+
function textToCenteredAlphabetPaths(text, fontSize) {
|
|
2782
|
+
const textLines = text.split("\n");
|
|
2783
|
+
const lineHeight = fontSize * LINE_HEIGHT;
|
|
2784
|
+
const totalHeight = textLines.length * lineHeight;
|
|
2785
|
+
const lineWidths = [];
|
|
2786
|
+
let maxWidth = 0;
|
|
2787
|
+
for (const line of textLines) {
|
|
2788
|
+
const { width } = textToAlphabetPath(line, fontSize);
|
|
2789
|
+
lineWidths.push(width);
|
|
2790
|
+
if (width > maxWidth) maxWidth = width;
|
|
2791
|
+
}
|
|
2792
|
+
const paths = [];
|
|
2793
|
+
let y = -totalHeight / 2;
|
|
2794
|
+
for (let i = 0; i < textLines.length; i++) {
|
|
2795
|
+
const line = textLines[i];
|
|
2796
|
+
const lineWidth = lineWidths[i];
|
|
2797
|
+
const charAdvance = (CHAR_WIDTH + CHAR_SPACING) * fontSize;
|
|
2798
|
+
let x = -lineWidth / 2;
|
|
2799
|
+
for (const char of line) {
|
|
2800
|
+
if (char === " ") {
|
|
2801
|
+
x += charAdvance * 0.6;
|
|
2802
|
+
continue;
|
|
2803
|
+
}
|
|
2804
|
+
const charLines = lineAlphabet[char];
|
|
2805
|
+
if (charLines) {
|
|
2806
|
+
paths.push(linesToPathData(charLines, x, y, fontSize));
|
|
2807
|
+
}
|
|
2808
|
+
x += charAdvance;
|
|
2809
|
+
}
|
|
2810
|
+
y += lineHeight;
|
|
2811
|
+
}
|
|
2812
|
+
return {
|
|
2813
|
+
pathData: paths.join(" "),
|
|
2814
|
+
width: maxWidth,
|
|
2815
|
+
height: totalHeight
|
|
2816
|
+
};
|
|
2817
|
+
}
|
|
2818
|
+
function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
|
|
2819
|
+
const { transform, layer: filterLayer, colorMap: colorMap2 } = ctx;
|
|
2820
|
+
const {
|
|
2821
|
+
anchor_position,
|
|
2822
|
+
text,
|
|
2823
|
+
font_size = "0.2mm",
|
|
2824
|
+
layer,
|
|
2825
|
+
ccw_rotation = 0,
|
|
2826
|
+
anchor_alignment = "center",
|
|
2827
|
+
is_knockout = false,
|
|
2828
|
+
knockout_padding,
|
|
2829
|
+
is_mirrored = false
|
|
2830
|
+
} = pcbCopperText;
|
|
2831
|
+
const layerName = layer ?? "top";
|
|
2832
|
+
if (filterLayer && filterLayer !== layerName) return [];
|
|
2833
|
+
if (!anchor_position) return [];
|
|
2834
|
+
const [ax, ay] = applyToPoint16(transform, [
|
|
2835
|
+
anchor_position.x,
|
|
2836
|
+
anchor_position.y
|
|
2837
|
+
]);
|
|
2838
|
+
const fontSizeNum = distance.parse(font_size) ?? 0.2;
|
|
2839
|
+
const scaleFactor = Math.abs(transform.a);
|
|
2840
|
+
const copperColor = layerNameToColor(layerName, colorMap2);
|
|
2841
|
+
const isBottom = layerName === "bottom";
|
|
2842
|
+
const applyMirror = isBottom ? true : is_mirrored === true;
|
|
2843
|
+
if (is_knockout) {
|
|
2844
|
+
const { pathData: pathData2, width: width2, height: height2 } = textToCenteredAlphabetPaths(
|
|
2845
|
+
text,
|
|
2846
|
+
fontSizeNum
|
|
2847
|
+
);
|
|
2848
|
+
const padX = knockout_padding?.left ?? fontSizeNum * 0.5;
|
|
2849
|
+
const padY = knockout_padding?.top ?? fontSizeNum * 0.3;
|
|
2850
|
+
const rectW = width2 + padX * 2;
|
|
2851
|
+
const rectH = height2 + padY * 2;
|
|
2852
|
+
const strokeWidth2 = fontSizeNum * 0.15;
|
|
2853
|
+
const knockoutTransform = matrixToString4(
|
|
2854
|
+
compose3(
|
|
2855
|
+
translate3(ax, ay),
|
|
2856
|
+
rotate3(-ccw_rotation * Math.PI / 180),
|
|
2857
|
+
...applyMirror ? [scale2(-1, 1)] : [],
|
|
2858
|
+
scale2(scaleFactor, scaleFactor)
|
|
2859
|
+
)
|
|
2860
|
+
);
|
|
2861
|
+
const maskId = `knockout-mask-${pcbCopperText.pcb_copper_text_id}-${maskIdCounter++}`;
|
|
2862
|
+
return [
|
|
2863
|
+
{
|
|
2864
|
+
name: "defs",
|
|
2865
|
+
type: "element",
|
|
2866
|
+
value: "",
|
|
2867
|
+
children: [
|
|
2868
|
+
{
|
|
2869
|
+
name: "mask",
|
|
2870
|
+
type: "element",
|
|
2871
|
+
value: "",
|
|
2872
|
+
attributes: {
|
|
2873
|
+
id: maskId
|
|
2874
|
+
},
|
|
2875
|
+
children: [
|
|
2876
|
+
// White background - area that will show copper
|
|
2877
|
+
{
|
|
2878
|
+
name: "rect",
|
|
2879
|
+
type: "element",
|
|
2880
|
+
value: "",
|
|
2881
|
+
attributes: {
|
|
2882
|
+
x: (-rectW / 2).toString(),
|
|
2883
|
+
y: (-rectH / 2).toString(),
|
|
2884
|
+
width: rectW.toString(),
|
|
2885
|
+
height: rectH.toString(),
|
|
2886
|
+
fill: "white"
|
|
2887
|
+
},
|
|
2888
|
+
children: []
|
|
2889
|
+
},
|
|
2890
|
+
// Black text strokes - area that will be cut out
|
|
2891
|
+
{
|
|
2892
|
+
name: "path",
|
|
2893
|
+
type: "element",
|
|
2894
|
+
value: "",
|
|
2895
|
+
attributes: {
|
|
2896
|
+
d: pathData2,
|
|
2897
|
+
fill: "none",
|
|
2898
|
+
stroke: "black",
|
|
2899
|
+
"stroke-width": strokeWidth2.toString(),
|
|
2900
|
+
"stroke-linecap": "round",
|
|
2901
|
+
"stroke-linejoin": "round"
|
|
2902
|
+
},
|
|
2903
|
+
children: []
|
|
2904
|
+
}
|
|
2905
|
+
]
|
|
2906
|
+
}
|
|
2907
|
+
],
|
|
2908
|
+
attributes: {}
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
name: "rect",
|
|
2912
|
+
type: "element",
|
|
2913
|
+
value: "",
|
|
2914
|
+
children: [],
|
|
2915
|
+
attributes: {
|
|
2916
|
+
x: (-rectW / 2).toString(),
|
|
2917
|
+
y: (-rectH / 2).toString(),
|
|
2918
|
+
width: rectW.toString(),
|
|
2919
|
+
height: rectH.toString(),
|
|
2920
|
+
fill: copperColor,
|
|
2921
|
+
mask: `url(#${maskId})`,
|
|
2922
|
+
transform: knockoutTransform,
|
|
2923
|
+
class: `pcb-copper-text-knockout pcb-copper-${layerName}`,
|
|
2924
|
+
"data-type": "pcb_copper_text",
|
|
2925
|
+
"data-pcb-copper-text-id": pcbCopperText.pcb_copper_text_id
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
];
|
|
2929
|
+
}
|
|
2930
|
+
const { pathData, width, height } = textToCenteredAlphabetPaths(
|
|
2931
|
+
text,
|
|
2932
|
+
fontSizeNum
|
|
2933
|
+
);
|
|
2934
|
+
let offsetX = 0;
|
|
2935
|
+
let offsetY = 0;
|
|
2936
|
+
switch (anchor_alignment) {
|
|
2937
|
+
case "top_left":
|
|
2938
|
+
offsetX = width / 2;
|
|
2939
|
+
offsetY = height / 2;
|
|
2940
|
+
break;
|
|
2941
|
+
case "top_center":
|
|
2942
|
+
offsetY = height / 2;
|
|
2943
|
+
break;
|
|
2944
|
+
case "top_right":
|
|
2945
|
+
offsetX = -width / 2;
|
|
2946
|
+
offsetY = height / 2;
|
|
2947
|
+
break;
|
|
2948
|
+
case "center_left":
|
|
2949
|
+
offsetX = width / 2;
|
|
2950
|
+
break;
|
|
2951
|
+
case "center_right":
|
|
2952
|
+
offsetX = -width / 2;
|
|
2953
|
+
break;
|
|
2954
|
+
case "bottom_left":
|
|
2955
|
+
offsetX = width / 2;
|
|
2956
|
+
offsetY = -height / 2;
|
|
2957
|
+
break;
|
|
2958
|
+
case "bottom_center":
|
|
2959
|
+
offsetY = -height / 2;
|
|
2960
|
+
break;
|
|
2961
|
+
case "bottom_right":
|
|
2962
|
+
offsetX = -width / 2;
|
|
2963
|
+
offsetY = -height / 2;
|
|
2964
|
+
break;
|
|
2965
|
+
}
|
|
2966
|
+
const textTransform = matrixToString4(
|
|
2967
|
+
compose3(
|
|
2968
|
+
translate3(ax, ay),
|
|
2969
|
+
rotate3(-ccw_rotation * Math.PI / 180),
|
|
2970
|
+
...applyMirror ? [scale2(-1, 1)] : [],
|
|
2971
|
+
translate3(offsetX, offsetY),
|
|
2972
|
+
scale2(scaleFactor, scaleFactor)
|
|
2973
|
+
)
|
|
2974
|
+
);
|
|
2975
|
+
const strokeWidth = fontSizeNum * 0.15;
|
|
2976
|
+
return [
|
|
2977
|
+
{
|
|
2978
|
+
name: "path",
|
|
2979
|
+
type: "element",
|
|
2980
|
+
attributes: {
|
|
2981
|
+
d: pathData,
|
|
2982
|
+
fill: "none",
|
|
2983
|
+
stroke: copperColor,
|
|
2984
|
+
"stroke-width": strokeWidth.toString(),
|
|
2985
|
+
"stroke-linecap": "round",
|
|
2986
|
+
"stroke-linejoin": "round",
|
|
2987
|
+
transform: textTransform,
|
|
2988
|
+
class: `pcb-copper-text pcb-copper-${layerName}`,
|
|
2989
|
+
"data-type": "pcb_copper_text",
|
|
2990
|
+
"data-pcb-copper-text-id": pcbCopperText.pcb_copper_text_id
|
|
2991
|
+
},
|
|
2992
|
+
children: [],
|
|
2993
|
+
value: ""
|
|
2994
|
+
}
|
|
2995
|
+
];
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2680
2998
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-circle.ts
|
|
2681
|
-
import { applyToPoint as
|
|
2999
|
+
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
2682
3000
|
function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
2683
3001
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
2684
3002
|
const {
|
|
@@ -2693,7 +3011,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
2693
3011
|
console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
|
|
2694
3012
|
return [];
|
|
2695
3013
|
}
|
|
2696
|
-
const [transformedX, transformedY] =
|
|
3014
|
+
const [transformedX, transformedY] = applyToPoint17(transform, [
|
|
2697
3015
|
center.x,
|
|
2698
3016
|
center.y
|
|
2699
3017
|
]);
|
|
@@ -2721,7 +3039,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
2721
3039
|
}
|
|
2722
3040
|
|
|
2723
3041
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-line.ts
|
|
2724
|
-
import { applyToPoint as
|
|
3042
|
+
import { applyToPoint as applyToPoint18 } from "transformation-matrix";
|
|
2725
3043
|
function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
2726
3044
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
2727
3045
|
const {
|
|
@@ -2738,8 +3056,8 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
|
2738
3056
|
console.error("Invalid coordinates:", { x1, y1, x2, y2 });
|
|
2739
3057
|
return [];
|
|
2740
3058
|
}
|
|
2741
|
-
const [transformedX1, transformedY1] =
|
|
2742
|
-
const [transformedX2, transformedY2] =
|
|
3059
|
+
const [transformedX1, transformedY1] = applyToPoint18(transform, [x1, y1]);
|
|
3060
|
+
const [transformedX2, transformedY2] = applyToPoint18(transform, [x2, y2]);
|
|
2743
3061
|
const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
|
|
2744
3062
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
2745
3063
|
return [
|
|
@@ -2765,7 +3083,7 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
|
2765
3083
|
}
|
|
2766
3084
|
|
|
2767
3085
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-courtyard-rect.ts
|
|
2768
|
-
import { applyToPoint as
|
|
3086
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
2769
3087
|
function createSvgObjectsFromPcbCourtyardRect(pcbCourtyardRect, ctx) {
|
|
2770
3088
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
2771
3089
|
const {
|
|
@@ -2784,7 +3102,7 @@ function createSvgObjectsFromPcbCourtyardRect(pcbCourtyardRect, ctx) {
|
|
|
2784
3102
|
});
|
|
2785
3103
|
return [];
|
|
2786
3104
|
}
|
|
2787
|
-
const [transformedX, transformedY] =
|
|
3105
|
+
const [transformedX, transformedY] = applyToPoint19(transform, [
|
|
2788
3106
|
center.x,
|
|
2789
3107
|
center.y
|
|
2790
3108
|
]);
|
|
@@ -2825,66 +3143,7 @@ function pairs(arr) {
|
|
|
2825
3143
|
}
|
|
2826
3144
|
|
|
2827
3145
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
2828
|
-
import { applyToPoint as
|
|
2829
|
-
|
|
2830
|
-
// lib/pcb/colors.ts
|
|
2831
|
-
var DEFAULT_PCB_COLOR_MAP = {
|
|
2832
|
-
copper: {
|
|
2833
|
-
top: "rgb(200, 52, 52)",
|
|
2834
|
-
inner1: "rgb(255, 140, 0)",
|
|
2835
|
-
inner2: "rgb(255, 215, 0)",
|
|
2836
|
-
inner3: "rgb(50, 205, 50)",
|
|
2837
|
-
inner4: "rgb(64, 224, 208)",
|
|
2838
|
-
inner5: "rgb(138, 43, 226)",
|
|
2839
|
-
inner6: "rgb(255, 105, 180)",
|
|
2840
|
-
bottom: "rgb(77, 127, 196)"
|
|
2841
|
-
},
|
|
2842
|
-
soldermaskWithCopperUnderneath: {
|
|
2843
|
-
top: "rgb(18, 82, 50)",
|
|
2844
|
-
bottom: "rgb(77, 127, 196)"
|
|
2845
|
-
},
|
|
2846
|
-
soldermask: {
|
|
2847
|
-
top: "rgb(12, 55, 33)",
|
|
2848
|
-
bottom: "rgb(12, 55, 33)"
|
|
2849
|
-
},
|
|
2850
|
-
soldermaskOverCopper: {
|
|
2851
|
-
top: "rgb(52, 135, 73)",
|
|
2852
|
-
bottom: "rgb(52, 135, 73)"
|
|
2853
|
-
},
|
|
2854
|
-
substrate: "rgb(201, 162, 110)",
|
|
2855
|
-
// FR4 substrate color (tan/beige)
|
|
2856
|
-
drill: "#FF26E2",
|
|
2857
|
-
silkscreen: {
|
|
2858
|
-
top: "#f2eda1",
|
|
2859
|
-
bottom: "#5da9e9"
|
|
2860
|
-
},
|
|
2861
|
-
boardOutline: "rgba(255, 255, 255, 0.5)",
|
|
2862
|
-
courtyard: "#FF00FF",
|
|
2863
|
-
debugComponent: {
|
|
2864
|
-
fill: null,
|
|
2865
|
-
stroke: null
|
|
2866
|
-
}
|
|
2867
|
-
};
|
|
2868
|
-
var HOLE_COLOR = DEFAULT_PCB_COLOR_MAP.drill;
|
|
2869
|
-
var SILKSCREEN_TOP_COLOR = DEFAULT_PCB_COLOR_MAP.silkscreen.top;
|
|
2870
|
-
var SILKSCREEN_BOTTOM_COLOR = DEFAULT_PCB_COLOR_MAP.silkscreen.bottom;
|
|
2871
|
-
|
|
2872
|
-
// lib/pcb/layer-name-to-color.ts
|
|
2873
|
-
var LAYER_NAME_TO_COLOR = {
|
|
2874
|
-
...DEFAULT_PCB_COLOR_MAP.copper
|
|
2875
|
-
};
|
|
2876
|
-
function layerNameToColor(layerName, colorMap2 = DEFAULT_PCB_COLOR_MAP) {
|
|
2877
|
-
return colorMap2.copper[layerName] ?? "white";
|
|
2878
|
-
}
|
|
2879
|
-
var SOLDER_PASTE_LAYER_NAME_TO_COLOR = {
|
|
2880
|
-
bottom: "rgb(105, 105, 105)",
|
|
2881
|
-
top: "rgb(105, 105, 105)"
|
|
2882
|
-
};
|
|
2883
|
-
function solderPasteLayerNameToColor(layerName) {
|
|
2884
|
-
return SOLDER_PASTE_LAYER_NAME_TO_COLOR[layerName] ?? "rgb(105, 105, 105)";
|
|
2885
|
-
}
|
|
2886
|
-
|
|
2887
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
3146
|
+
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
2888
3147
|
function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
2889
3148
|
const { transform, layer: layerFilter, colorMap: colorMap2, showSolderMask } = ctx;
|
|
2890
3149
|
if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2)
|
|
@@ -2892,8 +3151,8 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
2892
3151
|
const segments = pairs(trace.route);
|
|
2893
3152
|
const svgObjects = [];
|
|
2894
3153
|
for (const [start, end] of segments) {
|
|
2895
|
-
const startPoint =
|
|
2896
|
-
const endPoint =
|
|
3154
|
+
const startPoint = applyToPoint20(transform, [start.x, start.y]);
|
|
3155
|
+
const endPoint = applyToPoint20(transform, [end.x, end.y]);
|
|
2897
3156
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
2898
3157
|
if (!layer) continue;
|
|
2899
3158
|
if (layerFilter && layer !== layerFilter) continue;
|
|
@@ -2948,7 +3207,7 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
2948
3207
|
}
|
|
2949
3208
|
|
|
2950
3209
|
// lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
|
|
2951
|
-
import { applyToPoint as
|
|
3210
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
2952
3211
|
function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
2953
3212
|
const { transform, layer: layerFilter, colorMap: colorMap2, showSolderMask } = ctx;
|
|
2954
3213
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
@@ -2959,7 +3218,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2959
3218
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
2960
3219
|
const width = pad.width * Math.abs(transform.a);
|
|
2961
3220
|
const height = pad.height * Math.abs(transform.d);
|
|
2962
|
-
const [x, y] =
|
|
3221
|
+
const [x, y] = applyToPoint21(transform, [pad.x, pad.y]);
|
|
2963
3222
|
const cornerRadiusValue = pad.corner_radius ?? pad.rect_border_radius ?? 0;
|
|
2964
3223
|
const scaledBorderRadius = cornerRadiusValue * Math.abs(transform.a);
|
|
2965
3224
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
@@ -3201,7 +3460,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3201
3460
|
const width = pad.width * Math.abs(transform.a);
|
|
3202
3461
|
const height = pad.height * Math.abs(transform.d);
|
|
3203
3462
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3204
|
-
const [x, y] =
|
|
3463
|
+
const [x, y] = applyToPoint21(transform, [pad.x, pad.y]);
|
|
3205
3464
|
const rotationTransformAttributes = isRotated ? {
|
|
3206
3465
|
transform: `translate(${x} ${y}) rotate(${-(pad.ccw_rotation ?? 0)})`
|
|
3207
3466
|
} : void 0;
|
|
@@ -3319,7 +3578,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3319
3578
|
}
|
|
3320
3579
|
if (pad.shape === "circle") {
|
|
3321
3580
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3322
|
-
const [x, y] =
|
|
3581
|
+
const [x, y] = applyToPoint21(transform, [pad.x, pad.y]);
|
|
3323
3582
|
const padElement = {
|
|
3324
3583
|
name: "circle",
|
|
3325
3584
|
type: "element",
|
|
@@ -3409,7 +3668,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3409
3668
|
}
|
|
3410
3669
|
if (pad.shape === "polygon") {
|
|
3411
3670
|
const points = (pad.points ?? []).map(
|
|
3412
|
-
(point) =>
|
|
3671
|
+
(point) => applyToPoint21(transform, [point.x, point.y])
|
|
3413
3672
|
);
|
|
3414
3673
|
const padElement = {
|
|
3415
3674
|
name: "polygon",
|
|
@@ -3434,10 +3693,10 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3434
3693
|
maskPoints = points.map(([px, py]) => {
|
|
3435
3694
|
const dx = px - centroidX;
|
|
3436
3695
|
const dy = py - centroidY;
|
|
3437
|
-
const
|
|
3438
|
-
if (
|
|
3439
|
-
const normalizedDx = dx /
|
|
3440
|
-
const normalizedDy = dy /
|
|
3696
|
+
const distance4 = Math.sqrt(dx * dx + dy * dy);
|
|
3697
|
+
if (distance4 === 0) return [px, py];
|
|
3698
|
+
const normalizedDx = dx / distance4;
|
|
3699
|
+
const normalizedDy = dy / distance4;
|
|
3441
3700
|
return [
|
|
3442
3701
|
px + normalizedDx * soldermaskMargin,
|
|
3443
3702
|
py + normalizedDy * soldermaskMargin
|
|
@@ -3508,10 +3767,10 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3508
3767
|
}
|
|
3509
3768
|
|
|
3510
3769
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
3511
|
-
import { applyToPoint as
|
|
3770
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
3512
3771
|
|
|
3513
3772
|
// lib/utils/create-pcb-component-anchor-offset-indicators.ts
|
|
3514
|
-
import { applyToPoint as
|
|
3773
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
3515
3774
|
var OFFSET_THRESHOLD_MM = 0.01;
|
|
3516
3775
|
var TICK_SIZE_PX = 4;
|
|
3517
3776
|
var LABEL_GAP_PX = 8;
|
|
@@ -3532,19 +3791,19 @@ function createAnchorOffsetIndicators(params) {
|
|
|
3532
3791
|
componentHeight = 0
|
|
3533
3792
|
} = params;
|
|
3534
3793
|
const objects = [];
|
|
3535
|
-
const [screenGroupAnchorX, screenGroupAnchorY] =
|
|
3794
|
+
const [screenGroupAnchorX, screenGroupAnchorY] = applyToPoint22(transform, [
|
|
3536
3795
|
groupAnchorPosition.x,
|
|
3537
3796
|
groupAnchorPosition.y
|
|
3538
3797
|
]);
|
|
3539
|
-
const [screenComponentX, screenComponentY] =
|
|
3798
|
+
const [screenComponentX, screenComponentY] = applyToPoint22(transform, [
|
|
3540
3799
|
componentPosition.x,
|
|
3541
3800
|
componentPosition.y
|
|
3542
3801
|
]);
|
|
3543
3802
|
const offsetX = componentPosition.x - groupAnchorPosition.x;
|
|
3544
3803
|
const offsetY = componentPosition.y - groupAnchorPosition.y;
|
|
3545
|
-
const
|
|
3546
|
-
const screenComponentWidth = componentWidth *
|
|
3547
|
-
const screenComponentHeight = componentHeight *
|
|
3804
|
+
const scale10 = Math.abs(transform.a);
|
|
3805
|
+
const screenComponentWidth = componentWidth * scale10;
|
|
3806
|
+
const screenComponentHeight = componentHeight * scale10;
|
|
3548
3807
|
objects.push(createAnchorMarker(screenGroupAnchorX, screenGroupAnchorY));
|
|
3549
3808
|
objects.push({
|
|
3550
3809
|
name: "line",
|
|
@@ -3821,25 +4080,25 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
3821
4080
|
let path;
|
|
3822
4081
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
3823
4082
|
path = outline.map((point, index) => {
|
|
3824
|
-
const [x, y] =
|
|
4083
|
+
const [x, y] = applyToPoint23(transform, [point.x, point.y]);
|
|
3825
4084
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3826
4085
|
}).join(" ");
|
|
3827
4086
|
} else {
|
|
3828
4087
|
const halfWidth = width / 2;
|
|
3829
4088
|
const halfHeight = height / 2;
|
|
3830
|
-
const topLeft =
|
|
4089
|
+
const topLeft = applyToPoint23(transform, [
|
|
3831
4090
|
center.x - halfWidth,
|
|
3832
4091
|
center.y - halfHeight
|
|
3833
4092
|
]);
|
|
3834
|
-
const topRight =
|
|
4093
|
+
const topRight = applyToPoint23(transform, [
|
|
3835
4094
|
center.x + halfWidth,
|
|
3836
4095
|
center.y - halfHeight
|
|
3837
4096
|
]);
|
|
3838
|
-
const bottomRight =
|
|
4097
|
+
const bottomRight = applyToPoint23(transform, [
|
|
3839
4098
|
center.x + halfWidth,
|
|
3840
4099
|
center.y + halfHeight
|
|
3841
4100
|
]);
|
|
3842
|
-
const bottomLeft =
|
|
4101
|
+
const bottomLeft = applyToPoint23(transform, [
|
|
3843
4102
|
center.x - halfWidth,
|
|
3844
4103
|
center.y + halfHeight
|
|
3845
4104
|
]);
|
|
@@ -3902,7 +4161,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
3902
4161
|
}
|
|
3903
4162
|
|
|
3904
4163
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-panel.ts
|
|
3905
|
-
import { applyToPoint as
|
|
4164
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
3906
4165
|
function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
3907
4166
|
const { transform, colorMap: colorMap2, showSolderMask } = ctx;
|
|
3908
4167
|
const width = Number(pcbPanel.width);
|
|
@@ -3910,19 +4169,19 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
|
3910
4169
|
const center = pcbPanel.center ?? { x: width / 2, y: height / 2 };
|
|
3911
4170
|
const halfWidth = width / 2;
|
|
3912
4171
|
const halfHeight = height / 2;
|
|
3913
|
-
const topLeft =
|
|
4172
|
+
const topLeft = applyToPoint24(transform, [
|
|
3914
4173
|
center.x - halfWidth,
|
|
3915
4174
|
center.y - halfHeight
|
|
3916
4175
|
]);
|
|
3917
|
-
const topRight =
|
|
4176
|
+
const topRight = applyToPoint24(transform, [
|
|
3918
4177
|
center.x + halfWidth,
|
|
3919
4178
|
center.y - halfHeight
|
|
3920
4179
|
]);
|
|
3921
|
-
const bottomRight =
|
|
4180
|
+
const bottomRight = applyToPoint24(transform, [
|
|
3922
4181
|
center.x + halfWidth,
|
|
3923
4182
|
center.y + halfHeight
|
|
3924
4183
|
]);
|
|
3925
|
-
const bottomLeft =
|
|
4184
|
+
const bottomLeft = applyToPoint24(transform, [
|
|
3926
4185
|
center.x - halfWidth,
|
|
3927
4186
|
center.y + halfHeight
|
|
3928
4187
|
]);
|
|
@@ -3951,10 +4210,10 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
|
3951
4210
|
}
|
|
3952
4211
|
|
|
3953
4212
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
3954
|
-
import { applyToPoint as
|
|
4213
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
3955
4214
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
3956
4215
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
3957
|
-
const [x, y] =
|
|
4216
|
+
const [x, y] = applyToPoint25(transform, [hole.x, hole.y]);
|
|
3958
4217
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
3959
4218
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
3960
4219
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -4000,11 +4259,11 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
4000
4259
|
}
|
|
4001
4260
|
|
|
4002
4261
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
4003
|
-
import { applyToPoint as
|
|
4262
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
4004
4263
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
4005
4264
|
const { transform, colorMap: colorMap2, showSolderMask } = ctx;
|
|
4006
4265
|
const layer = ctx.layer ?? "top";
|
|
4007
|
-
const [x, y] =
|
|
4266
|
+
const [x, y] = applyToPoint26(transform, [hole.x, hole.y]);
|
|
4008
4267
|
const isCoveredWithSolderMask = Boolean(hole.is_covered_with_solder_mask);
|
|
4009
4268
|
const soldermaskMargin = (hole.soldermask_margin ?? 0) * Math.abs(transform.a);
|
|
4010
4269
|
const shouldShowSolderMask = showSolderMask && isCoveredWithSolderMask && soldermaskMargin !== 0;
|
|
@@ -4501,7 +4760,7 @@ import {
|
|
|
4501
4760
|
getFullConnectivityMapFromCircuitJson
|
|
4502
4761
|
} from "circuit-json-to-connectivity-map";
|
|
4503
4762
|
import "svgson";
|
|
4504
|
-
import { applyToPoint as
|
|
4763
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
4505
4764
|
|
|
4506
4765
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
4507
4766
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -4528,9 +4787,9 @@ var findNearestPointInNet = (sourcePoint, netId, connectivity, circuitJson) => {
|
|
|
4528
4787
|
if (pos) {
|
|
4529
4788
|
const dx = sourcePoint.x - pos.x;
|
|
4530
4789
|
const dy = sourcePoint.y - pos.y;
|
|
4531
|
-
const
|
|
4532
|
-
if (
|
|
4533
|
-
minDistance =
|
|
4790
|
+
const distance4 = Math.sqrt(dx * dx + dy * dy);
|
|
4791
|
+
if (distance4 > 0 && distance4 < minDistance) {
|
|
4792
|
+
minDistance = distance4;
|
|
4534
4793
|
nearestPoint = pos;
|
|
4535
4794
|
}
|
|
4536
4795
|
}
|
|
@@ -4581,11 +4840,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
4581
4840
|
});
|
|
4582
4841
|
const svgObjects = [];
|
|
4583
4842
|
for (const line of ratsNestLines) {
|
|
4584
|
-
const transformedStart =
|
|
4843
|
+
const transformedStart = applyToPoint27(transform, [
|
|
4585
4844
|
line.startPoint.x,
|
|
4586
4845
|
line.startPoint.y
|
|
4587
4846
|
]);
|
|
4588
|
-
const transformedEnd =
|
|
4847
|
+
const transformedEnd = applyToPoint27(transform, [
|
|
4589
4848
|
line.endPoint.x,
|
|
4590
4849
|
line.endPoint.y
|
|
4591
4850
|
]);
|
|
@@ -4613,17 +4872,17 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
4613
4872
|
|
|
4614
4873
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
4615
4874
|
import {
|
|
4616
|
-
applyToPoint as
|
|
4617
|
-
compose as
|
|
4618
|
-
rotate as
|
|
4619
|
-
translate as
|
|
4620
|
-
toString as
|
|
4875
|
+
applyToPoint as applyToPoint28,
|
|
4876
|
+
compose as compose4,
|
|
4877
|
+
rotate as rotate4,
|
|
4878
|
+
translate as translate4,
|
|
4879
|
+
toString as matrixToString7
|
|
4621
4880
|
} from "transformation-matrix";
|
|
4622
4881
|
function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
4623
4882
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
4624
4883
|
if (cutout.shape === "rect") {
|
|
4625
4884
|
const rectCutout = cutout;
|
|
4626
|
-
const [cx, cy] =
|
|
4885
|
+
const [cx, cy] = applyToPoint28(transform, [
|
|
4627
4886
|
rectCutout.center.x,
|
|
4628
4887
|
rectCutout.center.y
|
|
4629
4888
|
]);
|
|
@@ -4641,8 +4900,8 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
4641
4900
|
width: scaledWidth.toString(),
|
|
4642
4901
|
height: scaledHeight.toString(),
|
|
4643
4902
|
fill: colorMap2.drill,
|
|
4644
|
-
transform:
|
|
4645
|
-
|
|
4903
|
+
transform: matrixToString7(
|
|
4904
|
+
compose4(translate4(cx, cy), rotate4(svgRotation * Math.PI / 180))
|
|
4646
4905
|
),
|
|
4647
4906
|
"data-type": "pcb_cutout",
|
|
4648
4907
|
"data-pcb-layer": "drill"
|
|
@@ -4665,7 +4924,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
4665
4924
|
}
|
|
4666
4925
|
if (cutout.shape === "circle") {
|
|
4667
4926
|
const circleCutout = cutout;
|
|
4668
|
-
const [cx, cy] =
|
|
4927
|
+
const [cx, cy] = applyToPoint28(transform, [
|
|
4669
4928
|
circleCutout.center.x,
|
|
4670
4929
|
circleCutout.center.y
|
|
4671
4930
|
]);
|
|
@@ -4692,7 +4951,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
4692
4951
|
const polygonCutout = cutout;
|
|
4693
4952
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
4694
4953
|
const transformedPoints = polygonCutout.points.map(
|
|
4695
|
-
(p) =>
|
|
4954
|
+
(p) => applyToPoint28(transform, [p.x, p.y])
|
|
4696
4955
|
);
|
|
4697
4956
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
4698
4957
|
return [
|
|
@@ -4716,19 +4975,19 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
4716
4975
|
|
|
4717
4976
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
4718
4977
|
import {
|
|
4719
|
-
applyToPoint as
|
|
4720
|
-
compose as
|
|
4721
|
-
rotate as
|
|
4722
|
-
toString as
|
|
4723
|
-
translate as
|
|
4978
|
+
applyToPoint as applyToPoint30,
|
|
4979
|
+
compose as compose5,
|
|
4980
|
+
rotate as rotate5,
|
|
4981
|
+
toString as matrixToString8,
|
|
4982
|
+
translate as translate5
|
|
4724
4983
|
} from "transformation-matrix";
|
|
4725
4984
|
|
|
4726
4985
|
// lib/utils/ring-to-path-d.ts
|
|
4727
|
-
import { applyToPoint as
|
|
4986
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
4728
4987
|
function ringToPathD(vertices, transform) {
|
|
4729
4988
|
if (vertices.length === 0) return "";
|
|
4730
4989
|
const transformedVertices = vertices.map((v) => {
|
|
4731
|
-
const [x, y] =
|
|
4990
|
+
const [x, y] = applyToPoint29(transform, [v.x, v.y]);
|
|
4732
4991
|
return { ...v, x, y };
|
|
4733
4992
|
});
|
|
4734
4993
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -4817,7 +5076,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
4817
5076
|
const maskOverlayColor = layer === "bottom" ? colorMap2.soldermaskOverCopper.bottom : colorMap2.soldermaskOverCopper.top;
|
|
4818
5077
|
const maskOverlayOpacity = "0.9";
|
|
4819
5078
|
if (pour.shape === "rect") {
|
|
4820
|
-
const [cx, cy] =
|
|
5079
|
+
const [cx, cy] = applyToPoint30(transform, [pour.center.x, pour.center.y]);
|
|
4821
5080
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
4822
5081
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
4823
5082
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -4826,8 +5085,8 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
4826
5085
|
y: (-scaledHeight / 2).toString(),
|
|
4827
5086
|
width: scaledWidth.toString(),
|
|
4828
5087
|
height: scaledHeight.toString(),
|
|
4829
|
-
transform:
|
|
4830
|
-
|
|
5088
|
+
transform: matrixToString8(
|
|
5089
|
+
compose5(translate5(cx, cy), rotate5(svgRotation * Math.PI / 180))
|
|
4831
5090
|
)
|
|
4832
5091
|
};
|
|
4833
5092
|
const copperRect = {
|
|
@@ -4869,7 +5128,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
4869
5128
|
if (pour.shape === "polygon") {
|
|
4870
5129
|
if (!pour.points || pour.points.length === 0) return [];
|
|
4871
5130
|
const transformedPoints = pour.points.map(
|
|
4872
|
-
(p) =>
|
|
5131
|
+
(p) => applyToPoint30(transform, [p.x, p.y])
|
|
4873
5132
|
);
|
|
4874
5133
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
4875
5134
|
const copperPolygon = {
|
|
@@ -5092,11 +5351,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
5092
5351
|
}
|
|
5093
5352
|
|
|
5094
5353
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
5095
|
-
import { applyToPoint as
|
|
5354
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
5096
5355
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
5097
5356
|
const { transform, circuitJson } = ctx;
|
|
5098
5357
|
const { center, width, height, rotation = 0 } = component;
|
|
5099
|
-
const [x, y] =
|
|
5358
|
+
const [x, y] = applyToPoint31(transform, [center.x, center.y]);
|
|
5100
5359
|
const scaledWidth = width * Math.abs(transform.a);
|
|
5101
5360
|
const scaledHeight = height * Math.abs(transform.d);
|
|
5102
5361
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -5151,7 +5410,7 @@ function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
|
5151
5410
|
}
|
|
5152
5411
|
|
|
5153
5412
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-group.ts
|
|
5154
|
-
import { applyToPoint as
|
|
5413
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
5155
5414
|
var DEFAULT_GROUP_COLOR = "rgba(100, 200, 255, 0.6)";
|
|
5156
5415
|
var DEFAULT_STROKE_WIDTH = 0.1;
|
|
5157
5416
|
function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
@@ -5178,7 +5437,7 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5178
5437
|
(point) => point && typeof point.x === "number" && typeof point.y === "number"
|
|
5179
5438
|
)) {
|
|
5180
5439
|
const path = outline.map((point, index) => {
|
|
5181
|
-
const [x, y] =
|
|
5440
|
+
const [x, y] = applyToPoint32(transform, [point.x, point.y]);
|
|
5182
5441
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
5183
5442
|
}).join(" ");
|
|
5184
5443
|
return [
|
|
@@ -5200,11 +5459,11 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5200
5459
|
}
|
|
5201
5460
|
const halfWidth = width / 2;
|
|
5202
5461
|
const halfHeight = height / 2;
|
|
5203
|
-
const [topLeftX, topLeftY] =
|
|
5462
|
+
const [topLeftX, topLeftY] = applyToPoint32(transform, [
|
|
5204
5463
|
center.x - halfWidth,
|
|
5205
5464
|
center.y + halfHeight
|
|
5206
5465
|
]);
|
|
5207
|
-
const [bottomRightX, bottomRightY] =
|
|
5466
|
+
const [bottomRightX, bottomRightY] = applyToPoint32(transform, [
|
|
5208
5467
|
center.x + halfWidth,
|
|
5209
5468
|
center.y - halfHeight
|
|
5210
5469
|
]);
|
|
@@ -5240,7 +5499,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
5240
5499
|
var package_default = {
|
|
5241
5500
|
name: "circuit-to-svg",
|
|
5242
5501
|
type: "module",
|
|
5243
|
-
version: "0.0.
|
|
5502
|
+
version: "0.0.284",
|
|
5244
5503
|
description: "Convert Circuit JSON to SVG",
|
|
5245
5504
|
main: "dist/index.js",
|
|
5246
5505
|
files: [
|
|
@@ -5258,13 +5517,14 @@ var package_default = {
|
|
|
5258
5517
|
license: "ISC",
|
|
5259
5518
|
devDependencies: {
|
|
5260
5519
|
"@biomejs/biome": "^1.9.4",
|
|
5520
|
+
"@tscircuit/alphabet": "^0.0.8",
|
|
5261
5521
|
"@types/bun": "^1.2.8",
|
|
5262
5522
|
"@vitejs/plugin-react": "5.0.0",
|
|
5263
5523
|
biome: "^0.3.3",
|
|
5264
5524
|
"bun-match-svg": "^0.0.12",
|
|
5525
|
+
"circuit-json": "^0.0.327",
|
|
5265
5526
|
esbuild: "^0.20.2",
|
|
5266
5527
|
"performance-now": "^2.1.0",
|
|
5267
|
-
"circuit-json": "^0.0.327",
|
|
5268
5528
|
react: "19.1.0",
|
|
5269
5529
|
"react-cosmos": "7.0.0",
|
|
5270
5530
|
"react-cosmos-plugin-vite": "7.0.0",
|
|
@@ -5274,6 +5534,9 @@ var package_default = {
|
|
|
5274
5534
|
typescript: "^5.4.5",
|
|
5275
5535
|
"vite-tsconfig-paths": "^5.0.1"
|
|
5276
5536
|
},
|
|
5537
|
+
peerDependencies: {
|
|
5538
|
+
"@tscircuit/alphabet": "*"
|
|
5539
|
+
},
|
|
5277
5540
|
dependencies: {
|
|
5278
5541
|
"@types/node": "^22.5.5",
|
|
5279
5542
|
"bun-types": "^1.1.40",
|
|
@@ -5469,8 +5732,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5469
5732
|
for (const circuitJsonElm of circuitJson) {
|
|
5470
5733
|
if (circuitJsonElm.type === "pcb_panel") {
|
|
5471
5734
|
const panel = circuitJsonElm;
|
|
5472
|
-
const width =
|
|
5473
|
-
const height =
|
|
5735
|
+
const width = distance2.parse(panel.width);
|
|
5736
|
+
const height = distance2.parse(panel.height);
|
|
5474
5737
|
if (width === void 0 || height === void 0) {
|
|
5475
5738
|
continue;
|
|
5476
5739
|
}
|
|
@@ -5497,7 +5760,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5497
5760
|
if (pad.shape === "rect" || pad.shape === "rotated_rect" || pad.shape === "pill") {
|
|
5498
5761
|
updateBounds({ x: pad.x, y: pad.y }, pad.width, pad.height);
|
|
5499
5762
|
} else if (pad.shape === "circle") {
|
|
5500
|
-
const radius =
|
|
5763
|
+
const radius = distance2.parse(pad.radius);
|
|
5501
5764
|
if (radius !== void 0) {
|
|
5502
5765
|
updateBounds({ x: pad.x, y: pad.y }, radius * 2, radius * 2);
|
|
5503
5766
|
}
|
|
@@ -5519,7 +5782,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5519
5782
|
if (cutout.shape === "rect") {
|
|
5520
5783
|
updateBounds(cutout.center, cutout.width, cutout.height);
|
|
5521
5784
|
} else if (cutout.shape === "circle") {
|
|
5522
|
-
const radius =
|
|
5785
|
+
const radius = distance2.parse(cutout.radius);
|
|
5523
5786
|
if (radius !== void 0) {
|
|
5524
5787
|
updateBounds(cutout.center, radius * 2, radius * 2);
|
|
5525
5788
|
}
|
|
@@ -5528,6 +5791,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5528
5791
|
}
|
|
5529
5792
|
} else if (circuitJsonElm.type === "pcb_silkscreen_text" || circuitJsonElm.type === "pcb_silkscreen_rect" || circuitJsonElm.type === "pcb_silkscreen_circle" || circuitJsonElm.type === "pcb_silkscreen_line") {
|
|
5530
5793
|
updateSilkscreenBounds(circuitJsonElm);
|
|
5794
|
+
} else if (circuitJsonElm.type === "pcb_copper_text") {
|
|
5795
|
+
updateBounds(circuitJsonElm.anchor_position, 0, 0);
|
|
5531
5796
|
} else if (circuitJsonElm.type === "pcb_copper_pour") {
|
|
5532
5797
|
if (circuitJsonElm.shape === "rect") {
|
|
5533
5798
|
updateBounds(
|
|
@@ -5574,12 +5839,12 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5574
5839
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
5575
5840
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
5576
5841
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
5577
|
-
const transform =
|
|
5578
|
-
|
|
5842
|
+
const transform = compose6(
|
|
5843
|
+
translate6(
|
|
5579
5844
|
offsetX - boundsMinX * scaleFactor + padding * scaleFactor,
|
|
5580
5845
|
svgHeight - offsetY + boundsMinY * scaleFactor - padding * scaleFactor
|
|
5581
5846
|
),
|
|
5582
|
-
|
|
5847
|
+
scale3(scaleFactor, -scaleFactor)
|
|
5583
5848
|
// Flip in y-direction
|
|
5584
5849
|
);
|
|
5585
5850
|
const ctx = {
|
|
@@ -5695,11 +5960,11 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5695
5960
|
}
|
|
5696
5961
|
function updateBounds(center, width, height) {
|
|
5697
5962
|
if (!center) return;
|
|
5698
|
-
const centerX =
|
|
5699
|
-
const centerY =
|
|
5963
|
+
const centerX = distance2.parse(center.x);
|
|
5964
|
+
const centerY = distance2.parse(center.y);
|
|
5700
5965
|
if (centerX === void 0 || centerY === void 0) return;
|
|
5701
|
-
const numericWidth =
|
|
5702
|
-
const numericHeight =
|
|
5966
|
+
const numericWidth = distance2.parse(width) ?? 0;
|
|
5967
|
+
const numericHeight = distance2.parse(height) ?? 0;
|
|
5703
5968
|
const halfWidth = numericWidth / 2;
|
|
5704
5969
|
const halfHeight = numericHeight / 2;
|
|
5705
5970
|
minX = Math.min(minX, centerX - halfWidth);
|
|
@@ -5710,11 +5975,11 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5710
5975
|
}
|
|
5711
5976
|
function updateBoardBounds(center, width, height) {
|
|
5712
5977
|
if (!center) return;
|
|
5713
|
-
const centerX =
|
|
5714
|
-
const centerY =
|
|
5978
|
+
const centerX = distance2.parse(center.x);
|
|
5979
|
+
const centerY = distance2.parse(center.y);
|
|
5715
5980
|
if (centerX === void 0 || centerY === void 0) return;
|
|
5716
|
-
const numericWidth =
|
|
5717
|
-
const numericHeight =
|
|
5981
|
+
const numericWidth = distance2.parse(width) ?? 0;
|
|
5982
|
+
const numericHeight = distance2.parse(height) ?? 0;
|
|
5718
5983
|
const halfWidth = numericWidth / 2;
|
|
5719
5984
|
const halfHeight = numericHeight / 2;
|
|
5720
5985
|
boardMinX = Math.min(boardMinX, centerX - halfWidth);
|
|
@@ -5727,8 +5992,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5727
5992
|
function updateBoundsToIncludeOutline(outline) {
|
|
5728
5993
|
let updated = false;
|
|
5729
5994
|
for (const point of outline) {
|
|
5730
|
-
const x =
|
|
5731
|
-
const y =
|
|
5995
|
+
const x = distance2.parse(point.x);
|
|
5996
|
+
const y = distance2.parse(point.y);
|
|
5732
5997
|
if (x === void 0 || y === void 0) continue;
|
|
5733
5998
|
minX = Math.min(minX, x);
|
|
5734
5999
|
minY = Math.min(minY, y);
|
|
@@ -5743,8 +6008,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5743
6008
|
function updateBoardBoundsToIncludeOutline(outline) {
|
|
5744
6009
|
let updated = false;
|
|
5745
6010
|
for (const point of outline) {
|
|
5746
|
-
const x =
|
|
5747
|
-
const y =
|
|
6011
|
+
const x = distance2.parse(point.x);
|
|
6012
|
+
const y = distance2.parse(point.y);
|
|
5748
6013
|
if (x === void 0 || y === void 0) continue;
|
|
5749
6014
|
boardMinX = Math.min(boardMinX, x);
|
|
5750
6015
|
boardMinY = Math.min(boardMinY, y);
|
|
@@ -5760,8 +6025,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5760
6025
|
function updateTraceBounds(route) {
|
|
5761
6026
|
let updated = false;
|
|
5762
6027
|
for (const point of route) {
|
|
5763
|
-
const x =
|
|
5764
|
-
const y =
|
|
6028
|
+
const x = distance2.parse(point?.x);
|
|
6029
|
+
const y = distance2.parse(point?.y);
|
|
5765
6030
|
if (x === void 0 || y === void 0) continue;
|
|
5766
6031
|
minX = Math.min(minX, x);
|
|
5767
6032
|
minY = Math.min(minY, y);
|
|
@@ -5781,7 +6046,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5781
6046
|
} else if (item.type === "pcb_silkscreen_rect") {
|
|
5782
6047
|
updateBounds(item.center, item.width, item.height);
|
|
5783
6048
|
} else if (item.type === "pcb_silkscreen_circle") {
|
|
5784
|
-
const radius =
|
|
6049
|
+
const radius = distance2.parse(item.radius);
|
|
5785
6050
|
if (radius !== void 0) {
|
|
5786
6051
|
updateBounds(item.center, radius * 2, radius * 2);
|
|
5787
6052
|
}
|
|
@@ -5793,7 +6058,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5793
6058
|
if (cutout.shape === "rect") {
|
|
5794
6059
|
updateBounds(cutout.center, cutout.width, cutout.height);
|
|
5795
6060
|
} else if (cutout.shape === "circle") {
|
|
5796
|
-
const radius =
|
|
6061
|
+
const radius = distance2.parse(cutout.radius);
|
|
5797
6062
|
if (radius !== void 0) {
|
|
5798
6063
|
updateBounds(cutout.center, radius * 2, radius * 2);
|
|
5799
6064
|
}
|
|
@@ -5839,6 +6104,8 @@ function createSvgObjects({
|
|
|
5839
6104
|
return createSvgObjectsFromPcbSilkscreenCircle(elm, ctx);
|
|
5840
6105
|
case "pcb_silkscreen_line":
|
|
5841
6106
|
return createSvgObjectsFromPcbSilkscreenLine(elm, ctx);
|
|
6107
|
+
case "pcb_copper_text":
|
|
6108
|
+
return createSvgObjectsFromPcbCopperText(elm, ctx);
|
|
5842
6109
|
case "pcb_courtyard_rect":
|
|
5843
6110
|
if (!ctx.showCourtyards) return [];
|
|
5844
6111
|
return createSvgObjectsFromPcbCourtyardRect(elm, ctx);
|
|
@@ -5877,8 +6144,8 @@ function createSvgObjects({
|
|
|
5877
6144
|
}
|
|
5878
6145
|
}
|
|
5879
6146
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
5880
|
-
const [x1, y1] =
|
|
5881
|
-
const [x2, y2] =
|
|
6147
|
+
const [x1, y1] = applyToPoint33(transform, [minX, minY]);
|
|
6148
|
+
const [x2, y2] = applyToPoint33(transform, [maxX, maxY]);
|
|
5882
6149
|
const width = Math.abs(x2 - x1);
|
|
5883
6150
|
const height = Math.abs(y2 - y1);
|
|
5884
6151
|
const x = Math.min(x1, x2);
|
|
@@ -5908,14 +6175,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
5908
6175
|
import { stringify as stringify2 } from "svgson";
|
|
5909
6176
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
5910
6177
|
import {
|
|
5911
|
-
applyToPoint as
|
|
5912
|
-
compose as
|
|
5913
|
-
scale as
|
|
5914
|
-
translate as
|
|
6178
|
+
applyToPoint as applyToPoint40,
|
|
6179
|
+
compose as compose7,
|
|
6180
|
+
scale as scale4,
|
|
6181
|
+
translate as translate7
|
|
5915
6182
|
} from "transformation-matrix";
|
|
5916
6183
|
|
|
5917
6184
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
5918
|
-
import { applyToPoint as
|
|
6185
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
5919
6186
|
var DEFAULT_BOARD_STYLE = {
|
|
5920
6187
|
fill: "none",
|
|
5921
6188
|
stroke: "rgb(0,0,0)",
|
|
@@ -5927,25 +6194,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
5927
6194
|
let path;
|
|
5928
6195
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
5929
6196
|
path = outline.map((point, index) => {
|
|
5930
|
-
const [x, y] =
|
|
6197
|
+
const [x, y] = applyToPoint34(transform, [point.x, point.y]);
|
|
5931
6198
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
5932
6199
|
}).join(" ");
|
|
5933
6200
|
} else {
|
|
5934
6201
|
const halfWidth = width / 2;
|
|
5935
6202
|
const halfHeight = height / 2;
|
|
5936
|
-
const topLeft =
|
|
6203
|
+
const topLeft = applyToPoint34(transform, [
|
|
5937
6204
|
center.x - halfWidth,
|
|
5938
6205
|
center.y - halfHeight
|
|
5939
6206
|
]);
|
|
5940
|
-
const topRight =
|
|
6207
|
+
const topRight = applyToPoint34(transform, [
|
|
5941
6208
|
center.x + halfWidth,
|
|
5942
6209
|
center.y - halfHeight
|
|
5943
6210
|
]);
|
|
5944
|
-
const bottomRight =
|
|
6211
|
+
const bottomRight = applyToPoint34(transform, [
|
|
5945
6212
|
center.x + halfWidth,
|
|
5946
6213
|
center.y + halfHeight
|
|
5947
6214
|
]);
|
|
5948
|
-
const bottomLeft =
|
|
6215
|
+
const bottomLeft = applyToPoint34(transform, [
|
|
5949
6216
|
center.x - halfWidth,
|
|
5950
6217
|
center.y + halfHeight
|
|
5951
6218
|
]);
|
|
@@ -5971,7 +6238,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
5971
6238
|
}
|
|
5972
6239
|
|
|
5973
6240
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
5974
|
-
import { applyToPoint as
|
|
6241
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
5975
6242
|
|
|
5976
6243
|
// lib/utils/get-sch-font-size.ts
|
|
5977
6244
|
import "transformation-matrix";
|
|
@@ -5997,8 +6264,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
5997
6264
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
5998
6265
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
5999
6266
|
return null;
|
|
6000
|
-
const [x, y] =
|
|
6001
|
-
const [pinX, pinY] =
|
|
6267
|
+
const [x, y] = applyToPoint36(transform, [center.x, center.y]);
|
|
6268
|
+
const [pinX, pinY] = applyToPoint36(transform, [portPosition.x, portPosition.y]);
|
|
6002
6269
|
const scaledWidth = width * Math.abs(transform.a);
|
|
6003
6270
|
const scaledHeight = height * Math.abs(transform.d);
|
|
6004
6271
|
const isTopLayer = layer === "top";
|
|
@@ -6160,11 +6427,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
6160
6427
|
}
|
|
6161
6428
|
|
|
6162
6429
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
6163
|
-
import { applyToPoint as
|
|
6430
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
6164
6431
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
6165
6432
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
6166
6433
|
const { transform } = ctx;
|
|
6167
|
-
const [x, y] =
|
|
6434
|
+
const [x, y] = applyToPoint37(transform, [hole.x, hole.y]);
|
|
6168
6435
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
6169
6436
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
6170
6437
|
const radius = scaledDiameter / 2;
|
|
@@ -6228,12 +6495,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
6228
6495
|
}
|
|
6229
6496
|
|
|
6230
6497
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
6231
|
-
import { applyToPoint as
|
|
6498
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
6232
6499
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
6233
6500
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
6234
6501
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
6235
6502
|
const { transform } = ctx;
|
|
6236
|
-
const [x, y] =
|
|
6503
|
+
const [x, y] = applyToPoint38(transform, [hole.x, hole.y]);
|
|
6237
6504
|
if (hole.shape === "pill") {
|
|
6238
6505
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
6239
6506
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -6328,7 +6595,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6328
6595
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
6329
6596
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
6330
6597
|
const holeRadius = scaledHoleDiameter / 2;
|
|
6331
|
-
const [holeCx, holeCy] =
|
|
6598
|
+
const [holeCx, holeCy] = applyToPoint38(transform, [
|
|
6332
6599
|
circularHole.x + circularHole.hole_offset_x,
|
|
6333
6600
|
circularHole.y + circularHole.hole_offset_y
|
|
6334
6601
|
]);
|
|
@@ -6386,7 +6653,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6386
6653
|
const pillHoleWithOffsets = pillHole;
|
|
6387
6654
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
6388
6655
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
6389
|
-
const [holeCenterX, holeCenterY] =
|
|
6656
|
+
const [holeCenterX, holeCenterY] = applyToPoint38(transform, [
|
|
6390
6657
|
pillHole.x + holeOffsetX,
|
|
6391
6658
|
pillHole.y + holeOffsetY
|
|
6392
6659
|
]);
|
|
@@ -6448,7 +6715,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6448
6715
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
6449
6716
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
6450
6717
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
6451
|
-
const [holeCenterX, holeCenterY] =
|
|
6718
|
+
const [holeCenterX, holeCenterY] = applyToPoint38(transform, [
|
|
6452
6719
|
rotatedHole.x + holeOffsetX,
|
|
6453
6720
|
rotatedHole.y + holeOffsetY
|
|
6454
6721
|
]);
|
|
@@ -6504,14 +6771,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6504
6771
|
}
|
|
6505
6772
|
|
|
6506
6773
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
6507
|
-
import { applyToPoint as
|
|
6774
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
6508
6775
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
6509
6776
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
6510
6777
|
const { transform } = ctx;
|
|
6511
6778
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
6512
6779
|
const width = pad.width * Math.abs(transform.a);
|
|
6513
6780
|
const height = pad.height * Math.abs(transform.d);
|
|
6514
|
-
const [x, y] =
|
|
6781
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
6515
6782
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
6516
6783
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
6517
6784
|
return [
|
|
@@ -6563,7 +6830,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
6563
6830
|
const width = pad.width * Math.abs(transform.a);
|
|
6564
6831
|
const height = pad.height * Math.abs(transform.d);
|
|
6565
6832
|
const radius = pad.radius * Math.abs(transform.a);
|
|
6566
|
-
const [x, y] =
|
|
6833
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
6567
6834
|
return [
|
|
6568
6835
|
{
|
|
6569
6836
|
name: "rect",
|
|
@@ -6586,7 +6853,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
6586
6853
|
}
|
|
6587
6854
|
if (pad.shape === "circle") {
|
|
6588
6855
|
const radius = pad.radius * Math.abs(transform.a);
|
|
6589
|
-
const [x, y] =
|
|
6856
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
6590
6857
|
return [
|
|
6591
6858
|
{
|
|
6592
6859
|
name: "circle",
|
|
@@ -6606,7 +6873,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
6606
6873
|
}
|
|
6607
6874
|
if (pad.shape === "polygon") {
|
|
6608
6875
|
const points = (pad.points ?? []).map(
|
|
6609
|
-
(point) =>
|
|
6876
|
+
(point) => applyToPoint39(transform, [point.x, point.y])
|
|
6610
6877
|
);
|
|
6611
6878
|
return [
|
|
6612
6879
|
{
|
|
@@ -6660,12 +6927,12 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
6660
6927
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
6661
6928
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
6662
6929
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
6663
|
-
const transform =
|
|
6664
|
-
|
|
6930
|
+
const transform = compose7(
|
|
6931
|
+
translate7(
|
|
6665
6932
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
6666
6933
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
6667
6934
|
),
|
|
6668
|
-
|
|
6935
|
+
scale4(scaleFactor, -scaleFactor)
|
|
6669
6936
|
// Flip in y-direction
|
|
6670
6937
|
);
|
|
6671
6938
|
const ctx = { transform };
|
|
@@ -6790,8 +7057,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
6790
7057
|
}
|
|
6791
7058
|
}
|
|
6792
7059
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
6793
|
-
const [x1, y1] =
|
|
6794
|
-
const [x2, y2] =
|
|
7060
|
+
const [x1, y1] = applyToPoint40(transform, [minX, minY]);
|
|
7061
|
+
const [x2, y2] = applyToPoint40(transform, [maxX, maxY]);
|
|
6795
7062
|
const width = Math.abs(x2 - x1);
|
|
6796
7063
|
const height = Math.abs(y2 - y1);
|
|
6797
7064
|
const x = Math.min(x1, x2);
|
|
@@ -6814,13 +7081,13 @@ function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY)
|
|
|
6814
7081
|
// lib/pinout/convert-circuit-json-to-pinout-svg.ts
|
|
6815
7082
|
import { stringify as stringify3 } from "svgson";
|
|
6816
7083
|
import {
|
|
6817
|
-
compose as
|
|
7084
|
+
compose as compose8,
|
|
6818
7085
|
scale as matrixScale,
|
|
6819
|
-
translate as
|
|
7086
|
+
translate as translate8
|
|
6820
7087
|
} from "transformation-matrix";
|
|
6821
7088
|
|
|
6822
7089
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
6823
|
-
import { applyToPoint as
|
|
7090
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
6824
7091
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
6825
7092
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
6826
7093
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -6834,25 +7101,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
6834
7101
|
let path;
|
|
6835
7102
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
6836
7103
|
path = outline.map((point, index) => {
|
|
6837
|
-
const [x, y] =
|
|
7104
|
+
const [x, y] = applyToPoint41(transform, [point.x, point.y]);
|
|
6838
7105
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
6839
7106
|
}).join(" ");
|
|
6840
7107
|
} else {
|
|
6841
7108
|
const halfWidth = width / 2;
|
|
6842
7109
|
const halfHeight = height / 2;
|
|
6843
|
-
const topLeft =
|
|
7110
|
+
const topLeft = applyToPoint41(transform, [
|
|
6844
7111
|
center.x - halfWidth,
|
|
6845
7112
|
center.y - halfHeight
|
|
6846
7113
|
]);
|
|
6847
|
-
const topRight =
|
|
7114
|
+
const topRight = applyToPoint41(transform, [
|
|
6848
7115
|
center.x + halfWidth,
|
|
6849
7116
|
center.y - halfHeight
|
|
6850
7117
|
]);
|
|
6851
|
-
const bottomRight =
|
|
7118
|
+
const bottomRight = applyToPoint41(transform, [
|
|
6852
7119
|
center.x + halfWidth,
|
|
6853
7120
|
center.y + halfHeight
|
|
6854
7121
|
]);
|
|
6855
|
-
const bottomLeft =
|
|
7122
|
+
const bottomLeft = applyToPoint41(transform, [
|
|
6856
7123
|
center.x - halfWidth,
|
|
6857
7124
|
center.y + halfHeight
|
|
6858
7125
|
]);
|
|
@@ -6870,10 +7137,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
6870
7137
|
const halfWidth = width2 / 2;
|
|
6871
7138
|
const halfHeight = height2 / 2;
|
|
6872
7139
|
const [tl, tr, br, bl] = [
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
7140
|
+
applyToPoint41(transform, [x - halfWidth, y - halfHeight]),
|
|
7141
|
+
applyToPoint41(transform, [x + halfWidth, y - halfHeight]),
|
|
7142
|
+
applyToPoint41(transform, [x + halfWidth, y + halfHeight]),
|
|
7143
|
+
applyToPoint41(transform, [x - halfWidth, y + halfHeight])
|
|
6877
7144
|
];
|
|
6878
7145
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
6879
7146
|
} else if (cutout.shape === "circle") {
|
|
@@ -6923,7 +7190,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
6923
7190
|
|
|
6924
7191
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
6925
7192
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
6926
|
-
import { applyToPoint as
|
|
7193
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
6927
7194
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
6928
7195
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
6929
7196
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -6933,7 +7200,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
6933
7200
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
6934
7201
|
return [];
|
|
6935
7202
|
}
|
|
6936
|
-
const [x, y] =
|
|
7203
|
+
const [x, y] = applyToPoint42(transform, [center.x, center.y]);
|
|
6937
7204
|
const scaledWidth = width * Math.abs(transform.a);
|
|
6938
7205
|
const scaledHeight = height * Math.abs(transform.d);
|
|
6939
7206
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -6994,11 +7261,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
6994
7261
|
}
|
|
6995
7262
|
|
|
6996
7263
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
6997
|
-
import { applyToPoint as
|
|
7264
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
6998
7265
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
6999
7266
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
7000
7267
|
const { transform } = ctx;
|
|
7001
|
-
const [x, y] =
|
|
7268
|
+
const [x, y] = applyToPoint43(transform, [hole.x, hole.y]);
|
|
7002
7269
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
7003
7270
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
7004
7271
|
const radius = scaledDiameter / 2;
|
|
@@ -7062,12 +7329,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
7062
7329
|
}
|
|
7063
7330
|
|
|
7064
7331
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
7065
|
-
import { applyToPoint as
|
|
7332
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
7066
7333
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
7067
7334
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
7068
7335
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
7069
7336
|
const { transform } = ctx;
|
|
7070
|
-
const [x, y] =
|
|
7337
|
+
const [x, y] = applyToPoint44(transform, [hole.x, hole.y]);
|
|
7071
7338
|
if (hole.shape === "pill") {
|
|
7072
7339
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
7073
7340
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -7302,14 +7569,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
7302
7569
|
}
|
|
7303
7570
|
|
|
7304
7571
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
7305
|
-
import { applyToPoint as
|
|
7572
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
7306
7573
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
7307
7574
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
7308
7575
|
const { transform } = ctx;
|
|
7309
7576
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
7310
7577
|
const width = pad.width * Math.abs(transform.a);
|
|
7311
7578
|
const height = pad.height * Math.abs(transform.d);
|
|
7312
|
-
const [x, y] =
|
|
7579
|
+
const [x, y] = applyToPoint45(transform, [pad.x, pad.y]);
|
|
7313
7580
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
7314
7581
|
return [
|
|
7315
7582
|
{
|
|
@@ -7352,7 +7619,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7352
7619
|
const width = pad.width * Math.abs(transform.a);
|
|
7353
7620
|
const height = pad.height * Math.abs(transform.d);
|
|
7354
7621
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7355
|
-
const [x, y] =
|
|
7622
|
+
const [x, y] = applyToPoint45(transform, [pad.x, pad.y]);
|
|
7356
7623
|
return [
|
|
7357
7624
|
{
|
|
7358
7625
|
name: "rect",
|
|
@@ -7375,7 +7642,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7375
7642
|
}
|
|
7376
7643
|
if (pad.shape === "circle") {
|
|
7377
7644
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7378
|
-
const [x, y] =
|
|
7645
|
+
const [x, y] = applyToPoint45(transform, [pad.x, pad.y]);
|
|
7379
7646
|
return [
|
|
7380
7647
|
{
|
|
7381
7648
|
name: "circle",
|
|
@@ -7395,7 +7662,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7395
7662
|
}
|
|
7396
7663
|
if (pad.shape === "polygon") {
|
|
7397
7664
|
const points = (pad.points ?? []).map(
|
|
7398
|
-
(point) =>
|
|
7665
|
+
(point) => applyToPoint45(transform, [point.x, point.y])
|
|
7399
7666
|
);
|
|
7400
7667
|
return [
|
|
7401
7668
|
{
|
|
@@ -7416,7 +7683,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7416
7683
|
}
|
|
7417
7684
|
|
|
7418
7685
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
7419
|
-
import { applyToPoint as
|
|
7686
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
7420
7687
|
import { calculateElbow } from "calculate-elbow";
|
|
7421
7688
|
|
|
7422
7689
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -7493,7 +7760,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
7493
7760
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
7494
7761
|
if (!label_info) return [];
|
|
7495
7762
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
7496
|
-
const [port_x, port_y] =
|
|
7763
|
+
const [port_x, port_y] = applyToPoint46(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
7497
7764
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
7498
7765
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
7499
7766
|
const elbow_path = calculateElbow(
|
|
@@ -7634,7 +7901,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
7634
7901
|
}
|
|
7635
7902
|
|
|
7636
7903
|
// lib/pinout/calculate-label-positions.ts
|
|
7637
|
-
import { applyToPoint as
|
|
7904
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7638
7905
|
|
|
7639
7906
|
// lib/pinout/constants.ts
|
|
7640
7907
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -7672,7 +7939,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
7672
7939
|
);
|
|
7673
7940
|
const mapToEdgePort = (pinout_label) => ({
|
|
7674
7941
|
pcb_port: pinout_label.pcb_port,
|
|
7675
|
-
y:
|
|
7942
|
+
y: applyToPoint47(transform, [
|
|
7676
7943
|
pinout_label.pcb_port.x,
|
|
7677
7944
|
pinout_label.pcb_port.y
|
|
7678
7945
|
])[1],
|
|
@@ -7687,7 +7954,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
7687
7954
|
} else {
|
|
7688
7955
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
7689
7956
|
pcb_port: pinout_label.pcb_port,
|
|
7690
|
-
y:
|
|
7957
|
+
y: applyToPoint47(transform, [
|
|
7691
7958
|
pinout_label.pcb_port.x,
|
|
7692
7959
|
pinout_label.pcb_port.y
|
|
7693
7960
|
])[1],
|
|
@@ -7695,7 +7962,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
7695
7962
|
})).sort((a, b) => a.y - b.y);
|
|
7696
7963
|
}
|
|
7697
7964
|
if (edge_ports.length === 0) return;
|
|
7698
|
-
const board_edge_x =
|
|
7965
|
+
const board_edge_x = applyToPoint47(transform, [
|
|
7699
7966
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
7700
7967
|
0
|
|
7701
7968
|
])[0];
|
|
@@ -8015,8 +8282,8 @@ function convertCircuitJsonToPinoutSvg(soup, options) {
|
|
|
8015
8282
|
const pxPerMm = Math.min(pxPerMmX, pxPerMmY);
|
|
8016
8283
|
const offsetX = (svgWidth - circuitWidth * pxPerMm) / 2;
|
|
8017
8284
|
const offsetY = (svgHeight - circuitHeight * pxPerMm) / 2;
|
|
8018
|
-
const transform =
|
|
8019
|
-
|
|
8285
|
+
const transform = compose8(
|
|
8286
|
+
translate8(
|
|
8020
8287
|
offsetX - expandedMinX * pxPerMm + paddingMm * pxPerMm,
|
|
8021
8288
|
svgHeight - offsetY + minY * pxPerMm - paddingMm * pxPerMm
|
|
8022
8289
|
),
|
|
@@ -8117,14 +8384,14 @@ import {
|
|
|
8117
8384
|
} from "transformation-matrix";
|
|
8118
8385
|
|
|
8119
8386
|
// lib/sch/draw-schematic-grid.ts
|
|
8120
|
-
import { applyToPoint as
|
|
8387
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
8121
8388
|
function drawSchematicGrid(params) {
|
|
8122
8389
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
8123
8390
|
const cellSize = params.cellSize ?? 1;
|
|
8124
8391
|
const labelCells = params.labelCells ?? false;
|
|
8125
8392
|
const gridLines = [];
|
|
8126
8393
|
const transformPoint = (x, y) => {
|
|
8127
|
-
const [transformedX, transformedY] =
|
|
8394
|
+
const [transformedX, transformedY] = applyToPoint48(params.transform, [x, y]);
|
|
8128
8395
|
return { x: transformedX, y: transformedY };
|
|
8129
8396
|
};
|
|
8130
8397
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -8205,15 +8472,15 @@ function drawSchematicGrid(params) {
|
|
|
8205
8472
|
}
|
|
8206
8473
|
|
|
8207
8474
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
8208
|
-
import { applyToPoint as
|
|
8475
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
8209
8476
|
function drawSchematicLabeledPoints(params) {
|
|
8210
8477
|
const { points, transform } = params;
|
|
8211
8478
|
const labeledPointsGroup = [];
|
|
8212
8479
|
for (const point of points) {
|
|
8213
|
-
const [x1, y1] =
|
|
8214
|
-
const [x2, y2] =
|
|
8215
|
-
const [x3, y3] =
|
|
8216
|
-
const [x4, y4] =
|
|
8480
|
+
const [x1, y1] = applyToPoint49(transform, [point.x - 0.1, point.y - 0.1]);
|
|
8481
|
+
const [x2, y2] = applyToPoint49(transform, [point.x + 0.1, point.y + 0.1]);
|
|
8482
|
+
const [x3, y3] = applyToPoint49(transform, [point.x - 0.1, point.y + 0.1]);
|
|
8483
|
+
const [x4, y4] = applyToPoint49(transform, [point.x + 0.1, point.y - 0.1]);
|
|
8217
8484
|
labeledPointsGroup.push({
|
|
8218
8485
|
name: "path",
|
|
8219
8486
|
type: "element",
|
|
@@ -8224,7 +8491,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
8224
8491
|
"stroke-opacity": "0.7"
|
|
8225
8492
|
}
|
|
8226
8493
|
});
|
|
8227
|
-
const [labelX, labelY] =
|
|
8494
|
+
const [labelX, labelY] = applyToPoint49(transform, [
|
|
8228
8495
|
point.x + 0.15,
|
|
8229
8496
|
point.y - 0.15
|
|
8230
8497
|
]);
|
|
@@ -9318,8 +9585,8 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
9318
9585
|
import { symbols } from "schematic-symbols";
|
|
9319
9586
|
import "svgson";
|
|
9320
9587
|
import {
|
|
9321
|
-
applyToPoint as
|
|
9322
|
-
compose as
|
|
9588
|
+
applyToPoint as applyToPoint51,
|
|
9589
|
+
compose as compose10
|
|
9323
9590
|
} from "transformation-matrix";
|
|
9324
9591
|
|
|
9325
9592
|
// lib/utils/get-sch-stroke-size.ts
|
|
@@ -9389,26 +9656,26 @@ var matchSchPortsToSymbolPorts = ({
|
|
|
9389
9656
|
};
|
|
9390
9657
|
|
|
9391
9658
|
// lib/utils/point-pairs-to-matrix.ts
|
|
9392
|
-
import { compose as
|
|
9659
|
+
import { compose as compose9, scale as scale5, translate as translate9 } from "transformation-matrix";
|
|
9393
9660
|
function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
9394
9661
|
const tx = a2.x - a1.x;
|
|
9395
9662
|
const ty = a2.y - a1.y;
|
|
9396
9663
|
const originalDistance = Math.sqrt((b1.x - a1.x) ** 2 + (b1.y - a1.y) ** 2);
|
|
9397
9664
|
const transformedDistance = Math.sqrt((b2.x - a2.x) ** 2 + (b2.y - a2.y) ** 2);
|
|
9398
9665
|
const a = transformedDistance / originalDistance;
|
|
9399
|
-
const translateMatrix =
|
|
9400
|
-
const scaleMatrix =
|
|
9401
|
-
return
|
|
9666
|
+
const translateMatrix = translate9(tx, ty);
|
|
9667
|
+
const scaleMatrix = scale5(a, a);
|
|
9668
|
+
return compose9(translateMatrix, scaleMatrix);
|
|
9402
9669
|
}
|
|
9403
9670
|
|
|
9404
9671
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
9405
|
-
import { applyToPoint as
|
|
9672
|
+
import { applyToPoint as applyToPoint50 } from "transformation-matrix";
|
|
9406
9673
|
var createSvgSchErrorText = ({
|
|
9407
9674
|
text,
|
|
9408
9675
|
realCenter,
|
|
9409
9676
|
realToScreenTransform
|
|
9410
9677
|
}) => {
|
|
9411
|
-
const screenCenter =
|
|
9678
|
+
const screenCenter = applyToPoint50(realToScreenTransform, realCenter);
|
|
9412
9679
|
return {
|
|
9413
9680
|
type: "element",
|
|
9414
9681
|
name: "text",
|
|
@@ -9517,12 +9784,12 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
9517
9784
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
9518
9785
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
9519
9786
|
};
|
|
9520
|
-
const [screenMinX, screenMinY] =
|
|
9521
|
-
|
|
9787
|
+
const [screenMinX, screenMinY] = applyToPoint51(
|
|
9788
|
+
compose10(realToScreenTransform, transformFromSymbolToReal),
|
|
9522
9789
|
[bounds.minX, bounds.minY]
|
|
9523
9790
|
);
|
|
9524
|
-
const [screenMaxX, screenMaxY] =
|
|
9525
|
-
|
|
9791
|
+
const [screenMaxX, screenMaxY] = applyToPoint51(
|
|
9792
|
+
compose10(realToScreenTransform, transformFromSymbolToReal),
|
|
9526
9793
|
[bounds.maxX, bounds.maxY]
|
|
9527
9794
|
);
|
|
9528
9795
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -9550,8 +9817,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
9550
9817
|
name: "path",
|
|
9551
9818
|
attributes: {
|
|
9552
9819
|
d: points.map((p, i) => {
|
|
9553
|
-
const [x, y] =
|
|
9554
|
-
|
|
9820
|
+
const [x, y] = applyToPoint51(
|
|
9821
|
+
compose10(realToScreenTransform, transformFromSymbolToReal),
|
|
9555
9822
|
[p.x, p.y]
|
|
9556
9823
|
);
|
|
9557
9824
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -9566,8 +9833,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
9566
9833
|
});
|
|
9567
9834
|
}
|
|
9568
9835
|
for (const text of texts) {
|
|
9569
|
-
const screenTextPos =
|
|
9570
|
-
|
|
9836
|
+
const screenTextPos = applyToPoint51(
|
|
9837
|
+
compose10(realToScreenTransform, transformFromSymbolToReal),
|
|
9571
9838
|
text
|
|
9572
9839
|
);
|
|
9573
9840
|
let textValue = "";
|
|
@@ -9618,11 +9885,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
9618
9885
|
});
|
|
9619
9886
|
}
|
|
9620
9887
|
for (const box of boxes) {
|
|
9621
|
-
const screenBoxPos =
|
|
9622
|
-
|
|
9888
|
+
const screenBoxPos = applyToPoint51(
|
|
9889
|
+
compose10(realToScreenTransform, transformFromSymbolToReal),
|
|
9623
9890
|
box
|
|
9624
9891
|
);
|
|
9625
|
-
const symbolToScreenScale =
|
|
9892
|
+
const symbolToScreenScale = compose10(
|
|
9626
9893
|
realToScreenTransform,
|
|
9627
9894
|
transformFromSymbolToReal
|
|
9628
9895
|
).a;
|
|
@@ -9642,8 +9909,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
9642
9909
|
}
|
|
9643
9910
|
for (const port of symbol.ports) {
|
|
9644
9911
|
if (connectedSymbolPorts.has(port)) continue;
|
|
9645
|
-
const screenPortPos =
|
|
9646
|
-
|
|
9912
|
+
const screenPortPos = applyToPoint51(
|
|
9913
|
+
compose10(realToScreenTransform, transformFromSymbolToReal),
|
|
9647
9914
|
port
|
|
9648
9915
|
);
|
|
9649
9916
|
svgObjects.push({
|
|
@@ -9662,8 +9929,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
9662
9929
|
});
|
|
9663
9930
|
}
|
|
9664
9931
|
for (const circle of circles) {
|
|
9665
|
-
const screenCirclePos =
|
|
9666
|
-
|
|
9932
|
+
const screenCirclePos = applyToPoint51(
|
|
9933
|
+
compose10(realToScreenTransform, transformFromSymbolToReal),
|
|
9667
9934
|
circle
|
|
9668
9935
|
);
|
|
9669
9936
|
const screenRadius = Math.abs(circle.radius * realToScreenTransform.a);
|
|
@@ -9689,14 +9956,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
9689
9956
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
9690
9957
|
import "schematic-symbols";
|
|
9691
9958
|
import "svgson";
|
|
9692
|
-
import { applyToPoint as
|
|
9959
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
9693
9960
|
|
|
9694
9961
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
9695
9962
|
import "transformation-matrix";
|
|
9696
9963
|
import "@tscircuit/circuit-json-util";
|
|
9697
9964
|
|
|
9698
9965
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
9699
|
-
import { applyToPoint as
|
|
9966
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
9700
9967
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
9701
9968
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
9702
9969
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -9749,8 +10016,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
9749
10016
|
realEdgePos.y += realPinLineLength;
|
|
9750
10017
|
break;
|
|
9751
10018
|
}
|
|
9752
|
-
const screenSchPortPos =
|
|
9753
|
-
const screenRealEdgePos =
|
|
10019
|
+
const screenSchPortPos = applyToPoint52(transform, schPort.center);
|
|
10020
|
+
const screenRealEdgePos = applyToPoint52(transform, realEdgePos);
|
|
9754
10021
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
9755
10022
|
const realLineEnd = { ...schPort.center };
|
|
9756
10023
|
if (!isConnected) {
|
|
@@ -9769,7 +10036,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
9769
10036
|
break;
|
|
9770
10037
|
}
|
|
9771
10038
|
}
|
|
9772
|
-
const screenLineEnd =
|
|
10039
|
+
const screenLineEnd = applyToPoint52(transform, realLineEnd);
|
|
9773
10040
|
svgObjects.push({
|
|
9774
10041
|
name: "line",
|
|
9775
10042
|
type: "element",
|
|
@@ -9890,7 +10157,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
9890
10157
|
};
|
|
9891
10158
|
|
|
9892
10159
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
9893
|
-
import { applyToPoint as
|
|
10160
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
9894
10161
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
9895
10162
|
const svgObjects = [];
|
|
9896
10163
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -9908,7 +10175,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
9908
10175
|
} else {
|
|
9909
10176
|
realPinNumberPos.y += 0.02;
|
|
9910
10177
|
}
|
|
9911
|
-
const screenPinNumberTextPos =
|
|
10178
|
+
const screenPinNumberTextPos = applyToPoint53(transform, realPinNumberPos);
|
|
9912
10179
|
svgObjects.push({
|
|
9913
10180
|
name: "text",
|
|
9914
10181
|
type: "element",
|
|
@@ -9938,7 +10205,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
9938
10205
|
};
|
|
9939
10206
|
|
|
9940
10207
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
9941
|
-
import { applyToPoint as
|
|
10208
|
+
import { applyToPoint as applyToPoint54 } from "transformation-matrix";
|
|
9942
10209
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
9943
10210
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
9944
10211
|
const svgObjects = [];
|
|
@@ -9952,7 +10219,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
9952
10219
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
9953
10220
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
9954
10221
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
9955
|
-
const screenPinNumberTextPos =
|
|
10222
|
+
const screenPinNumberTextPos = applyToPoint54(transform, realPinNumberPos);
|
|
9956
10223
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
9957
10224
|
if (!label) return [];
|
|
9958
10225
|
const isNegated = label.startsWith("N_");
|
|
@@ -10000,13 +10267,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
10000
10267
|
};
|
|
10001
10268
|
|
|
10002
10269
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
10003
|
-
import { applyToPoint as
|
|
10270
|
+
import { applyToPoint as applyToPoint56 } from "transformation-matrix";
|
|
10004
10271
|
var createSvgSchText = ({
|
|
10005
10272
|
elm,
|
|
10006
10273
|
transform,
|
|
10007
10274
|
colorMap: colorMap2
|
|
10008
10275
|
}) => {
|
|
10009
|
-
const center =
|
|
10276
|
+
const center = applyToPoint56(transform, elm.position);
|
|
10010
10277
|
const textAnchorMap = {
|
|
10011
10278
|
center: "middle",
|
|
10012
10279
|
center_right: "end",
|
|
@@ -10090,11 +10357,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
10090
10357
|
colorMap: colorMap2
|
|
10091
10358
|
}) => {
|
|
10092
10359
|
const svgObjects = [];
|
|
10093
|
-
const componentScreenTopLeft =
|
|
10360
|
+
const componentScreenTopLeft = applyToPoint57(transform, {
|
|
10094
10361
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
10095
10362
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
10096
10363
|
});
|
|
10097
|
-
const componentScreenBottomRight =
|
|
10364
|
+
const componentScreenBottomRight = applyToPoint57(transform, {
|
|
10098
10365
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
10099
10366
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
10100
10367
|
});
|
|
@@ -10180,13 +10447,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
10180
10447
|
}
|
|
10181
10448
|
|
|
10182
10449
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
10183
|
-
import { applyToPoint as
|
|
10450
|
+
import { applyToPoint as applyToPoint58 } from "transformation-matrix";
|
|
10184
10451
|
function createSvgObjectsFromSchVoltageProbe({
|
|
10185
10452
|
probe,
|
|
10186
10453
|
transform,
|
|
10187
10454
|
colorMap: colorMap2
|
|
10188
10455
|
}) {
|
|
10189
|
-
const [screenX, screenY] =
|
|
10456
|
+
const [screenX, screenY] = applyToPoint58(transform, [
|
|
10190
10457
|
probe.position.x,
|
|
10191
10458
|
probe.position.y
|
|
10192
10459
|
]);
|
|
@@ -10293,17 +10560,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
10293
10560
|
}
|
|
10294
10561
|
|
|
10295
10562
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
10296
|
-
import { applyToPoint as
|
|
10563
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
10297
10564
|
function createSvgObjectsFromSchDebugObject({
|
|
10298
10565
|
debugObject,
|
|
10299
10566
|
transform
|
|
10300
10567
|
}) {
|
|
10301
10568
|
if (debugObject.shape === "rect") {
|
|
10302
|
-
let [screenLeft, screenTop] =
|
|
10569
|
+
let [screenLeft, screenTop] = applyToPoint59(transform, [
|
|
10303
10570
|
debugObject.center.x - debugObject.size.width / 2,
|
|
10304
10571
|
debugObject.center.y - debugObject.size.height / 2
|
|
10305
10572
|
]);
|
|
10306
|
-
let [screenRight, screenBottom] =
|
|
10573
|
+
let [screenRight, screenBottom] = applyToPoint59(transform, [
|
|
10307
10574
|
debugObject.center.x + debugObject.size.width / 2,
|
|
10308
10575
|
debugObject.center.y + debugObject.size.height / 2
|
|
10309
10576
|
]);
|
|
@@ -10313,7 +10580,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10313
10580
|
];
|
|
10314
10581
|
const width = Math.abs(screenRight - screenLeft);
|
|
10315
10582
|
const height = Math.abs(screenBottom - screenTop);
|
|
10316
|
-
const [screenCenterX, screenCenterY] =
|
|
10583
|
+
const [screenCenterX, screenCenterY] = applyToPoint59(transform, [
|
|
10317
10584
|
debugObject.center.x,
|
|
10318
10585
|
debugObject.center.y
|
|
10319
10586
|
]);
|
|
@@ -10359,11 +10626,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10359
10626
|
];
|
|
10360
10627
|
}
|
|
10361
10628
|
if (debugObject.shape === "line") {
|
|
10362
|
-
const [screenStartX, screenStartY] =
|
|
10629
|
+
const [screenStartX, screenStartY] = applyToPoint59(transform, [
|
|
10363
10630
|
debugObject.start.x,
|
|
10364
10631
|
debugObject.start.y
|
|
10365
10632
|
]);
|
|
10366
|
-
const [screenEndX, screenEndY] =
|
|
10633
|
+
const [screenEndX, screenEndY] = applyToPoint59(transform, [
|
|
10367
10634
|
debugObject.end.x,
|
|
10368
10635
|
debugObject.end.y
|
|
10369
10636
|
]);
|
|
@@ -10413,7 +10680,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10413
10680
|
}
|
|
10414
10681
|
|
|
10415
10682
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
10416
|
-
import { applyToPoint as
|
|
10683
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
10417
10684
|
function createSchematicTrace({
|
|
10418
10685
|
trace,
|
|
10419
10686
|
transform,
|
|
@@ -10427,11 +10694,11 @@ function createSchematicTrace({
|
|
|
10427
10694
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
10428
10695
|
const edge = edges[edgeIndex];
|
|
10429
10696
|
if (edge.is_crossing) continue;
|
|
10430
|
-
const [screenFromX, screenFromY] =
|
|
10697
|
+
const [screenFromX, screenFromY] = applyToPoint60(transform, [
|
|
10431
10698
|
edge.from.x,
|
|
10432
10699
|
edge.from.y
|
|
10433
10700
|
]);
|
|
10434
|
-
const [screenToX, screenToY] =
|
|
10701
|
+
const [screenToX, screenToY] = applyToPoint60(transform, [
|
|
10435
10702
|
edge.to.x,
|
|
10436
10703
|
edge.to.y
|
|
10437
10704
|
]);
|
|
@@ -10475,11 +10742,11 @@ function createSchematicTrace({
|
|
|
10475
10742
|
}
|
|
10476
10743
|
for (const edge of edges) {
|
|
10477
10744
|
if (!edge.is_crossing) continue;
|
|
10478
|
-
const [screenFromX, screenFromY] =
|
|
10745
|
+
const [screenFromX, screenFromY] = applyToPoint60(transform, [
|
|
10479
10746
|
edge.from.x,
|
|
10480
10747
|
edge.from.y
|
|
10481
10748
|
]);
|
|
10482
|
-
const [screenToX, screenToY] =
|
|
10749
|
+
const [screenToX, screenToY] = applyToPoint60(transform, [
|
|
10483
10750
|
edge.to.x,
|
|
10484
10751
|
edge.to.y
|
|
10485
10752
|
]);
|
|
@@ -10523,7 +10790,7 @@ function createSchematicTrace({
|
|
|
10523
10790
|
}
|
|
10524
10791
|
if (trace.junctions) {
|
|
10525
10792
|
for (const junction of trace.junctions) {
|
|
10526
|
-
const [screenX, screenY] =
|
|
10793
|
+
const [screenX, screenY] = applyToPoint60(transform, [
|
|
10527
10794
|
junction.x,
|
|
10528
10795
|
junction.y
|
|
10529
10796
|
]);
|
|
@@ -10577,6 +10844,15 @@ function createSchematicTrace({
|
|
|
10577
10844
|
}
|
|
10578
10845
|
|
|
10579
10846
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
10847
|
+
import {
|
|
10848
|
+
applyToPoint as applyToPoint62,
|
|
10849
|
+
compose as compose12,
|
|
10850
|
+
rotate as rotate7,
|
|
10851
|
+
scale as scale7,
|
|
10852
|
+
translate as translate12
|
|
10853
|
+
} from "transformation-matrix";
|
|
10854
|
+
|
|
10855
|
+
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
10580
10856
|
import {
|
|
10581
10857
|
applyToPoint as applyToPoint61,
|
|
10582
10858
|
compose as compose11,
|
|
@@ -10584,15 +10860,6 @@ import {
|
|
|
10584
10860
|
scale as scale6,
|
|
10585
10861
|
translate as translate11
|
|
10586
10862
|
} from "transformation-matrix";
|
|
10587
|
-
|
|
10588
|
-
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
10589
|
-
import {
|
|
10590
|
-
applyToPoint as applyToPoint60,
|
|
10591
|
-
compose as compose10,
|
|
10592
|
-
rotate as rotate5,
|
|
10593
|
-
scale as scale5,
|
|
10594
|
-
translate as translate10
|
|
10595
|
-
} from "transformation-matrix";
|
|
10596
10863
|
import { symbols as symbols3 } from "schematic-symbols";
|
|
10597
10864
|
var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
10598
10865
|
schNetLabel,
|
|
@@ -10635,7 +10902,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
10635
10902
|
y: schNetLabel.center.y - realTextGrowthVec.y * fullWidthFsr * fontSizeMm / 2
|
|
10636
10903
|
};
|
|
10637
10904
|
const pathRotation = 0;
|
|
10638
|
-
const rotationMatrix =
|
|
10905
|
+
const rotationMatrix = rotate6(pathRotation / 180 * Math.PI);
|
|
10639
10906
|
const symbolBounds = {
|
|
10640
10907
|
minX: Math.min(
|
|
10641
10908
|
...symbol.primitives.flatMap(
|
|
@@ -10662,22 +10929,22 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
10662
10929
|
x: symbolBounds.minX,
|
|
10663
10930
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
10664
10931
|
};
|
|
10665
|
-
const rotatedSymbolEnd =
|
|
10666
|
-
const symbolToRealTransform =
|
|
10667
|
-
|
|
10932
|
+
const rotatedSymbolEnd = applyToPoint61(rotationMatrix, symbolEndPoint);
|
|
10933
|
+
const symbolToRealTransform = compose11(
|
|
10934
|
+
translate11(
|
|
10668
10935
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
10669
10936
|
realAnchorPosition.y - rotatedSymbolEnd.y
|
|
10670
10937
|
),
|
|
10671
10938
|
rotationMatrix,
|
|
10672
|
-
|
|
10939
|
+
scale6(1)
|
|
10673
10940
|
// Use full symbol size
|
|
10674
10941
|
);
|
|
10675
|
-
const [screenMinX, screenMinY] =
|
|
10676
|
-
|
|
10942
|
+
const [screenMinX, screenMinY] = applyToPoint61(
|
|
10943
|
+
compose11(realToScreenTransform, symbolToRealTransform),
|
|
10677
10944
|
[bounds.minX, bounds.minY]
|
|
10678
10945
|
);
|
|
10679
|
-
const [screenMaxX, screenMaxY] =
|
|
10680
|
-
|
|
10946
|
+
const [screenMaxX, screenMaxY] = applyToPoint61(
|
|
10947
|
+
compose11(realToScreenTransform, symbolToRealTransform),
|
|
10681
10948
|
[bounds.maxX, bounds.maxY]
|
|
10682
10949
|
);
|
|
10683
10950
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -10700,8 +10967,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
10700
10967
|
});
|
|
10701
10968
|
for (const path of symbolPaths) {
|
|
10702
10969
|
const symbolPath = path.points.map((p, i) => {
|
|
10703
|
-
const [x, y] =
|
|
10704
|
-
|
|
10970
|
+
const [x, y] = applyToPoint61(
|
|
10971
|
+
compose11(realToScreenTransform, symbolToRealTransform),
|
|
10705
10972
|
[p.x, p.y]
|
|
10706
10973
|
);
|
|
10707
10974
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -10721,8 +10988,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
10721
10988
|
});
|
|
10722
10989
|
}
|
|
10723
10990
|
for (const text of symbolTexts) {
|
|
10724
|
-
const screenTextPos =
|
|
10725
|
-
|
|
10991
|
+
const screenTextPos = applyToPoint61(
|
|
10992
|
+
compose11(realToScreenTransform, symbolToRealTransform),
|
|
10726
10993
|
text
|
|
10727
10994
|
);
|
|
10728
10995
|
let textValue = text.text;
|
|
@@ -10731,8 +10998,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
10731
10998
|
} else if (textValue === "{VAL}") {
|
|
10732
10999
|
textValue = "";
|
|
10733
11000
|
}
|
|
10734
|
-
const
|
|
10735
|
-
const baseOffset =
|
|
11001
|
+
const scale10 = Math.abs(realToScreenTransform.a);
|
|
11002
|
+
const baseOffset = scale10 * 0.1;
|
|
10736
11003
|
const offsetScreenPos = {
|
|
10737
11004
|
x: screenTextPos.x,
|
|
10738
11005
|
y: screenTextPos.y
|
|
@@ -10763,11 +11030,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
10763
11030
|
});
|
|
10764
11031
|
}
|
|
10765
11032
|
for (const box of symbolBoxes) {
|
|
10766
|
-
const screenBoxPos =
|
|
10767
|
-
|
|
11033
|
+
const screenBoxPos = applyToPoint61(
|
|
11034
|
+
compose11(realToScreenTransform, symbolToRealTransform),
|
|
10768
11035
|
box
|
|
10769
11036
|
);
|
|
10770
|
-
const symbolToScreenScale =
|
|
11037
|
+
const symbolToScreenScale = compose11(
|
|
10771
11038
|
realToScreenTransform,
|
|
10772
11039
|
symbolToRealTransform
|
|
10773
11040
|
).a;
|
|
@@ -10786,11 +11053,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
10786
11053
|
});
|
|
10787
11054
|
}
|
|
10788
11055
|
for (const circle of symbolCircles) {
|
|
10789
|
-
const screenCirclePos =
|
|
10790
|
-
|
|
11056
|
+
const screenCirclePos = applyToPoint61(
|
|
11057
|
+
compose11(realToScreenTransform, symbolToRealTransform),
|
|
10791
11058
|
circle
|
|
10792
11059
|
);
|
|
10793
|
-
const symbolToScreenScale =
|
|
11060
|
+
const symbolToScreenScale = compose11(
|
|
10794
11061
|
realToScreenTransform,
|
|
10795
11062
|
symbolToRealTransform
|
|
10796
11063
|
).a;
|
|
@@ -10831,14 +11098,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
10831
11098
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
10832
11099
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
10833
11100
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
10834
|
-
const screenCenter =
|
|
11101
|
+
const screenCenter = applyToPoint62(realToScreenTransform, schNetLabel.center);
|
|
10835
11102
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
10836
11103
|
schNetLabel.anchor_side
|
|
10837
11104
|
);
|
|
10838
11105
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
10839
11106
|
screenTextGrowthVec.y *= -1;
|
|
10840
11107
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
10841
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
11108
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint62(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
10842
11109
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
10843
11110
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
10844
11111
|
};
|
|
@@ -10879,12 +11146,12 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
10879
11146
|
y: -0.6
|
|
10880
11147
|
}
|
|
10881
11148
|
].map(
|
|
10882
|
-
(fontRelativePoint) =>
|
|
10883
|
-
|
|
11149
|
+
(fontRelativePoint) => applyToPoint62(
|
|
11150
|
+
compose12(
|
|
10884
11151
|
realToScreenTransform,
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
11152
|
+
translate12(realAnchorPosition.x, realAnchorPosition.y),
|
|
11153
|
+
scale7(fontSizeMm),
|
|
11154
|
+
rotate7(pathRotation / 180 * Math.PI)
|
|
10888
11155
|
),
|
|
10889
11156
|
fontRelativePoint
|
|
10890
11157
|
)
|
|
@@ -10956,17 +11223,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
10956
11223
|
};
|
|
10957
11224
|
|
|
10958
11225
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
10959
|
-
import { applyToPoint as
|
|
11226
|
+
import { applyToPoint as applyToPoint63 } from "transformation-matrix";
|
|
10960
11227
|
var createSvgObjectsFromSchematicBox = ({
|
|
10961
11228
|
schematicBox,
|
|
10962
11229
|
transform,
|
|
10963
11230
|
colorMap: colorMap2
|
|
10964
11231
|
}) => {
|
|
10965
|
-
const topLeft =
|
|
11232
|
+
const topLeft = applyToPoint63(transform, {
|
|
10966
11233
|
x: schematicBox.x,
|
|
10967
11234
|
y: schematicBox.y
|
|
10968
11235
|
});
|
|
10969
|
-
const bottomRight =
|
|
11236
|
+
const bottomRight = applyToPoint63(transform, {
|
|
10970
11237
|
x: schematicBox.x + schematicBox.width,
|
|
10971
11238
|
y: schematicBox.y + schematicBox.height
|
|
10972
11239
|
});
|
|
@@ -11002,7 +11269,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
11002
11269
|
};
|
|
11003
11270
|
|
|
11004
11271
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
11005
|
-
import { applyToPoint as
|
|
11272
|
+
import { applyToPoint as applyToPoint64 } from "transformation-matrix";
|
|
11006
11273
|
var createSvgObjectsFromSchematicTable = ({
|
|
11007
11274
|
schematicTable,
|
|
11008
11275
|
transform,
|
|
@@ -11035,11 +11302,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11035
11302
|
const svgObjects = [];
|
|
11036
11303
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
11037
11304
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
11038
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
11305
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint64(transform, [
|
|
11039
11306
|
topLeftX,
|
|
11040
11307
|
topLeftY
|
|
11041
11308
|
]);
|
|
11042
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
11309
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint64(transform, [
|
|
11043
11310
|
topLeftX + totalWidth,
|
|
11044
11311
|
topLeftY - totalHeight
|
|
11045
11312
|
]);
|
|
@@ -11071,8 +11338,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11071
11338
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
11072
11339
|
);
|
|
11073
11340
|
if (!isMerged) {
|
|
11074
|
-
const start =
|
|
11075
|
-
const end =
|
|
11341
|
+
const start = applyToPoint64(transform, { x: currentX, y: segmentStartY });
|
|
11342
|
+
const end = applyToPoint64(transform, { x: currentX, y: segmentEndY });
|
|
11076
11343
|
svgObjects.push({
|
|
11077
11344
|
name: "line",
|
|
11078
11345
|
type: "element",
|
|
@@ -11101,11 +11368,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11101
11368
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
11102
11369
|
);
|
|
11103
11370
|
if (!isMerged) {
|
|
11104
|
-
const start =
|
|
11371
|
+
const start = applyToPoint64(transform, {
|
|
11105
11372
|
x: segmentStartX,
|
|
11106
11373
|
y: currentY
|
|
11107
11374
|
});
|
|
11108
|
-
const end =
|
|
11375
|
+
const end = applyToPoint64(transform, { x: segmentEndX, y: currentY });
|
|
11109
11376
|
svgObjects.push({
|
|
11110
11377
|
name: "line",
|
|
11111
11378
|
type: "element",
|
|
@@ -11147,7 +11414,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11147
11414
|
} else if (vertical_align === "bottom") {
|
|
11148
11415
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
11149
11416
|
}
|
|
11150
|
-
const screenTextAnchorPos =
|
|
11417
|
+
const screenTextAnchorPos = applyToPoint64(transform, realTextAnchorPos);
|
|
11151
11418
|
const fontSize = getSchScreenFontSize(
|
|
11152
11419
|
transform,
|
|
11153
11420
|
"reference_designator",
|
|
@@ -11203,13 +11470,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11203
11470
|
|
|
11204
11471
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
11205
11472
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
11206
|
-
import { applyToPoint as
|
|
11473
|
+
import { applyToPoint as applyToPoint65 } from "transformation-matrix";
|
|
11207
11474
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
11208
11475
|
var createSvgObjectsForSchPortHover = ({
|
|
11209
11476
|
schPort,
|
|
11210
11477
|
transform
|
|
11211
11478
|
}) => {
|
|
11212
|
-
const screenSchPortPos =
|
|
11479
|
+
const screenSchPortPos = applyToPoint65(transform, schPort.center);
|
|
11213
11480
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
11214
11481
|
return [
|
|
11215
11482
|
{
|
|
@@ -11254,14 +11521,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
11254
11521
|
};
|
|
11255
11522
|
|
|
11256
11523
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
11257
|
-
import { applyToPoint as
|
|
11524
|
+
import { applyToPoint as applyToPoint66 } from "transformation-matrix";
|
|
11258
11525
|
function createSvgObjectsFromSchematicLine({
|
|
11259
11526
|
schLine,
|
|
11260
11527
|
transform,
|
|
11261
11528
|
colorMap: colorMap2
|
|
11262
11529
|
}) {
|
|
11263
|
-
const p1 =
|
|
11264
|
-
const p2 =
|
|
11530
|
+
const p1 = applyToPoint66(transform, { x: schLine.x1, y: schLine.y1 });
|
|
11531
|
+
const p2 = applyToPoint66(transform, { x: schLine.x2, y: schLine.y2 });
|
|
11265
11532
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
11266
11533
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
11267
11534
|
return [
|
|
@@ -11290,13 +11557,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
11290
11557
|
}
|
|
11291
11558
|
|
|
11292
11559
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
11293
|
-
import { applyToPoint as
|
|
11560
|
+
import { applyToPoint as applyToPoint67 } from "transformation-matrix";
|
|
11294
11561
|
function createSvgObjectsFromSchematicCircle({
|
|
11295
11562
|
schCircle,
|
|
11296
11563
|
transform,
|
|
11297
11564
|
colorMap: colorMap2
|
|
11298
11565
|
}) {
|
|
11299
|
-
const center =
|
|
11566
|
+
const center = applyToPoint67(transform, schCircle.center);
|
|
11300
11567
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
11301
11568
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
11302
11569
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -11326,13 +11593,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
11326
11593
|
}
|
|
11327
11594
|
|
|
11328
11595
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
11329
|
-
import { applyToPoint as
|
|
11596
|
+
import { applyToPoint as applyToPoint68 } from "transformation-matrix";
|
|
11330
11597
|
function createSvgObjectsFromSchematicRect({
|
|
11331
11598
|
schRect,
|
|
11332
11599
|
transform,
|
|
11333
11600
|
colorMap: colorMap2
|
|
11334
11601
|
}) {
|
|
11335
|
-
const center =
|
|
11602
|
+
const center = applyToPoint68(transform, schRect.center);
|
|
11336
11603
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
11337
11604
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
11338
11605
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -11368,13 +11635,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
11368
11635
|
}
|
|
11369
11636
|
|
|
11370
11637
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
11371
|
-
import { applyToPoint as
|
|
11638
|
+
import { applyToPoint as applyToPoint69 } from "transformation-matrix";
|
|
11372
11639
|
function createSvgObjectsFromSchematicArc({
|
|
11373
11640
|
schArc,
|
|
11374
11641
|
transform,
|
|
11375
11642
|
colorMap: colorMap2
|
|
11376
11643
|
}) {
|
|
11377
|
-
const center =
|
|
11644
|
+
const center = applyToPoint69(transform, schArc.center);
|
|
11378
11645
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
11379
11646
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
11380
11647
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -12381,9 +12648,9 @@ function convertCircuitJsonToSchematicSimulationSvg({
|
|
|
12381
12648
|
const rawSchematicHeight = Math.max(1, height * clampedRatio);
|
|
12382
12649
|
const rawSimulationHeight = Math.max(1, height - rawSchematicHeight);
|
|
12383
12650
|
const totalRawHeight = rawSchematicHeight + rawSimulationHeight;
|
|
12384
|
-
const
|
|
12385
|
-
const schematicHeight = rawSchematicHeight *
|
|
12386
|
-
const simulationHeight = rawSimulationHeight *
|
|
12651
|
+
const scale10 = totalRawHeight === 0 ? 1 : height / totalRawHeight;
|
|
12652
|
+
const schematicHeight = rawSchematicHeight * scale10;
|
|
12653
|
+
const simulationHeight = rawSimulationHeight * scale10;
|
|
12387
12654
|
const schematicSvg = convertCircuitJsonToSchematicSvg(schematicElements, {
|
|
12388
12655
|
...schematicOptions,
|
|
12389
12656
|
width,
|
|
@@ -12475,21 +12742,21 @@ function formatNumber2(value) {
|
|
|
12475
12742
|
}
|
|
12476
12743
|
|
|
12477
12744
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
12478
|
-
import { distance as
|
|
12745
|
+
import { distance as distance3 } from "circuit-json";
|
|
12479
12746
|
import { stringify as stringify7 } from "svgson";
|
|
12480
12747
|
import {
|
|
12481
|
-
applyToPoint as
|
|
12482
|
-
compose as
|
|
12483
|
-
scale as
|
|
12484
|
-
translate as
|
|
12748
|
+
applyToPoint as applyToPoint72,
|
|
12749
|
+
compose as compose15,
|
|
12750
|
+
scale as scale9,
|
|
12751
|
+
translate as translate15
|
|
12485
12752
|
} from "transformation-matrix";
|
|
12486
12753
|
|
|
12487
12754
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
12488
|
-
import { applyToPoint as
|
|
12755
|
+
import { applyToPoint as applyToPoint71 } from "transformation-matrix";
|
|
12489
12756
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
12490
12757
|
const { transform, layer: layerFilter } = ctx;
|
|
12491
12758
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
12492
|
-
const [x, y] =
|
|
12759
|
+
const [x, y] = applyToPoint71(transform, [solderPaste.x, solderPaste.y]);
|
|
12493
12760
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
12494
12761
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
12495
12762
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -12593,8 +12860,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
12593
12860
|
}
|
|
12594
12861
|
} else if (item.type === "pcb_panel") {
|
|
12595
12862
|
const panel = item;
|
|
12596
|
-
const width =
|
|
12597
|
-
const height =
|
|
12863
|
+
const width = distance3.parse(panel.width);
|
|
12864
|
+
const height = distance3.parse(panel.height);
|
|
12598
12865
|
if (width !== void 0 && height !== void 0) {
|
|
12599
12866
|
const center = panel.center ?? { x: width / 2, y: height / 2 };
|
|
12600
12867
|
updateBounds(center, width, height);
|
|
@@ -12613,12 +12880,12 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
12613
12880
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
12614
12881
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
12615
12882
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
12616
|
-
const transform =
|
|
12617
|
-
|
|
12883
|
+
const transform = compose15(
|
|
12884
|
+
translate15(
|
|
12618
12885
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
12619
12886
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
12620
12887
|
),
|
|
12621
|
-
|
|
12888
|
+
scale9(scaleFactor, -scaleFactor)
|
|
12622
12889
|
// Flip in y-direction
|
|
12623
12890
|
);
|
|
12624
12891
|
const ctx = {
|
|
@@ -12715,8 +12982,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
12715
12982
|
}
|
|
12716
12983
|
}
|
|
12717
12984
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
12718
|
-
const [x1, y1] =
|
|
12719
|
-
const [x2, y2] =
|
|
12985
|
+
const [x1, y1] = applyToPoint72(transform, [minX, minY]);
|
|
12986
|
+
const [x2, y2] = applyToPoint72(transform, [maxX, maxY]);
|
|
12720
12987
|
const width = Math.abs(x2 - x1);
|
|
12721
12988
|
const height = Math.abs(y2 - y1);
|
|
12722
12989
|
const x = Math.min(x1, x2);
|