circuit-to-canvas 0.0.1 → 0.0.3

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.
Files changed (66) hide show
  1. package/.github/workflows/bun-formatcheck.yml +26 -0
  2. package/.github/workflows/bun-pver-release.yml +77 -0
  3. package/.github/workflows/bun-test.yml +31 -0
  4. package/.github/workflows/bun-typecheck.yml +26 -0
  5. package/LICENSE +21 -0
  6. package/README.md +66 -0
  7. package/dist/index.d.ts +146 -2
  8. package/dist/index.js +620 -0
  9. package/lib/drawer/CircuitToCanvasDrawer.ts +138 -1
  10. package/lib/drawer/elements/index.ts +30 -0
  11. package/lib/drawer/elements/pcb-board.ts +62 -0
  12. package/lib/drawer/elements/pcb-copper-pour.ts +84 -0
  13. package/lib/drawer/elements/pcb-cutout.ts +53 -0
  14. package/lib/drawer/elements/pcb-hole.ts +90 -0
  15. package/lib/drawer/elements/pcb-silkscreen.ts +171 -0
  16. package/lib/drawer/elements/pcb-smtpad.ts +108 -0
  17. package/lib/drawer/elements/pcb-trace.ts +59 -0
  18. package/lib/drawer/elements/pcb-via.ts +33 -0
  19. package/lib/drawer/shapes/index.ts +3 -0
  20. package/lib/drawer/shapes/line.ts +37 -0
  21. package/lib/drawer/shapes/path.ts +61 -0
  22. package/lib/drawer/shapes/polygon.ts +38 -0
  23. package/lib/drawer/types.ts +16 -0
  24. package/package.json +2 -2
  25. package/tests/elements/__snapshots__/board-with-elements.snap.png +0 -0
  26. package/tests/elements/__snapshots__/bottom-layer-pad.snap.png +0 -0
  27. package/tests/elements/__snapshots__/bottom-layer-trace.snap.png +0 -0
  28. package/tests/elements/__snapshots__/circular-cutout.snap.png +0 -0
  29. package/tests/elements/__snapshots__/circular-pad.snap.png +0 -0
  30. package/tests/elements/__snapshots__/copper-pour-with-trace.snap.png +0 -0
  31. package/tests/elements/__snapshots__/custom-outline-board.snap.png +0 -0
  32. package/tests/elements/__snapshots__/multi-segment-trace.snap.png +0 -0
  33. package/tests/elements/__snapshots__/multiple-traces.snap.png +0 -0
  34. package/tests/elements/__snapshots__/multiple-vias.snap.png +0 -0
  35. package/tests/elements/__snapshots__/oval-hole.snap.png +0 -0
  36. package/tests/elements/__snapshots__/pcb-board.snap.png +0 -0
  37. package/tests/elements/__snapshots__/pcb-copper-pour.snap.png +0 -0
  38. package/tests/elements/__snapshots__/pcb-cutout.snap.png +0 -0
  39. package/tests/elements/__snapshots__/pcb-hole.snap.png +0 -0
  40. package/tests/elements/__snapshots__/pcb-silkscreen.snap.png +0 -0
  41. package/tests/elements/__snapshots__/pcb-smtpad.snap.png +0 -0
  42. package/tests/elements/__snapshots__/pcb-trace.snap.png +0 -0
  43. package/tests/elements/__snapshots__/pcb-via.snap.png +0 -0
  44. package/tests/elements/__snapshots__/pill-hole.snap.png +0 -0
  45. package/tests/elements/__snapshots__/pill-pad.snap.png +0 -0
  46. package/tests/elements/__snapshots__/polygon-copper-pour.snap.png +0 -0
  47. package/tests/elements/__snapshots__/polygon-cutout.snap.png +0 -0
  48. package/tests/elements/__snapshots__/polygon-pad.snap.png +0 -0
  49. package/tests/elements/__snapshots__/rect-pad-with-border-radius.snap.png +0 -0
  50. package/tests/elements/__snapshots__/rotated-rect-pad.snap.png +0 -0
  51. package/tests/elements/__snapshots__/silkscreen-circle.snap.png +0 -0
  52. package/tests/elements/__snapshots__/silkscreen-line.snap.png +0 -0
  53. package/tests/elements/__snapshots__/silkscreen-on-component.snap.png +0 -0
  54. package/tests/elements/__snapshots__/silkscreen-path.snap.png +0 -0
  55. package/tests/elements/__snapshots__/silkscreen-rect.snap.png +0 -0
  56. package/tests/elements/__snapshots__/silkscreen-text-bottom.snap.png +0 -0
  57. package/tests/elements/__snapshots__/square-hole.snap.png +0 -0
  58. package/tests/elements/pcb-board.test.ts +155 -0
  59. package/tests/elements/pcb-copper-pour.test.ts +120 -0
  60. package/tests/elements/pcb-cutout.test.ts +82 -0
  61. package/tests/elements/pcb-hole.test.ts +105 -0
  62. package/tests/elements/pcb-silkscreen.test.ts +245 -0
  63. package/tests/elements/pcb-smtpad.test.ts +198 -0
  64. package/tests/elements/pcb-trace.test.ts +116 -0
  65. package/tests/elements/pcb-via.test.ts +75 -0
  66. package/.claude/settings.local.json +0 -7
package/dist/index.js CHANGED
@@ -285,6 +285,515 @@ function drawPcbPlatedHole(params) {
285
285
  }
286
286
  }
287
287
 
288
+ // lib/drawer/elements/pcb-via.ts
289
+ function drawPcbVia(params) {
290
+ const { ctx, via, transform, colorMap } = params;
291
+ drawCircle({
292
+ ctx,
293
+ center: { x: via.x, y: via.y },
294
+ radius: via.outer_diameter / 2,
295
+ fill: colorMap.copper.top,
296
+ transform
297
+ });
298
+ drawCircle({
299
+ ctx,
300
+ center: { x: via.x, y: via.y },
301
+ radius: via.hole_diameter / 2,
302
+ fill: colorMap.drill,
303
+ transform
304
+ });
305
+ }
306
+
307
+ // lib/drawer/elements/pcb-hole.ts
308
+ function drawPcbHole(params) {
309
+ const { ctx, hole, transform, colorMap } = params;
310
+ if (hole.hole_shape === "circle") {
311
+ drawCircle({
312
+ ctx,
313
+ center: { x: hole.x, y: hole.y },
314
+ radius: hole.hole_diameter / 2,
315
+ fill: colorMap.drill,
316
+ transform
317
+ });
318
+ return;
319
+ }
320
+ if (hole.hole_shape === "square") {
321
+ drawRect({
322
+ ctx,
323
+ center: { x: hole.x, y: hole.y },
324
+ width: hole.hole_diameter,
325
+ height: hole.hole_diameter,
326
+ fill: colorMap.drill,
327
+ transform
328
+ });
329
+ return;
330
+ }
331
+ if (hole.hole_shape === "oval") {
332
+ drawOval({
333
+ ctx,
334
+ center: { x: hole.x, y: hole.y },
335
+ width: hole.hole_width,
336
+ height: hole.hole_height,
337
+ fill: colorMap.drill,
338
+ transform
339
+ });
340
+ return;
341
+ }
342
+ if (hole.hole_shape === "rect") {
343
+ drawRect({
344
+ ctx,
345
+ center: { x: hole.x, y: hole.y },
346
+ width: hole.hole_width,
347
+ height: hole.hole_height,
348
+ fill: colorMap.drill,
349
+ transform
350
+ });
351
+ return;
352
+ }
353
+ if (hole.hole_shape === "pill") {
354
+ drawPill({
355
+ ctx,
356
+ center: { x: hole.x, y: hole.y },
357
+ width: hole.hole_width,
358
+ height: hole.hole_height,
359
+ fill: colorMap.drill,
360
+ transform
361
+ });
362
+ return;
363
+ }
364
+ if (hole.hole_shape === "rotated_pill") {
365
+ drawPill({
366
+ ctx,
367
+ center: { x: hole.x, y: hole.y },
368
+ width: hole.hole_width,
369
+ height: hole.hole_height,
370
+ fill: colorMap.drill,
371
+ transform,
372
+ rotation: hole.ccw_rotation ?? 0
373
+ });
374
+ return;
375
+ }
376
+ }
377
+
378
+ // lib/drawer/shapes/polygon.ts
379
+ import { applyToPoint as applyToPoint5 } from "transformation-matrix";
380
+ function drawPolygon(params) {
381
+ const { ctx, points, fill, transform } = params;
382
+ if (points.length < 3) return;
383
+ ctx.beginPath();
384
+ const transformedPoints = points.map(
385
+ (p) => applyToPoint5(transform, [p.x, p.y])
386
+ );
387
+ const firstPoint = transformedPoints[0];
388
+ if (!firstPoint) return;
389
+ const [firstX, firstY] = firstPoint;
390
+ ctx.moveTo(firstX, firstY);
391
+ for (let i = 1; i < transformedPoints.length; i++) {
392
+ const point = transformedPoints[i];
393
+ if (!point) continue;
394
+ const [x, y] = point;
395
+ ctx.lineTo(x, y);
396
+ }
397
+ ctx.closePath();
398
+ ctx.fillStyle = fill;
399
+ ctx.fill();
400
+ }
401
+
402
+ // lib/drawer/elements/pcb-smtpad.ts
403
+ function layerToColor(layer, colorMap) {
404
+ return colorMap.copper[layer] ?? colorMap.copper.top;
405
+ }
406
+ function drawPcbSmtPad(params) {
407
+ const { ctx, pad, transform, colorMap } = params;
408
+ const color = layerToColor(pad.layer, colorMap);
409
+ if (pad.shape === "rect") {
410
+ drawRect({
411
+ ctx,
412
+ center: { x: pad.x, y: pad.y },
413
+ width: pad.width,
414
+ height: pad.height,
415
+ fill: color,
416
+ transform,
417
+ borderRadius: pad.corner_radius ?? pad.rect_border_radius ?? 0
418
+ });
419
+ return;
420
+ }
421
+ if (pad.shape === "rotated_rect") {
422
+ drawRect({
423
+ ctx,
424
+ center: { x: pad.x, y: pad.y },
425
+ width: pad.width,
426
+ height: pad.height,
427
+ fill: color,
428
+ transform,
429
+ borderRadius: pad.corner_radius ?? pad.rect_border_radius ?? 0,
430
+ rotation: pad.ccw_rotation ?? 0
431
+ });
432
+ return;
433
+ }
434
+ if (pad.shape === "circle") {
435
+ drawCircle({
436
+ ctx,
437
+ center: { x: pad.x, y: pad.y },
438
+ radius: pad.radius,
439
+ fill: color,
440
+ transform
441
+ });
442
+ return;
443
+ }
444
+ if (pad.shape === "pill") {
445
+ drawPill({
446
+ ctx,
447
+ center: { x: pad.x, y: pad.y },
448
+ width: pad.width,
449
+ height: pad.height,
450
+ fill: color,
451
+ transform
452
+ });
453
+ return;
454
+ }
455
+ if (pad.shape === "rotated_pill") {
456
+ drawPill({
457
+ ctx,
458
+ center: { x: pad.x, y: pad.y },
459
+ width: pad.width,
460
+ height: pad.height,
461
+ fill: color,
462
+ transform,
463
+ rotation: pad.ccw_rotation ?? 0
464
+ });
465
+ return;
466
+ }
467
+ if (pad.shape === "polygon") {
468
+ if (pad.points && pad.points.length >= 3) {
469
+ drawPolygon({
470
+ ctx,
471
+ points: pad.points,
472
+ fill: color,
473
+ transform
474
+ });
475
+ }
476
+ return;
477
+ }
478
+ }
479
+
480
+ // lib/drawer/shapes/line.ts
481
+ import { applyToPoint as applyToPoint6 } from "transformation-matrix";
482
+ function drawLine(params) {
483
+ const {
484
+ ctx,
485
+ start,
486
+ end,
487
+ strokeWidth,
488
+ stroke,
489
+ transform,
490
+ lineCap = "round"
491
+ } = params;
492
+ const [x1, y1] = applyToPoint6(transform, [start.x, start.y]);
493
+ const [x2, y2] = applyToPoint6(transform, [end.x, end.y]);
494
+ const scaledStrokeWidth = strokeWidth * Math.abs(transform.a);
495
+ ctx.beginPath();
496
+ ctx.moveTo(x1, y1);
497
+ ctx.lineTo(x2, y2);
498
+ ctx.lineWidth = scaledStrokeWidth;
499
+ ctx.strokeStyle = stroke;
500
+ ctx.lineCap = lineCap;
501
+ ctx.stroke();
502
+ }
503
+
504
+ // lib/drawer/elements/pcb-trace.ts
505
+ function layerToColor2(layer, colorMap) {
506
+ return colorMap.copper[layer] ?? colorMap.copper.top;
507
+ }
508
+ function drawPcbTrace(params) {
509
+ const { ctx, trace, transform, colorMap } = params;
510
+ if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2) {
511
+ return;
512
+ }
513
+ for (let i = 0; i < trace.route.length - 1; i++) {
514
+ const start = trace.route[i];
515
+ const end = trace.route[i + 1];
516
+ if (!start || !end) continue;
517
+ const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
518
+ if (!layer) continue;
519
+ const color = layerToColor2(layer, colorMap);
520
+ const traceWidth = "width" in start ? start.width : "width" in end ? end.width : 0.1;
521
+ drawLine({
522
+ ctx,
523
+ start: { x: start.x, y: start.y },
524
+ end: { x: end.x, y: end.y },
525
+ strokeWidth: traceWidth,
526
+ stroke: color,
527
+ transform,
528
+ lineCap: "round"
529
+ });
530
+ }
531
+ }
532
+
533
+ // lib/drawer/shapes/path.ts
534
+ import { applyToPoint as applyToPoint7 } from "transformation-matrix";
535
+ function drawPath(params) {
536
+ const {
537
+ ctx,
538
+ points,
539
+ fill,
540
+ stroke,
541
+ strokeWidth = 1,
542
+ transform,
543
+ closePath = false
544
+ } = params;
545
+ if (points.length < 2) return;
546
+ ctx.beginPath();
547
+ const transformedPoints = points.map(
548
+ (p) => applyToPoint7(transform, [p.x, p.y])
549
+ );
550
+ const firstPoint = transformedPoints[0];
551
+ if (!firstPoint) return;
552
+ const [firstX, firstY] = firstPoint;
553
+ ctx.moveTo(firstX, firstY);
554
+ for (let i = 1; i < transformedPoints.length; i++) {
555
+ const point = transformedPoints[i];
556
+ if (!point) continue;
557
+ const [x, y] = point;
558
+ ctx.lineTo(x, y);
559
+ }
560
+ if (closePath) {
561
+ ctx.closePath();
562
+ }
563
+ if (fill) {
564
+ ctx.fillStyle = fill;
565
+ ctx.fill();
566
+ }
567
+ if (stroke) {
568
+ const scaledStrokeWidth = strokeWidth * Math.abs(transform.a);
569
+ ctx.strokeStyle = stroke;
570
+ ctx.lineWidth = scaledStrokeWidth;
571
+ ctx.stroke();
572
+ }
573
+ }
574
+
575
+ // lib/drawer/elements/pcb-board.ts
576
+ function drawPcbBoard(params) {
577
+ const { ctx, board, transform, colorMap } = params;
578
+ const { width, height, center, outline } = board;
579
+ if (outline && Array.isArray(outline) && outline.length >= 3) {
580
+ drawPath({
581
+ ctx,
582
+ points: outline.map((p) => ({ x: p.x, y: p.y })),
583
+ stroke: colorMap.boardOutline,
584
+ strokeWidth: 0.1,
585
+ transform,
586
+ closePath: true
587
+ });
588
+ return;
589
+ }
590
+ if (width !== void 0 && height !== void 0 && center) {
591
+ drawRect({
592
+ ctx,
593
+ center,
594
+ width,
595
+ height,
596
+ fill: "transparent",
597
+ transform
598
+ });
599
+ const halfWidth = width / 2;
600
+ const halfHeight = height / 2;
601
+ const corners = [
602
+ { x: center.x - halfWidth, y: center.y - halfHeight },
603
+ { x: center.x + halfWidth, y: center.y - halfHeight },
604
+ { x: center.x + halfWidth, y: center.y + halfHeight },
605
+ { x: center.x - halfWidth, y: center.y + halfHeight }
606
+ ];
607
+ drawPath({
608
+ ctx,
609
+ points: corners,
610
+ stroke: colorMap.boardOutline,
611
+ strokeWidth: 0.1,
612
+ transform,
613
+ closePath: true
614
+ });
615
+ }
616
+ }
617
+
618
+ // lib/drawer/elements/pcb-silkscreen.ts
619
+ import { applyToPoint as applyToPoint8 } from "transformation-matrix";
620
+ function layerToSilkscreenColor(layer, colorMap) {
621
+ return layer === "bottom" ? colorMap.silkscreen.bottom : colorMap.silkscreen.top;
622
+ }
623
+ function mapAnchorAlignment(alignment) {
624
+ if (!alignment) return "center";
625
+ if (alignment.includes("left")) return "left";
626
+ if (alignment.includes("right")) return "right";
627
+ return "center";
628
+ }
629
+ function drawPcbSilkscreenText(params) {
630
+ const { ctx, text, transform, colorMap } = params;
631
+ const color = layerToSilkscreenColor(text.layer, colorMap);
632
+ const [x, y] = applyToPoint8(transform, [
633
+ text.anchor_position.x,
634
+ text.anchor_position.y
635
+ ]);
636
+ const fontSize = (text.font_size ?? 1) * Math.abs(transform.a);
637
+ const rotation = text.ccw_rotation ?? 0;
638
+ ctx.save();
639
+ ctx.translate(x, y);
640
+ if (rotation !== 0) {
641
+ ctx.rotate(-rotation * (Math.PI / 180));
642
+ }
643
+ ctx.font = `${fontSize}px sans-serif`;
644
+ ctx.fillStyle = color;
645
+ ctx.textAlign = mapAnchorAlignment(text.anchor_alignment);
646
+ ctx.textBaseline = "middle";
647
+ ctx.fillText(text.text, 0, 0);
648
+ ctx.restore();
649
+ }
650
+ function drawPcbSilkscreenRect(params) {
651
+ const { ctx, rect, transform, colorMap } = params;
652
+ const color = layerToSilkscreenColor(rect.layer, colorMap);
653
+ drawRect({
654
+ ctx,
655
+ center: rect.center,
656
+ width: rect.width,
657
+ height: rect.height,
658
+ fill: color,
659
+ transform
660
+ });
661
+ }
662
+ function drawPcbSilkscreenCircle(params) {
663
+ const { ctx, circle, transform, colorMap } = params;
664
+ const color = layerToSilkscreenColor(circle.layer, colorMap);
665
+ drawCircle({
666
+ ctx,
667
+ center: circle.center,
668
+ radius: circle.radius,
669
+ fill: color,
670
+ transform
671
+ });
672
+ }
673
+ function drawPcbSilkscreenLine(params) {
674
+ const { ctx, line, transform, colorMap } = params;
675
+ const color = layerToSilkscreenColor(line.layer, colorMap);
676
+ drawLine({
677
+ ctx,
678
+ start: { x: line.x1, y: line.y1 },
679
+ end: { x: line.x2, y: line.y2 },
680
+ strokeWidth: line.stroke_width ?? 0.1,
681
+ stroke: color,
682
+ transform
683
+ });
684
+ }
685
+ function drawPcbSilkscreenPath(params) {
686
+ const { ctx, path, transform, colorMap } = params;
687
+ const color = layerToSilkscreenColor(path.layer, colorMap);
688
+ if (!path.route || path.route.length < 2) return;
689
+ for (let i = 0; i < path.route.length - 1; i++) {
690
+ const start = path.route[i];
691
+ const end = path.route[i + 1];
692
+ if (!start || !end) continue;
693
+ drawLine({
694
+ ctx,
695
+ start: { x: start.x, y: start.y },
696
+ end: { x: end.x, y: end.y },
697
+ strokeWidth: path.stroke_width ?? 0.1,
698
+ stroke: color,
699
+ transform
700
+ });
701
+ }
702
+ }
703
+
704
+ // lib/drawer/elements/pcb-cutout.ts
705
+ function drawPcbCutout(params) {
706
+ const { ctx, cutout, transform, colorMap } = params;
707
+ if (cutout.shape === "rect") {
708
+ drawRect({
709
+ ctx,
710
+ center: cutout.center,
711
+ width: cutout.width,
712
+ height: cutout.height,
713
+ fill: colorMap.drill,
714
+ transform,
715
+ rotation: cutout.rotation ?? 0
716
+ });
717
+ return;
718
+ }
719
+ if (cutout.shape === "circle") {
720
+ drawCircle({
721
+ ctx,
722
+ center: cutout.center,
723
+ radius: cutout.radius,
724
+ fill: colorMap.drill,
725
+ transform
726
+ });
727
+ return;
728
+ }
729
+ if (cutout.shape === "polygon") {
730
+ if (cutout.points && cutout.points.length >= 3) {
731
+ drawPolygon({
732
+ ctx,
733
+ points: cutout.points,
734
+ fill: colorMap.drill,
735
+ transform
736
+ });
737
+ }
738
+ return;
739
+ }
740
+ }
741
+
742
+ // lib/drawer/elements/pcb-copper-pour.ts
743
+ import { applyToPoint as applyToPoint9 } from "transformation-matrix";
744
+ function layerToColor3(layer, colorMap) {
745
+ return colorMap.copper[layer] ?? colorMap.copper.top;
746
+ }
747
+ function drawPcbCopperPour(params) {
748
+ const { ctx, pour, transform, colorMap } = params;
749
+ const color = layerToColor3(pour.layer, colorMap);
750
+ ctx.save();
751
+ if (pour.shape === "rect") {
752
+ const [cx, cy] = applyToPoint9(transform, [pour.center.x, pour.center.y]);
753
+ const scaledWidth = pour.width * Math.abs(transform.a);
754
+ const scaledHeight = pour.height * Math.abs(transform.a);
755
+ ctx.translate(cx, cy);
756
+ if (pour.rotation) {
757
+ ctx.rotate(-pour.rotation * (Math.PI / 180));
758
+ }
759
+ ctx.beginPath();
760
+ ctx.rect(-scaledWidth / 2, -scaledHeight / 2, scaledWidth, scaledHeight);
761
+ ctx.fillStyle = color;
762
+ ctx.globalAlpha = 0.5;
763
+ ctx.fill();
764
+ ctx.restore();
765
+ return;
766
+ }
767
+ if (pour.shape === "polygon") {
768
+ if (pour.points && pour.points.length >= 3) {
769
+ const transformedPoints = pour.points.map(
770
+ (p) => applyToPoint9(transform, [p.x, p.y])
771
+ );
772
+ const firstPoint = transformedPoints[0];
773
+ if (!firstPoint) {
774
+ ctx.restore();
775
+ return;
776
+ }
777
+ ctx.beginPath();
778
+ const [firstX, firstY] = firstPoint;
779
+ ctx.moveTo(firstX, firstY);
780
+ for (let i = 1; i < transformedPoints.length; i++) {
781
+ const point = transformedPoints[i];
782
+ if (!point) continue;
783
+ const [x, y] = point;
784
+ ctx.lineTo(x, y);
785
+ }
786
+ ctx.closePath();
787
+ ctx.fillStyle = color;
788
+ ctx.globalAlpha = 0.5;
789
+ ctx.fill();
790
+ }
791
+ ctx.restore();
792
+ return;
793
+ }
794
+ ctx.restore();
795
+ }
796
+
288
797
  // lib/drawer/CircuitToCanvasDrawer.ts
289
798
  var CircuitToCanvasDrawer = class {
290
799
  ctx;
@@ -362,14 +871,125 @@ var CircuitToCanvasDrawer = class {
362
871
  colorMap: this.colorMap
363
872
  });
364
873
  }
874
+ if (element.type === "pcb_via") {
875
+ drawPcbVia({
876
+ ctx: this.ctx,
877
+ via: element,
878
+ transform: this.realToCanvasMat,
879
+ colorMap: this.colorMap
880
+ });
881
+ }
882
+ if (element.type === "pcb_hole") {
883
+ drawPcbHole({
884
+ ctx: this.ctx,
885
+ hole: element,
886
+ transform: this.realToCanvasMat,
887
+ colorMap: this.colorMap
888
+ });
889
+ }
890
+ if (element.type === "pcb_smtpad") {
891
+ drawPcbSmtPad({
892
+ ctx: this.ctx,
893
+ pad: element,
894
+ transform: this.realToCanvasMat,
895
+ colorMap: this.colorMap
896
+ });
897
+ }
898
+ if (element.type === "pcb_trace") {
899
+ drawPcbTrace({
900
+ ctx: this.ctx,
901
+ trace: element,
902
+ transform: this.realToCanvasMat,
903
+ colorMap: this.colorMap
904
+ });
905
+ }
906
+ if (element.type === "pcb_board") {
907
+ drawPcbBoard({
908
+ ctx: this.ctx,
909
+ board: element,
910
+ transform: this.realToCanvasMat,
911
+ colorMap: this.colorMap
912
+ });
913
+ }
914
+ if (element.type === "pcb_silkscreen_text") {
915
+ drawPcbSilkscreenText({
916
+ ctx: this.ctx,
917
+ text: element,
918
+ transform: this.realToCanvasMat,
919
+ colorMap: this.colorMap
920
+ });
921
+ }
922
+ if (element.type === "pcb_silkscreen_rect") {
923
+ drawPcbSilkscreenRect({
924
+ ctx: this.ctx,
925
+ rect: element,
926
+ transform: this.realToCanvasMat,
927
+ colorMap: this.colorMap
928
+ });
929
+ }
930
+ if (element.type === "pcb_silkscreen_circle") {
931
+ drawPcbSilkscreenCircle({
932
+ ctx: this.ctx,
933
+ circle: element,
934
+ transform: this.realToCanvasMat,
935
+ colorMap: this.colorMap
936
+ });
937
+ }
938
+ if (element.type === "pcb_silkscreen_line") {
939
+ drawPcbSilkscreenLine({
940
+ ctx: this.ctx,
941
+ line: element,
942
+ transform: this.realToCanvasMat,
943
+ colorMap: this.colorMap
944
+ });
945
+ }
946
+ if (element.type === "pcb_silkscreen_path") {
947
+ drawPcbSilkscreenPath({
948
+ ctx: this.ctx,
949
+ path: element,
950
+ transform: this.realToCanvasMat,
951
+ colorMap: this.colorMap
952
+ });
953
+ }
954
+ if (element.type === "pcb_cutout") {
955
+ drawPcbCutout({
956
+ ctx: this.ctx,
957
+ cutout: element,
958
+ transform: this.realToCanvasMat,
959
+ colorMap: this.colorMap
960
+ });
961
+ }
962
+ if (element.type === "pcb_copper_pour") {
963
+ drawPcbCopperPour({
964
+ ctx: this.ctx,
965
+ pour: element,
966
+ transform: this.realToCanvasMat,
967
+ colorMap: this.colorMap
968
+ });
969
+ }
365
970
  }
366
971
  };
367
972
  export {
368
973
  CircuitToCanvasDrawer,
369
974
  DEFAULT_PCB_COLOR_MAP,
370
975
  drawCircle,
976
+ drawLine,
371
977
  drawOval,
978
+ drawPath,
979
+ drawPcbBoard,
980
+ drawPcbCopperPour,
981
+ drawPcbCutout,
982
+ drawPcbHole,
372
983
  drawPcbPlatedHole,
984
+ drawPcbSilkscreenCircle,
985
+ drawPcbSilkscreenLine,
986
+ drawPcbSilkscreenPath,
987
+ drawPcbSilkscreenRect,
988
+ drawPcbSilkscreenText,
989
+ drawPcbSmtPad,
990
+ drawPcbTrace,
991
+ drawPcbVia,
373
992
  drawPill,
993
+ drawPolygon,
374
994
  drawRect
375
995
  };