schematic-symbols 0.0.96 → 0.0.98
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +13 -1
- package/dist/index.js +110 -9
- package/dist/index.js.map +1 -1
- package/drawing/rotateSymbol.ts +159 -1
- package/package.json +1 -1
- package/symbols/capacitor_down.ts +4 -0
- package/symbols/capacitor_left.ts +4 -0
- package/symbols/capacitor_right.ts +3 -0
- package/symbols/capacitor_up.ts +4 -0
- package/symbols/led_left.ts +2 -2
- package/symbols/led_up.ts +24 -1
package/dist/index.d.ts
CHANGED
@@ -83,7 +83,11 @@ declare const _default: {
|
|
83
83
|
battery_vert: undefined;
|
84
84
|
boxresistor_horz: undefined;
|
85
85
|
boxresistor_vert: undefined;
|
86
|
+
capacitor_down: undefined;
|
86
87
|
capacitor_horz: undefined;
|
88
|
+
capacitor_left: undefined;
|
89
|
+
capacitor_right: undefined;
|
90
|
+
capacitor_up: undefined;
|
87
91
|
capacitor_vert: undefined;
|
88
92
|
constant_current_diode_horz: undefined;
|
89
93
|
constant_current_diode_vert: undefined;
|
@@ -148,7 +152,15 @@ declare const _default: {
|
|
148
152
|
led_down: undefined;
|
149
153
|
led_left: undefined;
|
150
154
|
led_right: undefined;
|
151
|
-
led_up:
|
155
|
+
led_up: {
|
156
|
+
primitives: Primitive[];
|
157
|
+
center: Point;
|
158
|
+
ports: Port[];
|
159
|
+
size: {
|
160
|
+
width: number;
|
161
|
+
height: number;
|
162
|
+
};
|
163
|
+
};
|
152
164
|
light_dependent_resistor_horz: undefined;
|
153
165
|
light_dependent_resistor_vert: undefined;
|
154
166
|
mosfet_depletion_normally_on_horz: undefined;
|
package/dist/index.js
CHANGED
@@ -194,7 +194,7 @@ var ac_voltmeter_horz_default = defineSymbol({
|
|
194
194
|
});
|
195
195
|
|
196
196
|
// drawing/rotateSymbol.ts
|
197
|
-
import { rotate, applyToPoint } from "transformation-matrix";
|
197
|
+
import { rotate, applyToPoint, transform } from "transformation-matrix";
|
198
198
|
var rotateAnchor = (anchor, orientation = "right") => {
|
199
199
|
switch (orientation) {
|
200
200
|
case "up":
|
@@ -238,6 +238,75 @@ var rotateAnchor = (anchor, orientation = "right") => {
|
|
238
238
|
}
|
239
239
|
return anchor;
|
240
240
|
};
|
241
|
+
var flipSymbolOverYAxis = (symbol, overrides) => {
|
242
|
+
const { primitives, center, ports, size } = symbol;
|
243
|
+
const transformMatrix = transform({
|
244
|
+
a: -1,
|
245
|
+
b: 0,
|
246
|
+
c: 0,
|
247
|
+
d: 1,
|
248
|
+
e: 0,
|
249
|
+
f: 2 * center.x
|
250
|
+
});
|
251
|
+
const flippedPrimitives = primitives.map((primitive) => {
|
252
|
+
primitive = { ...primitive };
|
253
|
+
switch (primitive.type) {
|
254
|
+
case "path":
|
255
|
+
return {
|
256
|
+
...primitive,
|
257
|
+
points: primitive.points.map(
|
258
|
+
(point) => applyToPoint(transformMatrix, point)
|
259
|
+
)
|
260
|
+
};
|
261
|
+
case "text":
|
262
|
+
const flippedPoint = applyToPoint(transformMatrix, {
|
263
|
+
x: primitive.x,
|
264
|
+
y: primitive.y
|
265
|
+
});
|
266
|
+
const anchorMap = {
|
267
|
+
top_left: "top_right",
|
268
|
+
top_right: "top_left",
|
269
|
+
bottom_left: "bottom_right",
|
270
|
+
bottom_right: "bottom_left",
|
271
|
+
center: "center",
|
272
|
+
middle_top: "middle_top",
|
273
|
+
middle_bottom: "middle_bottom",
|
274
|
+
middle_left: "middle_right",
|
275
|
+
middle_right: "middle_left"
|
276
|
+
};
|
277
|
+
return {
|
278
|
+
...primitive,
|
279
|
+
x: flippedPoint.x,
|
280
|
+
y: flippedPoint.y,
|
281
|
+
anchor: anchorMap[primitive.anchor]
|
282
|
+
};
|
283
|
+
case "circle":
|
284
|
+
case "box":
|
285
|
+
const flippedCenter = applyToPoint(transformMatrix, {
|
286
|
+
x: primitive.x,
|
287
|
+
y: primitive.y
|
288
|
+
});
|
289
|
+
return {
|
290
|
+
...primitive,
|
291
|
+
x: flippedCenter.x,
|
292
|
+
y: flippedCenter.y
|
293
|
+
};
|
294
|
+
}
|
295
|
+
});
|
296
|
+
const flippedPorts = ports.map(
|
297
|
+
(port) => ({
|
298
|
+
...port,
|
299
|
+
...applyToPoint(transformMatrix, port)
|
300
|
+
})
|
301
|
+
);
|
302
|
+
return {
|
303
|
+
primitives: flippedPrimitives,
|
304
|
+
center,
|
305
|
+
ports: flippedPorts,
|
306
|
+
size,
|
307
|
+
...overrides
|
308
|
+
};
|
309
|
+
};
|
241
310
|
var rotateSymbol = (symbol, orientation, overrides) => {
|
242
311
|
const angleMap = {
|
243
312
|
up: -Math.PI / 2,
|
@@ -245,7 +314,7 @@ var rotateSymbol = (symbol, orientation, overrides) => {
|
|
245
314
|
down: Math.PI / 2,
|
246
315
|
left: -Math.PI
|
247
316
|
};
|
248
|
-
const
|
317
|
+
const transform2 = rotate(
|
249
318
|
orientation ? angleMap[orientation] : Math.PI / 2,
|
250
319
|
symbol.center.x,
|
251
320
|
symbol.center.y
|
@@ -258,11 +327,11 @@ var rotateSymbol = (symbol, orientation, overrides) => {
|
|
258
327
|
return {
|
259
328
|
...primitive,
|
260
329
|
points: primitive.points.map(
|
261
|
-
(point) => applyToPoint(
|
330
|
+
(point) => applyToPoint(transform2, point)
|
262
331
|
)
|
263
332
|
};
|
264
333
|
case "text":
|
265
|
-
const rotatedPoint = applyToPoint(
|
334
|
+
const rotatedPoint = applyToPoint(transform2, {
|
266
335
|
x: primitive.x,
|
267
336
|
y: primitive.y
|
268
337
|
});
|
@@ -276,7 +345,7 @@ var rotateSymbol = (symbol, orientation, overrides) => {
|
|
276
345
|
y: rotatedPoint.y
|
277
346
|
};
|
278
347
|
case "circle":
|
279
|
-
const rotatedCenter = applyToPoint(
|
348
|
+
const rotatedCenter = applyToPoint(transform2, {
|
280
349
|
x: primitive.x,
|
281
350
|
y: primitive.y
|
282
351
|
});
|
@@ -286,7 +355,7 @@ var rotateSymbol = (symbol, orientation, overrides) => {
|
|
286
355
|
y: rotatedCenter.y
|
287
356
|
};
|
288
357
|
case "box":
|
289
|
-
const rotatedCorner = applyToPoint(
|
358
|
+
const rotatedCorner = applyToPoint(transform2, {
|
290
359
|
x: primitive.x,
|
291
360
|
y: primitive.y
|
292
361
|
});
|
@@ -302,7 +371,7 @@ var rotateSymbol = (symbol, orientation, overrides) => {
|
|
302
371
|
const rotatedPorts = ports.map(
|
303
372
|
(port) => ({
|
304
373
|
...port,
|
305
|
-
...applyToPoint(
|
374
|
+
...applyToPoint(transform2, port)
|
306
375
|
})
|
307
376
|
);
|
308
377
|
return {
|
@@ -893,6 +962,18 @@ var capacitor_horz_default = defineSymbol({
|
|
893
962
|
center: { x: bounds5.centerX, y: bounds5.centerY }
|
894
963
|
});
|
895
964
|
|
965
|
+
// symbols/capacitor_down.ts
|
966
|
+
var capacitor_down_default = rotateSymbol(capacitor_horz_default, "down");
|
967
|
+
|
968
|
+
// symbols/capacitor_left.ts
|
969
|
+
var capacitor_left_default = rotateSymbol(capacitor_horz_default, "left");
|
970
|
+
|
971
|
+
// symbols/capacitor_right.ts
|
972
|
+
var capacitor_right_default = capacitor_horz_default;
|
973
|
+
|
974
|
+
// symbols/capacitor_up.ts
|
975
|
+
var capacitor_up_default = rotateSymbol(capacitor_horz_default, "up");
|
976
|
+
|
896
977
|
// symbols/capacitor_vert.ts
|
897
978
|
var capacitor_vert_default = rotateSymbol(capacitor_horz_default);
|
898
979
|
|
@@ -5180,10 +5261,26 @@ var led_right_default = defineSymbol({
|
|
5180
5261
|
var led_down_default = rotateSymbol(led_right_default, "down");
|
5181
5262
|
|
5182
5263
|
// symbols/led_left.ts
|
5183
|
-
var led_left_default =
|
5264
|
+
var led_left_default = flipSymbolOverYAxis(led_right_default);
|
5184
5265
|
|
5185
5266
|
// symbols/led_up.ts
|
5186
|
-
var
|
5267
|
+
var baseSymbol = rotateSymbol(led_right_default, "up");
|
5268
|
+
var modifiedSymbol = {
|
5269
|
+
...baseSymbol,
|
5270
|
+
primitives: baseSymbol.primitives.map((primitive) => {
|
5271
|
+
if (primitive.type === "path" && (primitive.points.length === 3 || primitive.points.length === 4)) {
|
5272
|
+
return {
|
5273
|
+
...primitive,
|
5274
|
+
points: primitive.points.map((point) => ({
|
5275
|
+
x: point.x,
|
5276
|
+
y: -point.y + 2 * baseSymbol.center.y
|
5277
|
+
}))
|
5278
|
+
};
|
5279
|
+
}
|
5280
|
+
return primitive;
|
5281
|
+
})
|
5282
|
+
};
|
5283
|
+
var led_up_default = modifiedSymbol;
|
5187
5284
|
|
5188
5285
|
// assets/generated/light_dependent_resistor.json
|
5189
5286
|
var light_dependent_resistor_default = {
|
@@ -12753,7 +12850,11 @@ var symbols_index_default = {
|
|
12753
12850
|
"battery_vert": battery_vert_default,
|
12754
12851
|
"boxresistor_horz": boxresistor_horz_default,
|
12755
12852
|
"boxresistor_vert": boxresistor_vert_default,
|
12853
|
+
"capacitor_down": capacitor_down_default,
|
12756
12854
|
"capacitor_horz": capacitor_horz_default,
|
12855
|
+
"capacitor_left": capacitor_left_default,
|
12856
|
+
"capacitor_right": capacitor_right_default,
|
12857
|
+
"capacitor_up": capacitor_up_default,
|
12757
12858
|
"capacitor_vert": capacitor_vert_default,
|
12758
12859
|
"constant_current_diode_horz": constant_current_diode_horz_default,
|
12759
12860
|
"constant_current_diode_vert": constant_current_diode_vert_default,
|