circuit-to-svg 0.0.136 → 0.0.138
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 +64 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2454,7 +2454,10 @@ function getSchematicBoundsFromCircuitJson(soup, padding = 0.5) {
|
|
|
2454
2454
|
updateBounds(item.position, { width: 0.2, height: 0.4 }, 0);
|
|
2455
2455
|
} else if (item.type === "schematic_box") {
|
|
2456
2456
|
updateBounds(
|
|
2457
|
-
{
|
|
2457
|
+
{
|
|
2458
|
+
x: item.x + item.width / 2,
|
|
2459
|
+
y: item.y + item.height / 2
|
|
2460
|
+
},
|
|
2458
2461
|
{ width: item.width, height: item.height },
|
|
2459
2462
|
0
|
|
2460
2463
|
);
|
|
@@ -2810,13 +2813,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2810
2813
|
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
2811
2814
|
circle
|
|
2812
2815
|
);
|
|
2816
|
+
const screenRadius = Math.abs(circle.radius * realToScreenTransform.a);
|
|
2813
2817
|
svgObjects.push({
|
|
2814
2818
|
type: "element",
|
|
2815
2819
|
name: "circle",
|
|
2816
2820
|
attributes: {
|
|
2817
2821
|
cx: screenCirclePos.x.toString(),
|
|
2818
2822
|
cy: screenCirclePos.y.toString(),
|
|
2819
|
-
r: `${
|
|
2823
|
+
r: `${screenRadius}px`,
|
|
2820
2824
|
"stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`,
|
|
2821
2825
|
fill: "none",
|
|
2822
2826
|
stroke: colorMap2.schematic.component_outline
|
|
@@ -4728,6 +4732,49 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4728
4732
|
return svgObjects;
|
|
4729
4733
|
};
|
|
4730
4734
|
|
|
4735
|
+
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
4736
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4737
|
+
var createSvgObjectsFromSchematicBox = ({
|
|
4738
|
+
schematicBox,
|
|
4739
|
+
transform,
|
|
4740
|
+
colorMap: colorMap2
|
|
4741
|
+
}) => {
|
|
4742
|
+
const topLeft = applyToPoint37(transform, {
|
|
4743
|
+
x: schematicBox.x,
|
|
4744
|
+
y: schematicBox.y
|
|
4745
|
+
});
|
|
4746
|
+
const bottomRight = applyToPoint37(transform, {
|
|
4747
|
+
x: schematicBox.x + schematicBox.width,
|
|
4748
|
+
y: schematicBox.y + schematicBox.height
|
|
4749
|
+
});
|
|
4750
|
+
const yTop = Math.min(topLeft.y, bottomRight.y);
|
|
4751
|
+
const yBottom = Math.max(topLeft.y, bottomRight.y);
|
|
4752
|
+
const xLeft = Math.min(topLeft.x, bottomRight.x);
|
|
4753
|
+
const xRight = Math.max(topLeft.x, bottomRight.x);
|
|
4754
|
+
const attributes = {
|
|
4755
|
+
class: "schematic-box",
|
|
4756
|
+
x: xLeft.toString(),
|
|
4757
|
+
y: yTop.toString(),
|
|
4758
|
+
width: (xRight - xLeft).toString(),
|
|
4759
|
+
height: (yBottom - yTop).toString(),
|
|
4760
|
+
"stroke-width": "2px",
|
|
4761
|
+
stroke: colorMap2.schematic.component_outline || "black",
|
|
4762
|
+
fill: "transparent"
|
|
4763
|
+
};
|
|
4764
|
+
if (schematicBox.is_dashed) {
|
|
4765
|
+
attributes["stroke-dasharray"] = "20 8";
|
|
4766
|
+
}
|
|
4767
|
+
return [
|
|
4768
|
+
{
|
|
4769
|
+
name: "rect",
|
|
4770
|
+
type: "element",
|
|
4771
|
+
value: "",
|
|
4772
|
+
attributes,
|
|
4773
|
+
children: []
|
|
4774
|
+
}
|
|
4775
|
+
];
|
|
4776
|
+
};
|
|
4777
|
+
|
|
4731
4778
|
// lib/sch/convert-circuit-json-to-schematic-svg.ts
|
|
4732
4779
|
function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
4733
4780
|
const realBounds = getSchematicBoundsFromCircuitJson(circuitJson);
|
|
@@ -4797,6 +4844,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
4797
4844
|
const schNetLabel = [];
|
|
4798
4845
|
const schText = [];
|
|
4799
4846
|
const voltageProbeSvgs = [];
|
|
4847
|
+
const schBoxSvgs = [];
|
|
4800
4848
|
for (const elm of circuitJson) {
|
|
4801
4849
|
if (elm.type === "schematic_debug_object") {
|
|
4802
4850
|
schDebugObjectSvgs.push(
|
|
@@ -4814,6 +4862,14 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
4814
4862
|
colorMap: colorMap2
|
|
4815
4863
|
})
|
|
4816
4864
|
);
|
|
4865
|
+
} else if (elm.type === "schematic_box") {
|
|
4866
|
+
schBoxSvgs.push(
|
|
4867
|
+
...createSvgObjectsFromSchematicBox({
|
|
4868
|
+
schematicBox: elm,
|
|
4869
|
+
transform,
|
|
4870
|
+
colorMap: colorMap2
|
|
4871
|
+
})
|
|
4872
|
+
);
|
|
4817
4873
|
} else if (elm.type === "schematic_trace") {
|
|
4818
4874
|
schTraceSvgs.push(
|
|
4819
4875
|
...createSchematicTrace({
|
|
@@ -4854,6 +4910,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
4854
4910
|
...schTraceSvgs,
|
|
4855
4911
|
...schNetLabel,
|
|
4856
4912
|
...schText,
|
|
4913
|
+
...schBoxSvgs,
|
|
4857
4914
|
...voltageProbeSvgs
|
|
4858
4915
|
);
|
|
4859
4916
|
if (options?.labeledPoints) {
|
|
@@ -4920,18 +4977,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
4920
4977
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
4921
4978
|
import { stringify as stringify4 } from "svgson";
|
|
4922
4979
|
import {
|
|
4923
|
-
applyToPoint as
|
|
4980
|
+
applyToPoint as applyToPoint40,
|
|
4924
4981
|
compose as compose11,
|
|
4925
4982
|
scale as scale8,
|
|
4926
4983
|
translate as translate11
|
|
4927
4984
|
} from "transformation-matrix";
|
|
4928
4985
|
|
|
4929
4986
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
4930
|
-
import { applyToPoint as
|
|
4987
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
4931
4988
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
4932
4989
|
const { transform, layer: layerFilter } = ctx;
|
|
4933
4990
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
4934
|
-
const [x, y] =
|
|
4991
|
+
const [x, y] = applyToPoint39(transform, [solderPaste.x, solderPaste.y]);
|
|
4935
4992
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
4936
4993
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
4937
4994
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -5125,8 +5182,8 @@ function createSvgObjects3({ elm, ctx }) {
|
|
|
5125
5182
|
}
|
|
5126
5183
|
}
|
|
5127
5184
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
5128
|
-
const [x1, y1] =
|
|
5129
|
-
const [x2, y2] =
|
|
5185
|
+
const [x1, y1] = applyToPoint40(transform, [minX, minY]);
|
|
5186
|
+
const [x2, y2] = applyToPoint40(transform, [maxX, maxY]);
|
|
5130
5187
|
const width = Math.abs(x2 - x1);
|
|
5131
5188
|
const height = Math.abs(y2 - y1);
|
|
5132
5189
|
const x = Math.min(x1, x2);
|