circuit-to-svg 0.0.200 → 0.0.202

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
@@ -42,6 +42,7 @@ interface Options$4 {
42
42
  backgroundColor?: string;
43
43
  drawPaddingOutsideBoard?: boolean;
44
44
  includeVersion?: boolean;
45
+ renderSolderMask?: boolean;
45
46
  }
46
47
  interface PcbContext {
47
48
  transform: Matrix;
@@ -49,6 +50,7 @@ interface PcbContext {
49
50
  shouldDrawErrors?: boolean;
50
51
  drawPaddingOutsideBoard?: boolean;
51
52
  colorMap: PcbColorMap;
53
+ renderSolderMask?: boolean;
52
54
  }
53
55
  declare function convertCircuitJsonToPcbSvg(circuitJson: AnyCircuitElement[], options?: Options$4): string;
54
56
  /**
package/dist/index.js CHANGED
@@ -980,7 +980,7 @@ function solderPasteLayerNameToColor(layerName) {
980
980
 
981
981
  // lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
982
982
  function createSvgObjectsFromPcbTrace(trace, ctx) {
983
- const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
983
+ const { transform, layer: layerFilter, colorMap: colorMap2, renderSolderMask } = ctx;
984
984
  if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2)
985
985
  return [];
986
986
  const segments = pairs(trace.route);
@@ -991,26 +991,66 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
991
991
  const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
992
992
  if (!layer) continue;
993
993
  if (layerFilter && layer !== layerFilter) continue;
994
- const layerColor = colorMap2.soldermask[layer] ?? layerNameToColor(layer, colorMap2);
994
+ const copperColor = layerNameToColor(layer, colorMap2);
995
+ const maskColor = colorMap2.soldermask[layer] ?? copperColor;
995
996
  const traceWidth = "width" in start ? start.width : "width" in end ? end.width : null;
996
- const svgObject = {
997
- name: "path",
998
- type: "element",
999
- value: "",
1000
- children: [],
1001
- attributes: {
1002
- class: "pcb-trace",
1003
- stroke: layerColor,
1004
- fill: "none",
1005
- d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
1006
- "stroke-width": traceWidth ? (traceWidth * Math.abs(transform.a)).toString() : "0.3",
1007
- "stroke-linecap": "round",
1008
- "stroke-linejoin": "round",
1009
- "shape-rendering": "crispEdges",
1010
- "data-layer": layer
1011
- }
1012
- };
1013
- svgObjects.push(svgObject);
997
+ const width = traceWidth ? (traceWidth * Math.abs(transform.a)).toString() : "0.3";
998
+ if (renderSolderMask) {
999
+ const copperObject = {
1000
+ name: "path",
1001
+ type: "element",
1002
+ value: "",
1003
+ children: [],
1004
+ attributes: {
1005
+ class: "pcb-trace",
1006
+ stroke: copperColor,
1007
+ fill: "none",
1008
+ d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
1009
+ "stroke-width": width,
1010
+ "stroke-linecap": "round",
1011
+ "stroke-linejoin": "round",
1012
+ "shape-rendering": "crispEdges",
1013
+ "data-layer": layer
1014
+ }
1015
+ };
1016
+ const maskObject = {
1017
+ name: "path",
1018
+ type: "element",
1019
+ value: "",
1020
+ children: [],
1021
+ attributes: {
1022
+ class: "pcb-soldermask",
1023
+ stroke: maskColor,
1024
+ fill: "none",
1025
+ d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
1026
+ "stroke-width": width,
1027
+ "stroke-linecap": "round",
1028
+ "stroke-linejoin": "round",
1029
+ "shape-rendering": "crispEdges",
1030
+ "data-layer": layer
1031
+ }
1032
+ };
1033
+ svgObjects.push(maskObject, copperObject);
1034
+ } else {
1035
+ const maskOnlyObject = {
1036
+ name: "path",
1037
+ type: "element",
1038
+ value: "",
1039
+ children: [],
1040
+ attributes: {
1041
+ class: "pcb-trace",
1042
+ stroke: maskColor,
1043
+ fill: "none",
1044
+ d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
1045
+ "stroke-width": width,
1046
+ "stroke-linecap": "round",
1047
+ "stroke-linejoin": "round",
1048
+ "shape-rendering": "crispEdges",
1049
+ "data-layer": layer
1050
+ }
1051
+ };
1052
+ svgObjects.push(maskOnlyObject);
1053
+ }
1014
1054
  }
1015
1055
  svgObjects.sort((a, b) => {
1016
1056
  const layerA = a.attributes["data-layer"];
@@ -1743,7 +1783,7 @@ function getSoftwareUsedString(circuitJson) {
1743
1783
  var package_default = {
1744
1784
  name: "circuit-to-svg",
1745
1785
  type: "module",
1746
- version: "0.0.199",
1786
+ version: "0.0.201",
1747
1787
  description: "Convert Circuit JSON to SVG",
1748
1788
  main: "dist/index.js",
1749
1789
  files: [
@@ -1932,7 +1972,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
1932
1972
  layer,
1933
1973
  shouldDrawErrors: options?.shouldDrawErrors,
1934
1974
  drawPaddingOutsideBoard,
1935
- colorMap: colorMap2
1975
+ colorMap: colorMap2,
1976
+ renderSolderMask: options?.renderSolderMask
1936
1977
  };
1937
1978
  function getLayer(elm) {
1938
1979
  if (elm.type === "pcb_smtpad") {
@@ -5972,20 +6013,23 @@ var createSvgObjectsForSchPortBoxLine = ({
5972
6013
  }
5973
6014
  const screenSchPortPos = applyToPoint40(transform, schPort.center);
5974
6015
  const screenRealEdgePos = applyToPoint40(transform, realEdgePos);
6016
+ const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
5975
6017
  const realLineEnd = { ...schPort.center };
5976
- switch (schPort.side_of_component) {
5977
- case "left":
5978
- realLineEnd.x += PIN_CIRCLE_RADIUS_MM;
5979
- break;
5980
- case "right":
5981
- realLineEnd.x -= PIN_CIRCLE_RADIUS_MM;
5982
- break;
5983
- case "top":
5984
- realLineEnd.y -= PIN_CIRCLE_RADIUS_MM;
5985
- break;
5986
- case "bottom":
5987
- realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
5988
- break;
6018
+ if (!isConnected) {
6019
+ switch (schPort.side_of_component) {
6020
+ case "left":
6021
+ realLineEnd.x += PIN_CIRCLE_RADIUS_MM;
6022
+ break;
6023
+ case "right":
6024
+ realLineEnd.x -= PIN_CIRCLE_RADIUS_MM;
6025
+ break;
6026
+ case "top":
6027
+ realLineEnd.y -= PIN_CIRCLE_RADIUS_MM;
6028
+ break;
6029
+ case "bottom":
6030
+ realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
6031
+ break;
6032
+ }
5989
6033
  }
5990
6034
  const screenLineEnd = applyToPoint40(transform, realLineEnd);
5991
6035
  svgObjects.push({
@@ -5993,16 +6037,15 @@ var createSvgObjectsForSchPortBoxLine = ({
5993
6037
  type: "element",
5994
6038
  attributes: {
5995
6039
  class: "component-pin",
5996
- x1: screenLineEnd.x.toString(),
5997
- y1: screenLineEnd.y.toString(),
5998
- x2: screenRealEdgePos.x.toString(),
5999
- y2: screenRealEdgePos.y.toString(),
6040
+ x1: screenRealEdgePos.x.toString(),
6041
+ y1: screenRealEdgePos.y.toString(),
6042
+ x2: screenLineEnd.x.toString(),
6043
+ y2: screenLineEnd.y.toString(),
6000
6044
  "stroke-width": `${getSchStrokeSize(transform)}px`
6001
6045
  },
6002
6046
  value: "",
6003
6047
  children: []
6004
6048
  });
6005
- const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
6006
6049
  const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM;
6007
6050
  const pinChildren = [];
6008
6051
  if (!isConnected) {