schematic-symbols 0.0.96 → 0.0.97

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -148,7 +148,15 @@ declare const _default: {
148
148
  led_down: undefined;
149
149
  led_left: undefined;
150
150
  led_right: undefined;
151
- led_up: undefined;
151
+ led_up: {
152
+ primitives: Primitive[];
153
+ center: Point;
154
+ ports: Port[];
155
+ size: {
156
+ width: number;
157
+ height: number;
158
+ };
159
+ };
152
160
  light_dependent_resistor_horz: undefined;
153
161
  light_dependent_resistor_vert: undefined;
154
162
  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 transform = rotate(
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(transform, point)
330
+ (point) => applyToPoint(transform2, point)
262
331
  )
263
332
  };
264
333
  case "text":
265
- const rotatedPoint = applyToPoint(transform, {
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(transform, {
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(transform, {
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(transform, port)
374
+ ...applyToPoint(transform2, port)
306
375
  })
307
376
  );
308
377
  return {
@@ -5180,10 +5249,26 @@ var led_right_default = defineSymbol({
5180
5249
  var led_down_default = rotateSymbol(led_right_default, "down");
5181
5250
 
5182
5251
  // symbols/led_left.ts
5183
- var led_left_default = rotateSymbol(led_right_default, "left");
5252
+ var led_left_default = flipSymbolOverYAxis(led_right_default);
5184
5253
 
5185
5254
  // symbols/led_up.ts
5186
- var led_up_default = rotateSymbol(led_right_default, "up");
5255
+ var baseSymbol = rotateSymbol(led_right_default, "up");
5256
+ var modifiedSymbol = {
5257
+ ...baseSymbol,
5258
+ primitives: baseSymbol.primitives.map((primitive) => {
5259
+ if (primitive.type === "path" && (primitive.points.length === 3 || primitive.points.length === 4)) {
5260
+ return {
5261
+ ...primitive,
5262
+ points: primitive.points.map((point) => ({
5263
+ x: point.x,
5264
+ y: -point.y + 2 * baseSymbol.center.y
5265
+ }))
5266
+ };
5267
+ }
5268
+ return primitive;
5269
+ })
5270
+ };
5271
+ var led_up_default = modifiedSymbol;
5187
5272
 
5188
5273
  // assets/generated/light_dependent_resistor.json
5189
5274
  var light_dependent_resistor_default = {