schematic-symbols 0.0.40 → 0.0.42
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 +13 -1
- package/dist/index.js +477 -171
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/symbols/dc_ammeter_horz.ts +32 -0
- package/symbols/dc_ammeter_vert.ts +51 -0
- package/symbols/power_factor_meter_horz.ts +42 -0
- package/symbols/power_factor_meter_vert.ts +16 -0
package/package.json
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
import { defineSymbol } from "drawing/defineSymbol"
|
2
|
+
import svgJson from "assets/generated/dc_ammeter.json"
|
3
|
+
|
4
|
+
const { paths, texts, bounds, refblocks, circles } = svgJson
|
5
|
+
|
6
|
+
export default defineSymbol({
|
7
|
+
primitives: [
|
8
|
+
...Object.values(paths),
|
9
|
+
...Object.values(circles),
|
10
|
+
{
|
11
|
+
type: "text",
|
12
|
+
text: "{REF}",
|
13
|
+
x: 0,
|
14
|
+
y: -0.3594553499999995,
|
15
|
+
anchor: "middle_bottom",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
type: "text",
|
19
|
+
text: "{VAL}",
|
20
|
+
x: 0,
|
21
|
+
y: 0.35,
|
22
|
+
anchor: "middle_top",
|
23
|
+
},
|
24
|
+
{ ...texts.left1, anchor: "center", fontSize: 0.3 },
|
25
|
+
] as any,
|
26
|
+
ports: [
|
27
|
+
{ ...refblocks.left1, labels: ["1"] }, // TODO add more "standard" labels
|
28
|
+
{ ...refblocks.right1, labels: ["2"] }, // TODO add more "standard" labels
|
29
|
+
],
|
30
|
+
size: { width: bounds.width, height: bounds.height },
|
31
|
+
center: { x: bounds.centerX, y: bounds.centerY },
|
32
|
+
})
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { rotateSymbol } from "drawing/rotateSymbol"
|
2
|
+
import dc_ammeter_horz from "./dc_ammeter_horz"
|
3
|
+
import { PathPrimitive, Primitive, TextPrimitive } from "drawing/types"
|
4
|
+
|
5
|
+
function isPathPrimitive(value: any): value is PathPrimitive {
|
6
|
+
return (
|
7
|
+
typeof value === "object" &&
|
8
|
+
value !== null &&
|
9
|
+
value.type === "path" &&
|
10
|
+
Array.isArray(value.points) &&
|
11
|
+
typeof value.color === "string"
|
12
|
+
)
|
13
|
+
}
|
14
|
+
|
15
|
+
function isTextPrimitive(value: any): value is TextPrimitive {
|
16
|
+
return (
|
17
|
+
typeof value === "object" &&
|
18
|
+
value !== null &&
|
19
|
+
value.type === "text" &&
|
20
|
+
typeof value.text === "string" &&
|
21
|
+
typeof value.x === "number" &&
|
22
|
+
typeof value.y === "number" &&
|
23
|
+
typeof value.anchor === "string"
|
24
|
+
)
|
25
|
+
}
|
26
|
+
|
27
|
+
const { 6: letter, 2: underline, ...rest } = dc_ammeter_horz.primitives
|
28
|
+
|
29
|
+
if (isPathPrimitive(underline)) {
|
30
|
+
underline.points.map((p) => {
|
31
|
+
p.y += 0.05
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
if (isTextPrimitive(letter)) {
|
36
|
+
letter.y += 0.025
|
37
|
+
}
|
38
|
+
|
39
|
+
function isPrimitive(value: any): value is Primitive {
|
40
|
+
return typeof value === "object"
|
41
|
+
}
|
42
|
+
|
43
|
+
const rotatedSymbol = rotateSymbol({
|
44
|
+
...dc_ammeter_horz,
|
45
|
+
primitives: Object.values(rest).filter(isPrimitive),
|
46
|
+
})
|
47
|
+
|
48
|
+
export default {
|
49
|
+
...rotatedSymbol,
|
50
|
+
primitives: [...rotatedSymbol.primitives, letter, underline],
|
51
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { defineSymbol } from "drawing/defineSymbol"
|
2
|
+
import svgJson from "assets/generated/power_factor_meter.json"
|
3
|
+
import { ninePointAnchorToSvgAnchor } from "drawing/ninePointAnchorToSvgAnchor"
|
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_left" },
|
12
|
+
{
|
13
|
+
type: "text",
|
14
|
+
text: "{REF}",
|
15
|
+
x: -0.15,
|
16
|
+
y: -0.42330070000000064,
|
17
|
+
anchor: "middle_left",
|
18
|
+
},
|
19
|
+
// { ...texts.bottom1, anchor: "middle_left" },
|
20
|
+
{
|
21
|
+
type: "text",
|
22
|
+
text: "{VAL}",
|
23
|
+
x: -0.15,
|
24
|
+
y: 0.42330070000000064,
|
25
|
+
anchor: "middle_left",
|
26
|
+
},
|
27
|
+
// { ...texts.left1, anchor: "middle_left" },
|
28
|
+
{
|
29
|
+
type: "text",
|
30
|
+
text: "COS φ",
|
31
|
+
x: -0.14,
|
32
|
+
y: 0.014279000000000375,
|
33
|
+
anchor: "middle-left",
|
34
|
+
},
|
35
|
+
] as any,
|
36
|
+
ports: [
|
37
|
+
{ ...refblocks.left1, labels: ["1"] }, // TODO add more "standard" labels
|
38
|
+
{ ...refblocks.right1, labels: ["2"] }, // TODO add more "standard" labels
|
39
|
+
],
|
40
|
+
size: { width: bounds.width, height: bounds.height },
|
41
|
+
center: { x: bounds.centerX, y: bounds.centerY },
|
42
|
+
})
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { rotateSymbol } from "drawing/rotateSymbol"
|
2
|
+
import power_factor_meter_horz from "./power_factor_meter_horz"
|
3
|
+
import { text } from "drawing/text"
|
4
|
+
|
5
|
+
const rotatedSymbol = rotateSymbol(power_factor_meter_horz)
|
6
|
+
const texts = rotatedSymbol.primitives.filter((p) => p.type === "text")
|
7
|
+
const ref = texts.find((t) => t.text === "{REF}")!
|
8
|
+
const val = texts.find((t) => t.text === "{VAL}")!
|
9
|
+
const text_cos = texts.find((t) => t.text === "COS φ")!
|
10
|
+
ref.x = 0.35
|
11
|
+
ref.y = 0
|
12
|
+
val.x = -0.6
|
13
|
+
val.y = 0
|
14
|
+
text_cos.x = -0.1
|
15
|
+
text_cos.y = 0
|
16
|
+
export default rotatedSymbol
|