schematic-symbols 0.0.91 → 0.0.93
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +7 -3
- package/dist/index.js +875 -622
- 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/illuminated_push_button_normally_open_horz.ts +20 -0
- package/symbols/illuminated_push_button_normally_open_vert.ts +20 -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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { defineSymbol } from "drawing/defineSymbol"
|
2
|
+
import svgJson from "assets/generated/illuminated_push_button_normally_open.json"
|
3
|
+
import { Primitive } from "drawing/types"
|
4
|
+
|
5
|
+
const { paths, texts, bounds, refblocks, circles } = svgJson
|
6
|
+
|
7
|
+
export default defineSymbol({
|
8
|
+
primitives: [
|
9
|
+
...Object.values(paths),
|
10
|
+
...Object.values(circles),
|
11
|
+
{ ...texts.top1, anchor: "middle_right", x: 0, y: -0.4 },
|
12
|
+
{ ...texts.bottom1, anchor: "middle_right", x: 0 },
|
13
|
+
] as Primitive[],
|
14
|
+
ports: [
|
15
|
+
{ ...refblocks.left1, labels: ["1"] }, // TODO add more "standard" labels
|
16
|
+
{ ...refblocks.right1, labels: ["2"] }, // TODO add more "standard" labels
|
17
|
+
],
|
18
|
+
size: { width: bounds.width, height: bounds.height },
|
19
|
+
center: { x: bounds.centerX, y: bounds.centerY },
|
20
|
+
})
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { rotateSymbol } from "drawing/rotateSymbol"
|
2
|
+
import illuminated_push_button_normally_open_horz from "./illuminated_push_button_normally_open_horz"
|
3
|
+
|
4
|
+
const rotatedSymbol = rotateSymbol(illuminated_push_button_normally_open_horz)
|
5
|
+
|
6
|
+
const texts = rotatedSymbol.primitives.filter((p) => p.type === "text")!
|
7
|
+
|
8
|
+
const val = texts.find((t) => t.text === "{VAL}")!
|
9
|
+
|
10
|
+
val.x = -0.35
|
11
|
+
val.y = 0
|
12
|
+
val.anchor = "middle_right"
|
13
|
+
|
14
|
+
const ref = texts.find((t) => t.text === "{REF}")!
|
15
|
+
|
16
|
+
ref.y = 0
|
17
|
+
ref.x = 0.35
|
18
|
+
ref.anchor = "middle_left"
|
19
|
+
|
20
|
+
export default rotatedSymbol
|
package/symbols/varistor_vert.ts
CHANGED
package/symbols/diode_vert.ts
DELETED