schematic-symbols 0.0.93 → 0.0.95
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +4 -2
- package/dist/index.js +294 -259
- package/dist/index.js.map +1 -1
- package/drawing/rotateSymbol.ts +48 -7
- package/package.json +1 -1
- package/symbols/led_down.ts +4 -0
- package/symbols/led_left.ts +4 -0
- package/symbols/led_right.ts +20 -0
- package/symbols/led_up.ts +4 -0
- package/symbols/led_horz.ts +0 -18
- package/symbols/led_vert.ts +0 -22
package/drawing/rotateSymbol.ts
CHANGED
@@ -7,12 +7,50 @@ import type {
|
|
7
7
|
NinePointAnchor,
|
8
8
|
} from "./types"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
// Update rotateAnchor to handle all anchor rotations based on orientation
|
11
|
+
const rotateAnchor = (
|
12
|
+
anchor: NinePointAnchor,
|
13
|
+
orientation: "up" | "down" | "left" | "right" = "right",
|
14
|
+
): NinePointAnchor => {
|
15
|
+
switch (orientation) {
|
16
|
+
case "up":
|
17
|
+
switch (anchor) {
|
18
|
+
case "middle_top":
|
19
|
+
return "middle_left"
|
20
|
+
case "middle_bottom":
|
21
|
+
return "middle_right"
|
22
|
+
case "middle_left":
|
23
|
+
return "middle_bottom"
|
24
|
+
case "middle_right":
|
25
|
+
return "middle_top"
|
26
|
+
}
|
27
|
+
break
|
28
|
+
case "down":
|
29
|
+
switch (anchor) {
|
30
|
+
case "middle_top":
|
31
|
+
return "middle_right"
|
32
|
+
case "middle_bottom":
|
33
|
+
return "middle_left"
|
34
|
+
case "middle_left":
|
35
|
+
return "middle_top"
|
36
|
+
case "middle_right":
|
37
|
+
return "middle_bottom"
|
38
|
+
}
|
39
|
+
break
|
40
|
+
case "left":
|
41
|
+
switch (anchor) {
|
42
|
+
case "middle_top":
|
43
|
+
return "middle_bottom"
|
44
|
+
case "middle_bottom":
|
45
|
+
return "middle_top"
|
46
|
+
case "middle_left":
|
47
|
+
return "middle_right"
|
48
|
+
case "middle_right":
|
49
|
+
return "middle_left"
|
50
|
+
}
|
51
|
+
break
|
52
|
+
case "right":
|
53
|
+
return anchor // No change if orientation is "right"
|
16
54
|
}
|
17
55
|
return anchor
|
18
56
|
}
|
@@ -54,7 +92,10 @@ export const rotateSymbol = (
|
|
54
92
|
y: primitive.y,
|
55
93
|
}) as Point
|
56
94
|
|
57
|
-
primitive.anchor = rotateAnchor(
|
95
|
+
primitive.anchor = rotateAnchor(
|
96
|
+
primitive.anchor,
|
97
|
+
orientation ?? "right",
|
98
|
+
)
|
58
99
|
|
59
100
|
return {
|
60
101
|
...primitive,
|
package/package.json
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
import { defineSymbol } from "drawing/defineSymbol"
|
2
|
+
import svgJson from "assets/generated/led.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.bottom1, anchor: "middle_top" },
|
12
|
+
{ ...texts.right1, anchor: "middle_bottom" },
|
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
|
+
})
|
package/symbols/led_horz.ts
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import svgJson from "assets/generated/led.json"
|
2
|
-
import { defineSymbol } from "drawing/defineSymbol"
|
3
|
-
|
4
|
-
const { paths, texts, bounds, refblocks } = svgJson
|
5
|
-
|
6
|
-
export default defineSymbol({
|
7
|
-
primitives: [
|
8
|
-
...Object.values(paths),
|
9
|
-
{ ...texts.bottom1, anchor: "middle_right" },
|
10
|
-
{ ...texts.right1, anchor: "middle_left" },
|
11
|
-
] as any,
|
12
|
-
ports: [
|
13
|
-
{ ...refblocks.left1, labels: ["1", "anode", "pos"] },
|
14
|
-
{ ...refblocks.right1, labels: ["2", "cathode", "neg"] },
|
15
|
-
],
|
16
|
-
size: { width: bounds.width, height: bounds.height },
|
17
|
-
center: { x: bounds.centerX, y: bounds.centerY + 0.1 },
|
18
|
-
})
|
package/symbols/led_vert.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import { rotateSymbol } from "drawing/rotateSymbol"
|
2
|
-
import led_horz from "./led_horz"
|
3
|
-
import type { TextPrimitive } from "drawing"
|
4
|
-
|
5
|
-
const rotated = rotateSymbol(led_horz)
|
6
|
-
|
7
|
-
const ref = rotated.primitives.find(
|
8
|
-
(p) => p.type === "text" && p.text === "{REF}",
|
9
|
-
)! as TextPrimitive
|
10
|
-
const val = rotated.primitives.find(
|
11
|
-
(p) => p.type === "text" && p.text === "{VAL}",
|
12
|
-
)! as TextPrimitive
|
13
|
-
|
14
|
-
ref.anchor = "middle_left"
|
15
|
-
val.anchor = "middle_right"
|
16
|
-
|
17
|
-
ref.x += 0.1
|
18
|
-
ref.y += 0.017
|
19
|
-
val.y = ref.y
|
20
|
-
val.x = -0.3
|
21
|
-
|
22
|
-
export default rotated
|