circuit-to-svg 0.0.217 → 0.0.219

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
@@ -2,11 +2,12 @@ import { AnyCircuitElement, PcbPort, SchematicComponent } from 'circuit-json';
2
2
  import { Matrix } from 'transformation-matrix';
3
3
  import { INode } from 'svgson';
4
4
 
5
+ type CopperLayerName = "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
6
+ type CopperColorMap = Record<CopperLayerName, string> & {
7
+ [layer: string]: string;
8
+ };
5
9
  interface PcbColorMap {
6
- copper: {
7
- top: string;
8
- bottom: string;
9
- };
10
+ copper: CopperColorMap;
10
11
  drill: string;
11
12
  silkscreen: {
12
13
  top: string;
package/dist/index.js CHANGED
@@ -941,6 +941,12 @@ import { applyToPoint as applyToPoint10 } from "transformation-matrix";
941
941
  var DEFAULT_PCB_COLOR_MAP = {
942
942
  copper: {
943
943
  top: "rgb(200, 52, 52)",
944
+ inner1: "rgb(255, 140, 0)",
945
+ inner2: "rgb(255, 215, 0)",
946
+ inner3: "rgb(50, 205, 50)",
947
+ inner4: "rgb(64, 224, 208)",
948
+ inner5: "rgb(138, 43, 226)",
949
+ inner6: "rgb(255, 105, 180)",
944
950
  bottom: "rgb(77, 127, 196)"
945
951
  },
946
952
  soldermask: {
@@ -964,8 +970,7 @@ var SILKSCREEN_BOTTOM_COLOR = DEFAULT_PCB_COLOR_MAP.silkscreen.bottom;
964
970
 
965
971
  // lib/pcb/layer-name-to-color.ts
966
972
  var LAYER_NAME_TO_COLOR = {
967
- top: DEFAULT_PCB_COLOR_MAP.copper.top,
968
- bottom: DEFAULT_PCB_COLOR_MAP.copper.bottom
973
+ ...DEFAULT_PCB_COLOR_MAP.copper
969
974
  };
970
975
  function layerNameToColor(layerName, colorMap2 = DEFAULT_PCB_COLOR_MAP) {
971
976
  return colorMap2.copper[layerName] ?? "white";
@@ -1783,7 +1788,7 @@ function getSoftwareUsedString(circuitJson) {
1783
1788
  var package_default = {
1784
1789
  name: "circuit-to-svg",
1785
1790
  type: "module",
1786
- version: "0.0.216",
1791
+ version: "0.0.218",
1787
1792
  description: "Convert Circuit JSON to SVG",
1788
1793
  main: "dist/index.js",
1789
1794
  files: [
@@ -1853,11 +1858,18 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
1853
1858
  const drawPaddingOutsideBoard = options?.drawPaddingOutsideBoard ?? true;
1854
1859
  const layer = options?.layer;
1855
1860
  const colorOverrides = options?.colorOverrides;
1861
+ const copperColors = {
1862
+ ...DEFAULT_PCB_COLOR_MAP.copper
1863
+ };
1864
+ if (colorOverrides?.copper) {
1865
+ for (const [layerName, color] of Object.entries(colorOverrides.copper)) {
1866
+ if (color !== void 0) {
1867
+ copperColors[layerName] = color;
1868
+ }
1869
+ }
1870
+ }
1856
1871
  const colorMap2 = {
1857
- copper: {
1858
- top: colorOverrides?.copper?.top ?? DEFAULT_PCB_COLOR_MAP.copper.top,
1859
- bottom: colorOverrides?.copper?.bottom ?? DEFAULT_PCB_COLOR_MAP.copper.bottom
1860
- },
1872
+ copper: copperColors,
1861
1873
  drill: colorOverrides?.drill ?? DEFAULT_PCB_COLOR_MAP.drill,
1862
1874
  silkscreen: {
1863
1875
  top: colorOverrides?.silkscreen?.top ?? DEFAULT_PCB_COLOR_MAP.silkscreen.top,
@@ -8189,7 +8201,7 @@ function isSimulationExperiment(value) {
8189
8201
  // lib/sim/convert-circuit-json-to-simulation-graph-svg.ts
8190
8202
  var DEFAULT_WIDTH = 1200;
8191
8203
  var DEFAULT_HEIGHT = 600;
8192
- var MARGIN = { top: 64, right: 48, bottom: 80, left: 100 };
8204
+ var MARGIN = { top: 64, right: 100, bottom: 80, left: 100 };
8193
8205
  var FALLBACK_LINE_COLOR = "#1f77b4";
8194
8206
  function convertCircuitJsonToSimulationGraphSvg({
8195
8207
  circuitJson,
@@ -8262,7 +8274,7 @@ function convertCircuitJsonToSimulationGraphSvg({
8262
8274
  plotWidth,
8263
8275
  plotHeight
8264
8276
  }),
8265
- createLegend(preparedGraphs),
8277
+ createLegend(preparedGraphs, width),
8266
8278
  ...titleNode ? [titleNode] : []
8267
8279
  ];
8268
8280
  const svgObject = svgElement(
@@ -8577,14 +8589,15 @@ function createAxes({
8577
8589
  );
8578
8590
  return svgElement("g", { class: "axes" }, children);
8579
8591
  }
8580
- function createLegend(graphs) {
8592
+ function createLegend(graphs, width) {
8581
8593
  const children = graphs.map((entry, index) => {
8582
- const y = MARGIN.top - 28 + index * 20;
8594
+ const y = MARGIN.top + index * 24;
8595
+ const x = width - MARGIN.right + 20;
8583
8596
  return svgElement(
8584
8597
  "g",
8585
8598
  {
8586
8599
  class: "legend-item",
8587
- transform: `translate(${formatNumber(MARGIN.left)} ${formatNumber(y)})`
8600
+ transform: `translate(${formatNumber(x)} ${formatNumber(y)})`
8588
8601
  },
8589
8602
  [
8590
8603
  svgElement("line", {