circuit-to-svg 0.0.301 → 0.0.302
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 +2 -0
- package/dist/index.js +305 -199
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { distance as distance2 } from "circuit-json";
|
|
3
3
|
import { stringify } from "svgson";
|
|
4
4
|
import {
|
|
5
|
-
applyToPoint as
|
|
6
|
-
compose as
|
|
5
|
+
applyToPoint as applyToPoint35,
|
|
6
|
+
compose as compose7,
|
|
7
7
|
scale as scale3,
|
|
8
|
-
translate as
|
|
8
|
+
translate as translate7
|
|
9
9
|
} from "transformation-matrix";
|
|
10
10
|
|
|
11
11
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace-error.ts
|
|
@@ -2751,6 +2751,8 @@ var DEFAULT_PCB_COLOR_MAP = {
|
|
|
2751
2751
|
},
|
|
2752
2752
|
boardOutline: "rgba(255, 255, 255, 0.5)",
|
|
2753
2753
|
courtyard: "#FF00FF",
|
|
2754
|
+
keepout: "#FF6B6B",
|
|
2755
|
+
// Red color for keepout zones
|
|
2754
2756
|
debugComponent: {
|
|
2755
2757
|
fill: null,
|
|
2756
2758
|
stroke: null
|
|
@@ -5128,21 +5130,108 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
5128
5130
|
return [];
|
|
5129
5131
|
}
|
|
5130
5132
|
|
|
5131
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-
|
|
5133
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-keepout.ts
|
|
5132
5134
|
import {
|
|
5133
|
-
applyToPoint as
|
|
5135
|
+
applyToPoint as applyToPoint30,
|
|
5134
5136
|
compose as compose5,
|
|
5137
|
+
translate as translate5,
|
|
5138
|
+
toString as matrixToString8
|
|
5139
|
+
} from "transformation-matrix";
|
|
5140
|
+
function createSvgObjectsFromPcbKeepout(keepout, ctx) {
|
|
5141
|
+
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
5142
|
+
if (layerFilter && !keepout.layers.includes(layerFilter)) {
|
|
5143
|
+
return [];
|
|
5144
|
+
}
|
|
5145
|
+
const svgObjects = [];
|
|
5146
|
+
for (const layer of keepout.layers) {
|
|
5147
|
+
if (layerFilter && layer !== layerFilter) {
|
|
5148
|
+
continue;
|
|
5149
|
+
}
|
|
5150
|
+
if (keepout.shape === "rect") {
|
|
5151
|
+
const rectKeepout = keepout;
|
|
5152
|
+
const [cx, cy] = applyToPoint30(transform, [
|
|
5153
|
+
rectKeepout.center.x,
|
|
5154
|
+
rectKeepout.center.y
|
|
5155
|
+
]);
|
|
5156
|
+
const scaledWidth = rectKeepout.width * Math.abs(transform.a);
|
|
5157
|
+
const scaledHeight = rectKeepout.height * Math.abs(transform.d);
|
|
5158
|
+
const transformedStrokeWidth = 0.1 * Math.abs(transform.a);
|
|
5159
|
+
const attributes = {
|
|
5160
|
+
class: "pcb-keepout pcb-keepout-rect",
|
|
5161
|
+
x: (-scaledWidth / 2).toString(),
|
|
5162
|
+
y: (-scaledHeight / 2).toString(),
|
|
5163
|
+
width: scaledWidth.toString(),
|
|
5164
|
+
height: scaledHeight.toString(),
|
|
5165
|
+
fill: "none",
|
|
5166
|
+
stroke: colorMap2.keepout ?? "#FF6B6B",
|
|
5167
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
5168
|
+
"stroke-dasharray": `${transformedStrokeWidth * 3} ${transformedStrokeWidth * 2}`,
|
|
5169
|
+
transform: matrixToString8(compose5(translate5(cx, cy))),
|
|
5170
|
+
"data-type": "pcb_keepout",
|
|
5171
|
+
"data-pcb-layer": layer,
|
|
5172
|
+
"data-pcb-keepout-id": rectKeepout.pcb_keepout_id
|
|
5173
|
+
};
|
|
5174
|
+
if (rectKeepout.description) {
|
|
5175
|
+
attributes["data-description"] = rectKeepout.description;
|
|
5176
|
+
}
|
|
5177
|
+
svgObjects.push({
|
|
5178
|
+
name: "rect",
|
|
5179
|
+
type: "element",
|
|
5180
|
+
attributes,
|
|
5181
|
+
children: [],
|
|
5182
|
+
value: ""
|
|
5183
|
+
});
|
|
5184
|
+
} else if (keepout.shape === "circle") {
|
|
5185
|
+
const circleKeepout = keepout;
|
|
5186
|
+
const [cx, cy] = applyToPoint30(transform, [
|
|
5187
|
+
circleKeepout.center.x,
|
|
5188
|
+
circleKeepout.center.y
|
|
5189
|
+
]);
|
|
5190
|
+
const scaledRadius = circleKeepout.radius * Math.abs(transform.a);
|
|
5191
|
+
const transformedStrokeWidth = 0.1 * Math.abs(transform.a);
|
|
5192
|
+
const attributes = {
|
|
5193
|
+
class: "pcb-keepout pcb-keepout-circle",
|
|
5194
|
+
cx: cx.toString(),
|
|
5195
|
+
cy: cy.toString(),
|
|
5196
|
+
r: scaledRadius.toString(),
|
|
5197
|
+
fill: "none",
|
|
5198
|
+
stroke: colorMap2.keepout ?? "#FF6B6B",
|
|
5199
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
5200
|
+
"stroke-dasharray": `${transformedStrokeWidth * 3} ${transformedStrokeWidth * 2}`,
|
|
5201
|
+
"data-type": "pcb_keepout",
|
|
5202
|
+
"data-pcb-layer": layer,
|
|
5203
|
+
"data-pcb-keepout-id": circleKeepout.pcb_keepout_id
|
|
5204
|
+
};
|
|
5205
|
+
if (circleKeepout.description) {
|
|
5206
|
+
attributes["data-description"] = circleKeepout.description;
|
|
5207
|
+
}
|
|
5208
|
+
svgObjects.push({
|
|
5209
|
+
name: "circle",
|
|
5210
|
+
type: "element",
|
|
5211
|
+
attributes,
|
|
5212
|
+
children: [],
|
|
5213
|
+
value: ""
|
|
5214
|
+
});
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
return svgObjects;
|
|
5218
|
+
}
|
|
5219
|
+
|
|
5220
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
5221
|
+
import {
|
|
5222
|
+
applyToPoint as applyToPoint32,
|
|
5223
|
+
compose as compose6,
|
|
5135
5224
|
rotate as rotate5,
|
|
5136
|
-
toString as
|
|
5137
|
-
translate as
|
|
5225
|
+
toString as matrixToString9,
|
|
5226
|
+
translate as translate6
|
|
5138
5227
|
} from "transformation-matrix";
|
|
5139
5228
|
|
|
5140
5229
|
// lib/utils/ring-to-path-d.ts
|
|
5141
|
-
import { applyToPoint as
|
|
5230
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
5142
5231
|
function ringToPathD(vertices, transform) {
|
|
5143
5232
|
if (vertices.length === 0) return "";
|
|
5144
5233
|
const transformedVertices = vertices.map((v) => {
|
|
5145
|
-
const [x, y] =
|
|
5234
|
+
const [x, y] = applyToPoint31(transform, [v.x, v.y]);
|
|
5146
5235
|
return { ...v, x, y };
|
|
5147
5236
|
});
|
|
5148
5237
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -5231,7 +5320,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
5231
5320
|
const maskOverlayColor = layer === "bottom" ? colorMap2.soldermaskOverCopper.bottom : colorMap2.soldermaskOverCopper.top;
|
|
5232
5321
|
const maskOverlayOpacity = "0.9";
|
|
5233
5322
|
if (pour.shape === "rect") {
|
|
5234
|
-
const [cx, cy] =
|
|
5323
|
+
const [cx, cy] = applyToPoint32(transform, [pour.center.x, pour.center.y]);
|
|
5235
5324
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
5236
5325
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
5237
5326
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -5240,8 +5329,8 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
5240
5329
|
y: (-scaledHeight / 2).toString(),
|
|
5241
5330
|
width: scaledWidth.toString(),
|
|
5242
5331
|
height: scaledHeight.toString(),
|
|
5243
|
-
transform:
|
|
5244
|
-
|
|
5332
|
+
transform: matrixToString9(
|
|
5333
|
+
compose6(translate6(cx, cy), rotate5(svgRotation * Math.PI / 180))
|
|
5245
5334
|
)
|
|
5246
5335
|
};
|
|
5247
5336
|
const copperRect = {
|
|
@@ -5283,7 +5372,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
5283
5372
|
if (pour.shape === "polygon") {
|
|
5284
5373
|
if (!pour.points || pour.points.length === 0) return [];
|
|
5285
5374
|
const transformedPoints = pour.points.map(
|
|
5286
|
-
(p) =>
|
|
5375
|
+
(p) => applyToPoint32(transform, [p.x, p.y])
|
|
5287
5376
|
);
|
|
5288
5377
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
5289
5378
|
const copperPolygon = {
|
|
@@ -5506,11 +5595,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
5506
5595
|
}
|
|
5507
5596
|
|
|
5508
5597
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
5509
|
-
import { applyToPoint as
|
|
5598
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
5510
5599
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
5511
5600
|
const { transform, circuitJson } = ctx;
|
|
5512
5601
|
const { center, width, height, rotation = 0 } = component;
|
|
5513
|
-
const [x, y] =
|
|
5602
|
+
const [x, y] = applyToPoint33(transform, [center.x, center.y]);
|
|
5514
5603
|
const scaledWidth = width * Math.abs(transform.a);
|
|
5515
5604
|
const scaledHeight = height * Math.abs(transform.d);
|
|
5516
5605
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -5582,7 +5671,7 @@ function getParentAnchorPosition(component, circuitJson) {
|
|
|
5582
5671
|
}
|
|
5583
5672
|
|
|
5584
5673
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-group.ts
|
|
5585
|
-
import { applyToPoint as
|
|
5674
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
5586
5675
|
var DEFAULT_GROUP_COLOR = "rgba(100, 200, 255, 0.6)";
|
|
5587
5676
|
var DEFAULT_STROKE_WIDTH = 0.1;
|
|
5588
5677
|
function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
@@ -5626,7 +5715,7 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5626
5715
|
(point) => point && typeof point.x === "number" && typeof point.y === "number"
|
|
5627
5716
|
)) {
|
|
5628
5717
|
const path = outline.map((point, index) => {
|
|
5629
|
-
const [x, y] =
|
|
5718
|
+
const [x, y] = applyToPoint34(transform, [point.x, point.y]);
|
|
5630
5719
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
5631
5720
|
}).join(" ");
|
|
5632
5721
|
svgObjects.push({
|
|
@@ -5647,11 +5736,11 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5647
5736
|
}
|
|
5648
5737
|
const halfWidth = width / 2;
|
|
5649
5738
|
const halfHeight = height / 2;
|
|
5650
|
-
const [topLeftX, topLeftY] =
|
|
5739
|
+
const [topLeftX, topLeftY] = applyToPoint34(transform, [
|
|
5651
5740
|
center.x - halfWidth,
|
|
5652
5741
|
center.y + halfHeight
|
|
5653
5742
|
]);
|
|
5654
|
-
const [bottomRightX, bottomRightY] =
|
|
5743
|
+
const [bottomRightX, bottomRightY] = applyToPoint34(transform, [
|
|
5655
5744
|
center.x + halfWidth,
|
|
5656
5745
|
center.y - halfHeight
|
|
5657
5746
|
]);
|
|
@@ -5705,7 +5794,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
5705
5794
|
var package_default = {
|
|
5706
5795
|
name: "circuit-to-svg",
|
|
5707
5796
|
type: "module",
|
|
5708
|
-
version: "0.0.
|
|
5797
|
+
version: "0.0.301",
|
|
5709
5798
|
description: "Convert Circuit JSON to SVG",
|
|
5710
5799
|
main: "dist/index.js",
|
|
5711
5800
|
files: [
|
|
@@ -5762,6 +5851,7 @@ var TYPE_PRIORITY = {
|
|
|
5762
5851
|
pcb_panel: 5,
|
|
5763
5852
|
pcb_board: 10,
|
|
5764
5853
|
pcb_cutout: 15,
|
|
5854
|
+
pcb_keepout: 16,
|
|
5765
5855
|
pcb_hole: 18,
|
|
5766
5856
|
pcb_plated_hole_drill: 19,
|
|
5767
5857
|
pcb_plated_hole: 20,
|
|
@@ -5920,6 +6010,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5920
6010
|
},
|
|
5921
6011
|
substrate: colorOverrides?.substrate ?? DEFAULT_PCB_COLOR_MAP.substrate,
|
|
5922
6012
|
courtyard: colorOverrides?.courtyard ?? DEFAULT_PCB_COLOR_MAP.courtyard,
|
|
6013
|
+
keepout: colorOverrides?.keepout ?? DEFAULT_PCB_COLOR_MAP.keepout,
|
|
5923
6014
|
debugComponent: {
|
|
5924
6015
|
fill: colorOverrides?.debugComponent?.fill ?? DEFAULT_PCB_COLOR_MAP.debugComponent.fill,
|
|
5925
6016
|
stroke: colorOverrides?.debugComponent?.stroke ?? DEFAULT_PCB_COLOR_MAP.debugComponent.stroke
|
|
@@ -5995,6 +6086,16 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5995
6086
|
} else if (cutout.shape === "polygon") {
|
|
5996
6087
|
updateTraceBounds(cutout.points);
|
|
5997
6088
|
}
|
|
6089
|
+
} else if (circuitJsonElm.type === "pcb_keepout") {
|
|
6090
|
+
const keepout = circuitJsonElm;
|
|
6091
|
+
if (keepout.shape === "rect") {
|
|
6092
|
+
updateBounds(keepout.center, keepout.width, keepout.height);
|
|
6093
|
+
} else if (keepout.shape === "circle") {
|
|
6094
|
+
const radius = typeof keepout.radius === "number" ? keepout.radius : distance2.parse(keepout.radius) ?? 0;
|
|
6095
|
+
if (radius > 0) {
|
|
6096
|
+
updateBounds(keepout.center, radius * 2, radius * 2);
|
|
6097
|
+
}
|
|
6098
|
+
}
|
|
5998
6099
|
} else if (circuitJsonElm.type === "pcb_silkscreen_text" || circuitJsonElm.type === "pcb_silkscreen_rect" || circuitJsonElm.type === "pcb_silkscreen_circle" || circuitJsonElm.type === "pcb_silkscreen_line") {
|
|
5999
6100
|
updateSilkscreenBounds(circuitJsonElm);
|
|
6000
6101
|
} else if (circuitJsonElm.type === "pcb_copper_text") {
|
|
@@ -6045,8 +6146,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
6045
6146
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
6046
6147
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
6047
6148
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
6048
|
-
const transform =
|
|
6049
|
-
|
|
6149
|
+
const transform = compose7(
|
|
6150
|
+
translate7(
|
|
6050
6151
|
offsetX - boundsMinX * scaleFactor + padding * scaleFactor,
|
|
6051
6152
|
svgHeight - offsetY + boundsMinY * scaleFactor - padding * scaleFactor
|
|
6052
6153
|
),
|
|
@@ -6345,6 +6446,11 @@ function createSvgObjects({
|
|
|
6345
6446
|
return createSvgObjectsFromPcbVia(elm, ctx);
|
|
6346
6447
|
case "pcb_cutout":
|
|
6347
6448
|
return createSvgObjectsFromPcbCutout(elm, ctx);
|
|
6449
|
+
case "pcb_keepout":
|
|
6450
|
+
return createSvgObjectsFromPcbKeepout(
|
|
6451
|
+
elm,
|
|
6452
|
+
ctx
|
|
6453
|
+
);
|
|
6348
6454
|
case "pcb_group":
|
|
6349
6455
|
return ctx.showPcbGroups ? createSvgObjectsFromPcbGroup(elm, ctx) : [];
|
|
6350
6456
|
default:
|
|
@@ -6352,8 +6458,8 @@ function createSvgObjects({
|
|
|
6352
6458
|
}
|
|
6353
6459
|
}
|
|
6354
6460
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
6355
|
-
const [x1, y1] =
|
|
6356
|
-
const [x2, y2] =
|
|
6461
|
+
const [x1, y1] = applyToPoint35(transform, [minX, minY]);
|
|
6462
|
+
const [x2, y2] = applyToPoint35(transform, [maxX, maxY]);
|
|
6357
6463
|
const width = Math.abs(x2 - x1);
|
|
6358
6464
|
const height = Math.abs(y2 - y1);
|
|
6359
6465
|
const x = Math.min(x1, x2);
|
|
@@ -6383,14 +6489,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
6383
6489
|
import { stringify as stringify2 } from "svgson";
|
|
6384
6490
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
6385
6491
|
import {
|
|
6386
|
-
applyToPoint as
|
|
6387
|
-
compose as
|
|
6492
|
+
applyToPoint as applyToPoint42,
|
|
6493
|
+
compose as compose8,
|
|
6388
6494
|
scale as scale4,
|
|
6389
|
-
translate as
|
|
6495
|
+
translate as translate8
|
|
6390
6496
|
} from "transformation-matrix";
|
|
6391
6497
|
|
|
6392
6498
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
6393
|
-
import { applyToPoint as
|
|
6499
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
6394
6500
|
var DEFAULT_BOARD_STYLE = {
|
|
6395
6501
|
fill: "none",
|
|
6396
6502
|
stroke: "rgb(0,0,0)",
|
|
@@ -6402,25 +6508,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
6402
6508
|
let path;
|
|
6403
6509
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
6404
6510
|
path = outline.map((point, index) => {
|
|
6405
|
-
const [x, y] =
|
|
6511
|
+
const [x, y] = applyToPoint36(transform, [point.x, point.y]);
|
|
6406
6512
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
6407
6513
|
}).join(" ");
|
|
6408
6514
|
} else {
|
|
6409
6515
|
const halfWidth = width / 2;
|
|
6410
6516
|
const halfHeight = height / 2;
|
|
6411
|
-
const topLeft =
|
|
6517
|
+
const topLeft = applyToPoint36(transform, [
|
|
6412
6518
|
center.x - halfWidth,
|
|
6413
6519
|
center.y - halfHeight
|
|
6414
6520
|
]);
|
|
6415
|
-
const topRight =
|
|
6521
|
+
const topRight = applyToPoint36(transform, [
|
|
6416
6522
|
center.x + halfWidth,
|
|
6417
6523
|
center.y - halfHeight
|
|
6418
6524
|
]);
|
|
6419
|
-
const bottomRight =
|
|
6525
|
+
const bottomRight = applyToPoint36(transform, [
|
|
6420
6526
|
center.x + halfWidth,
|
|
6421
6527
|
center.y + halfHeight
|
|
6422
6528
|
]);
|
|
6423
|
-
const bottomLeft =
|
|
6529
|
+
const bottomLeft = applyToPoint36(transform, [
|
|
6424
6530
|
center.x - halfWidth,
|
|
6425
6531
|
center.y + halfHeight
|
|
6426
6532
|
]);
|
|
@@ -6446,7 +6552,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
6446
6552
|
}
|
|
6447
6553
|
|
|
6448
6554
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
6449
|
-
import { applyToPoint as
|
|
6555
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
6450
6556
|
|
|
6451
6557
|
// lib/utils/get-sch-font-size.ts
|
|
6452
6558
|
import "transformation-matrix";
|
|
@@ -6472,8 +6578,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
6472
6578
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
6473
6579
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
6474
6580
|
return null;
|
|
6475
|
-
const [x, y] =
|
|
6476
|
-
const [pinX, pinY] =
|
|
6581
|
+
const [x, y] = applyToPoint38(transform, [center.x, center.y]);
|
|
6582
|
+
const [pinX, pinY] = applyToPoint38(transform, [portPosition.x, portPosition.y]);
|
|
6477
6583
|
const scaledWidth = width * Math.abs(transform.a);
|
|
6478
6584
|
const scaledHeight = height * Math.abs(transform.d);
|
|
6479
6585
|
const isTopLayer = layer === "top";
|
|
@@ -6635,11 +6741,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
6635
6741
|
}
|
|
6636
6742
|
|
|
6637
6743
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
6638
|
-
import { applyToPoint as
|
|
6744
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
6639
6745
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
6640
6746
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
6641
6747
|
const { transform } = ctx;
|
|
6642
|
-
const [x, y] =
|
|
6748
|
+
const [x, y] = applyToPoint39(transform, [hole.x, hole.y]);
|
|
6643
6749
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
6644
6750
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
6645
6751
|
const radius = scaledDiameter / 2;
|
|
@@ -6703,12 +6809,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
6703
6809
|
}
|
|
6704
6810
|
|
|
6705
6811
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
6706
|
-
import { applyToPoint as
|
|
6812
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
6707
6813
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
6708
6814
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
6709
6815
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
6710
6816
|
const { transform } = ctx;
|
|
6711
|
-
const [x, y] =
|
|
6817
|
+
const [x, y] = applyToPoint40(transform, [hole.x, hole.y]);
|
|
6712
6818
|
if (hole.shape === "pill") {
|
|
6713
6819
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
6714
6820
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -6803,7 +6909,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6803
6909
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
6804
6910
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
6805
6911
|
const holeRadius = scaledHoleDiameter / 2;
|
|
6806
|
-
const [holeCx, holeCy] =
|
|
6912
|
+
const [holeCx, holeCy] = applyToPoint40(transform, [
|
|
6807
6913
|
circularHole.x + circularHole.hole_offset_x,
|
|
6808
6914
|
circularHole.y + circularHole.hole_offset_y
|
|
6809
6915
|
]);
|
|
@@ -6861,7 +6967,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6861
6967
|
const pillHoleWithOffsets = pillHole;
|
|
6862
6968
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
6863
6969
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
6864
|
-
const [holeCenterX, holeCenterY] =
|
|
6970
|
+
const [holeCenterX, holeCenterY] = applyToPoint40(transform, [
|
|
6865
6971
|
pillHole.x + holeOffsetX,
|
|
6866
6972
|
pillHole.y + holeOffsetY
|
|
6867
6973
|
]);
|
|
@@ -6923,7 +7029,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6923
7029
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
6924
7030
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
6925
7031
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
6926
|
-
const [holeCenterX, holeCenterY] =
|
|
7032
|
+
const [holeCenterX, holeCenterY] = applyToPoint40(transform, [
|
|
6927
7033
|
rotatedHole.x + holeOffsetX,
|
|
6928
7034
|
rotatedHole.y + holeOffsetY
|
|
6929
7035
|
]);
|
|
@@ -6979,14 +7085,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6979
7085
|
}
|
|
6980
7086
|
|
|
6981
7087
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
6982
|
-
import { applyToPoint as
|
|
7088
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
6983
7089
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
6984
7090
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
6985
7091
|
const { transform } = ctx;
|
|
6986
7092
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
6987
7093
|
const width = pad.width * Math.abs(transform.a);
|
|
6988
7094
|
const height = pad.height * Math.abs(transform.d);
|
|
6989
|
-
const [x, y] =
|
|
7095
|
+
const [x, y] = applyToPoint41(transform, [pad.x, pad.y]);
|
|
6990
7096
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
6991
7097
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
6992
7098
|
return [
|
|
@@ -7038,7 +7144,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
7038
7144
|
const width = pad.width * Math.abs(transform.a);
|
|
7039
7145
|
const height = pad.height * Math.abs(transform.d);
|
|
7040
7146
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7041
|
-
const [x, y] =
|
|
7147
|
+
const [x, y] = applyToPoint41(transform, [pad.x, pad.y]);
|
|
7042
7148
|
return [
|
|
7043
7149
|
{
|
|
7044
7150
|
name: "rect",
|
|
@@ -7061,7 +7167,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
7061
7167
|
}
|
|
7062
7168
|
if (pad.shape === "circle") {
|
|
7063
7169
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7064
|
-
const [x, y] =
|
|
7170
|
+
const [x, y] = applyToPoint41(transform, [pad.x, pad.y]);
|
|
7065
7171
|
return [
|
|
7066
7172
|
{
|
|
7067
7173
|
name: "circle",
|
|
@@ -7081,7 +7187,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
7081
7187
|
}
|
|
7082
7188
|
if (pad.shape === "polygon") {
|
|
7083
7189
|
const points = (pad.points ?? []).map(
|
|
7084
|
-
(point) =>
|
|
7190
|
+
(point) => applyToPoint41(transform, [point.x, point.y])
|
|
7085
7191
|
);
|
|
7086
7192
|
return [
|
|
7087
7193
|
{
|
|
@@ -7135,8 +7241,8 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
7135
7241
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
7136
7242
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
7137
7243
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
7138
|
-
const transform =
|
|
7139
|
-
|
|
7244
|
+
const transform = compose8(
|
|
7245
|
+
translate8(
|
|
7140
7246
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
7141
7247
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
7142
7248
|
),
|
|
@@ -7265,8 +7371,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
7265
7371
|
}
|
|
7266
7372
|
}
|
|
7267
7373
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
7268
|
-
const [x1, y1] =
|
|
7269
|
-
const [x2, y2] =
|
|
7374
|
+
const [x1, y1] = applyToPoint42(transform, [minX, minY]);
|
|
7375
|
+
const [x2, y2] = applyToPoint42(transform, [maxX, maxY]);
|
|
7270
7376
|
const width = Math.abs(x2 - x1);
|
|
7271
7377
|
const height = Math.abs(y2 - y1);
|
|
7272
7378
|
const x = Math.min(x1, x2);
|
|
@@ -7289,13 +7395,13 @@ function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY)
|
|
|
7289
7395
|
// lib/pinout/convert-circuit-json-to-pinout-svg.ts
|
|
7290
7396
|
import { stringify as stringify3 } from "svgson";
|
|
7291
7397
|
import {
|
|
7292
|
-
compose as
|
|
7398
|
+
compose as compose9,
|
|
7293
7399
|
scale as matrixScale,
|
|
7294
|
-
translate as
|
|
7400
|
+
translate as translate9
|
|
7295
7401
|
} from "transformation-matrix";
|
|
7296
7402
|
|
|
7297
7403
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
7298
|
-
import { applyToPoint as
|
|
7404
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
7299
7405
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
7300
7406
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
7301
7407
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -7309,25 +7415,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
7309
7415
|
let path;
|
|
7310
7416
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
7311
7417
|
path = outline.map((point, index) => {
|
|
7312
|
-
const [x, y] =
|
|
7418
|
+
const [x, y] = applyToPoint43(transform, [point.x, point.y]);
|
|
7313
7419
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
7314
7420
|
}).join(" ");
|
|
7315
7421
|
} else {
|
|
7316
7422
|
const halfWidth = width / 2;
|
|
7317
7423
|
const halfHeight = height / 2;
|
|
7318
|
-
const topLeft =
|
|
7424
|
+
const topLeft = applyToPoint43(transform, [
|
|
7319
7425
|
center.x - halfWidth,
|
|
7320
7426
|
center.y - halfHeight
|
|
7321
7427
|
]);
|
|
7322
|
-
const topRight =
|
|
7428
|
+
const topRight = applyToPoint43(transform, [
|
|
7323
7429
|
center.x + halfWidth,
|
|
7324
7430
|
center.y - halfHeight
|
|
7325
7431
|
]);
|
|
7326
|
-
const bottomRight =
|
|
7432
|
+
const bottomRight = applyToPoint43(transform, [
|
|
7327
7433
|
center.x + halfWidth,
|
|
7328
7434
|
center.y + halfHeight
|
|
7329
7435
|
]);
|
|
7330
|
-
const bottomLeft =
|
|
7436
|
+
const bottomLeft = applyToPoint43(transform, [
|
|
7331
7437
|
center.x - halfWidth,
|
|
7332
7438
|
center.y + halfHeight
|
|
7333
7439
|
]);
|
|
@@ -7345,10 +7451,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
7345
7451
|
const halfWidth = width2 / 2;
|
|
7346
7452
|
const halfHeight = height2 / 2;
|
|
7347
7453
|
const [tl, tr, br, bl] = [
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7454
|
+
applyToPoint43(transform, [x - halfWidth, y - halfHeight]),
|
|
7455
|
+
applyToPoint43(transform, [x + halfWidth, y - halfHeight]),
|
|
7456
|
+
applyToPoint43(transform, [x + halfWidth, y + halfHeight]),
|
|
7457
|
+
applyToPoint43(transform, [x - halfWidth, y + halfHeight])
|
|
7352
7458
|
];
|
|
7353
7459
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
7354
7460
|
} else if (cutout.shape === "circle") {
|
|
@@ -7398,7 +7504,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
7398
7504
|
|
|
7399
7505
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
7400
7506
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
7401
|
-
import { applyToPoint as
|
|
7507
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
7402
7508
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
7403
7509
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
7404
7510
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -7408,7 +7514,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
7408
7514
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
7409
7515
|
return [];
|
|
7410
7516
|
}
|
|
7411
|
-
const [x, y] =
|
|
7517
|
+
const [x, y] = applyToPoint44(transform, [center.x, center.y]);
|
|
7412
7518
|
const scaledWidth = width * Math.abs(transform.a);
|
|
7413
7519
|
const scaledHeight = height * Math.abs(transform.d);
|
|
7414
7520
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -7469,11 +7575,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
7469
7575
|
}
|
|
7470
7576
|
|
|
7471
7577
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
7472
|
-
import { applyToPoint as
|
|
7578
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
7473
7579
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
7474
7580
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
7475
7581
|
const { transform } = ctx;
|
|
7476
|
-
const [x, y] =
|
|
7582
|
+
const [x, y] = applyToPoint45(transform, [hole.x, hole.y]);
|
|
7477
7583
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
7478
7584
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
7479
7585
|
const radius = scaledDiameter / 2;
|
|
@@ -7537,12 +7643,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
7537
7643
|
}
|
|
7538
7644
|
|
|
7539
7645
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
7540
|
-
import { applyToPoint as
|
|
7646
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
7541
7647
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
7542
7648
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
7543
7649
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
7544
7650
|
const { transform } = ctx;
|
|
7545
|
-
const [x, y] =
|
|
7651
|
+
const [x, y] = applyToPoint46(transform, [hole.x, hole.y]);
|
|
7546
7652
|
if (hole.shape === "pill") {
|
|
7547
7653
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
7548
7654
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -7777,14 +7883,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
7777
7883
|
}
|
|
7778
7884
|
|
|
7779
7885
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
7780
|
-
import { applyToPoint as
|
|
7886
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7781
7887
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
7782
7888
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
7783
7889
|
const { transform } = ctx;
|
|
7784
7890
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
7785
7891
|
const width = pad.width * Math.abs(transform.a);
|
|
7786
7892
|
const height = pad.height * Math.abs(transform.d);
|
|
7787
|
-
const [x, y] =
|
|
7893
|
+
const [x, y] = applyToPoint47(transform, [pad.x, pad.y]);
|
|
7788
7894
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
7789
7895
|
return [
|
|
7790
7896
|
{
|
|
@@ -7827,7 +7933,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7827
7933
|
const width = pad.width * Math.abs(transform.a);
|
|
7828
7934
|
const height = pad.height * Math.abs(transform.d);
|
|
7829
7935
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7830
|
-
const [x, y] =
|
|
7936
|
+
const [x, y] = applyToPoint47(transform, [pad.x, pad.y]);
|
|
7831
7937
|
return [
|
|
7832
7938
|
{
|
|
7833
7939
|
name: "rect",
|
|
@@ -7850,7 +7956,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7850
7956
|
}
|
|
7851
7957
|
if (pad.shape === "circle") {
|
|
7852
7958
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7853
|
-
const [x, y] =
|
|
7959
|
+
const [x, y] = applyToPoint47(transform, [pad.x, pad.y]);
|
|
7854
7960
|
return [
|
|
7855
7961
|
{
|
|
7856
7962
|
name: "circle",
|
|
@@ -7870,7 +7976,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7870
7976
|
}
|
|
7871
7977
|
if (pad.shape === "polygon") {
|
|
7872
7978
|
const points = (pad.points ?? []).map(
|
|
7873
|
-
(point) =>
|
|
7979
|
+
(point) => applyToPoint47(transform, [point.x, point.y])
|
|
7874
7980
|
);
|
|
7875
7981
|
return [
|
|
7876
7982
|
{
|
|
@@ -7891,7 +7997,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7891
7997
|
}
|
|
7892
7998
|
|
|
7893
7999
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
7894
|
-
import { applyToPoint as
|
|
8000
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
7895
8001
|
import { calculateElbow } from "calculate-elbow";
|
|
7896
8002
|
|
|
7897
8003
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -7968,7 +8074,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
7968
8074
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
7969
8075
|
if (!label_info) return [];
|
|
7970
8076
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
7971
|
-
const [port_x, port_y] =
|
|
8077
|
+
const [port_x, port_y] = applyToPoint48(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
7972
8078
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
7973
8079
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
7974
8080
|
const elbow_path = calculateElbow(
|
|
@@ -8109,7 +8215,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
8109
8215
|
}
|
|
8110
8216
|
|
|
8111
8217
|
// lib/pinout/calculate-label-positions.ts
|
|
8112
|
-
import { applyToPoint as
|
|
8218
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
8113
8219
|
|
|
8114
8220
|
// lib/pinout/constants.ts
|
|
8115
8221
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -8147,7 +8253,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
8147
8253
|
);
|
|
8148
8254
|
const mapToEdgePort = (pinout_label) => ({
|
|
8149
8255
|
pcb_port: pinout_label.pcb_port,
|
|
8150
|
-
y:
|
|
8256
|
+
y: applyToPoint49(transform, [
|
|
8151
8257
|
pinout_label.pcb_port.x,
|
|
8152
8258
|
pinout_label.pcb_port.y
|
|
8153
8259
|
])[1],
|
|
@@ -8162,7 +8268,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
8162
8268
|
} else {
|
|
8163
8269
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
8164
8270
|
pcb_port: pinout_label.pcb_port,
|
|
8165
|
-
y:
|
|
8271
|
+
y: applyToPoint49(transform, [
|
|
8166
8272
|
pinout_label.pcb_port.x,
|
|
8167
8273
|
pinout_label.pcb_port.y
|
|
8168
8274
|
])[1],
|
|
@@ -8170,7 +8276,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
8170
8276
|
})).sort((a, b) => a.y - b.y);
|
|
8171
8277
|
}
|
|
8172
8278
|
if (edge_ports.length === 0) return;
|
|
8173
|
-
const board_edge_x =
|
|
8279
|
+
const board_edge_x = applyToPoint49(transform, [
|
|
8174
8280
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
8175
8281
|
0
|
|
8176
8282
|
])[0];
|
|
@@ -8490,8 +8596,8 @@ function convertCircuitJsonToPinoutSvg(soup, options) {
|
|
|
8490
8596
|
const pxPerMm = Math.min(pxPerMmX, pxPerMmY);
|
|
8491
8597
|
const offsetX = (svgWidth - circuitWidth * pxPerMm) / 2;
|
|
8492
8598
|
const offsetY = (svgHeight - circuitHeight * pxPerMm) / 2;
|
|
8493
|
-
const transform =
|
|
8494
|
-
|
|
8599
|
+
const transform = compose9(
|
|
8600
|
+
translate9(
|
|
8495
8601
|
offsetX - expandedMinX * pxPerMm + paddingMm * pxPerMm,
|
|
8496
8602
|
svgHeight - offsetY + minY * pxPerMm - paddingMm * pxPerMm
|
|
8497
8603
|
),
|
|
@@ -8592,14 +8698,14 @@ import {
|
|
|
8592
8698
|
} from "transformation-matrix";
|
|
8593
8699
|
|
|
8594
8700
|
// lib/sch/draw-schematic-grid.ts
|
|
8595
|
-
import { applyToPoint as
|
|
8701
|
+
import { applyToPoint as applyToPoint50 } from "transformation-matrix";
|
|
8596
8702
|
function drawSchematicGrid(params) {
|
|
8597
8703
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
8598
8704
|
const cellSize = params.cellSize ?? 1;
|
|
8599
8705
|
const labelCells = params.labelCells ?? false;
|
|
8600
8706
|
const gridLines = [];
|
|
8601
8707
|
const transformPoint = (x, y) => {
|
|
8602
|
-
const [transformedX, transformedY] =
|
|
8708
|
+
const [transformedX, transformedY] = applyToPoint50(params.transform, [x, y]);
|
|
8603
8709
|
return { x: transformedX, y: transformedY };
|
|
8604
8710
|
};
|
|
8605
8711
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -8680,15 +8786,15 @@ function drawSchematicGrid(params) {
|
|
|
8680
8786
|
}
|
|
8681
8787
|
|
|
8682
8788
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
8683
|
-
import { applyToPoint as
|
|
8789
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
8684
8790
|
function drawSchematicLabeledPoints(params) {
|
|
8685
8791
|
const { points, transform } = params;
|
|
8686
8792
|
const labeledPointsGroup = [];
|
|
8687
8793
|
for (const point of points) {
|
|
8688
|
-
const [x1, y1] =
|
|
8689
|
-
const [x2, y2] =
|
|
8690
|
-
const [x3, y3] =
|
|
8691
|
-
const [x4, y4] =
|
|
8794
|
+
const [x1, y1] = applyToPoint51(transform, [point.x - 0.1, point.y - 0.1]);
|
|
8795
|
+
const [x2, y2] = applyToPoint51(transform, [point.x + 0.1, point.y + 0.1]);
|
|
8796
|
+
const [x3, y3] = applyToPoint51(transform, [point.x - 0.1, point.y + 0.1]);
|
|
8797
|
+
const [x4, y4] = applyToPoint51(transform, [point.x + 0.1, point.y - 0.1]);
|
|
8692
8798
|
labeledPointsGroup.push({
|
|
8693
8799
|
name: "path",
|
|
8694
8800
|
type: "element",
|
|
@@ -8699,7 +8805,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
8699
8805
|
"stroke-opacity": "0.7"
|
|
8700
8806
|
}
|
|
8701
8807
|
});
|
|
8702
|
-
const [labelX, labelY] =
|
|
8808
|
+
const [labelX, labelY] = applyToPoint51(transform, [
|
|
8703
8809
|
point.x + 0.15,
|
|
8704
8810
|
point.y - 0.15
|
|
8705
8811
|
]);
|
|
@@ -9817,8 +9923,8 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
9817
9923
|
import { symbols } from "schematic-symbols";
|
|
9818
9924
|
import "svgson";
|
|
9819
9925
|
import {
|
|
9820
|
-
applyToPoint as
|
|
9821
|
-
compose as
|
|
9926
|
+
applyToPoint as applyToPoint53,
|
|
9927
|
+
compose as compose11
|
|
9822
9928
|
} from "transformation-matrix";
|
|
9823
9929
|
|
|
9824
9930
|
// lib/utils/get-sch-stroke-size.ts
|
|
@@ -9888,26 +9994,26 @@ var matchSchPortsToSymbolPorts = ({
|
|
|
9888
9994
|
};
|
|
9889
9995
|
|
|
9890
9996
|
// lib/utils/point-pairs-to-matrix.ts
|
|
9891
|
-
import { compose as
|
|
9997
|
+
import { compose as compose10, scale as scale5, translate as translate10 } from "transformation-matrix";
|
|
9892
9998
|
function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
9893
9999
|
const tx = a2.x - a1.x;
|
|
9894
10000
|
const ty = a2.y - a1.y;
|
|
9895
10001
|
const originalDistance = Math.sqrt((b1.x - a1.x) ** 2 + (b1.y - a1.y) ** 2);
|
|
9896
10002
|
const transformedDistance = Math.sqrt((b2.x - a2.x) ** 2 + (b2.y - a2.y) ** 2);
|
|
9897
10003
|
const a = transformedDistance / originalDistance;
|
|
9898
|
-
const translateMatrix =
|
|
10004
|
+
const translateMatrix = translate10(tx, ty);
|
|
9899
10005
|
const scaleMatrix = scale5(a, a);
|
|
9900
|
-
return
|
|
10006
|
+
return compose10(translateMatrix, scaleMatrix);
|
|
9901
10007
|
}
|
|
9902
10008
|
|
|
9903
10009
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
9904
|
-
import { applyToPoint as
|
|
10010
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
9905
10011
|
var createSvgSchErrorText = ({
|
|
9906
10012
|
text,
|
|
9907
10013
|
realCenter,
|
|
9908
10014
|
realToScreenTransform
|
|
9909
10015
|
}) => {
|
|
9910
|
-
const screenCenter =
|
|
10016
|
+
const screenCenter = applyToPoint52(realToScreenTransform, realCenter);
|
|
9911
10017
|
return {
|
|
9912
10018
|
type: "element",
|
|
9913
10019
|
name: "text",
|
|
@@ -10016,12 +10122,12 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10016
10122
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
10017
10123
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
10018
10124
|
};
|
|
10019
|
-
const [screenMinX, screenMinY] =
|
|
10020
|
-
|
|
10125
|
+
const [screenMinX, screenMinY] = applyToPoint53(
|
|
10126
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10021
10127
|
[bounds.minX, bounds.minY]
|
|
10022
10128
|
);
|
|
10023
|
-
const [screenMaxX, screenMaxY] =
|
|
10024
|
-
|
|
10129
|
+
const [screenMaxX, screenMaxY] = applyToPoint53(
|
|
10130
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10025
10131
|
[bounds.maxX, bounds.maxY]
|
|
10026
10132
|
);
|
|
10027
10133
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -10049,8 +10155,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10049
10155
|
name: "path",
|
|
10050
10156
|
attributes: {
|
|
10051
10157
|
d: points.map((p, i) => {
|
|
10052
|
-
const [x, y] =
|
|
10053
|
-
|
|
10158
|
+
const [x, y] = applyToPoint53(
|
|
10159
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10054
10160
|
[p.x, p.y]
|
|
10055
10161
|
);
|
|
10056
10162
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -10065,8 +10171,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10065
10171
|
});
|
|
10066
10172
|
}
|
|
10067
10173
|
for (const text of texts) {
|
|
10068
|
-
const screenTextPos =
|
|
10069
|
-
|
|
10174
|
+
const screenTextPos = applyToPoint53(
|
|
10175
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10070
10176
|
text
|
|
10071
10177
|
);
|
|
10072
10178
|
let textValue = "";
|
|
@@ -10117,11 +10223,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10117
10223
|
});
|
|
10118
10224
|
}
|
|
10119
10225
|
for (const box of boxes) {
|
|
10120
|
-
const screenBoxPos =
|
|
10121
|
-
|
|
10226
|
+
const screenBoxPos = applyToPoint53(
|
|
10227
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10122
10228
|
box
|
|
10123
10229
|
);
|
|
10124
|
-
const symbolToScreenScale =
|
|
10230
|
+
const symbolToScreenScale = compose11(
|
|
10125
10231
|
realToScreenTransform,
|
|
10126
10232
|
transformFromSymbolToReal
|
|
10127
10233
|
).a;
|
|
@@ -10141,8 +10247,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10141
10247
|
}
|
|
10142
10248
|
for (const port of symbol.ports) {
|
|
10143
10249
|
if (connectedSymbolPorts.has(port)) continue;
|
|
10144
|
-
const screenPortPos =
|
|
10145
|
-
|
|
10250
|
+
const screenPortPos = applyToPoint53(
|
|
10251
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10146
10252
|
port
|
|
10147
10253
|
);
|
|
10148
10254
|
svgObjects.push({
|
|
@@ -10161,8 +10267,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10161
10267
|
});
|
|
10162
10268
|
}
|
|
10163
10269
|
for (const circle of circles) {
|
|
10164
|
-
const screenCirclePos =
|
|
10165
|
-
|
|
10270
|
+
const screenCirclePos = applyToPoint53(
|
|
10271
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10166
10272
|
circle
|
|
10167
10273
|
);
|
|
10168
10274
|
const screenRadius = Math.abs(circle.radius * realToScreenTransform.a);
|
|
@@ -10188,14 +10294,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10188
10294
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
10189
10295
|
import "schematic-symbols";
|
|
10190
10296
|
import "svgson";
|
|
10191
|
-
import { applyToPoint as
|
|
10297
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
10192
10298
|
|
|
10193
10299
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
10194
10300
|
import "transformation-matrix";
|
|
10195
10301
|
import "@tscircuit/circuit-json-util";
|
|
10196
10302
|
|
|
10197
10303
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
10198
|
-
import { applyToPoint as
|
|
10304
|
+
import { applyToPoint as applyToPoint54 } from "transformation-matrix";
|
|
10199
10305
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
10200
10306
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
10201
10307
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -10248,8 +10354,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
10248
10354
|
realEdgePos.y += realPinLineLength;
|
|
10249
10355
|
break;
|
|
10250
10356
|
}
|
|
10251
|
-
const screenSchPortPos =
|
|
10252
|
-
const screenRealEdgePos =
|
|
10357
|
+
const screenSchPortPos = applyToPoint54(transform, schPort.center);
|
|
10358
|
+
const screenRealEdgePos = applyToPoint54(transform, realEdgePos);
|
|
10253
10359
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
10254
10360
|
const realLineEnd = { ...schPort.center };
|
|
10255
10361
|
if (!isConnected) {
|
|
@@ -10268,7 +10374,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
10268
10374
|
break;
|
|
10269
10375
|
}
|
|
10270
10376
|
}
|
|
10271
|
-
const screenLineEnd =
|
|
10377
|
+
const screenLineEnd = applyToPoint54(transform, realLineEnd);
|
|
10272
10378
|
svgObjects.push({
|
|
10273
10379
|
name: "line",
|
|
10274
10380
|
type: "element",
|
|
@@ -10389,7 +10495,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
10389
10495
|
};
|
|
10390
10496
|
|
|
10391
10497
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
10392
|
-
import { applyToPoint as
|
|
10498
|
+
import { applyToPoint as applyToPoint55 } from "transformation-matrix";
|
|
10393
10499
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
10394
10500
|
const svgObjects = [];
|
|
10395
10501
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -10407,7 +10513,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
10407
10513
|
} else {
|
|
10408
10514
|
realPinNumberPos.y += 0.02;
|
|
10409
10515
|
}
|
|
10410
|
-
const screenPinNumberTextPos =
|
|
10516
|
+
const screenPinNumberTextPos = applyToPoint55(transform, realPinNumberPos);
|
|
10411
10517
|
svgObjects.push({
|
|
10412
10518
|
name: "text",
|
|
10413
10519
|
type: "element",
|
|
@@ -10437,7 +10543,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
10437
10543
|
};
|
|
10438
10544
|
|
|
10439
10545
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
10440
|
-
import { applyToPoint as
|
|
10546
|
+
import { applyToPoint as applyToPoint56 } from "transformation-matrix";
|
|
10441
10547
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
10442
10548
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
10443
10549
|
const svgObjects = [];
|
|
@@ -10451,7 +10557,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
10451
10557
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
10452
10558
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
10453
10559
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
10454
|
-
const screenPinNumberTextPos =
|
|
10560
|
+
const screenPinNumberTextPos = applyToPoint56(transform, realPinNumberPos);
|
|
10455
10561
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
10456
10562
|
if (!label) return [];
|
|
10457
10563
|
const isNegated = label.startsWith("N_");
|
|
@@ -10499,13 +10605,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
10499
10605
|
};
|
|
10500
10606
|
|
|
10501
10607
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
10502
|
-
import { applyToPoint as
|
|
10608
|
+
import { applyToPoint as applyToPoint58 } from "transformation-matrix";
|
|
10503
10609
|
var createSvgSchText = ({
|
|
10504
10610
|
elm,
|
|
10505
10611
|
transform,
|
|
10506
10612
|
colorMap: colorMap2
|
|
10507
10613
|
}) => {
|
|
10508
|
-
const center =
|
|
10614
|
+
const center = applyToPoint58(transform, elm.position);
|
|
10509
10615
|
const textAnchorMap = {
|
|
10510
10616
|
center: "middle",
|
|
10511
10617
|
center_right: "end",
|
|
@@ -10589,11 +10695,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
10589
10695
|
colorMap: colorMap2
|
|
10590
10696
|
}) => {
|
|
10591
10697
|
const svgObjects = [];
|
|
10592
|
-
const componentScreenTopLeft =
|
|
10698
|
+
const componentScreenTopLeft = applyToPoint59(transform, {
|
|
10593
10699
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
10594
10700
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
10595
10701
|
});
|
|
10596
|
-
const componentScreenBottomRight =
|
|
10702
|
+
const componentScreenBottomRight = applyToPoint59(transform, {
|
|
10597
10703
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
10598
10704
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
10599
10705
|
});
|
|
@@ -10679,13 +10785,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
10679
10785
|
}
|
|
10680
10786
|
|
|
10681
10787
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
10682
|
-
import { applyToPoint as
|
|
10788
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
10683
10789
|
function createSvgObjectsFromSchVoltageProbe({
|
|
10684
10790
|
probe,
|
|
10685
10791
|
transform,
|
|
10686
10792
|
colorMap: colorMap2
|
|
10687
10793
|
}) {
|
|
10688
|
-
const [screenX, screenY] =
|
|
10794
|
+
const [screenX, screenY] = applyToPoint60(transform, [
|
|
10689
10795
|
probe.position.x,
|
|
10690
10796
|
probe.position.y
|
|
10691
10797
|
]);
|
|
@@ -10859,17 +10965,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
10859
10965
|
}
|
|
10860
10966
|
|
|
10861
10967
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
10862
|
-
import { applyToPoint as
|
|
10968
|
+
import { applyToPoint as applyToPoint61 } from "transformation-matrix";
|
|
10863
10969
|
function createSvgObjectsFromSchDebugObject({
|
|
10864
10970
|
debugObject,
|
|
10865
10971
|
transform
|
|
10866
10972
|
}) {
|
|
10867
10973
|
if (debugObject.shape === "rect") {
|
|
10868
|
-
let [screenLeft, screenTop] =
|
|
10974
|
+
let [screenLeft, screenTop] = applyToPoint61(transform, [
|
|
10869
10975
|
debugObject.center.x - debugObject.size.width / 2,
|
|
10870
10976
|
debugObject.center.y - debugObject.size.height / 2
|
|
10871
10977
|
]);
|
|
10872
|
-
let [screenRight, screenBottom] =
|
|
10978
|
+
let [screenRight, screenBottom] = applyToPoint61(transform, [
|
|
10873
10979
|
debugObject.center.x + debugObject.size.width / 2,
|
|
10874
10980
|
debugObject.center.y + debugObject.size.height / 2
|
|
10875
10981
|
]);
|
|
@@ -10879,7 +10985,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10879
10985
|
];
|
|
10880
10986
|
const width = Math.abs(screenRight - screenLeft);
|
|
10881
10987
|
const height = Math.abs(screenBottom - screenTop);
|
|
10882
|
-
const [screenCenterX, screenCenterY] =
|
|
10988
|
+
const [screenCenterX, screenCenterY] = applyToPoint61(transform, [
|
|
10883
10989
|
debugObject.center.x,
|
|
10884
10990
|
debugObject.center.y
|
|
10885
10991
|
]);
|
|
@@ -10925,11 +11031,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10925
11031
|
];
|
|
10926
11032
|
}
|
|
10927
11033
|
if (debugObject.shape === "line") {
|
|
10928
|
-
const [screenStartX, screenStartY] =
|
|
11034
|
+
const [screenStartX, screenStartY] = applyToPoint61(transform, [
|
|
10929
11035
|
debugObject.start.x,
|
|
10930
11036
|
debugObject.start.y
|
|
10931
11037
|
]);
|
|
10932
|
-
const [screenEndX, screenEndY] =
|
|
11038
|
+
const [screenEndX, screenEndY] = applyToPoint61(transform, [
|
|
10933
11039
|
debugObject.end.x,
|
|
10934
11040
|
debugObject.end.y
|
|
10935
11041
|
]);
|
|
@@ -10979,7 +11085,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10979
11085
|
}
|
|
10980
11086
|
|
|
10981
11087
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
10982
|
-
import { applyToPoint as
|
|
11088
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
10983
11089
|
function createSchematicTrace({
|
|
10984
11090
|
trace,
|
|
10985
11091
|
transform,
|
|
@@ -10993,11 +11099,11 @@ function createSchematicTrace({
|
|
|
10993
11099
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
10994
11100
|
const edge = edges[edgeIndex];
|
|
10995
11101
|
if (edge.is_crossing) continue;
|
|
10996
|
-
const [screenFromX, screenFromY] =
|
|
11102
|
+
const [screenFromX, screenFromY] = applyToPoint62(transform, [
|
|
10997
11103
|
edge.from.x,
|
|
10998
11104
|
edge.from.y
|
|
10999
11105
|
]);
|
|
11000
|
-
const [screenToX, screenToY] =
|
|
11106
|
+
const [screenToX, screenToY] = applyToPoint62(transform, [
|
|
11001
11107
|
edge.to.x,
|
|
11002
11108
|
edge.to.y
|
|
11003
11109
|
]);
|
|
@@ -11041,11 +11147,11 @@ function createSchematicTrace({
|
|
|
11041
11147
|
}
|
|
11042
11148
|
for (const edge of edges) {
|
|
11043
11149
|
if (!edge.is_crossing) continue;
|
|
11044
|
-
const [screenFromX, screenFromY] =
|
|
11150
|
+
const [screenFromX, screenFromY] = applyToPoint62(transform, [
|
|
11045
11151
|
edge.from.x,
|
|
11046
11152
|
edge.from.y
|
|
11047
11153
|
]);
|
|
11048
|
-
const [screenToX, screenToY] =
|
|
11154
|
+
const [screenToX, screenToY] = applyToPoint62(transform, [
|
|
11049
11155
|
edge.to.x,
|
|
11050
11156
|
edge.to.y
|
|
11051
11157
|
]);
|
|
@@ -11089,7 +11195,7 @@ function createSchematicTrace({
|
|
|
11089
11195
|
}
|
|
11090
11196
|
if (trace.junctions) {
|
|
11091
11197
|
for (const junction of trace.junctions) {
|
|
11092
|
-
const [screenX, screenY] =
|
|
11198
|
+
const [screenX, screenY] = applyToPoint62(transform, [
|
|
11093
11199
|
junction.x,
|
|
11094
11200
|
junction.y
|
|
11095
11201
|
]);
|
|
@@ -11144,20 +11250,20 @@ function createSchematicTrace({
|
|
|
11144
11250
|
|
|
11145
11251
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
11146
11252
|
import {
|
|
11147
|
-
applyToPoint as
|
|
11148
|
-
compose as
|
|
11253
|
+
applyToPoint as applyToPoint64,
|
|
11254
|
+
compose as compose13,
|
|
11149
11255
|
rotate as rotate7,
|
|
11150
11256
|
scale as scale7,
|
|
11151
|
-
translate as
|
|
11257
|
+
translate as translate13
|
|
11152
11258
|
} from "transformation-matrix";
|
|
11153
11259
|
|
|
11154
11260
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
11155
11261
|
import {
|
|
11156
|
-
applyToPoint as
|
|
11157
|
-
compose as
|
|
11262
|
+
applyToPoint as applyToPoint63,
|
|
11263
|
+
compose as compose12,
|
|
11158
11264
|
rotate as rotate6,
|
|
11159
11265
|
scale as scale6,
|
|
11160
|
-
translate as
|
|
11266
|
+
translate as translate12
|
|
11161
11267
|
} from "transformation-matrix";
|
|
11162
11268
|
import { symbols as symbols3 } from "schematic-symbols";
|
|
11163
11269
|
var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
@@ -11228,9 +11334,9 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11228
11334
|
x: symbolBounds.minX,
|
|
11229
11335
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
11230
11336
|
};
|
|
11231
|
-
const rotatedSymbolEnd =
|
|
11232
|
-
const symbolToRealTransform =
|
|
11233
|
-
|
|
11337
|
+
const rotatedSymbolEnd = applyToPoint63(rotationMatrix, symbolEndPoint);
|
|
11338
|
+
const symbolToRealTransform = compose12(
|
|
11339
|
+
translate12(
|
|
11234
11340
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
11235
11341
|
realAnchorPosition.y - rotatedSymbolEnd.y
|
|
11236
11342
|
),
|
|
@@ -11238,12 +11344,12 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11238
11344
|
scale6(1)
|
|
11239
11345
|
// Use full symbol size
|
|
11240
11346
|
);
|
|
11241
|
-
const [screenMinX, screenMinY] =
|
|
11242
|
-
|
|
11347
|
+
const [screenMinX, screenMinY] = applyToPoint63(
|
|
11348
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11243
11349
|
[bounds.minX, bounds.minY]
|
|
11244
11350
|
);
|
|
11245
|
-
const [screenMaxX, screenMaxY] =
|
|
11246
|
-
|
|
11351
|
+
const [screenMaxX, screenMaxY] = applyToPoint63(
|
|
11352
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11247
11353
|
[bounds.maxX, bounds.maxY]
|
|
11248
11354
|
);
|
|
11249
11355
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -11266,8 +11372,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11266
11372
|
});
|
|
11267
11373
|
for (const path of symbolPaths) {
|
|
11268
11374
|
const symbolPath = path.points.map((p, i) => {
|
|
11269
|
-
const [x, y] =
|
|
11270
|
-
|
|
11375
|
+
const [x, y] = applyToPoint63(
|
|
11376
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11271
11377
|
[p.x, p.y]
|
|
11272
11378
|
);
|
|
11273
11379
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -11287,8 +11393,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11287
11393
|
});
|
|
11288
11394
|
}
|
|
11289
11395
|
for (const text of symbolTexts) {
|
|
11290
|
-
const screenTextPos =
|
|
11291
|
-
|
|
11396
|
+
const screenTextPos = applyToPoint63(
|
|
11397
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11292
11398
|
text
|
|
11293
11399
|
);
|
|
11294
11400
|
let textValue = text.text;
|
|
@@ -11329,11 +11435,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11329
11435
|
});
|
|
11330
11436
|
}
|
|
11331
11437
|
for (const box of symbolBoxes) {
|
|
11332
|
-
const screenBoxPos =
|
|
11333
|
-
|
|
11438
|
+
const screenBoxPos = applyToPoint63(
|
|
11439
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11334
11440
|
box
|
|
11335
11441
|
);
|
|
11336
|
-
const symbolToScreenScale =
|
|
11442
|
+
const symbolToScreenScale = compose12(
|
|
11337
11443
|
realToScreenTransform,
|
|
11338
11444
|
symbolToRealTransform
|
|
11339
11445
|
).a;
|
|
@@ -11352,11 +11458,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11352
11458
|
});
|
|
11353
11459
|
}
|
|
11354
11460
|
for (const circle of symbolCircles) {
|
|
11355
|
-
const screenCirclePos =
|
|
11356
|
-
|
|
11461
|
+
const screenCirclePos = applyToPoint63(
|
|
11462
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11357
11463
|
circle
|
|
11358
11464
|
);
|
|
11359
|
-
const symbolToScreenScale =
|
|
11465
|
+
const symbolToScreenScale = compose12(
|
|
11360
11466
|
realToScreenTransform,
|
|
11361
11467
|
symbolToRealTransform
|
|
11362
11468
|
).a;
|
|
@@ -11397,14 +11503,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
11397
11503
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
11398
11504
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
11399
11505
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
11400
|
-
const screenCenter =
|
|
11506
|
+
const screenCenter = applyToPoint64(realToScreenTransform, schNetLabel.center);
|
|
11401
11507
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
11402
11508
|
schNetLabel.anchor_side
|
|
11403
11509
|
);
|
|
11404
11510
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
11405
11511
|
screenTextGrowthVec.y *= -1;
|
|
11406
11512
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
11407
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
11513
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint64(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
11408
11514
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
11409
11515
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
11410
11516
|
};
|
|
@@ -11445,10 +11551,10 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
11445
11551
|
y: -0.6
|
|
11446
11552
|
}
|
|
11447
11553
|
].map(
|
|
11448
|
-
(fontRelativePoint) =>
|
|
11449
|
-
|
|
11554
|
+
(fontRelativePoint) => applyToPoint64(
|
|
11555
|
+
compose13(
|
|
11450
11556
|
realToScreenTransform,
|
|
11451
|
-
|
|
11557
|
+
translate13(realAnchorPosition.x, realAnchorPosition.y),
|
|
11452
11558
|
scale7(fontSizeMm),
|
|
11453
11559
|
rotate7(pathRotation / 180 * Math.PI)
|
|
11454
11560
|
),
|
|
@@ -11522,17 +11628,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
11522
11628
|
};
|
|
11523
11629
|
|
|
11524
11630
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
11525
|
-
import { applyToPoint as
|
|
11631
|
+
import { applyToPoint as applyToPoint65 } from "transformation-matrix";
|
|
11526
11632
|
var createSvgObjectsFromSchematicBox = ({
|
|
11527
11633
|
schematicBox,
|
|
11528
11634
|
transform,
|
|
11529
11635
|
colorMap: colorMap2
|
|
11530
11636
|
}) => {
|
|
11531
|
-
const topLeft =
|
|
11637
|
+
const topLeft = applyToPoint65(transform, {
|
|
11532
11638
|
x: schematicBox.x,
|
|
11533
11639
|
y: schematicBox.y
|
|
11534
11640
|
});
|
|
11535
|
-
const bottomRight =
|
|
11641
|
+
const bottomRight = applyToPoint65(transform, {
|
|
11536
11642
|
x: schematicBox.x + schematicBox.width,
|
|
11537
11643
|
y: schematicBox.y + schematicBox.height
|
|
11538
11644
|
});
|
|
@@ -11568,7 +11674,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
11568
11674
|
};
|
|
11569
11675
|
|
|
11570
11676
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
11571
|
-
import { applyToPoint as
|
|
11677
|
+
import { applyToPoint as applyToPoint66 } from "transformation-matrix";
|
|
11572
11678
|
var createSvgObjectsFromSchematicTable = ({
|
|
11573
11679
|
schematicTable,
|
|
11574
11680
|
transform,
|
|
@@ -11601,11 +11707,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11601
11707
|
const svgObjects = [];
|
|
11602
11708
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
11603
11709
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
11604
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
11710
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint66(transform, [
|
|
11605
11711
|
topLeftX,
|
|
11606
11712
|
topLeftY
|
|
11607
11713
|
]);
|
|
11608
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
11714
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint66(transform, [
|
|
11609
11715
|
topLeftX + totalWidth,
|
|
11610
11716
|
topLeftY - totalHeight
|
|
11611
11717
|
]);
|
|
@@ -11637,8 +11743,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11637
11743
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
11638
11744
|
);
|
|
11639
11745
|
if (!isMerged) {
|
|
11640
|
-
const start =
|
|
11641
|
-
const end =
|
|
11746
|
+
const start = applyToPoint66(transform, { x: currentX, y: segmentStartY });
|
|
11747
|
+
const end = applyToPoint66(transform, { x: currentX, y: segmentEndY });
|
|
11642
11748
|
svgObjects.push({
|
|
11643
11749
|
name: "line",
|
|
11644
11750
|
type: "element",
|
|
@@ -11667,11 +11773,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11667
11773
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
11668
11774
|
);
|
|
11669
11775
|
if (!isMerged) {
|
|
11670
|
-
const start =
|
|
11776
|
+
const start = applyToPoint66(transform, {
|
|
11671
11777
|
x: segmentStartX,
|
|
11672
11778
|
y: currentY
|
|
11673
11779
|
});
|
|
11674
|
-
const end =
|
|
11780
|
+
const end = applyToPoint66(transform, { x: segmentEndX, y: currentY });
|
|
11675
11781
|
svgObjects.push({
|
|
11676
11782
|
name: "line",
|
|
11677
11783
|
type: "element",
|
|
@@ -11713,7 +11819,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11713
11819
|
} else if (vertical_align === "bottom") {
|
|
11714
11820
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
11715
11821
|
}
|
|
11716
|
-
const screenTextAnchorPos =
|
|
11822
|
+
const screenTextAnchorPos = applyToPoint66(transform, realTextAnchorPos);
|
|
11717
11823
|
const fontSize = getSchScreenFontSize(
|
|
11718
11824
|
transform,
|
|
11719
11825
|
"reference_designator",
|
|
@@ -11769,13 +11875,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11769
11875
|
|
|
11770
11876
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
11771
11877
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
11772
|
-
import { applyToPoint as
|
|
11878
|
+
import { applyToPoint as applyToPoint67 } from "transformation-matrix";
|
|
11773
11879
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
11774
11880
|
var createSvgObjectsForSchPortHover = ({
|
|
11775
11881
|
schPort,
|
|
11776
11882
|
transform
|
|
11777
11883
|
}) => {
|
|
11778
|
-
const screenSchPortPos =
|
|
11884
|
+
const screenSchPortPos = applyToPoint67(transform, schPort.center);
|
|
11779
11885
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
11780
11886
|
return [
|
|
11781
11887
|
{
|
|
@@ -11820,14 +11926,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
11820
11926
|
};
|
|
11821
11927
|
|
|
11822
11928
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
11823
|
-
import { applyToPoint as
|
|
11929
|
+
import { applyToPoint as applyToPoint68 } from "transformation-matrix";
|
|
11824
11930
|
function createSvgObjectsFromSchematicLine({
|
|
11825
11931
|
schLine,
|
|
11826
11932
|
transform,
|
|
11827
11933
|
colorMap: colorMap2
|
|
11828
11934
|
}) {
|
|
11829
|
-
const p1 =
|
|
11830
|
-
const p2 =
|
|
11935
|
+
const p1 = applyToPoint68(transform, { x: schLine.x1, y: schLine.y1 });
|
|
11936
|
+
const p2 = applyToPoint68(transform, { x: schLine.x2, y: schLine.y2 });
|
|
11831
11937
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
11832
11938
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
11833
11939
|
return [
|
|
@@ -11856,13 +11962,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
11856
11962
|
}
|
|
11857
11963
|
|
|
11858
11964
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
11859
|
-
import { applyToPoint as
|
|
11965
|
+
import { applyToPoint as applyToPoint69 } from "transformation-matrix";
|
|
11860
11966
|
function createSvgObjectsFromSchematicCircle({
|
|
11861
11967
|
schCircle,
|
|
11862
11968
|
transform,
|
|
11863
11969
|
colorMap: colorMap2
|
|
11864
11970
|
}) {
|
|
11865
|
-
const center =
|
|
11971
|
+
const center = applyToPoint69(transform, schCircle.center);
|
|
11866
11972
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
11867
11973
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
11868
11974
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -11892,13 +11998,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
11892
11998
|
}
|
|
11893
11999
|
|
|
11894
12000
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
11895
|
-
import { applyToPoint as
|
|
12001
|
+
import { applyToPoint as applyToPoint70 } from "transformation-matrix";
|
|
11896
12002
|
function createSvgObjectsFromSchematicRect({
|
|
11897
12003
|
schRect,
|
|
11898
12004
|
transform,
|
|
11899
12005
|
colorMap: colorMap2
|
|
11900
12006
|
}) {
|
|
11901
|
-
const center =
|
|
12007
|
+
const center = applyToPoint70(transform, schRect.center);
|
|
11902
12008
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
11903
12009
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
11904
12010
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -11934,13 +12040,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
11934
12040
|
}
|
|
11935
12041
|
|
|
11936
12042
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
11937
|
-
import { applyToPoint as
|
|
12043
|
+
import { applyToPoint as applyToPoint71 } from "transformation-matrix";
|
|
11938
12044
|
function createSvgObjectsFromSchematicArc({
|
|
11939
12045
|
schArc,
|
|
11940
12046
|
transform,
|
|
11941
12047
|
colorMap: colorMap2
|
|
11942
12048
|
}) {
|
|
11943
|
-
const center =
|
|
12049
|
+
const center = applyToPoint71(transform, schArc.center);
|
|
11944
12050
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
11945
12051
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
11946
12052
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -13060,18 +13166,18 @@ function formatNumber2(value) {
|
|
|
13060
13166
|
import { distance as distance3 } from "circuit-json";
|
|
13061
13167
|
import { stringify as stringify7 } from "svgson";
|
|
13062
13168
|
import {
|
|
13063
|
-
applyToPoint as
|
|
13064
|
-
compose as
|
|
13169
|
+
applyToPoint as applyToPoint74,
|
|
13170
|
+
compose as compose16,
|
|
13065
13171
|
scale as scale9,
|
|
13066
|
-
translate as
|
|
13172
|
+
translate as translate16
|
|
13067
13173
|
} from "transformation-matrix";
|
|
13068
13174
|
|
|
13069
13175
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
13070
|
-
import { applyToPoint as
|
|
13176
|
+
import { applyToPoint as applyToPoint73 } from "transformation-matrix";
|
|
13071
13177
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
13072
13178
|
const { transform, layer: layerFilter } = ctx;
|
|
13073
13179
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
13074
|
-
const [x, y] =
|
|
13180
|
+
const [x, y] = applyToPoint73(transform, [solderPaste.x, solderPaste.y]);
|
|
13075
13181
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
13076
13182
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
13077
13183
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -13195,8 +13301,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
13195
13301
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
13196
13302
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
13197
13303
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
13198
|
-
const transform =
|
|
13199
|
-
|
|
13304
|
+
const transform = compose16(
|
|
13305
|
+
translate16(
|
|
13200
13306
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
13201
13307
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
13202
13308
|
),
|
|
@@ -13297,8 +13403,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
13297
13403
|
}
|
|
13298
13404
|
}
|
|
13299
13405
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
13300
|
-
const [x1, y1] =
|
|
13301
|
-
const [x2, y2] =
|
|
13406
|
+
const [x1, y1] = applyToPoint74(transform, [minX, minY]);
|
|
13407
|
+
const [x2, y2] = applyToPoint74(transform, [maxX, maxY]);
|
|
13302
13408
|
const width = Math.abs(x2 - x1);
|
|
13303
13409
|
const height = Math.abs(y2 - y1);
|
|
13304
13410
|
const x = Math.min(x1, x2);
|