circuit-to-svg 0.0.265 → 0.0.267
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 +119 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1900,6 +1900,123 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1900
1900
|
}
|
|
1901
1901
|
];
|
|
1902
1902
|
}
|
|
1903
|
+
if (hole.shape === "hole_with_polygon_pad") {
|
|
1904
|
+
const polygonHole = hole;
|
|
1905
|
+
const padOutline = polygonHole.pad_outline || [];
|
|
1906
|
+
const holeX = polygonHole.x ?? 0;
|
|
1907
|
+
const holeY = polygonHole.y ?? 0;
|
|
1908
|
+
const padPoints = padOutline.map(
|
|
1909
|
+
(point) => applyToPoint12(transform, [holeX + point.x, holeY + point.y])
|
|
1910
|
+
);
|
|
1911
|
+
const padPointsString = padPoints.map((p) => p.join(",")).join(" ");
|
|
1912
|
+
const [holeCenterX, holeCenterY] = applyToPoint12(transform, [
|
|
1913
|
+
holeX + polygonHole.hole_offset_x,
|
|
1914
|
+
holeY + polygonHole.hole_offset_y
|
|
1915
|
+
]);
|
|
1916
|
+
const createHoleSvgObject = () => {
|
|
1917
|
+
if (polygonHole.hole_shape === "circle") {
|
|
1918
|
+
const scaledDiameter = (polygonHole.hole_diameter ?? 0) * Math.abs(transform.a);
|
|
1919
|
+
const radius = scaledDiameter / 2;
|
|
1920
|
+
return {
|
|
1921
|
+
name: "circle",
|
|
1922
|
+
type: "element",
|
|
1923
|
+
attributes: {
|
|
1924
|
+
class: "pcb-hole-inner",
|
|
1925
|
+
fill: colorMap2.drill,
|
|
1926
|
+
cx: holeCenterX.toString(),
|
|
1927
|
+
cy: holeCenterY.toString(),
|
|
1928
|
+
r: radius.toString(),
|
|
1929
|
+
"data-type": "pcb_plated_hole_drill",
|
|
1930
|
+
"data-pcb-layer": "drill"
|
|
1931
|
+
},
|
|
1932
|
+
value: "",
|
|
1933
|
+
children: []
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
if (polygonHole.hole_shape === "oval") {
|
|
1937
|
+
const scaledWidth = (polygonHole.hole_width ?? 0) * Math.abs(transform.a);
|
|
1938
|
+
const scaledHeight = (polygonHole.hole_height ?? 0) * Math.abs(transform.a);
|
|
1939
|
+
const rx = scaledWidth / 2;
|
|
1940
|
+
const ry = scaledHeight / 2;
|
|
1941
|
+
return {
|
|
1942
|
+
name: "ellipse",
|
|
1943
|
+
type: "element",
|
|
1944
|
+
attributes: {
|
|
1945
|
+
class: "pcb-hole-inner",
|
|
1946
|
+
fill: colorMap2.drill,
|
|
1947
|
+
cx: holeCenterX.toString(),
|
|
1948
|
+
cy: holeCenterY.toString(),
|
|
1949
|
+
rx: rx.toString(),
|
|
1950
|
+
ry: ry.toString(),
|
|
1951
|
+
"data-type": "pcb_plated_hole_drill",
|
|
1952
|
+
"data-pcb-layer": "drill"
|
|
1953
|
+
},
|
|
1954
|
+
value: "",
|
|
1955
|
+
children: []
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
if (polygonHole.hole_shape === "pill" || polygonHole.hole_shape === "rotated_pill") {
|
|
1959
|
+
const scaledWidth = (polygonHole.hole_width ?? 0) * Math.abs(transform.a);
|
|
1960
|
+
const scaledHeight = (polygonHole.hole_height ?? 0) * Math.abs(transform.a);
|
|
1961
|
+
const isHorizontal = scaledWidth > scaledHeight;
|
|
1962
|
+
const radius = Math.min(scaledWidth, scaledHeight) / 2;
|
|
1963
|
+
const straightLength = Math.abs(
|
|
1964
|
+
isHorizontal ? scaledWidth - scaledHeight : scaledHeight - scaledWidth
|
|
1965
|
+
);
|
|
1966
|
+
const pathD = isHorizontal ? `M${-straightLength / 2},${-radius} h${straightLength} a${radius},${radius} 0 0 1 0,${scaledHeight} h-${straightLength} a${radius},${radius} 0 0 1 0,-${scaledHeight} z` : `M${-radius},${-straightLength / 2} v${straightLength} a${radius},${radius} 0 0 0 ${scaledWidth},0 v-${straightLength} a${radius},${radius} 0 0 0 -${scaledWidth},0 z`;
|
|
1967
|
+
return {
|
|
1968
|
+
name: "path",
|
|
1969
|
+
type: "element",
|
|
1970
|
+
attributes: {
|
|
1971
|
+
class: "pcb-hole-inner",
|
|
1972
|
+
fill: colorMap2.drill,
|
|
1973
|
+
d: pathD,
|
|
1974
|
+
transform: `translate(${holeCenterX} ${holeCenterY})`,
|
|
1975
|
+
"data-type": "pcb_plated_hole_drill",
|
|
1976
|
+
"data-pcb-layer": "drill"
|
|
1977
|
+
},
|
|
1978
|
+
value: "",
|
|
1979
|
+
children: []
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
return {
|
|
1983
|
+
name: "g",
|
|
1984
|
+
type: "element",
|
|
1985
|
+
attributes: {},
|
|
1986
|
+
value: "",
|
|
1987
|
+
children: []
|
|
1988
|
+
};
|
|
1989
|
+
};
|
|
1990
|
+
return [
|
|
1991
|
+
{
|
|
1992
|
+
name: "g",
|
|
1993
|
+
type: "element",
|
|
1994
|
+
attributes: {
|
|
1995
|
+
"data-type": "pcb_plated_hole",
|
|
1996
|
+
"data-pcb-layer": "through"
|
|
1997
|
+
},
|
|
1998
|
+
children: [
|
|
1999
|
+
// Polygon pad (outer shape)
|
|
2000
|
+
{
|
|
2001
|
+
name: "polygon",
|
|
2002
|
+
type: "element",
|
|
2003
|
+
attributes: {
|
|
2004
|
+
class: "pcb-hole-outer-pad",
|
|
2005
|
+
fill: colorMap2.copper.top,
|
|
2006
|
+
points: padPointsString,
|
|
2007
|
+
"data-type": "pcb_plated_hole",
|
|
2008
|
+
"data-pcb-layer": copperLayer
|
|
2009
|
+
},
|
|
2010
|
+
value: "",
|
|
2011
|
+
children: []
|
|
2012
|
+
},
|
|
2013
|
+
// Hole inside the polygon (with offset)
|
|
2014
|
+
createHoleSvgObject()
|
|
2015
|
+
],
|
|
2016
|
+
value: ""
|
|
2017
|
+
}
|
|
2018
|
+
];
|
|
2019
|
+
}
|
|
1903
2020
|
return [];
|
|
1904
2021
|
}
|
|
1905
2022
|
|
|
@@ -3846,7 +3963,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
3846
3963
|
var package_default = {
|
|
3847
3964
|
name: "circuit-to-svg",
|
|
3848
3965
|
type: "module",
|
|
3849
|
-
version: "0.0.
|
|
3966
|
+
version: "0.0.266",
|
|
3850
3967
|
description: "Convert Circuit JSON to SVG",
|
|
3851
3968
|
main: "dist/index.js",
|
|
3852
3969
|
files: [
|
|
@@ -3870,7 +3987,7 @@ var package_default = {
|
|
|
3870
3987
|
"bun-match-svg": "^0.0.12",
|
|
3871
3988
|
esbuild: "^0.20.2",
|
|
3872
3989
|
"performance-now": "^2.1.0",
|
|
3873
|
-
"circuit-json": "^0.0.
|
|
3990
|
+
"circuit-json": "^0.0.308",
|
|
3874
3991
|
react: "19.1.0",
|
|
3875
3992
|
"react-cosmos": "7.0.0",
|
|
3876
3993
|
"react-cosmos-plugin-vite": "7.0.0",
|