circuit-to-svg 0.0.162 → 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 +460 -74
- 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
|
|
@@ -2042,8 +2042,387 @@ function getRectPathData(w, h, rotation) {
|
|
|
2042
2042
|
return `${path} Z`;
|
|
2043
2043
|
}
|
|
2044
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
|
+
|
|
2045
2418
|
// lib/assembly/convert-circuit-json-to-assembly-svg.ts
|
|
2046
|
-
var OBJECT_ORDER2 = [
|
|
2419
|
+
var OBJECT_ORDER2 = [
|
|
2420
|
+
"pcb_component",
|
|
2421
|
+
"pcb_smtpad",
|
|
2422
|
+
"pcb_hole",
|
|
2423
|
+
"pcb_plated_hole",
|
|
2424
|
+
"pcb_board"
|
|
2425
|
+
];
|
|
2047
2426
|
function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
2048
2427
|
let minX = Number.POSITIVE_INFINITY;
|
|
2049
2428
|
let minY = Number.POSITIVE_INFINITY;
|
|
@@ -2078,9 +2457,10 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2078
2457
|
scale3(scaleFactor, -scaleFactor)
|
|
2079
2458
|
// Flip in y-direction
|
|
2080
2459
|
);
|
|
2460
|
+
const ctx = { transform };
|
|
2081
2461
|
const svgObjects = soup.sort(
|
|
2082
2462
|
(a, b) => (OBJECT_ORDER2.indexOf(b.type) ?? 9999) - (OBJECT_ORDER2.indexOf(a.type) ?? 9999)
|
|
2083
|
-
).flatMap((item) => createSvgObjects2(item,
|
|
2463
|
+
).flatMap((item) => createSvgObjects2(item, ctx, soup));
|
|
2084
2464
|
const softwareUsedString = getSoftwareUsedString(soup);
|
|
2085
2465
|
const svgObject = {
|
|
2086
2466
|
name: "svg",
|
|
@@ -2103,7 +2483,7 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2103
2483
|
type: "text",
|
|
2104
2484
|
value: `
|
|
2105
2485
|
.assembly-component {
|
|
2106
|
-
fill:
|
|
2486
|
+
fill: none;
|
|
2107
2487
|
stroke: #000;
|
|
2108
2488
|
}
|
|
2109
2489
|
.assembly-board {
|
|
@@ -2151,11 +2531,11 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2151
2531
|
};
|
|
2152
2532
|
return stringify2(svgObject);
|
|
2153
2533
|
}
|
|
2154
|
-
function createSvgObjects2(elm,
|
|
2534
|
+
function createSvgObjects2(elm, ctx, soup) {
|
|
2155
2535
|
const sourceComponents = su3(soup).source_component.list();
|
|
2156
2536
|
switch (elm.type) {
|
|
2157
2537
|
case "pcb_board":
|
|
2158
|
-
return createSvgObjectsFromAssemblyBoard(elm, transform);
|
|
2538
|
+
return createSvgObjectsFromAssemblyBoard(elm, ctx.transform);
|
|
2159
2539
|
case "pcb_component": {
|
|
2160
2540
|
const sourceComponent = sourceComponents.find(
|
|
2161
2541
|
(item) => item.source_component_id === elm.source_component_id
|
|
@@ -2171,19 +2551,25 @@ function createSvgObjects2(elm, transform, soup) {
|
|
|
2171
2551
|
name: sourceComponent.name,
|
|
2172
2552
|
arePinsInterchangeable
|
|
2173
2553
|
},
|
|
2174
|
-
|
|
2554
|
+
ctx
|
|
2175
2555
|
);
|
|
2176
2556
|
return obj ? [obj] : [];
|
|
2177
2557
|
}
|
|
2178
2558
|
return [];
|
|
2179
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);
|
|
2180
2566
|
default:
|
|
2181
2567
|
return [];
|
|
2182
2568
|
}
|
|
2183
2569
|
}
|
|
2184
2570
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
2185
|
-
const [x1, y1] =
|
|
2186
|
-
const [x2, y2] =
|
|
2571
|
+
const [x1, y1] = applyToPoint25(transform, [minX, minY]);
|
|
2572
|
+
const [x2, y2] = applyToPoint25(transform, [maxX, maxY]);
|
|
2187
2573
|
const width = Math.abs(x2 - x1);
|
|
2188
2574
|
const height = Math.abs(y2 - y1);
|
|
2189
2575
|
const x = Math.min(x1, x2);
|
|
@@ -2449,14 +2835,14 @@ import {
|
|
|
2449
2835
|
} from "transformation-matrix";
|
|
2450
2836
|
|
|
2451
2837
|
// lib/sch/draw-schematic-grid.ts
|
|
2452
|
-
import { applyToPoint as
|
|
2838
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2453
2839
|
function drawSchematicGrid(params) {
|
|
2454
2840
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
2455
2841
|
const cellSize = params.cellSize ?? 1;
|
|
2456
2842
|
const labelCells = params.labelCells ?? false;
|
|
2457
2843
|
const gridLines = [];
|
|
2458
2844
|
const transformPoint = (x, y) => {
|
|
2459
|
-
const [transformedX, transformedY] =
|
|
2845
|
+
const [transformedX, transformedY] = applyToPoint26(params.transform, [x, y]);
|
|
2460
2846
|
return { x: transformedX, y: transformedY };
|
|
2461
2847
|
};
|
|
2462
2848
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -2537,15 +2923,15 @@ function drawSchematicGrid(params) {
|
|
|
2537
2923
|
}
|
|
2538
2924
|
|
|
2539
2925
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
2540
|
-
import { applyToPoint as
|
|
2926
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2541
2927
|
function drawSchematicLabeledPoints(params) {
|
|
2542
2928
|
const { points, transform } = params;
|
|
2543
2929
|
const labeledPointsGroup = [];
|
|
2544
2930
|
for (const point of points) {
|
|
2545
|
-
const [x1, y1] =
|
|
2546
|
-
const [x2, y2] =
|
|
2547
|
-
const [x3, y3] =
|
|
2548
|
-
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]);
|
|
2549
2935
|
labeledPointsGroup.push({
|
|
2550
2936
|
name: "path",
|
|
2551
2937
|
type: "element",
|
|
@@ -2556,7 +2942,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
2556
2942
|
"stroke-opacity": "0.7"
|
|
2557
2943
|
}
|
|
2558
2944
|
});
|
|
2559
|
-
const [labelX, labelY] =
|
|
2945
|
+
const [labelX, labelY] = applyToPoint27(transform, [
|
|
2560
2946
|
point.x + 0.15,
|
|
2561
2947
|
point.y - 0.15
|
|
2562
2948
|
]);
|
|
@@ -3525,7 +3911,7 @@ import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
|
3525
3911
|
import { symbols } from "schematic-symbols";
|
|
3526
3912
|
import "svgson";
|
|
3527
3913
|
import {
|
|
3528
|
-
applyToPoint as
|
|
3914
|
+
applyToPoint as applyToPoint29,
|
|
3529
3915
|
compose as compose7
|
|
3530
3916
|
} from "transformation-matrix";
|
|
3531
3917
|
|
|
@@ -3609,13 +3995,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
3609
3995
|
}
|
|
3610
3996
|
|
|
3611
3997
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
3612
|
-
import { applyToPoint as
|
|
3998
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
3613
3999
|
var createSvgSchErrorText = ({
|
|
3614
4000
|
text,
|
|
3615
4001
|
realCenter,
|
|
3616
4002
|
realToScreenTransform
|
|
3617
4003
|
}) => {
|
|
3618
|
-
const screenCenter =
|
|
4004
|
+
const screenCenter = applyToPoint28(realToScreenTransform, realCenter);
|
|
3619
4005
|
return {
|
|
3620
4006
|
type: "element",
|
|
3621
4007
|
name: "text",
|
|
@@ -3724,11 +4110,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3724
4110
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
3725
4111
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
3726
4112
|
};
|
|
3727
|
-
const [screenMinX, screenMinY] =
|
|
4113
|
+
const [screenMinX, screenMinY] = applyToPoint29(
|
|
3728
4114
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3729
4115
|
[bounds.minX, bounds.minY]
|
|
3730
4116
|
);
|
|
3731
|
-
const [screenMaxX, screenMaxY] =
|
|
4117
|
+
const [screenMaxX, screenMaxY] = applyToPoint29(
|
|
3732
4118
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3733
4119
|
[bounds.maxX, bounds.maxY]
|
|
3734
4120
|
);
|
|
@@ -3757,7 +4143,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3757
4143
|
name: "path",
|
|
3758
4144
|
attributes: {
|
|
3759
4145
|
d: points.map((p, i) => {
|
|
3760
|
-
const [x, y] =
|
|
4146
|
+
const [x, y] = applyToPoint29(
|
|
3761
4147
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3762
4148
|
[p.x, p.y]
|
|
3763
4149
|
);
|
|
@@ -3773,7 +4159,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3773
4159
|
});
|
|
3774
4160
|
}
|
|
3775
4161
|
for (const text of texts) {
|
|
3776
|
-
const screenTextPos =
|
|
4162
|
+
const screenTextPos = applyToPoint29(
|
|
3777
4163
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3778
4164
|
text
|
|
3779
4165
|
);
|
|
@@ -3819,7 +4205,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3819
4205
|
});
|
|
3820
4206
|
}
|
|
3821
4207
|
for (const box of boxes) {
|
|
3822
|
-
const screenBoxPos =
|
|
4208
|
+
const screenBoxPos = applyToPoint29(
|
|
3823
4209
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3824
4210
|
box
|
|
3825
4211
|
);
|
|
@@ -3843,7 +4229,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3843
4229
|
}
|
|
3844
4230
|
for (const port of symbol.ports) {
|
|
3845
4231
|
if (connectedSymbolPorts.has(port)) continue;
|
|
3846
|
-
const screenPortPos =
|
|
4232
|
+
const screenPortPos = applyToPoint29(
|
|
3847
4233
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3848
4234
|
port
|
|
3849
4235
|
);
|
|
@@ -3863,7 +4249,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3863
4249
|
});
|
|
3864
4250
|
}
|
|
3865
4251
|
for (const circle of circles) {
|
|
3866
|
-
const screenCirclePos =
|
|
4252
|
+
const screenCirclePos = applyToPoint29(
|
|
3867
4253
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
3868
4254
|
circle
|
|
3869
4255
|
);
|
|
@@ -3890,14 +4276,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
3890
4276
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
3891
4277
|
import "schematic-symbols";
|
|
3892
4278
|
import "svgson";
|
|
3893
|
-
import { applyToPoint as
|
|
4279
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
3894
4280
|
|
|
3895
4281
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
3896
4282
|
import "transformation-matrix";
|
|
3897
4283
|
import "@tscircuit/circuit-json-util";
|
|
3898
4284
|
|
|
3899
4285
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
3900
|
-
import { applyToPoint as
|
|
4286
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3901
4287
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
3902
4288
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
3903
4289
|
var createSvgObjectsForSchPortBoxLine = ({
|
|
@@ -3927,8 +4313,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3927
4313
|
realEdgePos.y += realPinLineLength;
|
|
3928
4314
|
break;
|
|
3929
4315
|
}
|
|
3930
|
-
const screenSchPortPos =
|
|
3931
|
-
const screenRealEdgePos =
|
|
4316
|
+
const screenSchPortPos = applyToPoint30(transform, schPort.center);
|
|
4317
|
+
const screenRealEdgePos = applyToPoint30(transform, realEdgePos);
|
|
3932
4318
|
const realLineEnd = { ...schPort.center };
|
|
3933
4319
|
switch (schPort.side_of_component) {
|
|
3934
4320
|
case "left":
|
|
@@ -3944,7 +4330,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3944
4330
|
realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
|
|
3945
4331
|
break;
|
|
3946
4332
|
}
|
|
3947
|
-
const screenLineEnd =
|
|
4333
|
+
const screenLineEnd = applyToPoint30(transform, realLineEnd);
|
|
3948
4334
|
svgObjects.push({
|
|
3949
4335
|
name: "line",
|
|
3950
4336
|
type: "element",
|
|
@@ -3979,7 +4365,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
3979
4365
|
};
|
|
3980
4366
|
|
|
3981
4367
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
3982
|
-
import { applyToPoint as
|
|
4368
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3983
4369
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
3984
4370
|
const svgObjects = [];
|
|
3985
4371
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -3997,7 +4383,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
3997
4383
|
} else {
|
|
3998
4384
|
realPinNumberPos.y += 0.02;
|
|
3999
4385
|
}
|
|
4000
|
-
const screenPinNumberTextPos =
|
|
4386
|
+
const screenPinNumberTextPos = applyToPoint31(transform, realPinNumberPos);
|
|
4001
4387
|
svgObjects.push({
|
|
4002
4388
|
name: "text",
|
|
4003
4389
|
type: "element",
|
|
@@ -4027,7 +4413,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
4027
4413
|
};
|
|
4028
4414
|
|
|
4029
4415
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
4030
|
-
import { applyToPoint as
|
|
4416
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
4031
4417
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
4032
4418
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
4033
4419
|
const svgObjects = [];
|
|
@@ -4041,7 +4427,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4041
4427
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
4042
4428
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4043
4429
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4044
|
-
const screenPinNumberTextPos =
|
|
4430
|
+
const screenPinNumberTextPos = applyToPoint32(transform, realPinNumberPos);
|
|
4045
4431
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
4046
4432
|
if (!label) return [];
|
|
4047
4433
|
const isNegated = label.startsWith("N_");
|
|
@@ -4085,13 +4471,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
4085
4471
|
};
|
|
4086
4472
|
|
|
4087
4473
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
4088
|
-
import { applyToPoint as
|
|
4474
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
4089
4475
|
var createSvgSchText = ({
|
|
4090
4476
|
elm,
|
|
4091
4477
|
transform,
|
|
4092
4478
|
colorMap: colorMap2
|
|
4093
4479
|
}) => {
|
|
4094
|
-
const center =
|
|
4480
|
+
const center = applyToPoint34(transform, elm.position);
|
|
4095
4481
|
const textAnchorMap = {
|
|
4096
4482
|
center: "middle",
|
|
4097
4483
|
center_right: "end",
|
|
@@ -4175,11 +4561,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
4175
4561
|
colorMap: colorMap2
|
|
4176
4562
|
}) => {
|
|
4177
4563
|
const svgObjects = [];
|
|
4178
|
-
const componentScreenTopLeft =
|
|
4564
|
+
const componentScreenTopLeft = applyToPoint35(transform, {
|
|
4179
4565
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
4180
4566
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
4181
4567
|
});
|
|
4182
|
-
const componentScreenBottomRight =
|
|
4568
|
+
const componentScreenBottomRight = applyToPoint35(transform, {
|
|
4183
4569
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
4184
4570
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
4185
4571
|
});
|
|
@@ -4262,13 +4648,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
4262
4648
|
}
|
|
4263
4649
|
|
|
4264
4650
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
4265
|
-
import { applyToPoint as
|
|
4651
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4266
4652
|
function createSvgObjectsFromSchVoltageProbe({
|
|
4267
4653
|
probe,
|
|
4268
4654
|
transform,
|
|
4269
4655
|
colorMap: colorMap2
|
|
4270
4656
|
}) {
|
|
4271
|
-
const [screenX, screenY] =
|
|
4657
|
+
const [screenX, screenY] = applyToPoint36(transform, [
|
|
4272
4658
|
probe.position.x,
|
|
4273
4659
|
probe.position.y
|
|
4274
4660
|
]);
|
|
@@ -4328,17 +4714,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
4328
4714
|
}
|
|
4329
4715
|
|
|
4330
4716
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
4331
|
-
import { applyToPoint as
|
|
4717
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4332
4718
|
function createSvgObjectsFromSchDebugObject({
|
|
4333
4719
|
debugObject,
|
|
4334
4720
|
transform
|
|
4335
4721
|
}) {
|
|
4336
4722
|
if (debugObject.shape === "rect") {
|
|
4337
|
-
let [screenLeft, screenTop] =
|
|
4723
|
+
let [screenLeft, screenTop] = applyToPoint37(transform, [
|
|
4338
4724
|
debugObject.center.x - debugObject.size.width / 2,
|
|
4339
4725
|
debugObject.center.y - debugObject.size.height / 2
|
|
4340
4726
|
]);
|
|
4341
|
-
let [screenRight, screenBottom] =
|
|
4727
|
+
let [screenRight, screenBottom] = applyToPoint37(transform, [
|
|
4342
4728
|
debugObject.center.x + debugObject.size.width / 2,
|
|
4343
4729
|
debugObject.center.y + debugObject.size.height / 2
|
|
4344
4730
|
]);
|
|
@@ -4348,7 +4734,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4348
4734
|
];
|
|
4349
4735
|
const width = Math.abs(screenRight - screenLeft);
|
|
4350
4736
|
const height = Math.abs(screenBottom - screenTop);
|
|
4351
|
-
const [screenCenterX, screenCenterY] =
|
|
4737
|
+
const [screenCenterX, screenCenterY] = applyToPoint37(transform, [
|
|
4352
4738
|
debugObject.center.x,
|
|
4353
4739
|
debugObject.center.y
|
|
4354
4740
|
]);
|
|
@@ -4394,11 +4780,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4394
4780
|
];
|
|
4395
4781
|
}
|
|
4396
4782
|
if (debugObject.shape === "line") {
|
|
4397
|
-
const [screenStartX, screenStartY] =
|
|
4783
|
+
const [screenStartX, screenStartY] = applyToPoint37(transform, [
|
|
4398
4784
|
debugObject.start.x,
|
|
4399
4785
|
debugObject.start.y
|
|
4400
4786
|
]);
|
|
4401
|
-
const [screenEndX, screenEndY] =
|
|
4787
|
+
const [screenEndX, screenEndY] = applyToPoint37(transform, [
|
|
4402
4788
|
debugObject.end.x,
|
|
4403
4789
|
debugObject.end.y
|
|
4404
4790
|
]);
|
|
@@ -4448,7 +4834,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
4448
4834
|
}
|
|
4449
4835
|
|
|
4450
4836
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
4451
|
-
import { applyToPoint as
|
|
4837
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4452
4838
|
function createSchematicTrace({
|
|
4453
4839
|
trace,
|
|
4454
4840
|
transform,
|
|
@@ -4461,11 +4847,11 @@ function createSchematicTrace({
|
|
|
4461
4847
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
4462
4848
|
const edge = edges[edgeIndex];
|
|
4463
4849
|
if (edge.is_crossing) continue;
|
|
4464
|
-
const [screenFromX, screenFromY] =
|
|
4850
|
+
const [screenFromX, screenFromY] = applyToPoint38(transform, [
|
|
4465
4851
|
edge.from.x,
|
|
4466
4852
|
edge.from.y
|
|
4467
4853
|
]);
|
|
4468
|
-
const [screenToX, screenToY] =
|
|
4854
|
+
const [screenToX, screenToY] = applyToPoint38(transform, [
|
|
4469
4855
|
edge.to.x,
|
|
4470
4856
|
edge.to.y
|
|
4471
4857
|
]);
|
|
@@ -4477,11 +4863,11 @@ function createSchematicTrace({
|
|
|
4477
4863
|
}
|
|
4478
4864
|
for (const edge of edges) {
|
|
4479
4865
|
if (!edge.is_crossing) continue;
|
|
4480
|
-
const [screenFromX, screenFromY] =
|
|
4866
|
+
const [screenFromX, screenFromY] = applyToPoint38(transform, [
|
|
4481
4867
|
edge.from.x,
|
|
4482
4868
|
edge.from.y
|
|
4483
4869
|
]);
|
|
4484
|
-
const [screenToX, screenToY] =
|
|
4870
|
+
const [screenToX, screenToY] = applyToPoint38(transform, [
|
|
4485
4871
|
edge.to.x,
|
|
4486
4872
|
edge.to.y
|
|
4487
4873
|
]);
|
|
@@ -4557,7 +4943,7 @@ function createSchematicTrace({
|
|
|
4557
4943
|
}
|
|
4558
4944
|
if (trace.junctions) {
|
|
4559
4945
|
for (const junction of trace.junctions) {
|
|
4560
|
-
const [screenX, screenY] =
|
|
4946
|
+
const [screenX, screenY] = applyToPoint38(transform, [
|
|
4561
4947
|
junction.x,
|
|
4562
4948
|
junction.y
|
|
4563
4949
|
]);
|
|
@@ -4593,7 +4979,7 @@ function createSchematicTrace({
|
|
|
4593
4979
|
|
|
4594
4980
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
4595
4981
|
import {
|
|
4596
|
-
applyToPoint as
|
|
4982
|
+
applyToPoint as applyToPoint40,
|
|
4597
4983
|
compose as compose9,
|
|
4598
4984
|
rotate as rotate5,
|
|
4599
4985
|
scale as scale6,
|
|
@@ -4602,7 +4988,7 @@ import {
|
|
|
4602
4988
|
|
|
4603
4989
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
4604
4990
|
import {
|
|
4605
|
-
applyToPoint as
|
|
4991
|
+
applyToPoint as applyToPoint39,
|
|
4606
4992
|
compose as compose8,
|
|
4607
4993
|
rotate as rotate4,
|
|
4608
4994
|
scale as scale5,
|
|
@@ -4677,7 +5063,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4677
5063
|
x: symbolBounds.minX,
|
|
4678
5064
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
4679
5065
|
};
|
|
4680
|
-
const rotatedSymbolEnd =
|
|
5066
|
+
const rotatedSymbolEnd = applyToPoint39(rotationMatrix, symbolEndPoint);
|
|
4681
5067
|
const symbolToRealTransform = compose8(
|
|
4682
5068
|
translate8(
|
|
4683
5069
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -4687,11 +5073,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4687
5073
|
scale5(1)
|
|
4688
5074
|
// Use full symbol size
|
|
4689
5075
|
);
|
|
4690
|
-
const [screenMinX, screenMinY] =
|
|
5076
|
+
const [screenMinX, screenMinY] = applyToPoint39(
|
|
4691
5077
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4692
5078
|
[bounds.minX, bounds.minY]
|
|
4693
5079
|
);
|
|
4694
|
-
const [screenMaxX, screenMaxY] =
|
|
5080
|
+
const [screenMaxX, screenMaxY] = applyToPoint39(
|
|
4695
5081
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4696
5082
|
[bounds.maxX, bounds.maxY]
|
|
4697
5083
|
);
|
|
@@ -4715,7 +5101,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4715
5101
|
});
|
|
4716
5102
|
for (const path of symbolPaths) {
|
|
4717
5103
|
const symbolPath = path.points.map((p, i) => {
|
|
4718
|
-
const [x, y] =
|
|
5104
|
+
const [x, y] = applyToPoint39(
|
|
4719
5105
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4720
5106
|
[p.x, p.y]
|
|
4721
5107
|
);
|
|
@@ -4736,7 +5122,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4736
5122
|
});
|
|
4737
5123
|
}
|
|
4738
5124
|
for (const text of symbolTexts) {
|
|
4739
|
-
const screenTextPos =
|
|
5125
|
+
const screenTextPos = applyToPoint39(
|
|
4740
5126
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4741
5127
|
text
|
|
4742
5128
|
);
|
|
@@ -4778,7 +5164,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4778
5164
|
});
|
|
4779
5165
|
}
|
|
4780
5166
|
for (const box of symbolBoxes) {
|
|
4781
|
-
const screenBoxPos =
|
|
5167
|
+
const screenBoxPos = applyToPoint39(
|
|
4782
5168
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4783
5169
|
box
|
|
4784
5170
|
);
|
|
@@ -4801,7 +5187,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4801
5187
|
});
|
|
4802
5188
|
}
|
|
4803
5189
|
for (const circle of symbolCircles) {
|
|
4804
|
-
const screenCirclePos =
|
|
5190
|
+
const screenCirclePos = applyToPoint39(
|
|
4805
5191
|
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4806
5192
|
circle
|
|
4807
5193
|
);
|
|
@@ -4847,14 +5233,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4847
5233
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
4848
5234
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4849
5235
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
4850
|
-
const screenCenter =
|
|
5236
|
+
const screenCenter = applyToPoint40(realToScreenTransform, schNetLabel.center);
|
|
4851
5237
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4852
5238
|
schNetLabel.anchor_side
|
|
4853
5239
|
);
|
|
4854
5240
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
4855
5241
|
screenTextGrowthVec.y *= -1;
|
|
4856
5242
|
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 ?
|
|
5243
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint40(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
4858
5244
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
4859
5245
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
4860
5246
|
};
|
|
@@ -4895,7 +5281,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4895
5281
|
y: -0.6
|
|
4896
5282
|
}
|
|
4897
5283
|
].map(
|
|
4898
|
-
(fontRelativePoint) =>
|
|
5284
|
+
(fontRelativePoint) => applyToPoint40(
|
|
4899
5285
|
compose9(
|
|
4900
5286
|
realToScreenTransform,
|
|
4901
5287
|
translate9(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -4973,17 +5359,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4973
5359
|
};
|
|
4974
5360
|
|
|
4975
5361
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
4976
|
-
import { applyToPoint as
|
|
5362
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
4977
5363
|
var createSvgObjectsFromSchematicBox = ({
|
|
4978
5364
|
schematicBox,
|
|
4979
5365
|
transform,
|
|
4980
5366
|
colorMap: colorMap2
|
|
4981
5367
|
}) => {
|
|
4982
|
-
const topLeft =
|
|
5368
|
+
const topLeft = applyToPoint41(transform, {
|
|
4983
5369
|
x: schematicBox.x,
|
|
4984
5370
|
y: schematicBox.y
|
|
4985
5371
|
});
|
|
4986
|
-
const bottomRight =
|
|
5372
|
+
const bottomRight = applyToPoint41(transform, {
|
|
4987
5373
|
x: schematicBox.x + schematicBox.width,
|
|
4988
5374
|
y: schematicBox.y + schematicBox.height
|
|
4989
5375
|
});
|
|
@@ -5225,18 +5611,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
5225
5611
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
5226
5612
|
import { stringify as stringify4 } from "svgson";
|
|
5227
5613
|
import {
|
|
5228
|
-
applyToPoint as
|
|
5614
|
+
applyToPoint as applyToPoint44,
|
|
5229
5615
|
compose as compose11,
|
|
5230
5616
|
scale as scale8,
|
|
5231
5617
|
translate as translate11
|
|
5232
5618
|
} from "transformation-matrix";
|
|
5233
5619
|
|
|
5234
5620
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
5235
|
-
import { applyToPoint as
|
|
5621
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5236
5622
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
5237
5623
|
const { transform, layer: layerFilter } = ctx;
|
|
5238
5624
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
5239
|
-
const [x, y] =
|
|
5625
|
+
const [x, y] = applyToPoint43(transform, [solderPaste.x, solderPaste.y]);
|
|
5240
5626
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
5241
5627
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
5242
5628
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -5435,8 +5821,8 @@ function createSvgObjects3({ elm, ctx }) {
|
|
|
5435
5821
|
}
|
|
5436
5822
|
}
|
|
5437
5823
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
5438
|
-
const [x1, y1] =
|
|
5439
|
-
const [x2, y2] =
|
|
5824
|
+
const [x1, y1] = applyToPoint44(transform, [minX, minY]);
|
|
5825
|
+
const [x2, y2] = applyToPoint44(transform, [maxX, maxY]);
|
|
5440
5826
|
const width = Math.abs(x2 - x1);
|
|
5441
5827
|
const height = Math.abs(y2 - y1);
|
|
5442
5828
|
const x = Math.min(x1, x2);
|