schematic-symbols 0.0.92 → 0.0.93
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.d.ts +5 -3
- package/dist/index.js +111 -123
- package/dist/index.js.map +1 -1
- package/drawing/rotateSymbol.ts +22 -4
- package/package.json +1 -1
- package/symbols/diode_down.ts +4 -0
- package/symbols/diode_left.ts +4 -0
- package/symbols/{diode_horz.ts → diode_right.ts} +5 -3
- package/symbols/diode_up.ts +4 -0
- package/symbols/varistor_vert.ts +1 -1
- package/symbols/diode_vert.ts +0 -4
package/drawing/rotateSymbol.ts
CHANGED
@@ -19,9 +19,22 @@ const rotateAnchor = (anchor: NinePointAnchor): NinePointAnchor => {
|
|
19
19
|
|
20
20
|
export const rotateSymbol = (
|
21
21
|
symbol: SchSymbol,
|
22
|
+
orientation?: "up" | "down" | "left" | "right",
|
22
23
|
overrides?: Partial<SchSymbol>,
|
23
24
|
): SchSymbol => {
|
24
|
-
|
25
|
+
// Assuming the default orientation is "right"
|
26
|
+
const angleMap = {
|
27
|
+
up: -Math.PI / 2,
|
28
|
+
right: 0,
|
29
|
+
down: Math.PI / 2,
|
30
|
+
left: -Math.PI,
|
31
|
+
}
|
32
|
+
|
33
|
+
const transform = rotate(
|
34
|
+
orientation ? angleMap[orientation] : Math.PI / 2,
|
35
|
+
symbol.center.x,
|
36
|
+
symbol.center.y,
|
37
|
+
)
|
25
38
|
|
26
39
|
const { primitives, center, size, ports } = symbol
|
27
40
|
|
@@ -84,10 +97,15 @@ export const rotateSymbol = (
|
|
84
97
|
primitives: rotatedPrimitives,
|
85
98
|
center,
|
86
99
|
ports: rotatedPorts,
|
87
|
-
// TODO recompute size using overrides
|
88
100
|
size: {
|
89
|
-
width:
|
90
|
-
|
101
|
+
width:
|
102
|
+
orientation === "up" || orientation === "down"
|
103
|
+
? size.width
|
104
|
+
: size.height,
|
105
|
+
height:
|
106
|
+
orientation === "up" || orientation === "down"
|
107
|
+
? size.height
|
108
|
+
: size.width,
|
91
109
|
},
|
92
110
|
...overrides,
|
93
111
|
}
|
package/package.json
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
import svgJson from "assets/generated/diode.json"
|
2
1
|
import { defineSymbol } from "drawing/defineSymbol"
|
2
|
+
import svgJson from "assets/generated/diode.json"
|
3
|
+
import { Primitive } from "drawing/types"
|
3
4
|
|
4
|
-
const { paths, texts, bounds, refblocks } = svgJson
|
5
|
+
const { paths, texts, bounds, refblocks, circles } = svgJson
|
5
6
|
|
6
7
|
export default defineSymbol({
|
7
8
|
primitives: [
|
8
9
|
...Object.values(paths),
|
10
|
+
...Object.values(circles),
|
9
11
|
{ ...texts.top1, anchor: "middle_bottom" },
|
10
12
|
{ ...texts.bottom1, anchor: "middle_top" },
|
11
|
-
] as
|
13
|
+
] as Primitive[],
|
12
14
|
ports: [
|
13
15
|
{ ...refblocks.left1, labels: ["1"] }, // TODO add more "standard" labels
|
14
16
|
{ ...refblocks.right1, labels: ["2"] }, // TODO add more "standard" labels
|
package/symbols/varistor_vert.ts
CHANGED
package/symbols/diode_vert.ts
DELETED