circuit-to-svg 0.0.141 → 0.0.143

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 CHANGED
@@ -1,7 +1,27 @@
1
1
  import { AnyCircuitElement } from 'circuit-json';
2
2
  import { Matrix } from 'transformation-matrix';
3
3
 
4
+ interface PcbColorMap {
5
+ copper: {
6
+ top: string;
7
+ bottom: string;
8
+ };
9
+ drill: string;
10
+ silkscreen: {
11
+ top: string;
12
+ bottom: string;
13
+ };
14
+ boardOutline: string;
15
+ }
16
+ interface PcbColorOverrides {
17
+ copper?: Partial<PcbColorMap["copper"]>;
18
+ drill?: string;
19
+ silkscreen?: Partial<PcbColorMap["silkscreen"]>;
20
+ boardOutline?: string;
21
+ }
22
+
4
23
  interface Options$3 {
24
+ colorOverrides?: PcbColorOverrides;
5
25
  width?: number;
6
26
  height?: number;
7
27
  shouldDrawErrors?: boolean;
@@ -16,6 +36,7 @@ interface PcbContext {
16
36
  layer?: "top" | "bottom";
17
37
  shouldDrawErrors?: boolean;
18
38
  drawPaddingOutsideBoard?: boolean;
39
+ colorMap: PcbColorMap;
19
40
  }
20
41
  declare function convertCircuitJsonToPcbSvg(circuitJson: AnyCircuitElement[], options?: Options$3): string;
21
42
  /**
@@ -219,4 +240,4 @@ interface Options {
219
240
  }
220
241
  declare function convertCircuitJsonToSolderPasteMask(circuitJson: AnyCircuitElement[], options: Options): string;
221
242
 
222
- export { type ColorMap, type ColorOverrides, type PcbContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSolderPasteMask };
243
+ export { type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSolderPasteMask };
package/dist/index.js CHANGED
@@ -333,7 +333,7 @@ function createSvgObjectsFromPcbFabricationNoteText(pcbFabNoteText, ctx) {
333
333
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-plated-hole.ts
334
334
  import { applyToPoint as applyToPoint4 } from "transformation-matrix";
335
335
  function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
336
- const { transform } = ctx;
336
+ const { transform, colorMap: colorMap2 } = ctx;
337
337
  const [x, y] = applyToPoint4(transform, [hole.x, hole.y]);
338
338
  if (hole.shape === "pill") {
339
339
  const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
@@ -356,7 +356,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
356
356
  type: "element",
357
357
  attributes: {
358
358
  class: "pcb-hole-outer",
359
- fill: "rgb(200, 52, 52)",
359
+ fill: colorMap2.copper.top,
360
360
  d: `M${x - outerRadiusX},${y - straightLength / 2} v${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 ${scaledOuterWidth},0 v-${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 -${scaledOuterWidth},0 z`
361
361
  },
362
362
  value: "",
@@ -368,7 +368,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
368
368
  type: "element",
369
369
  attributes: {
370
370
  class: "pcb-hole-inner",
371
- fill: "rgb(255, 38, 226)",
371
+ fill: colorMap2.drill,
372
372
  d: `M${x - innerRadiusX},${y - (scaledHoleHeight - scaledHoleWidth) / 2} v${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 ${scaledHoleWidth},0 v-${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 -${scaledHoleWidth},0 z`
373
373
  },
374
374
  value: "",
@@ -397,7 +397,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
397
397
  type: "element",
398
398
  attributes: {
399
399
  class: "pcb-hole-outer",
400
- fill: "rgb(200, 52, 52)",
400
+ fill: colorMap2.copper.top,
401
401
  cx: x.toString(),
402
402
  cy: y.toString(),
403
403
  r: outerRadius.toString()
@@ -410,7 +410,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
410
410
  type: "element",
411
411
  attributes: {
412
412
  class: "pcb-hole-inner",
413
- fill: "rgb(255, 38, 226)",
413
+ fill: colorMap2.drill,
414
414
  cx: x.toString(),
415
415
  cy: y.toString(),
416
416
  r: innerRadius.toString()
@@ -440,7 +440,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
440
440
  type: "element",
441
441
  attributes: {
442
442
  class: "pcb-hole-outer-pad",
443
- fill: "rgb(200, 52, 52)",
443
+ fill: colorMap2.copper.top,
444
444
  x: (x - scaledRectPadWidth / 2).toString(),
445
445
  y: (y - scaledRectPadHeight / 2).toString(),
446
446
  width: scaledRectPadWidth.toString(),
@@ -455,7 +455,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
455
455
  type: "element",
456
456
  attributes: {
457
457
  class: "pcb-hole-inner",
458
- fill: "rgb(255, 38, 226)",
458
+ fill: colorMap2.drill,
459
459
  cx: x.toString(),
460
460
  cy: y.toString(),
461
461
  r: holeRadius.toString()
@@ -486,7 +486,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
486
486
  type: "element",
487
487
  attributes: {
488
488
  class: "pcb-hole-outer-pad",
489
- fill: "rgb(200, 52, 52)",
489
+ fill: colorMap2.copper.top,
490
490
  x: (x - scaledRectPadWidth / 2).toString(),
491
491
  y: (y - scaledRectPadHeight / 2).toString(),
492
492
  width: scaledRectPadWidth.toString(),
@@ -501,7 +501,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
501
501
  type: "element",
502
502
  attributes: {
503
503
  class: "pcb-hole-inner",
504
- fill: "rgb(255, 38, 226)",
504
+ fill: colorMap2.drill,
505
505
  x: (x - scaledHoleWidth / 2).toString(),
506
506
  y: (y - scaledHoleHeight / 2).toString(),
507
507
  width: scaledHoleWidth.toString(),
@@ -523,15 +523,8 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
523
523
 
524
524
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-path.ts
525
525
  import { applyToPoint as applyToPoint5 } from "transformation-matrix";
526
-
527
- // lib/pcb/colors.ts
528
- var HOLE_COLOR = "#FF26E2";
529
- var SILKSCREEN_TOP_COLOR = "#f2eda1";
530
- var SILKSCREEN_BOTTOM_COLOR = "#5da9e9";
531
-
532
- // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-path.ts
533
526
  function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
534
- const { transform, layer: layerFilter } = ctx;
527
+ const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
535
528
  if (!silkscreenPath.route || !Array.isArray(silkscreenPath.route)) return [];
536
529
  let path = silkscreenPath.route.map((point, index) => {
537
530
  const [x, y] = applyToPoint5(transform, [point.x, point.y]);
@@ -544,7 +537,7 @@ function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
544
537
  }
545
538
  const layer = silkscreenPath.layer || "top";
546
539
  if (layerFilter && layer !== layerFilter) return [];
547
- const color = layer === "bottom" ? SILKSCREEN_BOTTOM_COLOR : SILKSCREEN_TOP_COLOR;
540
+ const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
548
541
  return [
549
542
  {
550
543
  name: "path",
@@ -576,7 +569,7 @@ import {
576
569
  toString as matrixToString2
577
570
  } from "transformation-matrix";
578
571
  function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
579
- const { transform, layer: layerFilter } = ctx;
572
+ const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
580
573
  const {
581
574
  anchor_position,
582
575
  text,
@@ -643,7 +636,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
643
636
  rotate2(ccw_rotation * Math.PI / 180),
644
637
  ...layer === "bottom" ? [scale(-1, 1)] : []
645
638
  );
646
- const color = layer === "bottom" ? SILKSCREEN_BOTTOM_COLOR : SILKSCREEN_TOP_COLOR;
639
+ const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
647
640
  const svgObject = {
648
641
  name: "text",
649
642
  type: "element",
@@ -679,7 +672,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
679
672
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-rect.ts
680
673
  import { applyToPoint as applyToPoint7 } from "transformation-matrix";
681
674
  function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
682
- const { transform, layer: layerFilter } = ctx;
675
+ const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
683
676
  const {
684
677
  center,
685
678
  width,
@@ -703,7 +696,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
703
696
  const transformedWidth = width * Math.abs(transform.a);
704
697
  const transformedHeight = height * Math.abs(transform.d);
705
698
  const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
706
- const color = layer === "bottom" ? SILKSCREEN_BOTTOM_COLOR : SILKSCREEN_TOP_COLOR;
699
+ const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
707
700
  const attributes = {
708
701
  x: (transformedX - transformedWidth / 2).toString(),
709
702
  y: (transformedY - transformedHeight / 2).toString(),
@@ -743,7 +736,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
743
736
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-circle.ts
744
737
  import { applyToPoint as applyToPoint8 } from "transformation-matrix";
745
738
  function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
746
- const { transform, layer: layerFilter } = ctx;
739
+ const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
747
740
  const {
748
741
  center,
749
742
  radius,
@@ -762,7 +755,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
762
755
  ]);
763
756
  const transformedRadius = radius * Math.abs(transform.a);
764
757
  const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
765
- const color = layer === "bottom" ? SILKSCREEN_BOTTOM_COLOR : SILKSCREEN_TOP_COLOR;
758
+ const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
766
759
  const svgObject = {
767
760
  name: "circle",
768
761
  type: "element",
@@ -784,7 +777,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
784
777
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-line.ts
785
778
  import { applyToPoint as applyToPoint9 } from "transformation-matrix";
786
779
  function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
787
- const { transform, layer: layerFilter } = ctx;
780
+ const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
788
781
  const {
789
782
  x1,
790
783
  y1,
@@ -802,7 +795,7 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
802
795
  const [transformedX1, transformedY1] = applyToPoint9(transform, [x1, y1]);
803
796
  const [transformedX2, transformedY2] = applyToPoint9(transform, [x2, y2]);
804
797
  const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
805
- const color = layer === "bottom" ? SILKSCREEN_BOTTOM_COLOR : SILKSCREEN_TOP_COLOR;
798
+ const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
806
799
  return [
807
800
  {
808
801
  name: "line",
@@ -835,13 +828,30 @@ function pairs(arr) {
835
828
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
836
829
  import { applyToPoint as applyToPoint10 } from "transformation-matrix";
837
830
 
831
+ // lib/pcb/colors.ts
832
+ var DEFAULT_PCB_COLOR_MAP = {
833
+ copper: {
834
+ top: "rgb(200, 52, 52)",
835
+ bottom: "rgb(77, 127, 196)"
836
+ },
837
+ drill: "#FF26E2",
838
+ silkscreen: {
839
+ top: "#f2eda1",
840
+ bottom: "#5da9e9"
841
+ },
842
+ boardOutline: "rgba(255, 255, 255, 0.5)"
843
+ };
844
+ var HOLE_COLOR = DEFAULT_PCB_COLOR_MAP.drill;
845
+ var SILKSCREEN_TOP_COLOR = DEFAULT_PCB_COLOR_MAP.silkscreen.top;
846
+ var SILKSCREEN_BOTTOM_COLOR = DEFAULT_PCB_COLOR_MAP.silkscreen.bottom;
847
+
838
848
  // lib/pcb/layer-name-to-color.ts
839
849
  var LAYER_NAME_TO_COLOR = {
840
- top: "rgb(200, 52, 52)",
841
- bottom: "rgb(77, 127, 196)"
850
+ top: DEFAULT_PCB_COLOR_MAP.copper.top,
851
+ bottom: DEFAULT_PCB_COLOR_MAP.copper.bottom
842
852
  };
843
- function layerNameToColor(layerName) {
844
- return LAYER_NAME_TO_COLOR[layerName] ?? "white";
853
+ function layerNameToColor(layerName, colorMap2 = DEFAULT_PCB_COLOR_MAP) {
854
+ return colorMap2.copper[layerName] ?? "white";
845
855
  }
846
856
  var SOLDER_PASTE_LAYER_NAME_TO_COLOR = {
847
857
  bottom: "rgb(105, 105, 105)",
@@ -853,7 +863,7 @@ function solderPasteLayerNameToColor(layerName) {
853
863
 
854
864
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
855
865
  function createSvgObjectsFromPcbTrace(trace, ctx) {
856
- const { transform, layer: layerFilter } = ctx;
866
+ const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
857
867
  if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2)
858
868
  return [];
859
869
  const segments = pairs(trace.route);
@@ -864,7 +874,7 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
864
874
  const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
865
875
  if (!layer) continue;
866
876
  if (layerFilter && layer !== layerFilter) continue;
867
- const layerColor = LAYER_NAME_TO_COLOR[layer] ?? "white";
877
+ const layerColor = layerNameToColor(layer, colorMap2);
868
878
  const traceWidth = "width" in start ? start.width : "width" in end ? end.width : null;
869
879
  const svgObject = {
870
880
  name: "path",
@@ -902,12 +912,12 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
902
912
  // lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
903
913
  import { applyToPoint as applyToPoint11 } from "transformation-matrix";
904
914
  function createSvgObjectsFromSmtPad(pad, ctx) {
905
- const { transform, layer: layerFilter } = ctx;
906
- const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
915
+ const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
907
916
  if (layerFilter && pad.layer !== layerFilter) return [];
908
917
  if (pad.shape === "rect" || pad.shape === "rotated_rect") {
909
918
  const width = pad.width * Math.abs(transform.a);
910
919
  const height = pad.height * Math.abs(transform.d);
920
+ const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
911
921
  if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
912
922
  return [
913
923
  {
@@ -915,7 +925,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
915
925
  type: "element",
916
926
  attributes: {
917
927
  class: "pcb-pad",
918
- fill: layerNameToColor(pad.layer),
928
+ fill: layerNameToColor(pad.layer, colorMap2),
919
929
  x: (-width / 2).toString(),
920
930
  y: (-height / 2).toString(),
921
931
  width: width.toString(),
@@ -931,7 +941,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
931
941
  type: "element",
932
942
  attributes: {
933
943
  class: "pcb-pad",
934
- fill: layerNameToColor(pad.layer),
944
+ fill: layerNameToColor(pad.layer, colorMap2),
935
945
  x: (x - width / 2).toString(),
936
946
  y: (y - height / 2).toString(),
937
947
  width: width.toString(),
@@ -944,13 +954,14 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
944
954
  const width = pad.width * Math.abs(transform.a);
945
955
  const height = pad.height * Math.abs(transform.d);
946
956
  const radius = pad.radius * Math.abs(transform.a);
957
+ const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
947
958
  return [
948
959
  {
949
960
  name: "rect",
950
961
  type: "element",
951
962
  attributes: {
952
963
  class: "pcb-pad",
953
- fill: layerNameToColor(pad.layer),
964
+ fill: layerNameToColor(pad.layer, colorMap2),
954
965
  x: (x - width / 2).toString(),
955
966
  y: (y - height / 2).toString(),
956
967
  width: width.toString(),
@@ -961,13 +972,29 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
961
972
  }
962
973
  ];
963
974
  }
975
+ if (pad.shape === "polygon") {
976
+ const points = (pad.points ?? []).map(
977
+ (point) => applyToPoint11(transform, [point.x, point.y])
978
+ );
979
+ return [
980
+ {
981
+ name: "polygon",
982
+ type: "element",
983
+ attributes: {
984
+ class: "pcb-pad",
985
+ fill: layerNameToColor(pad.layer),
986
+ points
987
+ }
988
+ }
989
+ ];
990
+ }
964
991
  return [];
965
992
  }
966
993
 
967
994
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
968
995
  import { applyToPoint as applyToPoint12 } from "transformation-matrix";
969
996
  function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
970
- const { transform } = ctx;
997
+ const { transform, colorMap: colorMap2 } = ctx;
971
998
  const { width, height, center, outline } = pcbBoard;
972
999
  let path;
973
1000
  if (outline && Array.isArray(outline) && outline.length >= 3) {
@@ -1007,7 +1034,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
1007
1034
  class: "pcb-board",
1008
1035
  d: path,
1009
1036
  fill: "none",
1010
- stroke: "rgba(255, 255, 255, 0.5)",
1037
+ stroke: colorMap2.boardOutline,
1011
1038
  "stroke-width": (0.1 * Math.abs(transform.a)).toString()
1012
1039
  }
1013
1040
  }
@@ -1017,7 +1044,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
1017
1044
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
1018
1045
  import { applyToPoint as applyToPoint13 } from "transformation-matrix";
1019
1046
  function createSvgObjectsFromPcbVia(hole, ctx) {
1020
- const { transform } = ctx;
1047
+ const { transform, colorMap: colorMap2 } = ctx;
1021
1048
  const [x, y] = applyToPoint13(transform, [hole.x, hole.y]);
1022
1049
  const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
1023
1050
  const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
@@ -1034,7 +1061,7 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
1034
1061
  type: "element",
1035
1062
  attributes: {
1036
1063
  class: "pcb-hole-outer",
1037
- fill: "rgb(200, 52, 52)",
1064
+ fill: colorMap2.copper.top,
1038
1065
  cx: x.toString(),
1039
1066
  cy: y.toString(),
1040
1067
  r: outerRadius.toString()
@@ -1045,7 +1072,7 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
1045
1072
  type: "element",
1046
1073
  attributes: {
1047
1074
  class: "pcb-hole-inner",
1048
- fill: "rgb(255, 38, 226)",
1075
+ fill: colorMap2.drill,
1049
1076
  cx: x.toString(),
1050
1077
  cy: y.toString(),
1051
1078
  r: innerRadius.toString()
@@ -1058,7 +1085,7 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
1058
1085
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
1059
1086
  import { applyToPoint as applyToPoint14 } from "transformation-matrix";
1060
1087
  function createSvgObjectsFromPcbHole(hole, ctx) {
1061
- const { transform } = ctx;
1088
+ const { transform, colorMap: colorMap2 } = ctx;
1062
1089
  const [x, y] = applyToPoint14(transform, [hole.x, hole.y]);
1063
1090
  if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
1064
1091
  const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
@@ -1073,7 +1100,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
1073
1100
  cx: x.toString(),
1074
1101
  cy: y.toString(),
1075
1102
  r: radius.toString(),
1076
- fill: HOLE_COLOR
1103
+ fill: colorMap2.drill
1077
1104
  },
1078
1105
  children: [],
1079
1106
  value: ""
@@ -1090,7 +1117,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
1090
1117
  y: (y - radius).toString(),
1091
1118
  width: scaledDiameter.toString(),
1092
1119
  height: scaledDiameter.toString(),
1093
- fill: HOLE_COLOR
1120
+ fill: colorMap2.drill
1094
1121
  },
1095
1122
  children: [],
1096
1123
  value: ""
@@ -1112,7 +1139,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
1112
1139
  cy: y.toString(),
1113
1140
  rx: rx.toString(),
1114
1141
  ry: ry.toString(),
1115
- fill: HOLE_COLOR
1142
+ fill: colorMap2.drill
1116
1143
  },
1117
1144
  children: [],
1118
1145
  value: ""
@@ -1244,7 +1271,7 @@ import {
1244
1271
  toString as matrixToString6
1245
1272
  } from "transformation-matrix";
1246
1273
  function createSvgObjectsFromPcbCutout(cutout, ctx) {
1247
- const { transform } = ctx;
1274
+ const { transform, colorMap: colorMap2 } = ctx;
1248
1275
  if (cutout.shape === "rect") {
1249
1276
  const rectCutout = cutout;
1250
1277
  const [cx, cy] = applyToPoint16(transform, [
@@ -1264,7 +1291,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
1264
1291
  y: (-scaledHeight / 2).toString(),
1265
1292
  width: scaledWidth.toString(),
1266
1293
  height: scaledHeight.toString(),
1267
- fill: HOLE_COLOR,
1294
+ fill: colorMap2.drill,
1268
1295
  transform: matrixToString6(
1269
1296
  compose3(translate3(cx, cy), rotate3(svgRotation * Math.PI / 180))
1270
1297
  )
@@ -1290,7 +1317,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
1290
1317
  cx: cx.toString(),
1291
1318
  cy: cy.toString(),
1292
1319
  r: scaledRadius.toString(),
1293
- fill: HOLE_COLOR
1320
+ fill: colorMap2.drill
1294
1321
  },
1295
1322
  children: [],
1296
1323
  value: ""
@@ -1311,7 +1338,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
1311
1338
  attributes: {
1312
1339
  class: "pcb-cutout pcb-cutout-polygon",
1313
1340
  points: pointsString,
1314
- fill: HOLE_COLOR
1341
+ fill: colorMap2.drill
1315
1342
  },
1316
1343
  children: [],
1317
1344
  value: ""
@@ -1339,6 +1366,19 @@ var OBJECT_ORDER = [
1339
1366
  function convertCircuitJsonToPcbSvg(circuitJson, options) {
1340
1367
  const drawPaddingOutsideBoard = options?.drawPaddingOutsideBoard ?? true;
1341
1368
  const layer = options?.layer;
1369
+ const colorOverrides = options?.colorOverrides;
1370
+ const colorMap2 = {
1371
+ copper: {
1372
+ top: colorOverrides?.copper?.top ?? DEFAULT_PCB_COLOR_MAP.copper.top,
1373
+ bottom: colorOverrides?.copper?.bottom ?? DEFAULT_PCB_COLOR_MAP.copper.bottom
1374
+ },
1375
+ drill: colorOverrides?.drill ?? DEFAULT_PCB_COLOR_MAP.drill,
1376
+ silkscreen: {
1377
+ top: colorOverrides?.silkscreen?.top ?? DEFAULT_PCB_COLOR_MAP.silkscreen.top,
1378
+ bottom: colorOverrides?.silkscreen?.bottom ?? DEFAULT_PCB_COLOR_MAP.silkscreen.bottom
1379
+ },
1380
+ boardOutline: colorOverrides?.boardOutline ?? DEFAULT_PCB_COLOR_MAP.boardOutline
1381
+ };
1342
1382
  let minX = Number.POSITIVE_INFINITY;
1343
1383
  let minY = Number.POSITIVE_INFINITY;
1344
1384
  let maxX = Number.NEGATIVE_INFINITY;
@@ -1414,7 +1454,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
1414
1454
  transform,
1415
1455
  layer,
1416
1456
  shouldDrawErrors: options?.shouldDrawErrors,
1417
- drawPaddingOutsideBoard
1457
+ drawPaddingOutsideBoard,
1458
+ colorMap: colorMap2
1418
1459
  };
1419
1460
  let svgObjects = circuitJson.sort(
1420
1461
  (a, b) => (OBJECT_ORDER.indexOf(b.type) ?? 9999) - (OBJECT_ORDER.indexOf(a.type) ?? 9999)
@@ -5139,7 +5180,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
5139
5180
  );
5140
5181
  const ctx = {
5141
5182
  transform,
5142
- layer: options.layer
5183
+ layer: options.layer,
5184
+ colorMap: DEFAULT_PCB_COLOR_MAP
5143
5185
  };
5144
5186
  const svgObjects = filteredCircuitJson.sort(
5145
5187
  (a, b) => (OBJECT_ORDER3.indexOf(b.type) ?? 9999) - (OBJECT_ORDER3.indexOf(a.type) ?? 9999)