circuit-to-canvas 0.0.95 → 0.0.97

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
@@ -733,7 +733,7 @@ function drawPcbCopperText(params) {
733
733
  realToCanvasMat,
734
734
  anchorAlignment: mapAnchorAlignment(text.anchor_alignment),
735
735
  rotation: text.ccw_rotation ?? 0,
736
- mirrorX: text.is_mirrored,
736
+ mirrorX: text.is_mirrored ?? text.layer === "bottom",
737
737
  knockout: text.is_knockout,
738
738
  knockoutPadding: text.is_knockout ? text.knockout_padding : void 0
739
739
  });
@@ -35,7 +35,7 @@ export function drawPcbCopperText(params: DrawPcbCopperTextParams): void {
35
35
  realToCanvasMat,
36
36
  anchorAlignment: mapAnchorAlignment(text.anchor_alignment),
37
37
  rotation: text.ccw_rotation ?? 0,
38
- mirrorX: text.is_mirrored,
38
+ mirrorX: text.is_mirrored ?? text.layer === "bottom",
39
39
  knockout: text.is_knockout,
40
40
  knockoutPadding: text.is_knockout ? text.knockout_padding : undefined,
41
41
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-to-canvas",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.95",
4
+ "version": "0.0.97",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup-node ./lib/index.ts --format esm --dts",
@@ -13,7 +13,7 @@
13
13
  "@napi-rs/canvas": "^0.1.84",
14
14
  "@resvg/resvg-js": "^2.6.2",
15
15
  "@tscircuit/alphabet": "^0.0.23",
16
- "@tscircuit/circuit-json-util": "^0.0.78",
16
+ "@tscircuit/circuit-json-util": "^0.0.91",
17
17
  "@tscircuit/math-utils": "^0.0.29",
18
18
  "@types/bun": "latest",
19
19
  "bun-match-svg": "^0.0.14",
@@ -49,6 +49,49 @@ test("draw copper text", async () => {
49
49
  )
50
50
  })
51
51
 
52
+ test("draw bottom copper text auto-mirrored when is_mirrored is omitted", async () => {
53
+ const SCALE = 4
54
+ const canvas = createCanvas(100 * SCALE, 100 * SCALE)
55
+ const ctx = canvas.getContext("2d")
56
+ ctx.scale(SCALE, SCALE)
57
+ const drawer = new CircuitToCanvasDrawer(ctx)
58
+
59
+ ctx.fillStyle = "#1a1a1a"
60
+ ctx.fillRect(0, 0, canvas.width / SCALE, canvas.height / SCALE)
61
+
62
+ const text: PcbCopperText[] = [
63
+ {
64
+ type: "pcb_copper_text",
65
+ pcb_copper_text_id: "copper-text-auto-mirror-top",
66
+ pcb_component_id: "component1",
67
+ layer: "top",
68
+ text: "F3",
69
+ anchor_position: { x: 30, y: 50 },
70
+ anchor_alignment: "center",
71
+ font: "tscircuit2024",
72
+ font_size: 8,
73
+ },
74
+ {
75
+ type: "pcb_copper_text",
76
+ pcb_copper_text_id: "copper-text-auto-mirror-bottom",
77
+ pcb_component_id: "component1",
78
+ layer: "bottom",
79
+ text: "F3",
80
+ anchor_position: { x: 70, y: 50 },
81
+ anchor_alignment: "center",
82
+ font: "tscircuit2024",
83
+ font_size: 8,
84
+ },
85
+ ]
86
+
87
+ drawer.drawElements(text)
88
+
89
+ await expect(canvas.toBuffer("image/png")).toMatchPngSnapshot(
90
+ import.meta.path,
91
+ "pcb-copper-text-bottom-auto-mirror",
92
+ )
93
+ })
94
+
52
95
  test("draw copper text knockout mirrored with padding", async () => {
53
96
  const SCALE = 4
54
97
  const canvas = createCanvas(100 * SCALE, 60 * SCALE)