@thi.ng/hiccup-canvas 2.2.12 → 2.3.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-03-27T19:05:49Z
3
+ - **Last updated**: 2023-04-08T11:09:50Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [2.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-canvas@2.3.0) (2023-04-08)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add support for __clear ctrl attrib ([2f3de82](https://github.com/thi-ng/umbrella/commit/2f3de82))
17
+
12
18
  ### [2.2.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-canvas@2.2.1) (2023-02-05)
13
19
 
14
20
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -49,6 +49,7 @@ This project is part of the
49
49
  - [Rotation](#rotation)
50
50
  - [Special attributes](#special-attributes)
51
51
  - [Background fill](#background-fill)
52
+ - [Background clear](#background-clear)
52
53
  - [Authors](#authors)
53
54
  - [License](#license)
54
55
 
@@ -94,7 +95,7 @@ For Node.js REPL:
94
95
  const hiccupCanvas = await import("@thi.ng/hiccup-canvas");
95
96
  ```
96
97
 
97
- Package sizes (brotli'd, pre-treeshake): ESM: 2.40 KB
98
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.43 KB
98
99
 
99
100
  ## Dependencies
100
101
 
@@ -504,6 +505,13 @@ a given background color. The attribute only makes sense if attached to the root
504
505
  group/shape and can take the same values as any other [color
505
506
  attribs](#color-attributes).
506
507
 
508
+ #### Background clear
509
+
510
+ The special `__clear` boolean attribute is used to force clearing of the canvas
511
+ before drawing. This attrib takes priority over `__background` and it too only
512
+ should be attached to the root group/shape. By default the canvas is **not**
513
+ being cleared.
514
+
507
515
  ## Authors
508
516
 
509
517
  - [Karsten Schmidt](https://thi.ng)
package/internal/state.js CHANGED
@@ -71,11 +71,17 @@ export const __mergeState = (ctx, state, attribs) => {
71
71
  setAttrib(ctx, state, id, k, v);
72
72
  }
73
73
  }
74
- else if (id === "__background") {
74
+ else if (id === "__background" || id === "__clear") {
75
75
  ctx.save();
76
76
  ctx.resetTransform();
77
- ctx.fillStyle = resolveGradientOrColor(state, attribs[id]);
78
- ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
77
+ if (id === "__clear") {
78
+ attribs[id] &&
79
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
80
+ }
81
+ else {
82
+ ctx.fillStyle = resolveGradientOrColor(state, attribs[id]);
83
+ ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
84
+ }
79
85
  ctx.restore();
80
86
  }
81
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hiccup-canvas",
3
- "version": "2.2.12",
3
+ "version": "2.3.1",
4
4
  "description": "Hiccup shape tree renderer for vanilla Canvas 2D contexts",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,20 +34,20 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.7.5",
38
- "@thi.ng/checks": "^3.3.11",
39
- "@thi.ng/color": "^5.4.6",
40
- "@thi.ng/math": "^5.4.6",
41
- "@thi.ng/pixel": "^4.1.11",
42
- "@thi.ng/vectors": "^7.6.10"
37
+ "@thi.ng/api": "^8.8.0",
38
+ "@thi.ng/checks": "^3.3.12",
39
+ "@thi.ng/color": "^5.5.0",
40
+ "@thi.ng/math": "^5.4.8",
41
+ "@thi.ng/pixel": "^4.2.1",
42
+ "@thi.ng/vectors": "^7.6.12"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-extractor": "^7.34.4",
46
- "@thi.ng/testament": "^0.3.14",
46
+ "@thi.ng/testament": "^0.3.15",
47
47
  "rimraf": "^4.4.1",
48
48
  "tools": "^0.0.1",
49
49
  "typedoc": "^0.23.28",
50
- "typescript": "^5.0.2"
50
+ "typescript": "^5.0.4"
51
51
  },
52
52
  "keywords": [
53
53
  "2d",
@@ -130,5 +130,5 @@
130
130
  ],
131
131
  "year": 2018
132
132
  },
133
- "gitHead": "83b15b34326d480cbca0472b20390d4d3bbb792a\n"
133
+ "gitHead": "3a56bc490f1e68754762a503d06327b5b34ff7eb\n"
134
134
  }