circuit-to-canvas 0.0.40 → 0.0.41

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
@@ -1645,7 +1645,8 @@ function drawPcbCutout(params) {
1645
1645
  height: cutout.height,
1646
1646
  fill: colorMap.drill,
1647
1647
  realToCanvasMat,
1648
- rotation: cutout.rotation ?? 0
1648
+ rotation: cutout.rotation ?? 0,
1649
+ borderRadius: cutout.corner_radius ?? 0
1649
1650
  });
1650
1651
  return;
1651
1652
  }
@@ -24,6 +24,7 @@ export function drawPcbCutout(params: DrawPcbCutoutParams): void {
24
24
  fill: colorMap.drill,
25
25
  realToCanvasMat,
26
26
  rotation: cutout.rotation ?? 0,
27
+ borderRadius: cutout.corner_radius ?? 0,
27
28
  })
28
29
  return
29
30
  }
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.40",
4
+ "version": "0.0.41",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup-node ./lib/index.ts --format esm --dts",
@@ -26,7 +26,31 @@ test("draw rectangular cutout", async () => {
26
26
  import.meta.path,
27
27
  )
28
28
  })
29
+ test("draw rectangular cutout with corner radius", async () => {
30
+ const canvas = createCanvas(100, 100)
31
+ const ctx = canvas.getContext("2d")
32
+ const drawer = new CircuitToCanvasDrawer(ctx)
33
+
34
+ ctx.fillStyle = "#1a1a1a"
35
+ ctx.fillRect(0, 0, 100, 100)
29
36
 
37
+ const cutout: PcbCutout = {
38
+ type: "pcb_cutout",
39
+ pcb_cutout_id: "cutout1",
40
+ shape: "rect",
41
+ center: { x: 50, y: 50 },
42
+ width: 30,
43
+ height: 20,
44
+ corner_radius: 10,
45
+ }
46
+
47
+ drawer.drawElements([cutout])
48
+
49
+ await expect(canvas.toBuffer("image/png")).toMatchPngSnapshot(
50
+ import.meta.path,
51
+ "rect-cutout-with-corner-radius",
52
+ )
53
+ })
30
54
  test("draw circular cutout", async () => {
31
55
  const canvas = createCanvas(100, 100)
32
56
  const ctx = canvas.getContext("2d")