circuit-to-svg 0.0.194 → 0.0.195
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 +144 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.194",
|
|
1670
1747
|
description: "Convert Circuit JSON to SVG",
|
|
1671
1748
|
main: "dist/index.js",
|
|
1672
1749
|
files: [
|