@thi.ng/hiccup-canvas 3.1.17 → 3.1.18

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/package.json +13 -13
  3. package/path.js +16 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-08-18T14:11:34Z
3
+ - **Last updated**: 2024-09-19T21:09:34Z
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hiccup-canvas",
3
- "version": "3.1.17",
3
+ "version": "3.1.18",
4
4
  "description": "Hiccup shape tree renderer for vanilla Canvas 2D contexts",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -36,19 +36,19 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.9",
40
- "@thi.ng/checks": "^3.6.11",
41
- "@thi.ng/color": "^5.7.4",
42
- "@thi.ng/geom-arc": "^2.1.146",
43
- "@thi.ng/math": "^5.11.9",
44
- "@thi.ng/pixel": "^7.3.3",
45
- "@thi.ng/vectors": "^7.12.1"
39
+ "@thi.ng/api": "^8.11.10",
40
+ "@thi.ng/checks": "^3.6.12",
41
+ "@thi.ng/color": "^5.7.5",
42
+ "@thi.ng/geom-arc": "^2.1.147",
43
+ "@thi.ng/math": "^5.11.10",
44
+ "@thi.ng/pixel": "^7.3.4",
45
+ "@thi.ng/vectors": "^7.12.2"
46
46
  },
47
47
  "devDependencies": {
48
- "@microsoft/api-extractor": "^7.47.5",
49
- "esbuild": "^0.23.0",
50
- "typedoc": "^0.26.5",
51
- "typescript": "^5.5.4"
48
+ "@microsoft/api-extractor": "^7.47.9",
49
+ "esbuild": "^0.23.1",
50
+ "typedoc": "^0.26.7",
51
+ "typescript": "^5.6.2"
52
52
  },
53
53
  "keywords": [
54
54
  "2d",
@@ -134,5 +134,5 @@
134
134
  ],
135
135
  "year": 2018
136
136
  },
137
- "gitHead": "8335e9571c2b9b13844ee4d8d24f99143c5f8816\n"
137
+ "gitHead": "b52baa3750ddd1256892df966ab7ac9b4806a9ef\n"
138
138
  }
package/path.js CHANGED
@@ -7,38 +7,45 @@ const path = (ctx, attribs, segments) => {
7
7
  const s = segments[i];
8
8
  let b = s[1], c, d;
9
9
  switch (s[0]) {
10
+ // move to
10
11
  case "m":
11
12
  b = [a[0] + b[0], a[1] + b[1]];
12
13
  case "M":
13
14
  ctx.moveTo(b[0], b[1]);
14
15
  a = b;
15
16
  break;
17
+ // line to
16
18
  case "l":
17
19
  b = [a[0] + b[0], a[1] + b[1]];
18
20
  case "L":
19
21
  ctx.lineTo(b[0], b[1]);
20
22
  a = b;
21
23
  break;
24
+ // horizontal line rel
22
25
  case "h":
23
26
  b = [a[0] + b, a[1]];
24
27
  ctx.lineTo(b[0], b[1]);
25
28
  a = b;
26
29
  break;
30
+ // horizontal line abs
27
31
  case "H":
28
32
  b = [b, a[1]];
29
33
  ctx.lineTo(b[0], b[1]);
30
34
  a = b;
31
35
  break;
36
+ // vertical line rel
32
37
  case "v":
33
38
  b = [a[0], a[1] + b];
34
39
  ctx.lineTo(b[0], b[1]);
35
40
  a = b;
36
41
  break;
42
+ // vertical line abs
37
43
  case "V":
38
44
  b = [a[0], b];
39
45
  ctx.lineTo(b[0], b[1]);
40
46
  a = b;
41
47
  break;
48
+ // cubic curve rel
42
49
  case "c":
43
50
  c = s[2];
44
51
  d = s[3];
@@ -53,23 +60,27 @@ const path = (ctx, attribs, segments) => {
53
60
  );
54
61
  a = d;
55
62
  break;
63
+ // cubic curve abs
56
64
  case "C":
57
65
  c = s[2];
58
66
  d = s[3];
59
67
  ctx.bezierCurveTo(b[0], b[1], c[0], c[1], d[0], d[1]);
60
68
  a = d;
61
69
  break;
70
+ // quadratic curve rel
62
71
  case "q":
63
72
  c = s[2];
64
73
  c = [a[0] + c[0], a[1] + c[1]];
65
74
  ctx.quadraticCurveTo(a[0] + b[0], a[1] + b[1], c[0], c[1]);
66
75
  a = c;
67
76
  break;
77
+ // quadratic curve abs
68
78
  case "Q":
69
79
  c = s[2];
70
80
  ctx.quadraticCurveTo(b[0], b[1], c[0], c[1]);
71
81
  a = c;
72
82
  break;
83
+ // elliptic arc (SVG compatible)
73
84
  case "A":
74
85
  case "a": {
75
86
  c = s[2];
@@ -84,17 +95,22 @@ const path = (ctx, attribs, segments) => {
84
95
  a = d;
85
96
  break;
86
97
  }
98
+ // circular arc rel
99
+ // Note: NOT compatible w/ SVG arc segments
87
100
  case "r":
88
101
  c = s[2];
89
102
  c = [a[0] + c[0], a[1] + c[1]];
90
103
  ctx.arcTo(a[0] + b[0], a[1] + b[1], c[0], c[1], s[3]);
91
104
  a = c;
92
105
  break;
106
+ // circular arc abs
107
+ // Note: NOT compatible w/ SVG arc segments
93
108
  case "R":
94
109
  c = s[2];
95
110
  ctx.arcTo(b[0], b[1], c[0], c[1], s[3]);
96
111
  a = c;
97
112
  break;
113
+ // close path
98
114
  case "z":
99
115
  case "Z":
100
116
  ctx.closePath();