circuit-to-svg 0.0.162 → 0.0.164
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 +476 -80
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1799,7 +1799,7 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
1799
1799
|
import { stringify as stringify2 } from "svgson";
|
|
1800
1800
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
1801
1801
|
import {
|
|
1802
|
-
applyToPoint as
|
|
1802
|
+
applyToPoint as applyToPoint25,
|
|
1803
1803
|
compose as compose5,
|
|
1804
1804
|
scale as scale3,
|
|
1805
1805
|
translate as translate5
|
|
@@ -1866,8 +1866,16 @@ import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
|
1866
1866
|
|
|
1867
1867
|
// lib/utils/get-sch-font-size.ts
|
|
1868
1868
|
import "transformation-matrix";
|
|
1869
|
+
var fontSizeMap = {
|
|
1870
|
+
pin_number: 0.15,
|
|
1871
|
+
negated_pin_number: 0.15 * 0.8,
|
|
1872
|
+
reference_designator: 0.18,
|
|
1873
|
+
manufacturer_number: 0.18,
|
|
1874
|
+
net_label: 0.18,
|
|
1875
|
+
error: 0.05
|
|
1876
|
+
};
|
|
1869
1877
|
var getSchMmFontSize = (textType, fontSize) => {
|
|
1870
|
-
return
|
|
1878
|
+
return fontSize ?? fontSizeMap[textType];
|
|
1871
1879
|
};
|
|
1872
1880
|
var getSchScreenFontSize = (transform, textType, fontSize) => {
|
|
1873
1881
|
return Math.abs(transform.a) * getSchMmFontSize(textType, fontSize);
|
|
@@ -2042,8 +2050,387 @@ function getRectPathData(w, h, rotation) {
|
|
|
2042
2050
|
return `${path} Z`;
|
|
2043
2051
|
}
|
|
2044
2052
|
|
|
2053
|
+
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
2054
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2055
|
+
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
2056
|
+
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
2057
|
+
const { transform } = ctx;
|
|
2058
|
+
const [x, y] = applyToPoint22(transform, [hole.x, hole.y]);
|
|
2059
|
+
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
2060
|
+
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2061
|
+
const radius = scaledDiameter / 2;
|
|
2062
|
+
if (hole.hole_shape === "circle") {
|
|
2063
|
+
return [
|
|
2064
|
+
{
|
|
2065
|
+
name: "circle",
|
|
2066
|
+
type: "element",
|
|
2067
|
+
attributes: {
|
|
2068
|
+
class: "assembly-hole",
|
|
2069
|
+
cx: x.toString(),
|
|
2070
|
+
cy: y.toString(),
|
|
2071
|
+
r: radius.toString(),
|
|
2072
|
+
fill: HOLE_COLOR2
|
|
2073
|
+
},
|
|
2074
|
+
children: [],
|
|
2075
|
+
value: ""
|
|
2076
|
+
}
|
|
2077
|
+
];
|
|
2078
|
+
}
|
|
2079
|
+
return [
|
|
2080
|
+
{
|
|
2081
|
+
name: "rect",
|
|
2082
|
+
type: "element",
|
|
2083
|
+
attributes: {
|
|
2084
|
+
class: "assembly-hole",
|
|
2085
|
+
x: (x - radius).toString(),
|
|
2086
|
+
y: (y - radius).toString(),
|
|
2087
|
+
width: scaledDiameter.toString(),
|
|
2088
|
+
height: scaledDiameter.toString(),
|
|
2089
|
+
fill: HOLE_COLOR2
|
|
2090
|
+
},
|
|
2091
|
+
children: [],
|
|
2092
|
+
value: ""
|
|
2093
|
+
}
|
|
2094
|
+
];
|
|
2095
|
+
}
|
|
2096
|
+
if (hole.hole_shape === "oval") {
|
|
2097
|
+
const scaledWidth = hole.hole_width * Math.abs(transform.a);
|
|
2098
|
+
const scaledHeight = hole.hole_height * Math.abs(transform.a);
|
|
2099
|
+
const rx = scaledWidth / 2;
|
|
2100
|
+
const ry = scaledHeight / 2;
|
|
2101
|
+
return [
|
|
2102
|
+
{
|
|
2103
|
+
name: "ellipse",
|
|
2104
|
+
type: "element",
|
|
2105
|
+
attributes: {
|
|
2106
|
+
class: "assembly-hole",
|
|
2107
|
+
cx: x.toString(),
|
|
2108
|
+
cy: y.toString(),
|
|
2109
|
+
rx: rx.toString(),
|
|
2110
|
+
ry: ry.toString(),
|
|
2111
|
+
fill: HOLE_COLOR2
|
|
2112
|
+
},
|
|
2113
|
+
children: [],
|
|
2114
|
+
value: ""
|
|
2115
|
+
}
|
|
2116
|
+
];
|
|
2117
|
+
}
|
|
2118
|
+
return [];
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
2122
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
2123
|
+
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
2124
|
+
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
2125
|
+
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
2126
|
+
const { transform } = ctx;
|
|
2127
|
+
const [x, y] = applyToPoint23(transform, [hole.x, hole.y]);
|
|
2128
|
+
if (hole.shape === "pill") {
|
|
2129
|
+
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
2130
|
+
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
2131
|
+
const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
|
|
2132
|
+
const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
|
|
2133
|
+
const outerRadiusX = scaledOuterWidth / 2;
|
|
2134
|
+
const straightLength = scaledOuterHeight - scaledOuterWidth;
|
|
2135
|
+
const innerRadiusX = scaledHoleWidth / 2;
|
|
2136
|
+
return [
|
|
2137
|
+
{
|
|
2138
|
+
name: "g",
|
|
2139
|
+
type: "element",
|
|
2140
|
+
children: [
|
|
2141
|
+
// Outer pill shape
|
|
2142
|
+
{
|
|
2143
|
+
name: "path",
|
|
2144
|
+
type: "element",
|
|
2145
|
+
attributes: {
|
|
2146
|
+
class: "assembly-hole-outer",
|
|
2147
|
+
fill: PAD_COLOR,
|
|
2148
|
+
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`
|
|
2149
|
+
},
|
|
2150
|
+
value: "",
|
|
2151
|
+
children: []
|
|
2152
|
+
},
|
|
2153
|
+
// Inner pill shape
|
|
2154
|
+
{
|
|
2155
|
+
name: "path",
|
|
2156
|
+
type: "element",
|
|
2157
|
+
attributes: {
|
|
2158
|
+
class: "assembly-hole-inner",
|
|
2159
|
+
fill: HOLE_COLOR3,
|
|
2160
|
+
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`
|
|
2161
|
+
},
|
|
2162
|
+
value: "",
|
|
2163
|
+
children: []
|
|
2164
|
+
}
|
|
2165
|
+
],
|
|
2166
|
+
value: "",
|
|
2167
|
+
attributes: {}
|
|
2168
|
+
}
|
|
2169
|
+
];
|
|
2170
|
+
}
|
|
2171
|
+
if (hole.shape === "circle") {
|
|
2172
|
+
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
2173
|
+
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
2174
|
+
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
2175
|
+
const scaledHoleHeight = hole.hole_diameter * Math.abs(transform.a);
|
|
2176
|
+
const outerRadius = Math.min(scaledOuterWidth, scaledOuterHeight) / 2;
|
|
2177
|
+
const innerRadius = Math.min(scaledHoleWidth, scaledHoleHeight) / 2;
|
|
2178
|
+
return [
|
|
2179
|
+
{
|
|
2180
|
+
name: "g",
|
|
2181
|
+
type: "element",
|
|
2182
|
+
children: [
|
|
2183
|
+
{
|
|
2184
|
+
name: "circle",
|
|
2185
|
+
type: "element",
|
|
2186
|
+
attributes: {
|
|
2187
|
+
class: "assembly-hole-outer",
|
|
2188
|
+
fill: PAD_COLOR,
|
|
2189
|
+
cx: x.toString(),
|
|
2190
|
+
cy: y.toString(),
|
|
2191
|
+
r: outerRadius.toString()
|
|
2192
|
+
},
|
|
2193
|
+
value: "",
|
|
2194
|
+
children: []
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
name: "circle",
|
|
2198
|
+
type: "element",
|
|
2199
|
+
attributes: {
|
|
2200
|
+
class: "assembly-hole-inner",
|
|
2201
|
+
fill: HOLE_COLOR3,
|
|
2202
|
+
cx: x.toString(),
|
|
2203
|
+
cy: y.toString(),
|
|
2204
|
+
r: innerRadius.toString()
|
|
2205
|
+
},
|
|
2206
|
+
value: "",
|
|
2207
|
+
children: []
|
|
2208
|
+
}
|
|
2209
|
+
],
|
|
2210
|
+
value: "",
|
|
2211
|
+
attributes: {}
|
|
2212
|
+
}
|
|
2213
|
+
];
|
|
2214
|
+
}
|
|
2215
|
+
if (hole.shape === "circular_hole_with_rect_pad") {
|
|
2216
|
+
const scaledHoleDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2217
|
+
const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
|
|
2218
|
+
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
2219
|
+
const holeRadius = scaledHoleDiameter / 2;
|
|
2220
|
+
return [
|
|
2221
|
+
{
|
|
2222
|
+
name: "g",
|
|
2223
|
+
type: "element",
|
|
2224
|
+
children: [
|
|
2225
|
+
// Rectangular pad (outer shape)
|
|
2226
|
+
{
|
|
2227
|
+
name: "rect",
|
|
2228
|
+
type: "element",
|
|
2229
|
+
attributes: {
|
|
2230
|
+
class: "assembly-hole-outer-pad",
|
|
2231
|
+
fill: PAD_COLOR,
|
|
2232
|
+
x: (x - scaledRectPadWidth / 2).toString(),
|
|
2233
|
+
y: (y - scaledRectPadHeight / 2).toString(),
|
|
2234
|
+
width: scaledRectPadWidth.toString(),
|
|
2235
|
+
height: scaledRectPadHeight.toString()
|
|
2236
|
+
},
|
|
2237
|
+
value: "",
|
|
2238
|
+
children: []
|
|
2239
|
+
},
|
|
2240
|
+
// Circular hole inside the rectangle
|
|
2241
|
+
{
|
|
2242
|
+
name: "circle",
|
|
2243
|
+
type: "element",
|
|
2244
|
+
attributes: {
|
|
2245
|
+
class: "assembly-hole-inner",
|
|
2246
|
+
fill: HOLE_COLOR3,
|
|
2247
|
+
cx: x.toString(),
|
|
2248
|
+
cy: y.toString(),
|
|
2249
|
+
r: holeRadius.toString()
|
|
2250
|
+
},
|
|
2251
|
+
value: "",
|
|
2252
|
+
children: []
|
|
2253
|
+
}
|
|
2254
|
+
],
|
|
2255
|
+
value: "",
|
|
2256
|
+
attributes: {}
|
|
2257
|
+
}
|
|
2258
|
+
];
|
|
2259
|
+
}
|
|
2260
|
+
if (hole.shape === "pill_hole_with_rect_pad") {
|
|
2261
|
+
const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
|
|
2262
|
+
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
2263
|
+
const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
|
|
2264
|
+
const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
|
|
2265
|
+
const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
|
|
2266
|
+
return [
|
|
2267
|
+
{
|
|
2268
|
+
name: "g",
|
|
2269
|
+
type: "element",
|
|
2270
|
+
children: [
|
|
2271
|
+
// Rectangular pad (outer shape)
|
|
2272
|
+
{
|
|
2273
|
+
name: "rect",
|
|
2274
|
+
type: "element",
|
|
2275
|
+
attributes: {
|
|
2276
|
+
class: "assembly-hole-outer-pad",
|
|
2277
|
+
fill: PAD_COLOR,
|
|
2278
|
+
x: (x - scaledRectPadWidth / 2).toString(),
|
|
2279
|
+
y: (y - scaledRectPadHeight / 2).toString(),
|
|
2280
|
+
width: scaledRectPadWidth.toString(),
|
|
2281
|
+
height: scaledRectPadHeight.toString()
|
|
2282
|
+
},
|
|
2283
|
+
value: "",
|
|
2284
|
+
children: []
|
|
2285
|
+
},
|
|
2286
|
+
// pill hole inside the rectangle
|
|
2287
|
+
{
|
|
2288
|
+
name: "rect",
|
|
2289
|
+
type: "element",
|
|
2290
|
+
attributes: {
|
|
2291
|
+
class: "assembly-hole-inner",
|
|
2292
|
+
fill: HOLE_COLOR3,
|
|
2293
|
+
x: (x - scaledHoleWidth / 2).toString(),
|
|
2294
|
+
y: (y - scaledHoleHeight / 2).toString(),
|
|
2295
|
+
width: scaledHoleWidth.toString(),
|
|
2296
|
+
height: scaledHoleHeight.toString(),
|
|
2297
|
+
rx: holeRadius.toString(),
|
|
2298
|
+
ry: holeRadius.toString()
|
|
2299
|
+
},
|
|
2300
|
+
value: "",
|
|
2301
|
+
children: []
|
|
2302
|
+
}
|
|
2303
|
+
],
|
|
2304
|
+
value: "",
|
|
2305
|
+
attributes: {}
|
|
2306
|
+
}
|
|
2307
|
+
];
|
|
2308
|
+
}
|
|
2309
|
+
return [];
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
2313
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2314
|
+
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
2315
|
+
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
2316
|
+
const { transform } = ctx;
|
|
2317
|
+
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
2318
|
+
const width = pad.width * Math.abs(transform.a);
|
|
2319
|
+
const height = pad.height * Math.abs(transform.d);
|
|
2320
|
+
const [x, y] = applyToPoint24(transform, [pad.x, pad.y]);
|
|
2321
|
+
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
2322
|
+
return [
|
|
2323
|
+
{
|
|
2324
|
+
name: "rect",
|
|
2325
|
+
type: "element",
|
|
2326
|
+
attributes: {
|
|
2327
|
+
class: "assembly-pad",
|
|
2328
|
+
fill: PAD_COLOR2,
|
|
2329
|
+
x: (-width / 2).toString(),
|
|
2330
|
+
y: (-height / 2).toString(),
|
|
2331
|
+
width: width.toString(),
|
|
2332
|
+
height: height.toString(),
|
|
2333
|
+
transform: `translate(${x} ${y}) rotate(${-pad.ccw_rotation})`,
|
|
2334
|
+
"data-layer": pad.layer
|
|
2335
|
+
},
|
|
2336
|
+
value: "",
|
|
2337
|
+
children: []
|
|
2338
|
+
}
|
|
2339
|
+
];
|
|
2340
|
+
}
|
|
2341
|
+
return [
|
|
2342
|
+
{
|
|
2343
|
+
name: "rect",
|
|
2344
|
+
type: "element",
|
|
2345
|
+
attributes: {
|
|
2346
|
+
class: "assembly-pad",
|
|
2347
|
+
fill: PAD_COLOR2,
|
|
2348
|
+
x: (x - width / 2).toString(),
|
|
2349
|
+
y: (y - height / 2).toString(),
|
|
2350
|
+
width: width.toString(),
|
|
2351
|
+
height: height.toString(),
|
|
2352
|
+
"data-layer": pad.layer
|
|
2353
|
+
},
|
|
2354
|
+
value: "",
|
|
2355
|
+
children: []
|
|
2356
|
+
}
|
|
2357
|
+
];
|
|
2358
|
+
}
|
|
2359
|
+
if (pad.shape === "pill") {
|
|
2360
|
+
const width = pad.width * Math.abs(transform.a);
|
|
2361
|
+
const height = pad.height * Math.abs(transform.d);
|
|
2362
|
+
const radius = pad.radius * Math.abs(transform.a);
|
|
2363
|
+
const [x, y] = applyToPoint24(transform, [pad.x, pad.y]);
|
|
2364
|
+
return [
|
|
2365
|
+
{
|
|
2366
|
+
name: "rect",
|
|
2367
|
+
type: "element",
|
|
2368
|
+
attributes: {
|
|
2369
|
+
class: "assembly-pad",
|
|
2370
|
+
fill: PAD_COLOR2,
|
|
2371
|
+
x: (x - width / 2).toString(),
|
|
2372
|
+
y: (y - height / 2).toString(),
|
|
2373
|
+
width: width.toString(),
|
|
2374
|
+
height: height.toString(),
|
|
2375
|
+
rx: radius.toString(),
|
|
2376
|
+
ry: radius.toString(),
|
|
2377
|
+
"data-layer": pad.layer
|
|
2378
|
+
},
|
|
2379
|
+
value: "",
|
|
2380
|
+
children: []
|
|
2381
|
+
}
|
|
2382
|
+
];
|
|
2383
|
+
}
|
|
2384
|
+
if (pad.shape === "circle") {
|
|
2385
|
+
const radius = pad.radius * Math.abs(transform.a);
|
|
2386
|
+
const [x, y] = applyToPoint24(transform, [pad.x, pad.y]);
|
|
2387
|
+
return [
|
|
2388
|
+
{
|
|
2389
|
+
name: "circle",
|
|
2390
|
+
type: "element",
|
|
2391
|
+
attributes: {
|
|
2392
|
+
class: "assembly-pad",
|
|
2393
|
+
fill: PAD_COLOR2,
|
|
2394
|
+
cx: x.toString(),
|
|
2395
|
+
cy: y.toString(),
|
|
2396
|
+
r: radius.toString(),
|
|
2397
|
+
"data-layer": pad.layer
|
|
2398
|
+
},
|
|
2399
|
+
value: "",
|
|
2400
|
+
children: []
|
|
2401
|
+
}
|
|
2402
|
+
];
|
|
2403
|
+
}
|
|
2404
|
+
if (pad.shape === "polygon") {
|
|
2405
|
+
const points = (pad.points ?? []).map(
|
|
2406
|
+
(point) => applyToPoint24(transform, [point.x, point.y])
|
|
2407
|
+
);
|
|
2408
|
+
return [
|
|
2409
|
+
{
|
|
2410
|
+
name: "polygon",
|
|
2411
|
+
type: "element",
|
|
2412
|
+
attributes: {
|
|
2413
|
+
class: "assembly-pad",
|
|
2414
|
+
fill: PAD_COLOR2,
|
|
2415
|
+
points: points.map((p) => p.join(",")).join(" "),
|
|
2416
|
+
"data-layer": pad.layer
|
|
2417
|
+
},
|
|
2418
|
+
value: "",
|
|
2419
|
+
children: []
|
|
2420
|
+
}
|
|
2421
|
+
];
|
|
2422
|
+
}
|
|
2423
|
+
return [];
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2045
2426
|
// lib/assembly/convert-circuit-json-to-assembly-svg.ts
|
|
2046
|
-
var OBJECT_ORDER2 = [
|
|
2427
|
+
var OBJECT_ORDER2 = [
|
|
2428
|
+
"pcb_component",
|
|
2429
|
+
"pcb_smtpad",
|
|
2430
|
+
"pcb_hole",
|
|
2431
|
+
"pcb_plated_hole",
|
|
2432
|
+
"pcb_board"
|
|
2433
|
+
];
|
|
2047
2434
|
function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
2048
2435
|
let minX = Number.POSITIVE_INFINITY;
|
|
2049
2436
|
let minY = Number.POSITIVE_INFINITY;
|
|
@@ -2078,9 +2465,10 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2078
2465
|
scale3(scaleFactor, -scaleFactor)
|
|
2079
2466
|
// Flip in y-direction
|
|
2080
2467
|
);
|
|
2468
|
+
const ctx = { transform };
|
|
2081
2469
|
const svgObjects = soup.sort(
|
|
2082
2470
|
(a, b) => (OBJECT_ORDER2.indexOf(b.type) ?? 9999) - (OBJECT_ORDER2.indexOf(a.type) ?? 9999)
|
|
2083
|
-
).flatMap((item) => createSvgObjects2(item,
|
|
2471
|
+
).flatMap((item) => createSvgObjects2(item, ctx, soup));
|
|
2084
2472
|
const softwareUsedString = getSoftwareUsedString(soup);
|
|
2085
2473
|
const svgObject = {
|
|
2086
2474
|
name: "svg",
|
|
@@ -2103,7 +2491,7 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2103
2491
|
type: "text",
|
|
2104
2492
|
value: `
|
|
2105
2493
|
.assembly-component {
|
|
2106
|
-
fill:
|
|
2494
|
+
fill: none;
|
|
2107
2495
|
stroke: #000;
|
|
2108
2496
|
}
|
|
2109
2497
|
.assembly-board {
|
|
@@ -2151,11 +2539,11 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2151
2539
|
};
|
|
2152
2540
|
return stringify2(svgObject);
|
|
2153
2541
|
}
|
|
2154
|
-
function createSvgObjects2(elm,
|
|
2542
|
+
function createSvgObjects2(elm, ctx, soup) {
|
|
2155
2543
|
const sourceComponents = su3(soup).source_component.list();
|
|
2156
2544
|
switch (elm.type) {
|
|
2157
2545
|
case "pcb_board":
|
|
2158
|
-
return createSvgObjectsFromAssemblyBoard(elm, transform);
|
|
2546
|
+
return createSvgObjectsFromAssemblyBoard(elm, ctx.transform);
|
|
2159
2547
|
case "pcb_component": {
|
|
2160
2548
|
const sourceComponent = sourceComponents.find(
|
|
2161
2549
|
(item) => item.source_component_id === elm.source_component_id
|
|
@@ -2171,19 +2559,25 @@ function createSvgObjects2(elm, transform, soup) {
|
|
|
2171
2559
|
name: sourceComponent.name,
|
|
2172
2560
|
arePinsInterchangeable
|
|
2173
2561
|
},
|
|
2174
|
-
|
|
2562
|
+
ctx
|
|
2175
2563
|
);
|
|
2176
2564
|
return obj ? [obj] : [];
|
|
2177
2565
|
}
|
|
2178
2566
|
return [];
|
|
2179
2567
|
}
|
|
2568
|
+
case "pcb_smtpad":
|
|
2569
|
+
return createSvgObjectsFromAssemblySmtPad(elm, ctx);
|
|
2570
|
+
case "pcb_hole":
|
|
2571
|
+
return createSvgObjectsFromAssemblyHole(elm, ctx);
|
|
2572
|
+
case "pcb_plated_hole":
|
|
2573
|
+
return createSvgObjectsFromAssemblyPlatedHole(elm, ctx);
|
|
2180
2574
|
default:
|
|
2181
2575
|
return [];
|
|
2182
2576
|
}
|
|
2183
2577
|
}
|
|
2184
2578
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
2185
|
-
const [x1, y1] =
|
|
2186
|
-
const [x2, y2] =
|
|
2579
|
+
const [x1, y1] = applyToPoint25(transform, [minX, minY]);
|
|
2580
|
+
const [x2, y2] = applyToPoint25(transform, [maxX, maxY]);
|
|
2187
2581
|
const width = Math.abs(x2 - x1);
|
|
2188
2582
|
const height = Math.abs(y2 - y1);
|
|
2189
2583
|
const x = Math.min(x1, x2);
|
|
@@ -2449,14 +2843,14 @@ import {
|
|
|
2449
2843
|
} from "transformation-matrix";
|
|
2450
2844
|
|
|
2451
2845
|
// lib/sch/draw-schematic-grid.ts
|
|
2452
|
-
import { applyToPoint as
|
|
2846
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2453
2847
|
function drawSchematicGrid(params) {
|
|
2454
2848
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
2455
2849
|
const cellSize = params.cellSize ?? 1;
|
|
2456
2850
|
const labelCells = params.labelCells ?? false;
|
|
2457
2851
|
const gridLines = [];
|
|
2458
2852
|
const transformPoint = (x, y) => {
|
|
2459
|
-
const [transformedX, transformedY] =
|
|
2853
|
+
const [transformedX, transformedY] = applyToPoint26(params.transform, [x, y]);
|
|
2460
2854
|
return { x: transformedX, y: transformedY };
|
|
2461
2855
|
};
|
|
2462
2856
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -2537,15 +2931,15 @@ function drawSchematicGrid(params) {
|
|
|
2537
2931
|
}
|
|
2538
2932
|
|
|
2539
2933
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
2540
|
-
import { applyToPoint as
|
|
2934
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2541
2935
|
function drawSchematicLabeledPoints(params) {
|
|
2542
2936
|
const { points, transform } = params;
|
|
2543
2937
|
const labeledPointsGroup = [];
|
|
2544
2938
|
for (const point of points) {
|
|
2545
|
-
const [x1, y1] =
|
|
2546
|
-
const [x2, y2] =
|
|
2547
|
-
const [x3, y3] =
|
|
2548
|
-
const [x4, y4] =
|
|
2939
|
+
const [x1, y1] = applyToPoint27(transform, [point.x - 0.1, point.y - 0.1]);
|
|
2940
|
+
const [x2, y2] = applyToPoint27(transform, [point.x + 0.1, point.y + 0.1]);
|
|
2941
|
+
const [x3, y3] = applyToPoint27(transform, [point.x - 0.1, point.y + 0.1]);
|
|
2942
|
+
const [x4, y4] = applyToPoint27(transform, [point.x + 0.1, point.y - 0.1]);
|
|
2549
2943
|
labeledPointsGroup.push({
|
|
2550
2944
|
name: "path",
|
|
2551
2945
|
type: "element",
|
|
@@ -2556,7 +2950,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
2556
2950
|
"stroke-opacity": "0.7"
|
|
2557
2951
|
}
|
|
2558
2952
|
});
|
|
2559
|
-
const [labelX, labelY] =
|
|
2953
|
+
const [labelX, labelY] = applyToPoint27(transform, [
|
|
2560
2954
|
point.x + 0.15,
|
|
2561
2955
|
point.y - 0.15
|
|
2562
2956
|
]);
|
|
@@ -3525,7 +3919,7 @@ import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
|
3525
3919
|
import { symbols } from "schematic-symbols";
|
|
3526
3920
|
import "svgson";
|
|
3527
3921
|
import {
|
|
3528
|
-
applyToPoint as
|
|
3922
|
+
applyToPoint as applyToPoint29,
|
|
3529
3923
|
compose as compose7
|
|
3530
3924
|
} from "transformation-matrix";
|
|
3531
3925
|
|
|
@@ -3609,13 +4003,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
3609
4003
|
}
|
|
3610
4004
|
|
|
3611
4005
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
3612
|
-
import { applyToPoint as
|
|
4006
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
3613
4007
|
var createSvgSchErrorText = ({
|
|
3614
4008
|
text,
|
|
3615
4009
|
realCenter,
|
|
3616
4010
|
realToScreenTransform
|
|
3617
4011
|
}) => {
|
|
3618
|
-
const screenCenter =
|
|
4012
|
+
const screenCenter = applyToPoint28(realToScreenTransform, realCenter);
|
|
3619
4013
|
return {
|
|
3620
4014
|
type: "element",
|
|
3621
4015
|
name: "text",
|
|
@@ -3724,11 +4118,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3724
4118
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
3725
4119
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
3726
4120
|
};
|
|
3727
|
-
const [screenMinX, screenMinY] =
|
|
4121
|
+
const [screenMinX, screenMinY] = applyToPoint29(
|
|
3728
4122
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3729
4123
|
[bounds.minX, bounds.minY]
|
|
3730
4124
|
);
|
|
3731
|
-
const [screenMaxX, screenMaxY] =
|
|
4125
|
+
const [screenMaxX, screenMaxY] = applyToPoint29(
|
|
3732
4126
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3733
4127
|
[bounds.maxX, bounds.maxY]
|
|
3734
4128
|
);
|
|
@@ -3757,7 +4151,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3757
4151
|
name: "path",
|
|
3758
4152
|
attributes: {
|
|
3759
4153
|
d: points.map((p, i) => {
|
|
3760
|
-
const [x, y] =
|
|
4154
|
+
const [x, y] = applyToPoint29(
|
|
3761
4155
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3762
4156
|
[p.x, p.y]
|
|
3763
4157
|
);
|
|
@@ -3773,7 +4167,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3773
4167
|
});
|
|
3774
4168
|
}
|
|
3775
4169
|
for (const text of texts) {
|
|
3776
|
-
const screenTextPos =
|
|
4170
|
+
const screenTextPos = applyToPoint29(
|
|
3777
4171
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3778
4172
|
text
|
|
3779
4173
|
);
|
|
@@ -3819,7 +4213,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3819
4213
|
});
|
|
3820
4214
|
}
|
|
3821
4215
|
for (const box of boxes) {
|
|
3822
|
-
const screenBoxPos =
|
|
4216
|
+
const screenBoxPos = applyToPoint29(
|
|
3823
4217
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3824
4218
|
box
|
|
3825
4219
|
);
|
|
@@ -3843,7 +4237,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3843
4237
|
}
|
|
3844
4238
|
for (const port of symbol.ports) {
|
|
3845
4239
|
if (connectedSymbolPorts.has(port)) continue;
|
|
3846
|
-
const screenPortPos =
|
|
4240
|
+
const screenPortPos = applyToPoint29(
|
|
3847
4241
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3848
4242
|
port
|
|
3849
4243
|
);
|
|
@@ -3863,7 +4257,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3863
4257
|
});
|
|
3864
4258
|
}
|
|
3865
4259
|
for (const circle of circles) {
|
|
3866
|
-
const screenCirclePos =
|
|
4260
|
+
const screenCirclePos = applyToPoint29(
|
|
3867
4261
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3868
4262
|
circle
|
|
3869
4263
|
);
|
|
@@ -3890,14 +4284,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3890
4284
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
3891
4285
|
import "schematic-symbols";
|
|
3892
4286
|
import "svgson";
|
|
3893
|
-
import { applyToPoint as
|
|
4287
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
3894
4288
|
|
|
3895
4289
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
3896
4290
|
import "transformation-matrix";
|
|
3897
4291
|
import "@tscircuit/circuit-json-util";
|
|
3898
4292
|
|
|
3899
4293
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
3900
|
-
import { applyToPoint as
|
|
4294
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3901
4295
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
3902
4296
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
3903
4297
|
var createSvgObjectsForSchPortBoxLine = ({
|
|
@@ -3927,8 +4321,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3927
4321
|
realEdgePos.y += realPinLineLength;
|
|
3928
4322
|
break;
|
|
3929
4323
|
}
|
|
3930
|
-
const screenSchPortPos =
|
|
3931
|
-
const screenRealEdgePos =
|
|
4324
|
+
const screenSchPortPos = applyToPoint30(transform, schPort.center);
|
|
4325
|
+
const screenRealEdgePos = applyToPoint30(transform, realEdgePos);
|
|
3932
4326
|
const realLineEnd = { ...schPort.center };
|
|
3933
4327
|
switch (schPort.side_of_component) {
|
|
3934
4328
|
case "left":
|
|
@@ -3944,7 +4338,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3944
4338
|
realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
|
|
3945
4339
|
break;
|
|
3946
4340
|
}
|
|
3947
|
-
const screenLineEnd =
|
|
4341
|
+
const screenLineEnd = applyToPoint30(transform, realLineEnd);
|
|
3948
4342
|
svgObjects.push({
|
|
3949
4343
|
name: "line",
|
|
3950
4344
|
type: "element",
|
|
@@ -3979,7 +4373,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3979
4373
|
};
|
|
3980
4374
|
|
|
3981
4375
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
3982
|
-
import { applyToPoint as
|
|
4376
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3983
4377
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
3984
4378
|
const svgObjects = [];
|
|
3985
4379
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -3997,7 +4391,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
3997
4391
|
} else {
|
|
3998
4392
|
realPinNumberPos.y += 0.02;
|
|
3999
4393
|
}
|
|
4000
|
-
const screenPinNumberTextPos =
|
|
4394
|
+
const screenPinNumberTextPos = applyToPoint31(transform, realPinNumberPos);
|
|
4001
4395
|
svgObjects.push({
|
|
4002
4396
|
name: "text",
|
|
4003
4397
|
type: "element",
|
|
@@ -4027,7 +4421,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
4027
4421
|
};
|
|
4028
4422
|
|
|
4029
4423
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
4030
|
-
import { applyToPoint as
|
|
4424
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
4031
4425
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
4032
4426
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
4033
4427
|
const svgObjects = [];
|
|
@@ -4041,11 +4435,15 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4041
4435
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
4042
4436
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4043
4437
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4044
|
-
const screenPinNumberTextPos =
|
|
4438
|
+
const screenPinNumberTextPos = applyToPoint32(transform, realPinNumberPos);
|
|
4045
4439
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
4046
4440
|
if (!label) return [];
|
|
4047
4441
|
const isNegated = label.startsWith("N_");
|
|
4048
4442
|
const displayLabel = isNegated ? label.slice(2) : label;
|
|
4443
|
+
let fontSizePx = getSchScreenFontSize(
|
|
4444
|
+
transform,
|
|
4445
|
+
isNegated ? "negated_pin_number" : "pin_number"
|
|
4446
|
+
);
|
|
4049
4447
|
svgObjects.push({
|
|
4050
4448
|
name: "text",
|
|
4051
4449
|
type: "element",
|
|
@@ -4057,7 +4455,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4057
4455
|
fill: colorMap.schematic.pin_number,
|
|
4058
4456
|
"text-anchor": schPort.side_of_component === "left" || schPort.side_of_component === "bottom" ? "start" : "end",
|
|
4059
4457
|
"dominant-baseline": "middle",
|
|
4060
|
-
"font-size": `${
|
|
4458
|
+
"font-size": `${fontSizePx}px`,
|
|
4061
4459
|
transform: schPort.side_of_component === "top" || schPort.side_of_component === "bottom" ? `rotate(-90 ${screenPinNumberTextPos.x} ${screenPinNumberTextPos.y})` : ""
|
|
4062
4460
|
},
|
|
4063
4461
|
children: [
|
|
@@ -4085,13 +4483,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
4085
4483
|
};
|
|
4086
4484
|
|
|
4087
4485
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
4088
|
-
import { applyToPoint as
|
|
4486
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
4089
4487
|
var createSvgSchText = ({
|
|
4090
4488
|
elm,
|
|
4091
4489
|
transform,
|
|
4092
4490
|
colorMap: colorMap2
|
|
4093
4491
|
}) => {
|
|
4094
|
-
const center =
|
|
4492
|
+
const center = applyToPoint34(transform, elm.position);
|
|
4095
4493
|
const textAnchorMap = {
|
|
4096
4494
|
center: "middle",
|
|
4097
4495
|
center_right: "end",
|
|
@@ -4175,11 +4573,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
4175
4573
|
colorMap: colorMap2
|
|
4176
4574
|
}) => {
|
|
4177
4575
|
const svgObjects = [];
|
|
4178
|
-
const componentScreenTopLeft =
|
|
4576
|
+
const componentScreenTopLeft = applyToPoint35(transform, {
|
|
4179
4577
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
4180
4578
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
4181
4579
|
});
|
|
4182
|
-
const componentScreenBottomRight =
|
|
4580
|
+
const componentScreenBottomRight = applyToPoint35(transform, {
|
|
4183
4581
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
4184
4582
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
4185
4583
|
});
|
|
@@ -4262,13 +4660,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
4262
4660
|
}
|
|
4263
4661
|
|
|
4264
4662
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
4265
|
-
import { applyToPoint as
|
|
4663
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4266
4664
|
function createSvgObjectsFromSchVoltageProbe({
|
|
4267
4665
|
probe,
|
|
4268
4666
|
transform,
|
|
4269
4667
|
colorMap: colorMap2
|
|
4270
4668
|
}) {
|
|
4271
|
-
const [screenX, screenY] =
|
|
4669
|
+
const [screenX, screenY] = applyToPoint36(transform, [
|
|
4272
4670
|
probe.position.x,
|
|
4273
4671
|
probe.position.y
|
|
4274
4672
|
]);
|
|
@@ -4328,17 +4726,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
4328
4726
|
}
|
|
4329
4727
|
|
|
4330
4728
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
4331
|
-
import { applyToPoint as
|
|
4729
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4332
4730
|
function createSvgObjectsFromSchDebugObject({
|
|
4333
4731
|
debugObject,
|
|
4334
4732
|
transform
|
|
4335
4733
|
}) {
|
|
4336
4734
|
if (debugObject.shape === "rect") {
|
|
4337
|
-
let [screenLeft, screenTop] =
|
|
4735
|
+
let [screenLeft, screenTop] = applyToPoint37(transform, [
|
|
4338
4736
|
debugObject.center.x - debugObject.size.width / 2,
|
|
4339
4737
|
debugObject.center.y - debugObject.size.height / 2
|
|
4340
4738
|
]);
|
|
4341
|
-
let [screenRight, screenBottom] =
|
|
4739
|
+
let [screenRight, screenBottom] = applyToPoint37(transform, [
|
|
4342
4740
|
debugObject.center.x + debugObject.size.width / 2,
|
|
4343
4741
|
debugObject.center.y + debugObject.size.height / 2
|
|
4344
4742
|
]);
|
|
@@ -4348,7 +4746,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4348
4746
|
];
|
|
4349
4747
|
const width = Math.abs(screenRight - screenLeft);
|
|
4350
4748
|
const height = Math.abs(screenBottom - screenTop);
|
|
4351
|
-
const [screenCenterX, screenCenterY] =
|
|
4749
|
+
const [screenCenterX, screenCenterY] = applyToPoint37(transform, [
|
|
4352
4750
|
debugObject.center.x,
|
|
4353
4751
|
debugObject.center.y
|
|
4354
4752
|
]);
|
|
@@ -4394,11 +4792,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4394
4792
|
];
|
|
4395
4793
|
}
|
|
4396
4794
|
if (debugObject.shape === "line") {
|
|
4397
|
-
const [screenStartX, screenStartY] =
|
|
4795
|
+
const [screenStartX, screenStartY] = applyToPoint37(transform, [
|
|
4398
4796
|
debugObject.start.x,
|
|
4399
4797
|
debugObject.start.y
|
|
4400
4798
|
]);
|
|
4401
|
-
const [screenEndX, screenEndY] =
|
|
4799
|
+
const [screenEndX, screenEndY] = applyToPoint37(transform, [
|
|
4402
4800
|
debugObject.end.x,
|
|
4403
4801
|
debugObject.end.y
|
|
4404
4802
|
]);
|
|
@@ -4448,7 +4846,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4448
4846
|
}
|
|
4449
4847
|
|
|
4450
4848
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
4451
|
-
import { applyToPoint as
|
|
4849
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4452
4850
|
function createSchematicTrace({
|
|
4453
4851
|
trace,
|
|
4454
4852
|
transform,
|
|
@@ -4461,11 +4859,11 @@ function createSchematicTrace({
|
|
|
4461
4859
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
4462
4860
|
const edge = edges[edgeIndex];
|
|
4463
4861
|
if (edge.is_crossing) continue;
|
|
4464
|
-
const [screenFromX, screenFromY] =
|
|
4862
|
+
const [screenFromX, screenFromY] = applyToPoint38(transform, [
|
|
4465
4863
|
edge.from.x,
|
|
4466
4864
|
edge.from.y
|
|
4467
4865
|
]);
|
|
4468
|
-
const [screenToX, screenToY] =
|
|
4866
|
+
const [screenToX, screenToY] = applyToPoint38(transform, [
|
|
4469
4867
|
edge.to.x,
|
|
4470
4868
|
edge.to.y
|
|
4471
4869
|
]);
|
|
@@ -4477,11 +4875,11 @@ function createSchematicTrace({
|
|
|
4477
4875
|
}
|
|
4478
4876
|
for (const edge of edges) {
|
|
4479
4877
|
if (!edge.is_crossing) continue;
|
|
4480
|
-
const [screenFromX, screenFromY] =
|
|
4878
|
+
const [screenFromX, screenFromY] = applyToPoint38(transform, [
|
|
4481
4879
|
edge.from.x,
|
|
4482
4880
|
edge.from.y
|
|
4483
4881
|
]);
|
|
4484
|
-
const [screenToX, screenToY] =
|
|
4882
|
+
const [screenToX, screenToY] = applyToPoint38(transform, [
|
|
4485
4883
|
edge.to.x,
|
|
4486
4884
|
edge.to.y
|
|
4487
4885
|
]);
|
|
@@ -4557,7 +4955,7 @@ function createSchematicTrace({
|
|
|
4557
4955
|
}
|
|
4558
4956
|
if (trace.junctions) {
|
|
4559
4957
|
for (const junction of trace.junctions) {
|
|
4560
|
-
const [screenX, screenY] =
|
|
4958
|
+
const [screenX, screenY] = applyToPoint38(transform, [
|
|
4561
4959
|
junction.x,
|
|
4562
4960
|
junction.y
|
|
4563
4961
|
]);
|
|
@@ -4593,7 +4991,7 @@ function createSchematicTrace({
|
|
|
4593
4991
|
|
|
4594
4992
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
4595
4993
|
import {
|
|
4596
|
-
applyToPoint as
|
|
4994
|
+
applyToPoint as applyToPoint40,
|
|
4597
4995
|
compose as compose9,
|
|
4598
4996
|
rotate as rotate5,
|
|
4599
4997
|
scale as scale6,
|
|
@@ -4602,7 +5000,7 @@ import {
|
|
|
4602
5000
|
|
|
4603
5001
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
4604
5002
|
import {
|
|
4605
|
-
applyToPoint as
|
|
5003
|
+
applyToPoint as applyToPoint39,
|
|
4606
5004
|
compose as compose8,
|
|
4607
5005
|
rotate as rotate4,
|
|
4608
5006
|
scale as scale5,
|
|
@@ -4677,7 +5075,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4677
5075
|
x: symbolBounds.minX,
|
|
4678
5076
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
4679
5077
|
};
|
|
4680
|
-
const rotatedSymbolEnd =
|
|
5078
|
+
const rotatedSymbolEnd = applyToPoint39(rotationMatrix, symbolEndPoint);
|
|
4681
5079
|
const symbolToRealTransform = compose8(
|
|
4682
5080
|
translate8(
|
|
4683
5081
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -4687,11 +5085,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4687
5085
|
scale5(1)
|
|
4688
5086
|
// Use full symbol size
|
|
4689
5087
|
);
|
|
4690
|
-
const [screenMinX, screenMinY] =
|
|
5088
|
+
const [screenMinX, screenMinY] = applyToPoint39(
|
|
4691
5089
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4692
5090
|
[bounds.minX, bounds.minY]
|
|
4693
5091
|
);
|
|
4694
|
-
const [screenMaxX, screenMaxY] =
|
|
5092
|
+
const [screenMaxX, screenMaxY] = applyToPoint39(
|
|
4695
5093
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4696
5094
|
[bounds.maxX, bounds.maxY]
|
|
4697
5095
|
);
|
|
@@ -4715,7 +5113,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4715
5113
|
});
|
|
4716
5114
|
for (const path of symbolPaths) {
|
|
4717
5115
|
const symbolPath = path.points.map((p, i) => {
|
|
4718
|
-
const [x, y] =
|
|
5116
|
+
const [x, y] = applyToPoint39(
|
|
4719
5117
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4720
5118
|
[p.x, p.y]
|
|
4721
5119
|
);
|
|
@@ -4736,7 +5134,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4736
5134
|
});
|
|
4737
5135
|
}
|
|
4738
5136
|
for (const text of symbolTexts) {
|
|
4739
|
-
const screenTextPos =
|
|
5137
|
+
const screenTextPos = applyToPoint39(
|
|
4740
5138
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4741
5139
|
text
|
|
4742
5140
|
);
|
|
@@ -4778,7 +5176,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4778
5176
|
});
|
|
4779
5177
|
}
|
|
4780
5178
|
for (const box of symbolBoxes) {
|
|
4781
|
-
const screenBoxPos =
|
|
5179
|
+
const screenBoxPos = applyToPoint39(
|
|
4782
5180
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4783
5181
|
box
|
|
4784
5182
|
);
|
|
@@ -4801,7 +5199,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4801
5199
|
});
|
|
4802
5200
|
}
|
|
4803
5201
|
for (const circle of symbolCircles) {
|
|
4804
|
-
const screenCirclePos =
|
|
5202
|
+
const screenCirclePos = applyToPoint39(
|
|
4805
5203
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4806
5204
|
circle
|
|
4807
5205
|
);
|
|
@@ -4834,8 +5232,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4834
5232
|
colorMap: colorMap2
|
|
4835
5233
|
}) => {
|
|
4836
5234
|
if (!schNetLabel.text) return [];
|
|
4837
|
-
const
|
|
4838
|
-
const labelText = isNegated ? schNetLabel.text.slice(2) : schNetLabel.text;
|
|
5235
|
+
const labelText = schNetLabel.text;
|
|
4839
5236
|
if (schNetLabel.symbol_name) {
|
|
4840
5237
|
return createSvgObjectsForSchNetLabelWithSymbol({
|
|
4841
5238
|
schNetLabel,
|
|
@@ -4847,14 +5244,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4847
5244
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
4848
5245
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4849
5246
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
4850
|
-
const screenCenter =
|
|
5247
|
+
const screenCenter = applyToPoint40(realToScreenTransform, schNetLabel.center);
|
|
4851
5248
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4852
5249
|
schNetLabel.anchor_side
|
|
4853
5250
|
);
|
|
4854
5251
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
4855
5252
|
screenTextGrowthVec.y *= -1;
|
|
4856
5253
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
4857
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
5254
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint40(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
4858
5255
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
4859
5256
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
4860
5257
|
};
|
|
@@ -4895,7 +5292,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4895
5292
|
y: -0.6
|
|
4896
5293
|
}
|
|
4897
5294
|
].map(
|
|
4898
|
-
(fontRelativePoint) =>
|
|
5295
|
+
(fontRelativePoint) => applyToPoint40(
|
|
4899
5296
|
compose9(
|
|
4900
5297
|
realToScreenTransform,
|
|
4901
5298
|
translate9(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -4955,8 +5352,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4955
5352
|
"font-family": "sans-serif",
|
|
4956
5353
|
"font-variant-numeric": "tabular-nums",
|
|
4957
5354
|
"font-size": `${fontSizePx}px`,
|
|
4958
|
-
transform: textTransformString
|
|
4959
|
-
...isNegated ? { style: "text-decoration: overline;" } : {}
|
|
5355
|
+
transform: textTransformString
|
|
4960
5356
|
},
|
|
4961
5357
|
children: [
|
|
4962
5358
|
{
|
|
@@ -4973,17 +5369,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4973
5369
|
};
|
|
4974
5370
|
|
|
4975
5371
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
4976
|
-
import { applyToPoint as
|
|
5372
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
4977
5373
|
var createSvgObjectsFromSchematicBox = ({
|
|
4978
5374
|
schematicBox,
|
|
4979
5375
|
transform,
|
|
4980
5376
|
colorMap: colorMap2
|
|
4981
5377
|
}) => {
|
|
4982
|
-
const topLeft =
|
|
5378
|
+
const topLeft = applyToPoint41(transform, {
|
|
4983
5379
|
x: schematicBox.x,
|
|
4984
5380
|
y: schematicBox.y
|
|
4985
5381
|
});
|
|
4986
|
-
const bottomRight =
|
|
5382
|
+
const bottomRight = applyToPoint41(transform, {
|
|
4987
5383
|
x: schematicBox.x + schematicBox.width,
|
|
4988
5384
|
y: schematicBox.y + schematicBox.height
|
|
4989
5385
|
});
|
|
@@ -5225,18 +5621,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
5225
5621
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
5226
5622
|
import { stringify as stringify4 } from "svgson";
|
|
5227
5623
|
import {
|
|
5228
|
-
applyToPoint as
|
|
5624
|
+
applyToPoint as applyToPoint44,
|
|
5229
5625
|
compose as compose11,
|
|
5230
5626
|
scale as scale8,
|
|
5231
5627
|
translate as translate11
|
|
5232
5628
|
} from "transformation-matrix";
|
|
5233
5629
|
|
|
5234
5630
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
5235
|
-
import { applyToPoint as
|
|
5631
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5236
5632
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
5237
5633
|
const { transform, layer: layerFilter } = ctx;
|
|
5238
5634
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
5239
|
-
const [x, y] =
|
|
5635
|
+
const [x, y] = applyToPoint43(transform, [solderPaste.x, solderPaste.y]);
|
|
5240
5636
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
5241
5637
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
5242
5638
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -5435,8 +5831,8 @@ function createSvgObjects3({ elm, ctx }) {
|
|
|
5435
5831
|
}
|
|
5436
5832
|
}
|
|
5437
5833
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
5438
|
-
const [x1, y1] =
|
|
5439
|
-
const [x2, y2] =
|
|
5834
|
+
const [x1, y1] = applyToPoint44(transform, [minX, minY]);
|
|
5835
|
+
const [x2, y2] = applyToPoint44(transform, [maxX, maxY]);
|
|
5440
5836
|
const width = Math.abs(x2 - x1);
|
|
5441
5837
|
const height = Math.abs(y2 - y1);
|
|
5442
5838
|
const x = Math.min(x1, x2);
|