circuit-to-svg 0.0.161 → 0.0.163
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.d.ts +4 -1
- package/dist/index.js +488 -83
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -637,6 +637,33 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
637
637
|
...layer === "bottom" ? [scale(-1, 1)] : []
|
|
638
638
|
);
|
|
639
639
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
640
|
+
const lines = text.split("\n");
|
|
641
|
+
const children = lines.length === 1 ? [
|
|
642
|
+
{
|
|
643
|
+
type: "text",
|
|
644
|
+
value: text,
|
|
645
|
+
name: "",
|
|
646
|
+
attributes: {},
|
|
647
|
+
children: []
|
|
648
|
+
}
|
|
649
|
+
] : lines.map((line, idx) => ({
|
|
650
|
+
type: "element",
|
|
651
|
+
name: "tspan",
|
|
652
|
+
value: "",
|
|
653
|
+
attributes: {
|
|
654
|
+
x: "0",
|
|
655
|
+
...idx > 0 ? { dy: transformedFontSize.toString() } : {}
|
|
656
|
+
},
|
|
657
|
+
children: [
|
|
658
|
+
{
|
|
659
|
+
type: "text",
|
|
660
|
+
value: line,
|
|
661
|
+
name: "",
|
|
662
|
+
attributes: {},
|
|
663
|
+
children: []
|
|
664
|
+
}
|
|
665
|
+
]
|
|
666
|
+
}));
|
|
640
667
|
const svgObject = {
|
|
641
668
|
name: "text",
|
|
642
669
|
type: "element",
|
|
@@ -655,15 +682,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
655
682
|
"data-pcb-silkscreen-text-id": pcbSilkscreenText.pcb_component_id,
|
|
656
683
|
stroke: "none"
|
|
657
684
|
},
|
|
658
|
-
children
|
|
659
|
-
{
|
|
660
|
-
type: "text",
|
|
661
|
-
value: text,
|
|
662
|
-
name: "",
|
|
663
|
-
attributes: {},
|
|
664
|
-
children: []
|
|
665
|
-
}
|
|
666
|
-
],
|
|
685
|
+
children,
|
|
667
686
|
value: ""
|
|
668
687
|
};
|
|
669
688
|
return [svgObject];
|
|
@@ -1780,7 +1799,7 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
1780
1799
|
import { stringify as stringify2 } from "svgson";
|
|
1781
1800
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
1782
1801
|
import {
|
|
1783
|
-
applyToPoint as
|
|
1802
|
+
applyToPoint as applyToPoint25,
|
|
1784
1803
|
compose as compose5,
|
|
1785
1804
|
scale as scale3,
|
|
1786
1805
|
translate as translate5
|
|
@@ -2023,8 +2042,387 @@ function getRectPathData(w, h, rotation) {
|
|
|
2023
2042
|
return `${path} Z`;
|
|
2024
2043
|
}
|
|
2025
2044
|
|
|
2045
|
+
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
2046
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2047
|
+
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
2048
|
+
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
2049
|
+
const { transform } = ctx;
|
|
2050
|
+
const [x, y] = applyToPoint22(transform, [hole.x, hole.y]);
|
|
2051
|
+
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
2052
|
+
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2053
|
+
const radius = scaledDiameter / 2;
|
|
2054
|
+
if (hole.hole_shape === "circle") {
|
|
2055
|
+
return [
|
|
2056
|
+
{
|
|
2057
|
+
name: "circle",
|
|
2058
|
+
type: "element",
|
|
2059
|
+
attributes: {
|
|
2060
|
+
class: "assembly-hole",
|
|
2061
|
+
cx: x.toString(),
|
|
2062
|
+
cy: y.toString(),
|
|
2063
|
+
r: radius.toString(),
|
|
2064
|
+
fill: HOLE_COLOR2
|
|
2065
|
+
},
|
|
2066
|
+
children: [],
|
|
2067
|
+
value: ""
|
|
2068
|
+
}
|
|
2069
|
+
];
|
|
2070
|
+
}
|
|
2071
|
+
return [
|
|
2072
|
+
{
|
|
2073
|
+
name: "rect",
|
|
2074
|
+
type: "element",
|
|
2075
|
+
attributes: {
|
|
2076
|
+
class: "assembly-hole",
|
|
2077
|
+
x: (x - radius).toString(),
|
|
2078
|
+
y: (y - radius).toString(),
|
|
2079
|
+
width: scaledDiameter.toString(),
|
|
2080
|
+
height: scaledDiameter.toString(),
|
|
2081
|
+
fill: HOLE_COLOR2
|
|
2082
|
+
},
|
|
2083
|
+
children: [],
|
|
2084
|
+
value: ""
|
|
2085
|
+
}
|
|
2086
|
+
];
|
|
2087
|
+
}
|
|
2088
|
+
if (hole.hole_shape === "oval") {
|
|
2089
|
+
const scaledWidth = hole.hole_width * Math.abs(transform.a);
|
|
2090
|
+
const scaledHeight = hole.hole_height * Math.abs(transform.a);
|
|
2091
|
+
const rx = scaledWidth / 2;
|
|
2092
|
+
const ry = scaledHeight / 2;
|
|
2093
|
+
return [
|
|
2094
|
+
{
|
|
2095
|
+
name: "ellipse",
|
|
2096
|
+
type: "element",
|
|
2097
|
+
attributes: {
|
|
2098
|
+
class: "assembly-hole",
|
|
2099
|
+
cx: x.toString(),
|
|
2100
|
+
cy: y.toString(),
|
|
2101
|
+
rx: rx.toString(),
|
|
2102
|
+
ry: ry.toString(),
|
|
2103
|
+
fill: HOLE_COLOR2
|
|
2104
|
+
},
|
|
2105
|
+
children: [],
|
|
2106
|
+
value: ""
|
|
2107
|
+
}
|
|
2108
|
+
];
|
|
2109
|
+
}
|
|
2110
|
+
return [];
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
2114
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
2115
|
+
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
2116
|
+
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
2117
|
+
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
2118
|
+
const { transform } = ctx;
|
|
2119
|
+
const [x, y] = applyToPoint23(transform, [hole.x, hole.y]);
|
|
2120
|
+
if (hole.shape === "pill") {
|
|
2121
|
+
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
2122
|
+
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
2123
|
+
const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
|
|
2124
|
+
const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
|
|
2125
|
+
const outerRadiusX = scaledOuterWidth / 2;
|
|
2126
|
+
const straightLength = scaledOuterHeight - scaledOuterWidth;
|
|
2127
|
+
const innerRadiusX = scaledHoleWidth / 2;
|
|
2128
|
+
return [
|
|
2129
|
+
{
|
|
2130
|
+
name: "g",
|
|
2131
|
+
type: "element",
|
|
2132
|
+
children: [
|
|
2133
|
+
// Outer pill shape
|
|
2134
|
+
{
|
|
2135
|
+
name: "path",
|
|
2136
|
+
type: "element",
|
|
2137
|
+
attributes: {
|
|
2138
|
+
class: "assembly-hole-outer",
|
|
2139
|
+
fill: PAD_COLOR,
|
|
2140
|
+
d: `M${x - outerRadiusX},${y - straightLength / 2} v${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 ${scaledOuterWidth},0 v-${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 -${scaledOuterWidth},0 z`
|
|
2141
|
+
},
|
|
2142
|
+
value: "",
|
|
2143
|
+
children: []
|
|
2144
|
+
},
|
|
2145
|
+
// Inner pill shape
|
|
2146
|
+
{
|
|
2147
|
+
name: "path",
|
|
2148
|
+
type: "element",
|
|
2149
|
+
attributes: {
|
|
2150
|
+
class: "assembly-hole-inner",
|
|
2151
|
+
fill: HOLE_COLOR3,
|
|
2152
|
+
d: `M${x - innerRadiusX},${y - (scaledHoleHeight - scaledHoleWidth) / 2} v${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 ${scaledHoleWidth},0 v-${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 -${scaledHoleWidth},0 z`
|
|
2153
|
+
},
|
|
2154
|
+
value: "",
|
|
2155
|
+
children: []
|
|
2156
|
+
}
|
|
2157
|
+
],
|
|
2158
|
+
value: "",
|
|
2159
|
+
attributes: {}
|
|
2160
|
+
}
|
|
2161
|
+
];
|
|
2162
|
+
}
|
|
2163
|
+
if (hole.shape === "circle") {
|
|
2164
|
+
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
2165
|
+
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
2166
|
+
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
2167
|
+
const scaledHoleHeight = hole.hole_diameter * Math.abs(transform.a);
|
|
2168
|
+
const outerRadius = Math.min(scaledOuterWidth, scaledOuterHeight) / 2;
|
|
2169
|
+
const innerRadius = Math.min(scaledHoleWidth, scaledHoleHeight) / 2;
|
|
2170
|
+
return [
|
|
2171
|
+
{
|
|
2172
|
+
name: "g",
|
|
2173
|
+
type: "element",
|
|
2174
|
+
children: [
|
|
2175
|
+
{
|
|
2176
|
+
name: "circle",
|
|
2177
|
+
type: "element",
|
|
2178
|
+
attributes: {
|
|
2179
|
+
class: "assembly-hole-outer",
|
|
2180
|
+
fill: PAD_COLOR,
|
|
2181
|
+
cx: x.toString(),
|
|
2182
|
+
cy: y.toString(),
|
|
2183
|
+
r: outerRadius.toString()
|
|
2184
|
+
},
|
|
2185
|
+
value: "",
|
|
2186
|
+
children: []
|
|
2187
|
+
},
|
|
2188
|
+
{
|
|
2189
|
+
name: "circle",
|
|
2190
|
+
type: "element",
|
|
2191
|
+
attributes: {
|
|
2192
|
+
class: "assembly-hole-inner",
|
|
2193
|
+
fill: HOLE_COLOR3,
|
|
2194
|
+
cx: x.toString(),
|
|
2195
|
+
cy: y.toString(),
|
|
2196
|
+
r: innerRadius.toString()
|
|
2197
|
+
},
|
|
2198
|
+
value: "",
|
|
2199
|
+
children: []
|
|
2200
|
+
}
|
|
2201
|
+
],
|
|
2202
|
+
value: "",
|
|
2203
|
+
attributes: {}
|
|
2204
|
+
}
|
|
2205
|
+
];
|
|
2206
|
+
}
|
|
2207
|
+
if (hole.shape === "circular_hole_with_rect_pad") {
|
|
2208
|
+
const scaledHoleDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2209
|
+
const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
|
|
2210
|
+
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
2211
|
+
const holeRadius = scaledHoleDiameter / 2;
|
|
2212
|
+
return [
|
|
2213
|
+
{
|
|
2214
|
+
name: "g",
|
|
2215
|
+
type: "element",
|
|
2216
|
+
children: [
|
|
2217
|
+
// Rectangular pad (outer shape)
|
|
2218
|
+
{
|
|
2219
|
+
name: "rect",
|
|
2220
|
+
type: "element",
|
|
2221
|
+
attributes: {
|
|
2222
|
+
class: "assembly-hole-outer-pad",
|
|
2223
|
+
fill: PAD_COLOR,
|
|
2224
|
+
x: (x - scaledRectPadWidth / 2).toString(),
|
|
2225
|
+
y: (y - scaledRectPadHeight / 2).toString(),
|
|
2226
|
+
width: scaledRectPadWidth.toString(),
|
|
2227
|
+
height: scaledRectPadHeight.toString()
|
|
2228
|
+
},
|
|
2229
|
+
value: "",
|
|
2230
|
+
children: []
|
|
2231
|
+
},
|
|
2232
|
+
// Circular hole inside the rectangle
|
|
2233
|
+
{
|
|
2234
|
+
name: "circle",
|
|
2235
|
+
type: "element",
|
|
2236
|
+
attributes: {
|
|
2237
|
+
class: "assembly-hole-inner",
|
|
2238
|
+
fill: HOLE_COLOR3,
|
|
2239
|
+
cx: x.toString(),
|
|
2240
|
+
cy: y.toString(),
|
|
2241
|
+
r: holeRadius.toString()
|
|
2242
|
+
},
|
|
2243
|
+
value: "",
|
|
2244
|
+
children: []
|
|
2245
|
+
}
|
|
2246
|
+
],
|
|
2247
|
+
value: "",
|
|
2248
|
+
attributes: {}
|
|
2249
|
+
}
|
|
2250
|
+
];
|
|
2251
|
+
}
|
|
2252
|
+
if (hole.shape === "pill_hole_with_rect_pad") {
|
|
2253
|
+
const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
|
|
2254
|
+
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
2255
|
+
const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
|
|
2256
|
+
const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
|
|
2257
|
+
const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
|
|
2258
|
+
return [
|
|
2259
|
+
{
|
|
2260
|
+
name: "g",
|
|
2261
|
+
type: "element",
|
|
2262
|
+
children: [
|
|
2263
|
+
// Rectangular pad (outer shape)
|
|
2264
|
+
{
|
|
2265
|
+
name: "rect",
|
|
2266
|
+
type: "element",
|
|
2267
|
+
attributes: {
|
|
2268
|
+
class: "assembly-hole-outer-pad",
|
|
2269
|
+
fill: PAD_COLOR,
|
|
2270
|
+
x: (x - scaledRectPadWidth / 2).toString(),
|
|
2271
|
+
y: (y - scaledRectPadHeight / 2).toString(),
|
|
2272
|
+
width: scaledRectPadWidth.toString(),
|
|
2273
|
+
height: scaledRectPadHeight.toString()
|
|
2274
|
+
},
|
|
2275
|
+
value: "",
|
|
2276
|
+
children: []
|
|
2277
|
+
},
|
|
2278
|
+
// pill hole inside the rectangle
|
|
2279
|
+
{
|
|
2280
|
+
name: "rect",
|
|
2281
|
+
type: "element",
|
|
2282
|
+
attributes: {
|
|
2283
|
+
class: "assembly-hole-inner",
|
|
2284
|
+
fill: HOLE_COLOR3,
|
|
2285
|
+
x: (x - scaledHoleWidth / 2).toString(),
|
|
2286
|
+
y: (y - scaledHoleHeight / 2).toString(),
|
|
2287
|
+
width: scaledHoleWidth.toString(),
|
|
2288
|
+
height: scaledHoleHeight.toString(),
|
|
2289
|
+
rx: holeRadius.toString(),
|
|
2290
|
+
ry: holeRadius.toString()
|
|
2291
|
+
},
|
|
2292
|
+
value: "",
|
|
2293
|
+
children: []
|
|
2294
|
+
}
|
|
2295
|
+
],
|
|
2296
|
+
value: "",
|
|
2297
|
+
attributes: {}
|
|
2298
|
+
}
|
|
2299
|
+
];
|
|
2300
|
+
}
|
|
2301
|
+
return [];
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
2305
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2306
|
+
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
2307
|
+
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
2308
|
+
const { transform } = ctx;
|
|
2309
|
+
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
2310
|
+
const width = pad.width * Math.abs(transform.a);
|
|
2311
|
+
const height = pad.height * Math.abs(transform.d);
|
|
2312
|
+
const [x, y] = applyToPoint24(transform, [pad.x, pad.y]);
|
|
2313
|
+
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
2314
|
+
return [
|
|
2315
|
+
{
|
|
2316
|
+
name: "rect",
|
|
2317
|
+
type: "element",
|
|
2318
|
+
attributes: {
|
|
2319
|
+
class: "assembly-pad",
|
|
2320
|
+
fill: PAD_COLOR2,
|
|
2321
|
+
x: (-width / 2).toString(),
|
|
2322
|
+
y: (-height / 2).toString(),
|
|
2323
|
+
width: width.toString(),
|
|
2324
|
+
height: height.toString(),
|
|
2325
|
+
transform: `translate(${x} ${y}) rotate(${-pad.ccw_rotation})`,
|
|
2326
|
+
"data-layer": pad.layer
|
|
2327
|
+
},
|
|
2328
|
+
value: "",
|
|
2329
|
+
children: []
|
|
2330
|
+
}
|
|
2331
|
+
];
|
|
2332
|
+
}
|
|
2333
|
+
return [
|
|
2334
|
+
{
|
|
2335
|
+
name: "rect",
|
|
2336
|
+
type: "element",
|
|
2337
|
+
attributes: {
|
|
2338
|
+
class: "assembly-pad",
|
|
2339
|
+
fill: PAD_COLOR2,
|
|
2340
|
+
x: (x - width / 2).toString(),
|
|
2341
|
+
y: (y - height / 2).toString(),
|
|
2342
|
+
width: width.toString(),
|
|
2343
|
+
height: height.toString(),
|
|
2344
|
+
"data-layer": pad.layer
|
|
2345
|
+
},
|
|
2346
|
+
value: "",
|
|
2347
|
+
children: []
|
|
2348
|
+
}
|
|
2349
|
+
];
|
|
2350
|
+
}
|
|
2351
|
+
if (pad.shape === "pill") {
|
|
2352
|
+
const width = pad.width * Math.abs(transform.a);
|
|
2353
|
+
const height = pad.height * Math.abs(transform.d);
|
|
2354
|
+
const radius = pad.radius * Math.abs(transform.a);
|
|
2355
|
+
const [x, y] = applyToPoint24(transform, [pad.x, pad.y]);
|
|
2356
|
+
return [
|
|
2357
|
+
{
|
|
2358
|
+
name: "rect",
|
|
2359
|
+
type: "element",
|
|
2360
|
+
attributes: {
|
|
2361
|
+
class: "assembly-pad",
|
|
2362
|
+
fill: PAD_COLOR2,
|
|
2363
|
+
x: (x - width / 2).toString(),
|
|
2364
|
+
y: (y - height / 2).toString(),
|
|
2365
|
+
width: width.toString(),
|
|
2366
|
+
height: height.toString(),
|
|
2367
|
+
rx: radius.toString(),
|
|
2368
|
+
ry: radius.toString(),
|
|
2369
|
+
"data-layer": pad.layer
|
|
2370
|
+
},
|
|
2371
|
+
value: "",
|
|
2372
|
+
children: []
|
|
2373
|
+
}
|
|
2374
|
+
];
|
|
2375
|
+
}
|
|
2376
|
+
if (pad.shape === "circle") {
|
|
2377
|
+
const radius = pad.radius * Math.abs(transform.a);
|
|
2378
|
+
const [x, y] = applyToPoint24(transform, [pad.x, pad.y]);
|
|
2379
|
+
return [
|
|
2380
|
+
{
|
|
2381
|
+
name: "circle",
|
|
2382
|
+
type: "element",
|
|
2383
|
+
attributes: {
|
|
2384
|
+
class: "assembly-pad",
|
|
2385
|
+
fill: PAD_COLOR2,
|
|
2386
|
+
cx: x.toString(),
|
|
2387
|
+
cy: y.toString(),
|
|
2388
|
+
r: radius.toString(),
|
|
2389
|
+
"data-layer": pad.layer
|
|
2390
|
+
},
|
|
2391
|
+
value: "",
|
|
2392
|
+
children: []
|
|
2393
|
+
}
|
|
2394
|
+
];
|
|
2395
|
+
}
|
|
2396
|
+
if (pad.shape === "polygon") {
|
|
2397
|
+
const points = (pad.points ?? []).map(
|
|
2398
|
+
(point) => applyToPoint24(transform, [point.x, point.y])
|
|
2399
|
+
);
|
|
2400
|
+
return [
|
|
2401
|
+
{
|
|
2402
|
+
name: "polygon",
|
|
2403
|
+
type: "element",
|
|
2404
|
+
attributes: {
|
|
2405
|
+
class: "assembly-pad",
|
|
2406
|
+
fill: PAD_COLOR2,
|
|
2407
|
+
points: points.map((p) => p.join(",")).join(" "),
|
|
2408
|
+
"data-layer": pad.layer
|
|
2409
|
+
},
|
|
2410
|
+
value: "",
|
|
2411
|
+
children: []
|
|
2412
|
+
}
|
|
2413
|
+
];
|
|
2414
|
+
}
|
|
2415
|
+
return [];
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2026
2418
|
// lib/assembly/convert-circuit-json-to-assembly-svg.ts
|
|
2027
|
-
var OBJECT_ORDER2 = [
|
|
2419
|
+
var OBJECT_ORDER2 = [
|
|
2420
|
+
"pcb_component",
|
|
2421
|
+
"pcb_smtpad",
|
|
2422
|
+
"pcb_hole",
|
|
2423
|
+
"pcb_plated_hole",
|
|
2424
|
+
"pcb_board"
|
|
2425
|
+
];
|
|
2028
2426
|
function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
2029
2427
|
let minX = Number.POSITIVE_INFINITY;
|
|
2030
2428
|
let minY = Number.POSITIVE_INFINITY;
|
|
@@ -2059,9 +2457,10 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2059
2457
|
scale3(scaleFactor, -scaleFactor)
|
|
2060
2458
|
// Flip in y-direction
|
|
2061
2459
|
);
|
|
2460
|
+
const ctx = { transform };
|
|
2062
2461
|
const svgObjects = soup.sort(
|
|
2063
2462
|
(a, b) => (OBJECT_ORDER2.indexOf(b.type) ?? 9999) - (OBJECT_ORDER2.indexOf(a.type) ?? 9999)
|
|
2064
|
-
).flatMap((item) => createSvgObjects2(item,
|
|
2463
|
+
).flatMap((item) => createSvgObjects2(item, ctx, soup));
|
|
2065
2464
|
const softwareUsedString = getSoftwareUsedString(soup);
|
|
2066
2465
|
const svgObject = {
|
|
2067
2466
|
name: "svg",
|
|
@@ -2084,7 +2483,7 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2084
2483
|
type: "text",
|
|
2085
2484
|
value: `
|
|
2086
2485
|
.assembly-component {
|
|
2087
|
-
fill:
|
|
2486
|
+
fill: none;
|
|
2088
2487
|
stroke: #000;
|
|
2089
2488
|
}
|
|
2090
2489
|
.assembly-board {
|
|
@@ -2132,11 +2531,11 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2132
2531
|
};
|
|
2133
2532
|
return stringify2(svgObject);
|
|
2134
2533
|
}
|
|
2135
|
-
function createSvgObjects2(elm,
|
|
2534
|
+
function createSvgObjects2(elm, ctx, soup) {
|
|
2136
2535
|
const sourceComponents = su3(soup).source_component.list();
|
|
2137
2536
|
switch (elm.type) {
|
|
2138
2537
|
case "pcb_board":
|
|
2139
|
-
return createSvgObjectsFromAssemblyBoard(elm, transform);
|
|
2538
|
+
return createSvgObjectsFromAssemblyBoard(elm, ctx.transform);
|
|
2140
2539
|
case "pcb_component": {
|
|
2141
2540
|
const sourceComponent = sourceComponents.find(
|
|
2142
2541
|
(item) => item.source_component_id === elm.source_component_id
|
|
@@ -2152,19 +2551,25 @@ function createSvgObjects2(elm, transform, soup) {
|
|
|
2152
2551
|
name: sourceComponent.name,
|
|
2153
2552
|
arePinsInterchangeable
|
|
2154
2553
|
},
|
|
2155
|
-
|
|
2554
|
+
ctx
|
|
2156
2555
|
);
|
|
2157
2556
|
return obj ? [obj] : [];
|
|
2158
2557
|
}
|
|
2159
2558
|
return [];
|
|
2160
2559
|
}
|
|
2560
|
+
case "pcb_smtpad":
|
|
2561
|
+
return createSvgObjectsFromAssemblySmtPad(elm, ctx);
|
|
2562
|
+
case "pcb_hole":
|
|
2563
|
+
return createSvgObjectsFromAssemblyHole(elm, ctx);
|
|
2564
|
+
case "pcb_plated_hole":
|
|
2565
|
+
return createSvgObjectsFromAssemblyPlatedHole(elm, ctx);
|
|
2161
2566
|
default:
|
|
2162
2567
|
return [];
|
|
2163
2568
|
}
|
|
2164
2569
|
}
|
|
2165
2570
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
2166
|
-
const [x1, y1] =
|
|
2167
|
-
const [x2, y2] =
|
|
2571
|
+
const [x1, y1] = applyToPoint25(transform, [minX, minY]);
|
|
2572
|
+
const [x2, y2] = applyToPoint25(transform, [maxX, maxY]);
|
|
2168
2573
|
const width = Math.abs(x2 - x1);
|
|
2169
2574
|
const height = Math.abs(y2 - y1);
|
|
2170
2575
|
const x = Math.min(x1, x2);
|
|
@@ -2430,14 +2835,14 @@ import {
|
|
|
2430
2835
|
} from "transformation-matrix";
|
|
2431
2836
|
|
|
2432
2837
|
// lib/sch/draw-schematic-grid.ts
|
|
2433
|
-
import { applyToPoint as
|
|
2838
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2434
2839
|
function drawSchematicGrid(params) {
|
|
2435
2840
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
2436
2841
|
const cellSize = params.cellSize ?? 1;
|
|
2437
2842
|
const labelCells = params.labelCells ?? false;
|
|
2438
2843
|
const gridLines = [];
|
|
2439
2844
|
const transformPoint = (x, y) => {
|
|
2440
|
-
const [transformedX, transformedY] =
|
|
2845
|
+
const [transformedX, transformedY] = applyToPoint26(params.transform, [x, y]);
|
|
2441
2846
|
return { x: transformedX, y: transformedY };
|
|
2442
2847
|
};
|
|
2443
2848
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -2518,15 +2923,15 @@ function drawSchematicGrid(params) {
|
|
|
2518
2923
|
}
|
|
2519
2924
|
|
|
2520
2925
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
2521
|
-
import { applyToPoint as
|
|
2926
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2522
2927
|
function drawSchematicLabeledPoints(params) {
|
|
2523
2928
|
const { points, transform } = params;
|
|
2524
2929
|
const labeledPointsGroup = [];
|
|
2525
2930
|
for (const point of points) {
|
|
2526
|
-
const [x1, y1] =
|
|
2527
|
-
const [x2, y2] =
|
|
2528
|
-
const [x3, y3] =
|
|
2529
|
-
const [x4, y4] =
|
|
2931
|
+
const [x1, y1] = applyToPoint27(transform, [point.x - 0.1, point.y - 0.1]);
|
|
2932
|
+
const [x2, y2] = applyToPoint27(transform, [point.x + 0.1, point.y + 0.1]);
|
|
2933
|
+
const [x3, y3] = applyToPoint27(transform, [point.x - 0.1, point.y + 0.1]);
|
|
2934
|
+
const [x4, y4] = applyToPoint27(transform, [point.x + 0.1, point.y - 0.1]);
|
|
2530
2935
|
labeledPointsGroup.push({
|
|
2531
2936
|
name: "path",
|
|
2532
2937
|
type: "element",
|
|
@@ -2537,7 +2942,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
2537
2942
|
"stroke-opacity": "0.7"
|
|
2538
2943
|
}
|
|
2539
2944
|
});
|
|
2540
|
-
const [labelX, labelY] =
|
|
2945
|
+
const [labelX, labelY] = applyToPoint27(transform, [
|
|
2541
2946
|
point.x + 0.15,
|
|
2542
2947
|
point.y - 0.15
|
|
2543
2948
|
]);
|
|
@@ -3506,7 +3911,7 @@ import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
|
3506
3911
|
import { symbols } from "schematic-symbols";
|
|
3507
3912
|
import "svgson";
|
|
3508
3913
|
import {
|
|
3509
|
-
applyToPoint as
|
|
3914
|
+
applyToPoint as applyToPoint29,
|
|
3510
3915
|
compose as compose7
|
|
3511
3916
|
} from "transformation-matrix";
|
|
3512
3917
|
|
|
@@ -3590,13 +3995,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
3590
3995
|
}
|
|
3591
3996
|
|
|
3592
3997
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
3593
|
-
import { applyToPoint as
|
|
3998
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
3594
3999
|
var createSvgSchErrorText = ({
|
|
3595
4000
|
text,
|
|
3596
4001
|
realCenter,
|
|
3597
4002
|
realToScreenTransform
|
|
3598
4003
|
}) => {
|
|
3599
|
-
const screenCenter =
|
|
4004
|
+
const screenCenter = applyToPoint28(realToScreenTransform, realCenter);
|
|
3600
4005
|
return {
|
|
3601
4006
|
type: "element",
|
|
3602
4007
|
name: "text",
|
|
@@ -3705,11 +4110,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3705
4110
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
3706
4111
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
3707
4112
|
};
|
|
3708
|
-
const [screenMinX, screenMinY] =
|
|
4113
|
+
const [screenMinX, screenMinY] = applyToPoint29(
|
|
3709
4114
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3710
4115
|
[bounds.minX, bounds.minY]
|
|
3711
4116
|
);
|
|
3712
|
-
const [screenMaxX, screenMaxY] =
|
|
4117
|
+
const [screenMaxX, screenMaxY] = applyToPoint29(
|
|
3713
4118
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3714
4119
|
[bounds.maxX, bounds.maxY]
|
|
3715
4120
|
);
|
|
@@ -3738,7 +4143,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3738
4143
|
name: "path",
|
|
3739
4144
|
attributes: {
|
|
3740
4145
|
d: points.map((p, i) => {
|
|
3741
|
-
const [x, y] =
|
|
4146
|
+
const [x, y] = applyToPoint29(
|
|
3742
4147
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3743
4148
|
[p.x, p.y]
|
|
3744
4149
|
);
|
|
@@ -3754,7 +4159,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3754
4159
|
});
|
|
3755
4160
|
}
|
|
3756
4161
|
for (const text of texts) {
|
|
3757
|
-
const screenTextPos =
|
|
4162
|
+
const screenTextPos = applyToPoint29(
|
|
3758
4163
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3759
4164
|
text
|
|
3760
4165
|
);
|
|
@@ -3800,7 +4205,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3800
4205
|
});
|
|
3801
4206
|
}
|
|
3802
4207
|
for (const box of boxes) {
|
|
3803
|
-
const screenBoxPos =
|
|
4208
|
+
const screenBoxPos = applyToPoint29(
|
|
3804
4209
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3805
4210
|
box
|
|
3806
4211
|
);
|
|
@@ -3824,7 +4229,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3824
4229
|
}
|
|
3825
4230
|
for (const port of symbol.ports) {
|
|
3826
4231
|
if (connectedSymbolPorts.has(port)) continue;
|
|
3827
|
-
const screenPortPos =
|
|
4232
|
+
const screenPortPos = applyToPoint29(
|
|
3828
4233
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3829
4234
|
port
|
|
3830
4235
|
);
|
|
@@ -3844,7 +4249,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3844
4249
|
});
|
|
3845
4250
|
}
|
|
3846
4251
|
for (const circle of circles) {
|
|
3847
|
-
const screenCirclePos =
|
|
4252
|
+
const screenCirclePos = applyToPoint29(
|
|
3848
4253
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3849
4254
|
circle
|
|
3850
4255
|
);
|
|
@@ -3871,14 +4276,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3871
4276
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
3872
4277
|
import "schematic-symbols";
|
|
3873
4278
|
import "svgson";
|
|
3874
|
-
import { applyToPoint as
|
|
4279
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
3875
4280
|
|
|
3876
4281
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
3877
4282
|
import "transformation-matrix";
|
|
3878
4283
|
import "@tscircuit/circuit-json-util";
|
|
3879
4284
|
|
|
3880
4285
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
3881
|
-
import { applyToPoint as
|
|
4286
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3882
4287
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
3883
4288
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
3884
4289
|
var createSvgObjectsForSchPortBoxLine = ({
|
|
@@ -3908,8 +4313,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3908
4313
|
realEdgePos.y += realPinLineLength;
|
|
3909
4314
|
break;
|
|
3910
4315
|
}
|
|
3911
|
-
const screenSchPortPos =
|
|
3912
|
-
const screenRealEdgePos =
|
|
4316
|
+
const screenSchPortPos = applyToPoint30(transform, schPort.center);
|
|
4317
|
+
const screenRealEdgePos = applyToPoint30(transform, realEdgePos);
|
|
3913
4318
|
const realLineEnd = { ...schPort.center };
|
|
3914
4319
|
switch (schPort.side_of_component) {
|
|
3915
4320
|
case "left":
|
|
@@ -3925,7 +4330,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3925
4330
|
realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
|
|
3926
4331
|
break;
|
|
3927
4332
|
}
|
|
3928
|
-
const screenLineEnd =
|
|
4333
|
+
const screenLineEnd = applyToPoint30(transform, realLineEnd);
|
|
3929
4334
|
svgObjects.push({
|
|
3930
4335
|
name: "line",
|
|
3931
4336
|
type: "element",
|
|
@@ -3960,7 +4365,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3960
4365
|
};
|
|
3961
4366
|
|
|
3962
4367
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
3963
|
-
import { applyToPoint as
|
|
4368
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3964
4369
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
3965
4370
|
const svgObjects = [];
|
|
3966
4371
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -3978,7 +4383,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
3978
4383
|
} else {
|
|
3979
4384
|
realPinNumberPos.y += 0.02;
|
|
3980
4385
|
}
|
|
3981
|
-
const screenPinNumberTextPos =
|
|
4386
|
+
const screenPinNumberTextPos = applyToPoint31(transform, realPinNumberPos);
|
|
3982
4387
|
svgObjects.push({
|
|
3983
4388
|
name: "text",
|
|
3984
4389
|
type: "element",
|
|
@@ -4008,7 +4413,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
4008
4413
|
};
|
|
4009
4414
|
|
|
4010
4415
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
4011
|
-
import { applyToPoint as
|
|
4416
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
4012
4417
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
4013
4418
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
4014
4419
|
const svgObjects = [];
|
|
@@ -4022,7 +4427,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4022
4427
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
4023
4428
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4024
4429
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4025
|
-
const screenPinNumberTextPos =
|
|
4430
|
+
const screenPinNumberTextPos = applyToPoint32(transform, realPinNumberPos);
|
|
4026
4431
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
4027
4432
|
if (!label) return [];
|
|
4028
4433
|
const isNegated = label.startsWith("N_");
|
|
@@ -4066,13 +4471,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
4066
4471
|
};
|
|
4067
4472
|
|
|
4068
4473
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
4069
|
-
import { applyToPoint as
|
|
4474
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
4070
4475
|
var createSvgSchText = ({
|
|
4071
4476
|
elm,
|
|
4072
4477
|
transform,
|
|
4073
4478
|
colorMap: colorMap2
|
|
4074
4479
|
}) => {
|
|
4075
|
-
const center =
|
|
4480
|
+
const center = applyToPoint34(transform, elm.position);
|
|
4076
4481
|
const textAnchorMap = {
|
|
4077
4482
|
center: "middle",
|
|
4078
4483
|
center_right: "end",
|
|
@@ -4156,11 +4561,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
4156
4561
|
colorMap: colorMap2
|
|
4157
4562
|
}) => {
|
|
4158
4563
|
const svgObjects = [];
|
|
4159
|
-
const componentScreenTopLeft =
|
|
4564
|
+
const componentScreenTopLeft = applyToPoint35(transform, {
|
|
4160
4565
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
4161
4566
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
4162
4567
|
});
|
|
4163
|
-
const componentScreenBottomRight =
|
|
4568
|
+
const componentScreenBottomRight = applyToPoint35(transform, {
|
|
4164
4569
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
4165
4570
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
4166
4571
|
});
|
|
@@ -4243,13 +4648,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
4243
4648
|
}
|
|
4244
4649
|
|
|
4245
4650
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
4246
|
-
import { applyToPoint as
|
|
4651
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4247
4652
|
function createSvgObjectsFromSchVoltageProbe({
|
|
4248
4653
|
probe,
|
|
4249
4654
|
transform,
|
|
4250
4655
|
colorMap: colorMap2
|
|
4251
4656
|
}) {
|
|
4252
|
-
const [screenX, screenY] =
|
|
4657
|
+
const [screenX, screenY] = applyToPoint36(transform, [
|
|
4253
4658
|
probe.position.x,
|
|
4254
4659
|
probe.position.y
|
|
4255
4660
|
]);
|
|
@@ -4309,17 +4714,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
4309
4714
|
}
|
|
4310
4715
|
|
|
4311
4716
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
4312
|
-
import { applyToPoint as
|
|
4717
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4313
4718
|
function createSvgObjectsFromSchDebugObject({
|
|
4314
4719
|
debugObject,
|
|
4315
4720
|
transform
|
|
4316
4721
|
}) {
|
|
4317
4722
|
if (debugObject.shape === "rect") {
|
|
4318
|
-
let [screenLeft, screenTop] =
|
|
4723
|
+
let [screenLeft, screenTop] = applyToPoint37(transform, [
|
|
4319
4724
|
debugObject.center.x - debugObject.size.width / 2,
|
|
4320
4725
|
debugObject.center.y - debugObject.size.height / 2
|
|
4321
4726
|
]);
|
|
4322
|
-
let [screenRight, screenBottom] =
|
|
4727
|
+
let [screenRight, screenBottom] = applyToPoint37(transform, [
|
|
4323
4728
|
debugObject.center.x + debugObject.size.width / 2,
|
|
4324
4729
|
debugObject.center.y + debugObject.size.height / 2
|
|
4325
4730
|
]);
|
|
@@ -4329,7 +4734,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4329
4734
|
];
|
|
4330
4735
|
const width = Math.abs(screenRight - screenLeft);
|
|
4331
4736
|
const height = Math.abs(screenBottom - screenTop);
|
|
4332
|
-
const [screenCenterX, screenCenterY] =
|
|
4737
|
+
const [screenCenterX, screenCenterY] = applyToPoint37(transform, [
|
|
4333
4738
|
debugObject.center.x,
|
|
4334
4739
|
debugObject.center.y
|
|
4335
4740
|
]);
|
|
@@ -4375,11 +4780,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4375
4780
|
];
|
|
4376
4781
|
}
|
|
4377
4782
|
if (debugObject.shape === "line") {
|
|
4378
|
-
const [screenStartX, screenStartY] =
|
|
4783
|
+
const [screenStartX, screenStartY] = applyToPoint37(transform, [
|
|
4379
4784
|
debugObject.start.x,
|
|
4380
4785
|
debugObject.start.y
|
|
4381
4786
|
]);
|
|
4382
|
-
const [screenEndX, screenEndY] =
|
|
4787
|
+
const [screenEndX, screenEndY] = applyToPoint37(transform, [
|
|
4383
4788
|
debugObject.end.x,
|
|
4384
4789
|
debugObject.end.y
|
|
4385
4790
|
]);
|
|
@@ -4429,7 +4834,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4429
4834
|
}
|
|
4430
4835
|
|
|
4431
4836
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
4432
|
-
import { applyToPoint as
|
|
4837
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4433
4838
|
function createSchematicTrace({
|
|
4434
4839
|
trace,
|
|
4435
4840
|
transform,
|
|
@@ -4442,11 +4847,11 @@ function createSchematicTrace({
|
|
|
4442
4847
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
4443
4848
|
const edge = edges[edgeIndex];
|
|
4444
4849
|
if (edge.is_crossing) continue;
|
|
4445
|
-
const [screenFromX, screenFromY] =
|
|
4850
|
+
const [screenFromX, screenFromY] = applyToPoint38(transform, [
|
|
4446
4851
|
edge.from.x,
|
|
4447
4852
|
edge.from.y
|
|
4448
4853
|
]);
|
|
4449
|
-
const [screenToX, screenToY] =
|
|
4854
|
+
const [screenToX, screenToY] = applyToPoint38(transform, [
|
|
4450
4855
|
edge.to.x,
|
|
4451
4856
|
edge.to.y
|
|
4452
4857
|
]);
|
|
@@ -4458,11 +4863,11 @@ function createSchematicTrace({
|
|
|
4458
4863
|
}
|
|
4459
4864
|
for (const edge of edges) {
|
|
4460
4865
|
if (!edge.is_crossing) continue;
|
|
4461
|
-
const [screenFromX, screenFromY] =
|
|
4866
|
+
const [screenFromX, screenFromY] = applyToPoint38(transform, [
|
|
4462
4867
|
edge.from.x,
|
|
4463
4868
|
edge.from.y
|
|
4464
4869
|
]);
|
|
4465
|
-
const [screenToX, screenToY] =
|
|
4870
|
+
const [screenToX, screenToY] = applyToPoint38(transform, [
|
|
4466
4871
|
edge.to.x,
|
|
4467
4872
|
edge.to.y
|
|
4468
4873
|
]);
|
|
@@ -4538,7 +4943,7 @@ function createSchematicTrace({
|
|
|
4538
4943
|
}
|
|
4539
4944
|
if (trace.junctions) {
|
|
4540
4945
|
for (const junction of trace.junctions) {
|
|
4541
|
-
const [screenX, screenY] =
|
|
4946
|
+
const [screenX, screenY] = applyToPoint38(transform, [
|
|
4542
4947
|
junction.x,
|
|
4543
4948
|
junction.y
|
|
4544
4949
|
]);
|
|
@@ -4574,7 +4979,7 @@ function createSchematicTrace({
|
|
|
4574
4979
|
|
|
4575
4980
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
4576
4981
|
import {
|
|
4577
|
-
applyToPoint as
|
|
4982
|
+
applyToPoint as applyToPoint40,
|
|
4578
4983
|
compose as compose9,
|
|
4579
4984
|
rotate as rotate5,
|
|
4580
4985
|
scale as scale6,
|
|
@@ -4583,7 +4988,7 @@ import {
|
|
|
4583
4988
|
|
|
4584
4989
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
4585
4990
|
import {
|
|
4586
|
-
applyToPoint as
|
|
4991
|
+
applyToPoint as applyToPoint39,
|
|
4587
4992
|
compose as compose8,
|
|
4588
4993
|
rotate as rotate4,
|
|
4589
4994
|
scale as scale5,
|
|
@@ -4658,7 +5063,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4658
5063
|
x: symbolBounds.minX,
|
|
4659
5064
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
4660
5065
|
};
|
|
4661
|
-
const rotatedSymbolEnd =
|
|
5066
|
+
const rotatedSymbolEnd = applyToPoint39(rotationMatrix, symbolEndPoint);
|
|
4662
5067
|
const symbolToRealTransform = compose8(
|
|
4663
5068
|
translate8(
|
|
4664
5069
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -4668,11 +5073,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4668
5073
|
scale5(1)
|
|
4669
5074
|
// Use full symbol size
|
|
4670
5075
|
);
|
|
4671
|
-
const [screenMinX, screenMinY] =
|
|
5076
|
+
const [screenMinX, screenMinY] = applyToPoint39(
|
|
4672
5077
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4673
5078
|
[bounds.minX, bounds.minY]
|
|
4674
5079
|
);
|
|
4675
|
-
const [screenMaxX, screenMaxY] =
|
|
5080
|
+
const [screenMaxX, screenMaxY] = applyToPoint39(
|
|
4676
5081
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4677
5082
|
[bounds.maxX, bounds.maxY]
|
|
4678
5083
|
);
|
|
@@ -4696,7 +5101,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4696
5101
|
});
|
|
4697
5102
|
for (const path of symbolPaths) {
|
|
4698
5103
|
const symbolPath = path.points.map((p, i) => {
|
|
4699
|
-
const [x, y] =
|
|
5104
|
+
const [x, y] = applyToPoint39(
|
|
4700
5105
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4701
5106
|
[p.x, p.y]
|
|
4702
5107
|
);
|
|
@@ -4717,7 +5122,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4717
5122
|
});
|
|
4718
5123
|
}
|
|
4719
5124
|
for (const text of symbolTexts) {
|
|
4720
|
-
const screenTextPos =
|
|
5125
|
+
const screenTextPos = applyToPoint39(
|
|
4721
5126
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4722
5127
|
text
|
|
4723
5128
|
);
|
|
@@ -4759,7 +5164,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4759
5164
|
});
|
|
4760
5165
|
}
|
|
4761
5166
|
for (const box of symbolBoxes) {
|
|
4762
|
-
const screenBoxPos =
|
|
5167
|
+
const screenBoxPos = applyToPoint39(
|
|
4763
5168
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4764
5169
|
box
|
|
4765
5170
|
);
|
|
@@ -4782,7 +5187,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4782
5187
|
});
|
|
4783
5188
|
}
|
|
4784
5189
|
for (const circle of symbolCircles) {
|
|
4785
|
-
const screenCirclePos =
|
|
5190
|
+
const screenCirclePos = applyToPoint39(
|
|
4786
5191
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4787
5192
|
circle
|
|
4788
5193
|
);
|
|
@@ -4828,14 +5233,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4828
5233
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
4829
5234
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4830
5235
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
4831
|
-
const screenCenter =
|
|
5236
|
+
const screenCenter = applyToPoint40(realToScreenTransform, schNetLabel.center);
|
|
4832
5237
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4833
5238
|
schNetLabel.anchor_side
|
|
4834
5239
|
);
|
|
4835
5240
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
4836
5241
|
screenTextGrowthVec.y *= -1;
|
|
4837
5242
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
4838
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
5243
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint40(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
4839
5244
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
4840
5245
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
4841
5246
|
};
|
|
@@ -4876,7 +5281,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4876
5281
|
y: -0.6
|
|
4877
5282
|
}
|
|
4878
5283
|
].map(
|
|
4879
|
-
(fontRelativePoint) =>
|
|
5284
|
+
(fontRelativePoint) => applyToPoint40(
|
|
4880
5285
|
compose9(
|
|
4881
5286
|
realToScreenTransform,
|
|
4882
5287
|
translate9(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -4954,17 +5359,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4954
5359
|
};
|
|
4955
5360
|
|
|
4956
5361
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
4957
|
-
import { applyToPoint as
|
|
5362
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
4958
5363
|
var createSvgObjectsFromSchematicBox = ({
|
|
4959
5364
|
schematicBox,
|
|
4960
5365
|
transform,
|
|
4961
5366
|
colorMap: colorMap2
|
|
4962
5367
|
}) => {
|
|
4963
|
-
const topLeft =
|
|
5368
|
+
const topLeft = applyToPoint41(transform, {
|
|
4964
5369
|
x: schematicBox.x,
|
|
4965
5370
|
y: schematicBox.y
|
|
4966
5371
|
});
|
|
4967
|
-
const bottomRight =
|
|
5372
|
+
const bottomRight = applyToPoint41(transform, {
|
|
4968
5373
|
x: schematicBox.x + schematicBox.width,
|
|
4969
5374
|
y: schematicBox.y + schematicBox.height
|
|
4970
5375
|
});
|
|
@@ -5206,18 +5611,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
5206
5611
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
5207
5612
|
import { stringify as stringify4 } from "svgson";
|
|
5208
5613
|
import {
|
|
5209
|
-
applyToPoint as
|
|
5614
|
+
applyToPoint as applyToPoint44,
|
|
5210
5615
|
compose as compose11,
|
|
5211
5616
|
scale as scale8,
|
|
5212
5617
|
translate as translate11
|
|
5213
5618
|
} from "transformation-matrix";
|
|
5214
5619
|
|
|
5215
5620
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
5216
|
-
import { applyToPoint as
|
|
5621
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5217
5622
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
5218
5623
|
const { transform, layer: layerFilter } = ctx;
|
|
5219
5624
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
5220
|
-
const [x, y] =
|
|
5625
|
+
const [x, y] = applyToPoint43(transform, [solderPaste.x, solderPaste.y]);
|
|
5221
5626
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
5222
5627
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
5223
5628
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -5416,8 +5821,8 @@ function createSvgObjects3({ elm, ctx }) {
|
|
|
5416
5821
|
}
|
|
5417
5822
|
}
|
|
5418
5823
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
5419
|
-
const [x1, y1] =
|
|
5420
|
-
const [x2, y2] =
|
|
5824
|
+
const [x1, y1] = applyToPoint44(transform, [minX, minY]);
|
|
5825
|
+
const [x2, y2] = applyToPoint44(transform, [maxX, maxY]);
|
|
5421
5826
|
const width = Math.abs(x2 - x1);
|
|
5422
5827
|
const height = Math.abs(y2 - y1);
|
|
5423
5828
|
const x = Math.min(x1, x2);
|