circuit-to-svg 0.0.138 → 0.0.139

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.js CHANGED
@@ -686,7 +686,10 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
686
686
  height,
687
687
  layer = "top",
688
688
  pcb_silkscreen_rect_id,
689
- stroke_width = 1
689
+ stroke_width,
690
+ is_filled,
691
+ has_stroke,
692
+ is_stroke_dashed
690
693
  } = pcbSilkscreenRect;
691
694
  if (layerFilter && layer !== layerFilter) return [];
692
695
  if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof width !== "number" || typeof height !== "number") {
@@ -701,20 +704,36 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
701
704
  const transformedHeight = height * Math.abs(transform.d);
702
705
  const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
703
706
  const color = layer === "bottom" ? SILKSCREEN_BOTTOM_COLOR : SILKSCREEN_TOP_COLOR;
707
+ const attributes = {
708
+ x: (transformedX - transformedWidth / 2).toString(),
709
+ y: (transformedY - transformedHeight / 2).toString(),
710
+ width: transformedWidth.toString(),
711
+ height: transformedHeight.toString(),
712
+ class: `pcb-silkscreen-rect pcb-silkscreen-${layer}`,
713
+ "data-pcb-silkscreen-rect-id": pcb_silkscreen_rect_id
714
+ };
715
+ attributes.fill = is_filled ? color : "none";
716
+ let actualHasStroke;
717
+ if (has_stroke === void 0) {
718
+ actualHasStroke = transformedStrokeWidth > 0;
719
+ } else {
720
+ actualHasStroke = has_stroke;
721
+ }
722
+ if (actualHasStroke) {
723
+ attributes.stroke = color;
724
+ attributes["stroke-width"] = transformedStrokeWidth.toString();
725
+ if (is_stroke_dashed) {
726
+ const dashLength = 0.1 * Math.abs(transform.a);
727
+ const gapLength = 0.05 * Math.abs(transform.a);
728
+ attributes["stroke-dasharray"] = `${dashLength} ${gapLength}`;
729
+ }
730
+ } else {
731
+ attributes.stroke = "none";
732
+ }
704
733
  const svgObject = {
705
734
  name: "rect",
706
735
  type: "element",
707
- attributes: {
708
- x: (transformedX - transformedWidth / 2).toString(),
709
- y: (transformedY - transformedHeight / 2).toString(),
710
- width: transformedWidth.toString(),
711
- height: transformedHeight.toString(),
712
- class: `pcb-silkscreen-rect pcb-silkscreen-${layer}`,
713
- fill: "none",
714
- stroke: color,
715
- "stroke-width": transformedStrokeWidth.toString(),
716
- "data-pcb-silkscreen-rect-id": pcb_silkscreen_rect_id
717
- },
736
+ attributes,
718
737
  value: "",
719
738
  children: []
720
739
  };