circuit-to-svg 0.0.275 → 0.0.277
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 +79 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1671,6 +1671,64 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1671
1671
|
}
|
|
1672
1672
|
];
|
|
1673
1673
|
}
|
|
1674
|
+
if (hole.shape === "oval") {
|
|
1675
|
+
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
1676
|
+
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
1677
|
+
const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
|
|
1678
|
+
const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
|
|
1679
|
+
const rotation = hole.ccw_rotation || 0;
|
|
1680
|
+
const transformStr = rotation ? `translate(${x} ${y}) rotate(${-rotation})` : `translate(${x} ${y})`;
|
|
1681
|
+
const children = [
|
|
1682
|
+
// Outer oval shape
|
|
1683
|
+
{
|
|
1684
|
+
name: "ellipse",
|
|
1685
|
+
type: "element",
|
|
1686
|
+
attributes: {
|
|
1687
|
+
class: "pcb-hole-outer",
|
|
1688
|
+
fill: colorMap2.copper.top,
|
|
1689
|
+
cx: "0",
|
|
1690
|
+
cy: "0",
|
|
1691
|
+
rx: (scaledOuterWidth / 2).toString(),
|
|
1692
|
+
ry: (scaledOuterHeight / 2).toString(),
|
|
1693
|
+
transform: transformStr,
|
|
1694
|
+
"data-type": "pcb_plated_hole",
|
|
1695
|
+
"data-pcb-layer": copperLayer
|
|
1696
|
+
},
|
|
1697
|
+
value: "",
|
|
1698
|
+
children: []
|
|
1699
|
+
},
|
|
1700
|
+
// Inner oval shape
|
|
1701
|
+
{
|
|
1702
|
+
name: "ellipse",
|
|
1703
|
+
type: "element",
|
|
1704
|
+
attributes: {
|
|
1705
|
+
class: "pcb-hole-inner",
|
|
1706
|
+
fill: colorMap2.drill,
|
|
1707
|
+
cx: "0",
|
|
1708
|
+
cy: "0",
|
|
1709
|
+
rx: (scaledHoleWidth / 2).toString(),
|
|
1710
|
+
ry: (scaledHoleHeight / 2).toString(),
|
|
1711
|
+
transform: transformStr,
|
|
1712
|
+
"data-type": "pcb_plated_hole_drill",
|
|
1713
|
+
"data-pcb-layer": "drill"
|
|
1714
|
+
},
|
|
1715
|
+
value: "",
|
|
1716
|
+
children: []
|
|
1717
|
+
}
|
|
1718
|
+
];
|
|
1719
|
+
return [
|
|
1720
|
+
{
|
|
1721
|
+
name: "g",
|
|
1722
|
+
type: "element",
|
|
1723
|
+
attributes: {
|
|
1724
|
+
"data-type": "pcb_plated_hole",
|
|
1725
|
+
"data-pcb-layer": "through"
|
|
1726
|
+
},
|
|
1727
|
+
children,
|
|
1728
|
+
value: ""
|
|
1729
|
+
}
|
|
1730
|
+
];
|
|
1731
|
+
}
|
|
1674
1732
|
if (hole.shape === "circle") {
|
|
1675
1733
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
1676
1734
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
@@ -4292,7 +4350,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
4292
4350
|
var package_default = {
|
|
4293
4351
|
name: "circuit-to-svg",
|
|
4294
4352
|
type: "module",
|
|
4295
|
-
version: "0.0.
|
|
4353
|
+
version: "0.0.276",
|
|
4296
4354
|
description: "Convert Circuit JSON to SVG",
|
|
4297
4355
|
main: "dist/index.js",
|
|
4298
4356
|
files: [
|
|
@@ -10813,7 +10871,10 @@ function convertCircuitJsonToSimulationGraphSvg({
|
|
|
10813
10871
|
);
|
|
10814
10872
|
}
|
|
10815
10873
|
const timeAxis = buildAxisInfo(allPoints.map((point) => point.timeMs));
|
|
10816
|
-
const voltageAxis = buildAxisInfo(
|
|
10874
|
+
const voltageAxis = buildAxisInfo(
|
|
10875
|
+
allPoints.map((point) => point.voltage),
|
|
10876
|
+
true
|
|
10877
|
+
);
|
|
10817
10878
|
const plotWidth = Math.max(1, width - MARGIN.left - MARGIN.right);
|
|
10818
10879
|
const plotHeight = Math.max(1, height - MARGIN.top - MARGIN.bottom);
|
|
10819
10880
|
const scaleX = createLinearScale(
|
|
@@ -10932,7 +10993,7 @@ function getTimestamps(graph) {
|
|
|
10932
10993
|
}
|
|
10933
10994
|
return timestamps;
|
|
10934
10995
|
}
|
|
10935
|
-
function buildAxisInfo(values) {
|
|
10996
|
+
function buildAxisInfo(values, applyPadding = false) {
|
|
10936
10997
|
if (values.length === 0) {
|
|
10937
10998
|
return {
|
|
10938
10999
|
domainMin: 0,
|
|
@@ -10951,9 +11012,21 @@ function buildAxisInfo(values) {
|
|
|
10951
11012
|
};
|
|
10952
11013
|
}
|
|
10953
11014
|
const ticks = generateTickValues(min, max);
|
|
10954
|
-
const safeTicks = ticks.length > 0 ? ticks : [min, max];
|
|
10955
|
-
|
|
10956
|
-
|
|
11015
|
+
const safeTicks = ticks.length > 0 ? [...ticks] : [min, max];
|
|
11016
|
+
let domainMin = safeTicks[0];
|
|
11017
|
+
let domainMax = safeTicks[safeTicks.length - 1];
|
|
11018
|
+
if (applyPadding && safeTicks.length > 1) {
|
|
11019
|
+
const tickStep = Math.abs(safeTicks[1] - safeTicks[0]);
|
|
11020
|
+
const PADDING_TOLERANCE_RATIO = 0.1;
|
|
11021
|
+
if (min < domainMin + tickStep * PADDING_TOLERANCE_RATIO) {
|
|
11022
|
+
domainMin -= tickStep;
|
|
11023
|
+
safeTicks.unshift(domainMin);
|
|
11024
|
+
}
|
|
11025
|
+
if (max > domainMax - tickStep * PADDING_TOLERANCE_RATIO) {
|
|
11026
|
+
domainMax += tickStep;
|
|
11027
|
+
safeTicks.push(domainMax);
|
|
11028
|
+
}
|
|
11029
|
+
}
|
|
10957
11030
|
return { domainMin, domainMax, ticks: safeTicks };
|
|
10958
11031
|
}
|
|
10959
11032
|
function generateTickValues(min, max, desired = 6) {
|