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.
@@ -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
- const transform = rotate(Math.PI / 2, symbol.center.x, symbol.center.y)
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: size.height,
90
- height: size.width,
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,7 +1,7 @@
1
1
  {
2
2
  "name": "schematic-symbols",
3
3
  "main": "./dist/index.js",
4
- "version": "0.0.92",
4
+ "version": "0.0.93",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -0,0 +1,4 @@
1
+ import { rotateSymbol } from "drawing/rotateSymbol"
2
+ import diode_right from "./diode_right"
3
+
4
+ export default rotateSymbol(diode_right, "down")
@@ -0,0 +1,4 @@
1
+ import { rotateSymbol } from "drawing/rotateSymbol"
2
+ import diode_right from "./diode_right"
3
+
4
+ export default rotateSymbol(diode_right, "left")
@@ -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 any,
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,4 @@
1
+ import { rotateSymbol } from "drawing/rotateSymbol"
2
+ import diode_right from "./diode_right"
3
+
4
+ export default rotateSymbol(diode_right, "up")
@@ -1,4 +1,4 @@
1
1
  import { rotateSymbol } from "drawing/rotateSymbol"
2
2
  import varistor_horz from "./varistor_horz"
3
3
 
4
- export default rotateSymbol(varistor_horz, {})
4
+ export default rotateSymbol(varistor_horz)
@@ -1,4 +0,0 @@
1
- import { rotateSymbol } from "drawing/rotateSymbol"
2
- import diode_horz from "./diode_horz"
3
-
4
- export default rotateSymbol(diode_horz)