circuit-to-svg 0.0.160 → 0.0.161
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 +20 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4025,6 +4025,8 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4025
4025
|
const screenPinNumberTextPos = applyToPoint29(transform, realPinNumberPos);
|
|
4026
4026
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
4027
4027
|
if (!label) return [];
|
|
4028
|
+
const isNegated = label.startsWith("N_");
|
|
4029
|
+
const displayLabel = isNegated ? label.slice(2) : label;
|
|
4028
4030
|
svgObjects.push({
|
|
4029
4031
|
name: "text",
|
|
4030
4032
|
type: "element",
|
|
@@ -4032,7 +4034,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4032
4034
|
class: "pin-number",
|
|
4033
4035
|
x: screenPinNumberTextPos.x.toString(),
|
|
4034
4036
|
y: screenPinNumberTextPos.y.toString(),
|
|
4035
|
-
style:
|
|
4037
|
+
style: `font-family: sans-serif;${isNegated ? " text-decoration: overline;" : ""}`,
|
|
4036
4038
|
fill: colorMap.schematic.pin_number,
|
|
4037
4039
|
"text-anchor": schPort.side_of_component === "left" || schPort.side_of_component === "bottom" ? "start" : "end",
|
|
4038
4040
|
"dominant-baseline": "middle",
|
|
@@ -4042,7 +4044,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4042
4044
|
children: [
|
|
4043
4045
|
{
|
|
4044
4046
|
type: "text",
|
|
4045
|
-
value:
|
|
4047
|
+
value: displayLabel || "",
|
|
4046
4048
|
name: "",
|
|
4047
4049
|
attributes: {},
|
|
4048
4050
|
children: []
|
|
@@ -4594,6 +4596,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4594
4596
|
colorMap: colorMap2
|
|
4595
4597
|
}) => {
|
|
4596
4598
|
if (!schNetLabel.text) return [];
|
|
4599
|
+
const isNegated = schNetLabel.text.startsWith("N_");
|
|
4600
|
+
const labelText = isNegated ? schNetLabel.text.slice(2) : schNetLabel.text;
|
|
4597
4601
|
const svgObjects = [];
|
|
4598
4602
|
const symbol = symbols3[schNetLabel.symbol_name];
|
|
4599
4603
|
if (!symbol) {
|
|
@@ -4617,8 +4621,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4617
4621
|
maxY: Math.max(...symbolPaths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
4618
4622
|
};
|
|
4619
4623
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4620
|
-
const textWidthFSR = estimateTextWidth(
|
|
4621
|
-
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4624
|
+
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
4625
|
+
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
4622
4626
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4623
4627
|
schNetLabel.anchor_side
|
|
4624
4628
|
);
|
|
@@ -4719,7 +4723,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4719
4723
|
);
|
|
4720
4724
|
let textValue = text.text;
|
|
4721
4725
|
if (textValue === "{REF}") {
|
|
4722
|
-
textValue =
|
|
4726
|
+
textValue = labelText || "";
|
|
4723
4727
|
} else if (textValue === "{VAL}") {
|
|
4724
4728
|
textValue = "";
|
|
4725
4729
|
}
|
|
@@ -4739,7 +4743,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4739
4743
|
"font-family": "sans-serif",
|
|
4740
4744
|
"text-anchor": ninePointAnchorToTextAnchor[text.anchor],
|
|
4741
4745
|
"dominant-baseline": ninePointAnchorToDominantBaseline[text.anchor],
|
|
4742
|
-
"font-size": `${getSchScreenFontSize(realToScreenTransform, "reference_designator")}px
|
|
4746
|
+
"font-size": `${getSchScreenFontSize(realToScreenTransform, "reference_designator")}px`,
|
|
4747
|
+
...isNegated && textValue === labelText ? { style: "text-decoration: overline;" } : {}
|
|
4743
4748
|
},
|
|
4744
4749
|
children: [
|
|
4745
4750
|
{
|
|
@@ -4810,6 +4815,8 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4810
4815
|
colorMap: colorMap2
|
|
4811
4816
|
}) => {
|
|
4812
4817
|
if (!schNetLabel.text) return [];
|
|
4818
|
+
const isNegated = schNetLabel.text.startsWith("N_");
|
|
4819
|
+
const labelText = isNegated ? schNetLabel.text.slice(2) : schNetLabel.text;
|
|
4813
4820
|
if (schNetLabel.symbol_name) {
|
|
4814
4821
|
return createSvgObjectsForSchNetLabelWithSymbol({
|
|
4815
4822
|
schNetLabel,
|
|
@@ -4820,14 +4827,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4820
4827
|
const svgObjects = [];
|
|
4821
4828
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
4822
4829
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4823
|
-
const textWidthFSR = estimateTextWidth(
|
|
4830
|
+
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
4824
4831
|
const screenCenter = applyToPoint37(realToScreenTransform, schNetLabel.center);
|
|
4825
4832
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4826
4833
|
schNetLabel.anchor_side
|
|
4827
4834
|
);
|
|
4828
4835
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
4829
4836
|
screenTextGrowthVec.y *= -1;
|
|
4830
|
-
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4837
|
+
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
4831
4838
|
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint37(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
4832
4839
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
4833
4840
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
@@ -4855,12 +4862,12 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4855
4862
|
},
|
|
4856
4863
|
// Top right corner in font-relative coordinates
|
|
4857
4864
|
{
|
|
4858
|
-
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4865
|
+
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + textWidthFSR,
|
|
4859
4866
|
y: 0.6
|
|
4860
4867
|
},
|
|
4861
4868
|
// Bottom right corner in font-relative coordinates
|
|
4862
4869
|
{
|
|
4863
|
-
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR *
|
|
4870
|
+
x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + textWidthFSR,
|
|
4864
4871
|
y: -0.6
|
|
4865
4872
|
},
|
|
4866
4873
|
// Bottom left corner in font-relative coordinates
|
|
@@ -4929,12 +4936,13 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4929
4936
|
"font-family": "sans-serif",
|
|
4930
4937
|
"font-variant-numeric": "tabular-nums",
|
|
4931
4938
|
"font-size": `${fontSizePx}px`,
|
|
4932
|
-
transform: textTransformString
|
|
4939
|
+
transform: textTransformString,
|
|
4940
|
+
...isNegated ? { style: "text-decoration: overline;" } : {}
|
|
4933
4941
|
},
|
|
4934
4942
|
children: [
|
|
4935
4943
|
{
|
|
4936
4944
|
type: "text",
|
|
4937
|
-
value:
|
|
4945
|
+
value: labelText || "",
|
|
4938
4946
|
name: "",
|
|
4939
4947
|
attributes: {},
|
|
4940
4948
|
children: []
|