circuit-to-svg 0.0.194 → 0.0.196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +384 -82
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1031,110 +1031,187 @@ import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
|
1031
1031
|
function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
1032
1032
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1033
1033
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
1034
|
+
const isCoveredWithSolderMask = Boolean(pad?.is_covered_with_solder_mask);
|
|
1035
|
+
const solderMaskColor = colorMap2.soldermask[pad.layer] ?? colorMap2.soldermask.top;
|
|
1034
1036
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
1035
1037
|
const width = pad.width * Math.abs(transform.a);
|
|
1036
1038
|
const height = pad.height * Math.abs(transform.d);
|
|
1037
1039
|
const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
|
|
1038
1040
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
1039
1041
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
1040
|
-
|
|
1041
|
-
{
|
|
1042
|
-
name: "rect",
|
|
1043
|
-
type: "element",
|
|
1044
|
-
attributes: {
|
|
1045
|
-
class: "pcb-pad",
|
|
1046
|
-
fill: layerNameToColor(pad.layer, colorMap2),
|
|
1047
|
-
x: (-width / 2).toString(),
|
|
1048
|
-
y: (-height / 2).toString(),
|
|
1049
|
-
width: width.toString(),
|
|
1050
|
-
height: height.toString(),
|
|
1051
|
-
transform: `translate(${x} ${y}) rotate(${-pad.ccw_rotation})`,
|
|
1052
|
-
"data-layer": pad.layer,
|
|
1053
|
-
...scaledBorderRadius ? {
|
|
1054
|
-
rx: scaledBorderRadius.toString(),
|
|
1055
|
-
ry: scaledBorderRadius.toString()
|
|
1056
|
-
} : {}
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
];
|
|
1060
|
-
}
|
|
1061
|
-
return [
|
|
1062
|
-
{
|
|
1042
|
+
const padElement2 = {
|
|
1063
1043
|
name: "rect",
|
|
1064
1044
|
type: "element",
|
|
1045
|
+
value: "",
|
|
1046
|
+
children: [],
|
|
1065
1047
|
attributes: {
|
|
1066
1048
|
class: "pcb-pad",
|
|
1067
1049
|
fill: layerNameToColor(pad.layer, colorMap2),
|
|
1068
|
-
x: (
|
|
1069
|
-
y: (
|
|
1050
|
+
x: (-width / 2).toString(),
|
|
1051
|
+
y: (-height / 2).toString(),
|
|
1070
1052
|
width: width.toString(),
|
|
1071
1053
|
height: height.toString(),
|
|
1054
|
+
transform: `translate(${x} ${y}) rotate(${-pad.ccw_rotation})`,
|
|
1072
1055
|
"data-layer": pad.layer,
|
|
1073
1056
|
...scaledBorderRadius ? {
|
|
1074
1057
|
rx: scaledBorderRadius.toString(),
|
|
1075
1058
|
ry: scaledBorderRadius.toString()
|
|
1076
1059
|
} : {}
|
|
1077
1060
|
}
|
|
1061
|
+
};
|
|
1062
|
+
if (!isCoveredWithSolderMask) {
|
|
1063
|
+
return [padElement2];
|
|
1078
1064
|
}
|
|
1079
|
-
|
|
1065
|
+
const maskElement2 = {
|
|
1066
|
+
name: padElement2.name,
|
|
1067
|
+
type: padElement2.type,
|
|
1068
|
+
value: "",
|
|
1069
|
+
children: [],
|
|
1070
|
+
attributes: {
|
|
1071
|
+
...padElement2.attributes,
|
|
1072
|
+
class: "pcb-solder-mask",
|
|
1073
|
+
fill: solderMaskColor
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
return [padElement2, maskElement2];
|
|
1077
|
+
}
|
|
1078
|
+
const padElement = {
|
|
1079
|
+
name: "rect",
|
|
1080
|
+
type: "element",
|
|
1081
|
+
value: "",
|
|
1082
|
+
children: [],
|
|
1083
|
+
attributes: {
|
|
1084
|
+
class: "pcb-pad",
|
|
1085
|
+
fill: layerNameToColor(pad.layer, colorMap2),
|
|
1086
|
+
x: (x - width / 2).toString(),
|
|
1087
|
+
y: (y - height / 2).toString(),
|
|
1088
|
+
width: width.toString(),
|
|
1089
|
+
height: height.toString(),
|
|
1090
|
+
"data-layer": pad.layer,
|
|
1091
|
+
...scaledBorderRadius ? {
|
|
1092
|
+
rx: scaledBorderRadius.toString(),
|
|
1093
|
+
ry: scaledBorderRadius.toString()
|
|
1094
|
+
} : {}
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
if (!isCoveredWithSolderMask) {
|
|
1098
|
+
return [padElement];
|
|
1099
|
+
}
|
|
1100
|
+
const maskElement = {
|
|
1101
|
+
name: padElement.name,
|
|
1102
|
+
type: padElement.type,
|
|
1103
|
+
value: "",
|
|
1104
|
+
children: [],
|
|
1105
|
+
attributes: {
|
|
1106
|
+
...padElement.attributes,
|
|
1107
|
+
class: "pcb-solder-mask",
|
|
1108
|
+
fill: solderMaskColor
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
return [padElement, maskElement];
|
|
1080
1112
|
}
|
|
1081
1113
|
if (pad.shape === "pill") {
|
|
1082
1114
|
const width = pad.width * Math.abs(transform.a);
|
|
1083
1115
|
const height = pad.height * Math.abs(transform.d);
|
|
1084
1116
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1085
1117
|
const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1118
|
+
const padElement = {
|
|
1119
|
+
name: "rect",
|
|
1120
|
+
type: "element",
|
|
1121
|
+
value: "",
|
|
1122
|
+
children: [],
|
|
1123
|
+
attributes: {
|
|
1124
|
+
class: "pcb-pad",
|
|
1125
|
+
fill: layerNameToColor(pad.layer, colorMap2),
|
|
1126
|
+
x: (x - width / 2).toString(),
|
|
1127
|
+
y: (y - height / 2).toString(),
|
|
1128
|
+
width: width.toString(),
|
|
1129
|
+
height: height.toString(),
|
|
1130
|
+
rx: radius.toString(),
|
|
1131
|
+
ry: radius.toString(),
|
|
1132
|
+
"data-layer": pad.layer
|
|
1101
1133
|
}
|
|
1102
|
-
|
|
1134
|
+
};
|
|
1135
|
+
if (!isCoveredWithSolderMask) {
|
|
1136
|
+
return [padElement];
|
|
1137
|
+
}
|
|
1138
|
+
const maskElement = {
|
|
1139
|
+
name: padElement.name,
|
|
1140
|
+
type: padElement.type,
|
|
1141
|
+
value: "",
|
|
1142
|
+
children: [],
|
|
1143
|
+
attributes: {
|
|
1144
|
+
...padElement.attributes,
|
|
1145
|
+
class: "pcb-solder-mask",
|
|
1146
|
+
fill: solderMaskColor
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
return [padElement, maskElement];
|
|
1103
1150
|
}
|
|
1104
1151
|
if (pad.shape === "circle") {
|
|
1105
1152
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1106
1153
|
const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1154
|
+
const padElement = {
|
|
1155
|
+
name: "circle",
|
|
1156
|
+
type: "element",
|
|
1157
|
+
value: "",
|
|
1158
|
+
children: [],
|
|
1159
|
+
attributes: {
|
|
1160
|
+
class: "pcb-pad",
|
|
1161
|
+
fill: layerNameToColor(pad.layer, colorMap2),
|
|
1162
|
+
cx: x.toString(),
|
|
1163
|
+
cy: y.toString(),
|
|
1164
|
+
r: radius.toString(),
|
|
1165
|
+
"data-layer": pad.layer
|
|
1119
1166
|
}
|
|
1120
|
-
|
|
1167
|
+
};
|
|
1168
|
+
if (!isCoveredWithSolderMask) {
|
|
1169
|
+
return [padElement];
|
|
1170
|
+
}
|
|
1171
|
+
const maskElement = {
|
|
1172
|
+
name: padElement.name,
|
|
1173
|
+
type: padElement.type,
|
|
1174
|
+
value: "",
|
|
1175
|
+
children: [],
|
|
1176
|
+
attributes: {
|
|
1177
|
+
...padElement.attributes,
|
|
1178
|
+
class: "pcb-solder-mask",
|
|
1179
|
+
fill: solderMaskColor
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
return [padElement, maskElement];
|
|
1121
1183
|
}
|
|
1122
1184
|
if (pad.shape === "polygon") {
|
|
1123
1185
|
const points = (pad.points ?? []).map(
|
|
1124
1186
|
(point) => applyToPoint11(transform, [point.x, point.y])
|
|
1125
1187
|
);
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1188
|
+
const padElement = {
|
|
1189
|
+
name: "polygon",
|
|
1190
|
+
type: "element",
|
|
1191
|
+
value: "",
|
|
1192
|
+
children: [],
|
|
1193
|
+
attributes: {
|
|
1194
|
+
class: "pcb-pad",
|
|
1195
|
+
fill: layerNameToColor(pad.layer, colorMap2),
|
|
1196
|
+
points: points.map((p) => p.join(",")).join(" "),
|
|
1197
|
+
"data-layer": pad.layer
|
|
1136
1198
|
}
|
|
1137
|
-
|
|
1199
|
+
};
|
|
1200
|
+
if (!isCoveredWithSolderMask) {
|
|
1201
|
+
return [padElement];
|
|
1202
|
+
}
|
|
1203
|
+
const maskElement = {
|
|
1204
|
+
name: padElement.name,
|
|
1205
|
+
type: padElement.type,
|
|
1206
|
+
value: "",
|
|
1207
|
+
children: [],
|
|
1208
|
+
attributes: {
|
|
1209
|
+
...padElement.attributes,
|
|
1210
|
+
class: "pcb-solder-mask",
|
|
1211
|
+
fill: solderMaskColor
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
return [padElement, maskElement];
|
|
1138
1215
|
}
|
|
1139
1216
|
return [];
|
|
1140
1217
|
}
|
|
@@ -1666,7 +1743,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
1666
1743
|
var package_default = {
|
|
1667
1744
|
name: "circuit-to-svg",
|
|
1668
1745
|
type: "module",
|
|
1669
|
-
version: "0.0.
|
|
1746
|
+
version: "0.0.195",
|
|
1670
1747
|
description: "Convert Circuit JSON to SVG",
|
|
1671
1748
|
main: "dist/index.js",
|
|
1672
1749
|
files: [
|
|
@@ -1690,12 +1767,12 @@ var package_default = {
|
|
|
1690
1767
|
"bun-match-svg": "^0.0.12",
|
|
1691
1768
|
esbuild: "^0.20.2",
|
|
1692
1769
|
"performance-now": "^2.1.0",
|
|
1693
|
-
"circuit-json": "^0.0.
|
|
1770
|
+
"circuit-json": "^0.0.260",
|
|
1694
1771
|
react: "19.1.0",
|
|
1695
1772
|
"react-cosmos": "7.0.0",
|
|
1696
1773
|
"react-cosmos-plugin-vite": "7.0.0",
|
|
1697
1774
|
"react-dom": "19.1.0",
|
|
1698
|
-
tscircuit: "^0.0.
|
|
1775
|
+
tscircuit: "^0.0.654",
|
|
1699
1776
|
tsup: "^8.0.2",
|
|
1700
1777
|
typescript: "^5.4.5",
|
|
1701
1778
|
"vite-tsconfig-paths": "^5.0.1"
|
|
@@ -1808,10 +1885,10 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
1808
1885
|
}
|
|
1809
1886
|
}
|
|
1810
1887
|
const padding = drawPaddingOutsideBoard ? 1 : 0;
|
|
1811
|
-
const boundsMinX = drawPaddingOutsideBoard || !isFinite(boardMinX) ? minX : boardMinX;
|
|
1812
|
-
const boundsMinY = drawPaddingOutsideBoard || !isFinite(boardMinY) ? minY : boardMinY;
|
|
1813
|
-
const boundsMaxX = drawPaddingOutsideBoard || !isFinite(boardMaxX) ? maxX : boardMaxX;
|
|
1814
|
-
const boundsMaxY = drawPaddingOutsideBoard || !isFinite(boardMaxY) ? maxY : boardMaxY;
|
|
1888
|
+
const boundsMinX = drawPaddingOutsideBoard || !Number.isFinite(boardMinX) ? minX : boardMinX;
|
|
1889
|
+
const boundsMinY = drawPaddingOutsideBoard || !Number.isFinite(boardMinY) ? minY : boardMinY;
|
|
1890
|
+
const boundsMaxX = drawPaddingOutsideBoard || !Number.isFinite(boardMaxX) ? maxX : boardMaxX;
|
|
1891
|
+
const boundsMaxY = drawPaddingOutsideBoard || !Number.isFinite(boardMaxY) ? maxY : boardMaxY;
|
|
1815
1892
|
const circuitWidth = boundsMaxX - boundsMinX + 2 * padding;
|
|
1816
1893
|
const circuitHeight = boundsMaxY - boundsMinY + 2 * padding;
|
|
1817
1894
|
let svgWidth = options?.width ?? 800;
|
|
@@ -4390,6 +4467,27 @@ function getSchematicBoundsFromCircuitJson(soup, padding = 0.5) {
|
|
|
4390
4467
|
{ width: totalWidth, height: totalHeight },
|
|
4391
4468
|
0
|
|
4392
4469
|
);
|
|
4470
|
+
} else if (item.type === "schematic_line") {
|
|
4471
|
+
updateBounds({ x: item.x1, y: item.y1 }, { width: 0.02, height: 0.02 }, 0);
|
|
4472
|
+
updateBounds({ x: item.x2, y: item.y2 }, { width: 0.02, height: 0.02 }, 0);
|
|
4473
|
+
} else if (item.type === "schematic_circle") {
|
|
4474
|
+
updateBounds(
|
|
4475
|
+
item.center,
|
|
4476
|
+
{ width: item.radius * 2, height: item.radius * 2 },
|
|
4477
|
+
0
|
|
4478
|
+
);
|
|
4479
|
+
} else if (item.type === "schematic_rect") {
|
|
4480
|
+
updateBounds(
|
|
4481
|
+
item.center,
|
|
4482
|
+
{ width: item.width, height: item.height },
|
|
4483
|
+
item.rotation
|
|
4484
|
+
);
|
|
4485
|
+
} else if (item.type === "schematic_arc") {
|
|
4486
|
+
updateBounds(
|
|
4487
|
+
item.center,
|
|
4488
|
+
{ width: item.radius * 2, height: item.radius * 2 },
|
|
4489
|
+
0
|
|
4490
|
+
);
|
|
4393
4491
|
}
|
|
4394
4492
|
}
|
|
4395
4493
|
minX -= padding;
|
|
@@ -6303,6 +6401,170 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
6303
6401
|
return svgs;
|
|
6304
6402
|
};
|
|
6305
6403
|
|
|
6404
|
+
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
6405
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
6406
|
+
function createSvgObjectsFromSchematicLine({
|
|
6407
|
+
schLine,
|
|
6408
|
+
transform,
|
|
6409
|
+
colorMap: colorMap2
|
|
6410
|
+
}) {
|
|
6411
|
+
const p1 = applyToPoint46(transform, { x: schLine.x1, y: schLine.y1 });
|
|
6412
|
+
const p2 = applyToPoint46(transform, { x: schLine.x2, y: schLine.y2 });
|
|
6413
|
+
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
6414
|
+
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
6415
|
+
return [
|
|
6416
|
+
{
|
|
6417
|
+
name: "line",
|
|
6418
|
+
type: "element",
|
|
6419
|
+
attributes: {
|
|
6420
|
+
x1: p1.x.toString(),
|
|
6421
|
+
y1: p1.y.toString(),
|
|
6422
|
+
x2: p2.x.toString(),
|
|
6423
|
+
y2: p2.y.toString(),
|
|
6424
|
+
stroke: schLine.color,
|
|
6425
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
6426
|
+
...schLine.is_dashed && {
|
|
6427
|
+
"stroke-dasharray": (transformedStrokeWidth * 3).toString()
|
|
6428
|
+
},
|
|
6429
|
+
"data-schematic-line-id": schLine.schematic_line_id,
|
|
6430
|
+
...schLine.schematic_component_id && {
|
|
6431
|
+
"data-schematic-component-id": schLine.schematic_component_id
|
|
6432
|
+
}
|
|
6433
|
+
},
|
|
6434
|
+
children: [],
|
|
6435
|
+
value: ""
|
|
6436
|
+
}
|
|
6437
|
+
];
|
|
6438
|
+
}
|
|
6439
|
+
|
|
6440
|
+
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
6441
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
6442
|
+
function createSvgObjectsFromSchematicCircle({
|
|
6443
|
+
schCircle,
|
|
6444
|
+
transform,
|
|
6445
|
+
colorMap: colorMap2
|
|
6446
|
+
}) {
|
|
6447
|
+
const center = applyToPoint47(transform, schCircle.center);
|
|
6448
|
+
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
6449
|
+
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
6450
|
+
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
6451
|
+
return [
|
|
6452
|
+
{
|
|
6453
|
+
name: "circle",
|
|
6454
|
+
type: "element",
|
|
6455
|
+
attributes: {
|
|
6456
|
+
cx: center.x.toString(),
|
|
6457
|
+
cy: center.y.toString(),
|
|
6458
|
+
r: transformedRadius.toString(),
|
|
6459
|
+
fill: schCircle.is_filled ? schCircle.fill_color ?? schCircle.color : "none",
|
|
6460
|
+
stroke: schCircle.color,
|
|
6461
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
6462
|
+
...schCircle.is_dashed && {
|
|
6463
|
+
"stroke-dasharray": (transformedStrokeWidth * 3).toString()
|
|
6464
|
+
},
|
|
6465
|
+
"data-schematic-circle-id": schCircle.schematic_circle_id,
|
|
6466
|
+
...schCircle.schematic_component_id && {
|
|
6467
|
+
"data-schematic-component-id": schCircle.schematic_component_id
|
|
6468
|
+
}
|
|
6469
|
+
},
|
|
6470
|
+
children: [],
|
|
6471
|
+
value: ""
|
|
6472
|
+
}
|
|
6473
|
+
];
|
|
6474
|
+
}
|
|
6475
|
+
|
|
6476
|
+
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
6477
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
6478
|
+
function createSvgObjectsFromSchematicRect({
|
|
6479
|
+
schRect,
|
|
6480
|
+
transform,
|
|
6481
|
+
colorMap: colorMap2
|
|
6482
|
+
}) {
|
|
6483
|
+
const center = applyToPoint48(transform, schRect.center);
|
|
6484
|
+
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
6485
|
+
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
6486
|
+
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
6487
|
+
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
6488
|
+
const x = center.x - transformedWidth / 2;
|
|
6489
|
+
const y = center.y - transformedHeight / 2;
|
|
6490
|
+
const svgRect = {
|
|
6491
|
+
name: "rect",
|
|
6492
|
+
type: "element",
|
|
6493
|
+
attributes: {
|
|
6494
|
+
x: x.toString(),
|
|
6495
|
+
y: y.toString(),
|
|
6496
|
+
width: transformedWidth.toString(),
|
|
6497
|
+
height: transformedHeight.toString(),
|
|
6498
|
+
fill: schRect.is_filled ? schRect.fill_color ?? schRect.color : "none",
|
|
6499
|
+
stroke: schRect.color,
|
|
6500
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
6501
|
+
...schRect.is_dashed && {
|
|
6502
|
+
"stroke-dasharray": (transformedStrokeWidth * 3).toString()
|
|
6503
|
+
},
|
|
6504
|
+
...schRect.rotation !== 0 && {
|
|
6505
|
+
transform: `rotate(${schRect.rotation} ${center.x} ${center.y})`
|
|
6506
|
+
},
|
|
6507
|
+
"data-schematic-rect-id": schRect.schematic_rect_id,
|
|
6508
|
+
...schRect.schematic_component_id && {
|
|
6509
|
+
"data-schematic-component-id": schRect.schematic_component_id
|
|
6510
|
+
}
|
|
6511
|
+
},
|
|
6512
|
+
children: [],
|
|
6513
|
+
value: ""
|
|
6514
|
+
};
|
|
6515
|
+
return [svgRect];
|
|
6516
|
+
}
|
|
6517
|
+
|
|
6518
|
+
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
6519
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
6520
|
+
function createSvgObjectsFromSchematicArc({
|
|
6521
|
+
schArc,
|
|
6522
|
+
transform,
|
|
6523
|
+
colorMap: colorMap2
|
|
6524
|
+
}) {
|
|
6525
|
+
const center = applyToPoint49(transform, schArc.center);
|
|
6526
|
+
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
6527
|
+
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
6528
|
+
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
6529
|
+
const startAngleRad = schArc.start_angle_degrees * Math.PI / 180;
|
|
6530
|
+
const endAngleRad = schArc.end_angle_degrees * Math.PI / 180;
|
|
6531
|
+
const startX = center.x + transformedRadius * Math.cos(startAngleRad);
|
|
6532
|
+
const startY = center.y + transformedRadius * Math.sin(startAngleRad);
|
|
6533
|
+
const endX = center.x + transformedRadius * Math.cos(endAngleRad);
|
|
6534
|
+
const endY = center.y + transformedRadius * Math.sin(endAngleRad);
|
|
6535
|
+
let angleDiff = schArc.end_angle_degrees - schArc.start_angle_degrees;
|
|
6536
|
+
if (schArc.direction === "clockwise") {
|
|
6537
|
+
angleDiff = -angleDiff;
|
|
6538
|
+
}
|
|
6539
|
+
if (angleDiff < 0) {
|
|
6540
|
+
angleDiff += 360;
|
|
6541
|
+
}
|
|
6542
|
+
const largeArcFlag = angleDiff > 180 ? 1 : 0;
|
|
6543
|
+
const sweepFlag = schArc.direction === "clockwise" ? 1 : 0;
|
|
6544
|
+
const pathData = `M ${startX} ${startY} A ${transformedRadius} ${transformedRadius} 0 ${largeArcFlag} ${sweepFlag} ${endX} ${endY}`;
|
|
6545
|
+
return [
|
|
6546
|
+
{
|
|
6547
|
+
name: "path",
|
|
6548
|
+
type: "element",
|
|
6549
|
+
attributes: {
|
|
6550
|
+
d: pathData,
|
|
6551
|
+
fill: "none",
|
|
6552
|
+
stroke: schArc.color,
|
|
6553
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
6554
|
+
...schArc.is_dashed && {
|
|
6555
|
+
"stroke-dasharray": (transformedStrokeWidth * 3).toString()
|
|
6556
|
+
},
|
|
6557
|
+
"data-schematic-arc-id": schArc.schematic_arc_id,
|
|
6558
|
+
...schArc.schematic_component_id && {
|
|
6559
|
+
"data-schematic-component-id": schArc.schematic_component_id
|
|
6560
|
+
}
|
|
6561
|
+
},
|
|
6562
|
+
children: [],
|
|
6563
|
+
value: ""
|
|
6564
|
+
}
|
|
6565
|
+
];
|
|
6566
|
+
}
|
|
6567
|
+
|
|
6306
6568
|
// lib/sch/convert-circuit-json-to-schematic-svg.ts
|
|
6307
6569
|
function buildNetHoverStyles(connectivityKeys) {
|
|
6308
6570
|
const rules = [];
|
|
@@ -6393,6 +6655,10 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6393
6655
|
const schBoxSvgs = [];
|
|
6394
6656
|
const schTableSvgs = [];
|
|
6395
6657
|
const schPortHoverSvgs = [];
|
|
6658
|
+
const schLineSvgs = [];
|
|
6659
|
+
const schCircleSvgs = [];
|
|
6660
|
+
const schRectSvgs = [];
|
|
6661
|
+
const schArcSvgs = [];
|
|
6396
6662
|
for (const elm of circuitJson) {
|
|
6397
6663
|
if (elm.type === "schematic_debug_object") {
|
|
6398
6664
|
schDebugObjectSvgs.push(
|
|
@@ -6467,6 +6733,38 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6467
6733
|
circuitJson
|
|
6468
6734
|
})
|
|
6469
6735
|
);
|
|
6736
|
+
} else if (elm.type === "schematic_line") {
|
|
6737
|
+
schLineSvgs.push(
|
|
6738
|
+
...createSvgObjectsFromSchematicLine({
|
|
6739
|
+
schLine: elm,
|
|
6740
|
+
transform,
|
|
6741
|
+
colorMap: colorMap2
|
|
6742
|
+
})
|
|
6743
|
+
);
|
|
6744
|
+
} else if (elm.type === "schematic_circle") {
|
|
6745
|
+
schCircleSvgs.push(
|
|
6746
|
+
...createSvgObjectsFromSchematicCircle({
|
|
6747
|
+
schCircle: elm,
|
|
6748
|
+
transform,
|
|
6749
|
+
colorMap: colorMap2
|
|
6750
|
+
})
|
|
6751
|
+
);
|
|
6752
|
+
} else if (elm.type === "schematic_rect") {
|
|
6753
|
+
schRectSvgs.push(
|
|
6754
|
+
...createSvgObjectsFromSchematicRect({
|
|
6755
|
+
schRect: elm,
|
|
6756
|
+
transform,
|
|
6757
|
+
colorMap: colorMap2
|
|
6758
|
+
})
|
|
6759
|
+
);
|
|
6760
|
+
} else if (elm.type === "schematic_arc") {
|
|
6761
|
+
schArcSvgs.push(
|
|
6762
|
+
...createSvgObjectsFromSchematicArc({
|
|
6763
|
+
schArc: elm,
|
|
6764
|
+
transform,
|
|
6765
|
+
colorMap: colorMap2
|
|
6766
|
+
})
|
|
6767
|
+
);
|
|
6470
6768
|
}
|
|
6471
6769
|
}
|
|
6472
6770
|
const schTraceBaseSvgs = schTraceSvgs.filter(
|
|
@@ -6479,6 +6777,10 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
6479
6777
|
...schDebugObjectSvgs,
|
|
6480
6778
|
...schTraceBaseSvgs,
|
|
6481
6779
|
...schTraceOverlaySvgs,
|
|
6780
|
+
...schLineSvgs,
|
|
6781
|
+
...schCircleSvgs,
|
|
6782
|
+
...schRectSvgs,
|
|
6783
|
+
...schArcSvgs,
|
|
6482
6784
|
...schComponentSvgs,
|
|
6483
6785
|
...schPortHoverSvgs,
|
|
6484
6786
|
...schNetLabel,
|
|
@@ -6567,18 +6869,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
6567
6869
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
6568
6870
|
import { stringify as stringify4 } from "svgson";
|
|
6569
6871
|
import {
|
|
6570
|
-
applyToPoint as
|
|
6571
|
-
compose as
|
|
6872
|
+
applyToPoint as applyToPoint52,
|
|
6873
|
+
compose as compose13,
|
|
6572
6874
|
scale as scale8,
|
|
6573
|
-
translate as
|
|
6875
|
+
translate as translate13
|
|
6574
6876
|
} from "transformation-matrix";
|
|
6575
6877
|
|
|
6576
6878
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
6577
|
-
import { applyToPoint as
|
|
6879
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
6578
6880
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
6579
6881
|
const { transform, layer: layerFilter } = ctx;
|
|
6580
6882
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
6581
|
-
const [x, y] =
|
|
6883
|
+
const [x, y] = applyToPoint51(transform, [solderPaste.x, solderPaste.y]);
|
|
6582
6884
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
6583
6885
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
6584
6886
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -6686,8 +6988,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
6686
6988
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
6687
6989
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
6688
6990
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
6689
|
-
const transform =
|
|
6690
|
-
|
|
6991
|
+
const transform = compose13(
|
|
6992
|
+
translate13(
|
|
6691
6993
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
6692
6994
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
6693
6995
|
),
|
|
@@ -6781,8 +7083,8 @@ function createSvgObjects3({ elm, ctx }) {
|
|
|
6781
7083
|
}
|
|
6782
7084
|
}
|
|
6783
7085
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
6784
|
-
const [x1, y1] =
|
|
6785
|
-
const [x2, y2] =
|
|
7086
|
+
const [x1, y1] = applyToPoint52(transform, [minX, minY]);
|
|
7087
|
+
const [x2, y2] = applyToPoint52(transform, [maxX, maxY]);
|
|
6786
7088
|
const width = Math.abs(x2 - x1);
|
|
6787
7089
|
const height = Math.abs(y2 - y1);
|
|
6788
7090
|
const x = Math.min(x1, x2);
|