circuit-to-svg 0.0.109 → 0.0.111

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.js CHANGED
@@ -288,6 +288,51 @@ function createSvgObjectsFromPcbPlatedHole(hole, transform) {
288
288
  }
289
289
  ];
290
290
  }
291
+ if (hole.shape === "circular_hole_with_rect_pad") {
292
+ const scaledHoleDiameter = hole.hole_diameter * Math.abs(transform.a);
293
+ const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
294
+ const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
295
+ const holeRadius = scaledHoleDiameter / 2;
296
+ return [
297
+ {
298
+ name: "g",
299
+ type: "element",
300
+ children: [
301
+ // Rectangular pad (outer shape)
302
+ {
303
+ name: "rect",
304
+ type: "element",
305
+ attributes: {
306
+ class: "pcb-hole-outer-pad",
307
+ fill: "rgb(200, 52, 52)",
308
+ x: (x - scaledRectPadWidth / 2).toString(),
309
+ y: (y - scaledRectPadHeight / 2).toString(),
310
+ width: scaledRectPadWidth.toString(),
311
+ height: scaledRectPadHeight.toString()
312
+ },
313
+ value: "",
314
+ children: []
315
+ },
316
+ // Circular hole inside the rectangle
317
+ {
318
+ name: "circle",
319
+ type: "element",
320
+ attributes: {
321
+ class: "pcb-hole-inner",
322
+ fill: "rgb(255, 38, 226)",
323
+ cx: x.toString(),
324
+ cy: y.toString(),
325
+ r: holeRadius.toString()
326
+ },
327
+ value: "",
328
+ children: []
329
+ }
330
+ ],
331
+ value: "",
332
+ attributes: {}
333
+ }
334
+ ];
335
+ }
291
336
  return [];
292
337
  }
293
338
 
@@ -337,7 +382,8 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
337
382
  text,
338
383
  font_size = 1,
339
384
  layer = "top",
340
- ccw_rotation = 0
385
+ ccw_rotation = 0,
386
+ stroke_width = 0
341
387
  } = pcbSilkscreenText;
342
388
  if (!anchor_position || typeof anchor_position.x !== "number" || typeof anchor_position.y !== "number") {
343
389
  console.error("Invalid anchor_position:", anchor_position);
@@ -348,10 +394,10 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
348
394
  anchor_position.y
349
395
  ]);
350
396
  const transformedFontSize = font_size * Math.abs(transform.a);
397
+ const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
351
398
  const textTransform = compose2(
352
399
  translate2(transformedX, transformedY),
353
400
  rotate2(ccw_rotation * Math.PI / 180)
354
- // Convert degrees to radians
355
401
  );
356
402
  const svgObject = {
357
403
  name: "text",
@@ -366,7 +412,9 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
366
412
  "dominant-baseline": "central",
367
413
  transform: matrixToString2(textTransform),
368
414
  class: `pcb-silkscreen-text pcb-silkscreen-${layer}`,
369
- "data-pcb-silkscreen-text-id": pcbSilkscreenText.pcb_component_id
415
+ "data-pcb-silkscreen-text-id": pcbSilkscreenText.pcb_component_id,
416
+ stroke: "#f2eda1",
417
+ "stroke-width": transformedStrokeWidth.toString()
370
418
  },
371
419
  children: [
372
420
  {
@@ -392,7 +440,8 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, transform) {
392
440
  width,
393
441
  height,
394
442
  layer = "top",
395
- pcb_silkscreen_rect_id
443
+ pcb_silkscreen_rect_id,
444
+ stroke_width = 1
396
445
  } = pcbSilkscreenRect;
397
446
  if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof width !== "number" || typeof height !== "number") {
398
447
  console.error("Invalid rectangle data:", { center, width, height });
@@ -404,6 +453,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, transform) {
404
453
  ]);
405
454
  const transformedWidth = width * Math.abs(transform.a);
406
455
  const transformedHeight = height * Math.abs(transform.d);
456
+ const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
407
457
  const svgObject = {
408
458
  name: "rect",
409
459
  type: "element",
@@ -415,7 +465,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, transform) {
415
465
  class: `pcb-silkscreen-rect pcb-silkscreen-${layer}`,
416
466
  fill: "none",
417
467
  stroke: "#f2eda1",
418
- "stroke-width": "1",
468
+ "stroke-width": transformedStrokeWidth.toString(),
419
469
  "data-pcb-silkscreen-rect-id": pcb_silkscreen_rect_id
420
470
  },
421
471
  value: "",
@@ -433,7 +483,8 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, transform)
433
483
  center,
434
484
  radius,
435
485
  layer = "top",
436
- pcb_silkscreen_circle_id
486
+ pcb_silkscreen_circle_id,
487
+ stroke_width = 1
437
488
  } = pcbSilkscreenCircle;
438
489
  if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof radius !== "number") {
439
490
  console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
@@ -444,6 +495,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, transform)
444
495
  center.y
445
496
  ]);
446
497
  const transformedRadius = radius * Math.abs(transform.a);
498
+ const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
447
499
  const svgObject = {
448
500
  name: "circle",
449
501
  type: "element",
@@ -453,7 +505,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, transform)
453
505
  r: transformedRadius.toString(),
454
506
  class: `pcb-silkscreen-circle pcb-silkscreen-${layer}`,
455
507
  stroke: "#f2eda1",
456
- "stroke-width": "1",
508
+ "stroke-width": transformedStrokeWidth.toString(),
457
509
  "data-pcb-silkscreen-circle-id": pcb_silkscreen_circle_id
458
510
  },
459
511
  value: "",
@@ -1899,7 +1951,7 @@ function getSchematicBoundsFromCircuitJson(soup, padding = 0.5) {
1899
1951
  const portSize = 0.2;
1900
1952
  for (const item of soup) {
1901
1953
  if (item.type === "schematic_component") {
1902
- updateBounds(item.center, item.size, item.rotation || 0);
1954
+ updateBounds(item.center, item.size, 0);
1903
1955
  } else if (item.type === "schematic_port") {
1904
1956
  updateBounds(item.center, { width: portSize, height: portSize }, 0);
1905
1957
  } else if (item.type === "schematic_debug_object") {