circuit-to-svg 0.0.141 → 0.0.142
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 +22 -1
- package/dist/index.js +76 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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" ?
|
|
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" ?
|
|
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" ?
|
|
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" ?
|
|
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" ?
|
|
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:
|
|
841
|
-
bottom:
|
|
850
|
+
top: DEFAULT_PCB_COLOR_MAP.copper.top,
|
|
851
|
+
bottom: DEFAULT_PCB_COLOR_MAP.copper.bottom
|
|
842
852
|
};
|
|
843
|
-
function layerNameToColor(layerName) {
|
|
844
|
-
return
|
|
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 =
|
|
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,7 +912,7 @@ 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;
|
|
915
|
+
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
906
916
|
const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
|
|
907
917
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
908
918
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
@@ -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(),
|
|
@@ -950,7 +960,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
950
960
|
type: "element",
|
|
951
961
|
attributes: {
|
|
952
962
|
class: "pcb-pad",
|
|
953
|
-
fill: layerNameToColor(pad.layer),
|
|
963
|
+
fill: layerNameToColor(pad.layer, colorMap2),
|
|
954
964
|
x: (x - width / 2).toString(),
|
|
955
965
|
y: (y - height / 2).toString(),
|
|
956
966
|
width: width.toString(),
|
|
@@ -967,7 +977,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
967
977
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
968
978
|
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
969
979
|
function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
970
|
-
const { transform } = ctx;
|
|
980
|
+
const { transform, colorMap: colorMap2 } = ctx;
|
|
971
981
|
const { width, height, center, outline } = pcbBoard;
|
|
972
982
|
let path;
|
|
973
983
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
@@ -1007,7 +1017,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
1007
1017
|
class: "pcb-board",
|
|
1008
1018
|
d: path,
|
|
1009
1019
|
fill: "none",
|
|
1010
|
-
stroke:
|
|
1020
|
+
stroke: colorMap2.boardOutline,
|
|
1011
1021
|
"stroke-width": (0.1 * Math.abs(transform.a)).toString()
|
|
1012
1022
|
}
|
|
1013
1023
|
}
|
|
@@ -1017,7 +1027,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
1017
1027
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
1018
1028
|
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
1019
1029
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
1020
|
-
const { transform } = ctx;
|
|
1030
|
+
const { transform, colorMap: colorMap2 } = ctx;
|
|
1021
1031
|
const [x, y] = applyToPoint13(transform, [hole.x, hole.y]);
|
|
1022
1032
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
1023
1033
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
@@ -1034,7 +1044,7 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
1034
1044
|
type: "element",
|
|
1035
1045
|
attributes: {
|
|
1036
1046
|
class: "pcb-hole-outer",
|
|
1037
|
-
fill:
|
|
1047
|
+
fill: colorMap2.copper.top,
|
|
1038
1048
|
cx: x.toString(),
|
|
1039
1049
|
cy: y.toString(),
|
|
1040
1050
|
r: outerRadius.toString()
|
|
@@ -1045,7 +1055,7 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
1045
1055
|
type: "element",
|
|
1046
1056
|
attributes: {
|
|
1047
1057
|
class: "pcb-hole-inner",
|
|
1048
|
-
fill:
|
|
1058
|
+
fill: colorMap2.drill,
|
|
1049
1059
|
cx: x.toString(),
|
|
1050
1060
|
cy: y.toString(),
|
|
1051
1061
|
r: innerRadius.toString()
|
|
@@ -1058,7 +1068,7 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
1058
1068
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
1059
1069
|
import { applyToPoint as applyToPoint14 } from "transformation-matrix";
|
|
1060
1070
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
1061
|
-
const { transform } = ctx;
|
|
1071
|
+
const { transform, colorMap: colorMap2 } = ctx;
|
|
1062
1072
|
const [x, y] = applyToPoint14(transform, [hole.x, hole.y]);
|
|
1063
1073
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
1064
1074
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -1073,7 +1083,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
1073
1083
|
cx: x.toString(),
|
|
1074
1084
|
cy: y.toString(),
|
|
1075
1085
|
r: radius.toString(),
|
|
1076
|
-
fill:
|
|
1086
|
+
fill: colorMap2.drill
|
|
1077
1087
|
},
|
|
1078
1088
|
children: [],
|
|
1079
1089
|
value: ""
|
|
@@ -1090,7 +1100,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
1090
1100
|
y: (y - radius).toString(),
|
|
1091
1101
|
width: scaledDiameter.toString(),
|
|
1092
1102
|
height: scaledDiameter.toString(),
|
|
1093
|
-
fill:
|
|
1103
|
+
fill: colorMap2.drill
|
|
1094
1104
|
},
|
|
1095
1105
|
children: [],
|
|
1096
1106
|
value: ""
|
|
@@ -1112,7 +1122,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
1112
1122
|
cy: y.toString(),
|
|
1113
1123
|
rx: rx.toString(),
|
|
1114
1124
|
ry: ry.toString(),
|
|
1115
|
-
fill:
|
|
1125
|
+
fill: colorMap2.drill
|
|
1116
1126
|
},
|
|
1117
1127
|
children: [],
|
|
1118
1128
|
value: ""
|
|
@@ -1244,7 +1254,7 @@ import {
|
|
|
1244
1254
|
toString as matrixToString6
|
|
1245
1255
|
} from "transformation-matrix";
|
|
1246
1256
|
function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
1247
|
-
const { transform } = ctx;
|
|
1257
|
+
const { transform, colorMap: colorMap2 } = ctx;
|
|
1248
1258
|
if (cutout.shape === "rect") {
|
|
1249
1259
|
const rectCutout = cutout;
|
|
1250
1260
|
const [cx, cy] = applyToPoint16(transform, [
|
|
@@ -1264,7 +1274,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1264
1274
|
y: (-scaledHeight / 2).toString(),
|
|
1265
1275
|
width: scaledWidth.toString(),
|
|
1266
1276
|
height: scaledHeight.toString(),
|
|
1267
|
-
fill:
|
|
1277
|
+
fill: colorMap2.drill,
|
|
1268
1278
|
transform: matrixToString6(
|
|
1269
1279
|
compose3(translate3(cx, cy), rotate3(svgRotation * Math.PI / 180))
|
|
1270
1280
|
)
|
|
@@ -1290,7 +1300,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1290
1300
|
cx: cx.toString(),
|
|
1291
1301
|
cy: cy.toString(),
|
|
1292
1302
|
r: scaledRadius.toString(),
|
|
1293
|
-
fill:
|
|
1303
|
+
fill: colorMap2.drill
|
|
1294
1304
|
},
|
|
1295
1305
|
children: [],
|
|
1296
1306
|
value: ""
|
|
@@ -1311,7 +1321,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1311
1321
|
attributes: {
|
|
1312
1322
|
class: "pcb-cutout pcb-cutout-polygon",
|
|
1313
1323
|
points: pointsString,
|
|
1314
|
-
fill:
|
|
1324
|
+
fill: colorMap2.drill
|
|
1315
1325
|
},
|
|
1316
1326
|
children: [],
|
|
1317
1327
|
value: ""
|
|
@@ -1339,6 +1349,19 @@ var OBJECT_ORDER = [
|
|
|
1339
1349
|
function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
1340
1350
|
const drawPaddingOutsideBoard = options?.drawPaddingOutsideBoard ?? true;
|
|
1341
1351
|
const layer = options?.layer;
|
|
1352
|
+
const colorOverrides = options?.colorOverrides;
|
|
1353
|
+
const colorMap2 = {
|
|
1354
|
+
copper: {
|
|
1355
|
+
top: colorOverrides?.copper?.top ?? DEFAULT_PCB_COLOR_MAP.copper.top,
|
|
1356
|
+
bottom: colorOverrides?.copper?.bottom ?? DEFAULT_PCB_COLOR_MAP.copper.bottom
|
|
1357
|
+
},
|
|
1358
|
+
drill: colorOverrides?.drill ?? DEFAULT_PCB_COLOR_MAP.drill,
|
|
1359
|
+
silkscreen: {
|
|
1360
|
+
top: colorOverrides?.silkscreen?.top ?? DEFAULT_PCB_COLOR_MAP.silkscreen.top,
|
|
1361
|
+
bottom: colorOverrides?.silkscreen?.bottom ?? DEFAULT_PCB_COLOR_MAP.silkscreen.bottom
|
|
1362
|
+
},
|
|
1363
|
+
boardOutline: colorOverrides?.boardOutline ?? DEFAULT_PCB_COLOR_MAP.boardOutline
|
|
1364
|
+
};
|
|
1342
1365
|
let minX = Number.POSITIVE_INFINITY;
|
|
1343
1366
|
let minY = Number.POSITIVE_INFINITY;
|
|
1344
1367
|
let maxX = Number.NEGATIVE_INFINITY;
|
|
@@ -1414,7 +1437,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
1414
1437
|
transform,
|
|
1415
1438
|
layer,
|
|
1416
1439
|
shouldDrawErrors: options?.shouldDrawErrors,
|
|
1417
|
-
drawPaddingOutsideBoard
|
|
1440
|
+
drawPaddingOutsideBoard,
|
|
1441
|
+
colorMap: colorMap2
|
|
1418
1442
|
};
|
|
1419
1443
|
let svgObjects = circuitJson.sort(
|
|
1420
1444
|
(a, b) => (OBJECT_ORDER.indexOf(b.type) ?? 9999) - (OBJECT_ORDER.indexOf(a.type) ?? 9999)
|
|
@@ -5139,7 +5163,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
5139
5163
|
);
|
|
5140
5164
|
const ctx = {
|
|
5141
5165
|
transform,
|
|
5142
|
-
layer: options.layer
|
|
5166
|
+
layer: options.layer,
|
|
5167
|
+
colorMap: DEFAULT_PCB_COLOR_MAP
|
|
5143
5168
|
};
|
|
5144
5169
|
const svgObjects = filteredCircuitJson.sort(
|
|
5145
5170
|
(a, b) => (OBJECT_ORDER3.indexOf(b.type) ?? 9999) - (OBJECT_ORDER3.indexOf(a.type) ?? 9999)
|