path2d-polyfill 1.1.7 → 1.2.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 +75 -0
- package/README.md +11 -27
- package/dist/index.esm.js +65 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +27 -17
- package/src/index.js +3 -3
- package/src/parse-path.js +7 -11
- package/src/path2d-polyfill.js +58 -109
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
undefined
|
|
2
|
+
|
|
3
|
+
### [1.2.1](https://github.com/nilzona/path2d-polyfill/compare/v1.2.0...v1.2.1) (2022-03-06)## [1.2.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2021-10-30)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- fixup lint and build ([94be3cd](https://github.com/nilzona/path2d-polyfill/commit/94be3cd38a58f83efc403a58380ff3c23b4f18bf))
|
|
8
|
+
- sync version in package.json with tags ([e12e852](https://github.com/nilzona/path2d-polyfill/commit/e12e852ffb13034fa13efd5112c59b6b13a46013))
|
|
9
|
+
|
|
10
|
+
### [1.1.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2021-05-04)
|
|
11
|
+
|
|
12
|
+
### [1.1.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2020-11-16)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- support for isPointInPath ([605f5d1](https://github.com/nilzona/path2d-polyfill/commit/605f5d188812e472575ccbaba351b9bbc58d3677))
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- documentation readme ([5a0abaa](https://github.com/nilzona/path2d-polyfill/commit/5a0abaab6976f10c57ac83e6f6481ed425ac940e))
|
|
21
|
+
|
|
22
|
+
### [1.0.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2020-08-27)
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
- remove unused css rule ([54e5174](https://github.com/nilzona/path2d-polyfill/commit/54e5174c64f6e84ef891d8830c828efc45c73b93))
|
|
27
|
+
- update badge in README.md ([483afe2](https://github.com/nilzona/path2d-polyfill/commit/483afe2b3440083bbb0c3dae74510959055d0f86))
|
|
28
|
+
|
|
29
|
+
## [1.0.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2020-05-27)
|
|
30
|
+
|
|
31
|
+
### [0.4.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2019-08-28)
|
|
32
|
+
|
|
33
|
+
### [0.4.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2019-04-15)
|
|
34
|
+
|
|
35
|
+
## [0.4.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2019-04-12)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
- support ellipse commands ([#7](https://github.com/nilzona/path2d-polyfill/issues/7)) ([02af6d5](https://github.com/nilzona/path2d-polyfill/commit/02af6d55365b8ef70b8eecad88b913e71ae191b2))
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
- move current position when a path is closed ([#9](https://github.com/nilzona/path2d-polyfill/issues/9)) ([ff6d2f7](https://github.com/nilzona/path2d-polyfill/commit/ff6d2f770f9895be2ac2e947697b8f76e488cb37))
|
|
44
|
+
|
|
45
|
+
### [0.3.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-09-26)
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
- better checks if polyfill is needed ([bd65468](https://github.com/nilzona/path2d-polyfill/commit/bd654681662530d19a0958db22c5990424fb77f2))
|
|
50
|
+
|
|
51
|
+
## [0.3.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-09-25)
|
|
52
|
+
|
|
53
|
+
### [0.2.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-09-04)
|
|
54
|
+
|
|
55
|
+
### [0.2.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-06-05)
|
|
56
|
+
|
|
57
|
+
## [0.2.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-06-04)
|
|
58
|
+
|
|
59
|
+
### [0.1.3](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-05-22)
|
|
60
|
+
|
|
61
|
+
### Bug Fixes
|
|
62
|
+
|
|
63
|
+
- Avoid reference to global window ([9d3e742](https://github.com/nilzona/path2d-polyfill/commit/9d3e74241eb0652afe22d34523f10f3a3837e179))
|
|
64
|
+
- Remove wrong removeChild call ([123db85](https://github.com/nilzona/path2d-polyfill/commit/123db8571ff8b1b6c2fa917b513c74f8215acc37))
|
|
65
|
+
- Update README.md ([bcb01e1](https://github.com/nilzona/path2d-polyfill/commit/bcb01e153add2dccf95adaced13646e871086a3a))
|
|
66
|
+
|
|
67
|
+
### [0.1.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-05-18)
|
|
68
|
+
|
|
69
|
+
## [0.1.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-05-18)
|
|
70
|
+
|
|
71
|
+
### Features
|
|
72
|
+
|
|
73
|
+
- Added examples ([261165c](https://github.com/nilzona/path2d-polyfill/commit/261165cfb0ea3a9910624f719a34a3596f1791d0))
|
|
74
|
+
- First version of Path2D polyfill ([a660f19](https://github.com/nilzona/path2d-polyfill/commit/a660f194f416785a40d8d7f5ad451bb54cec15c3))
|
|
75
|
+
- Implement addPath ([72d4228](https://github.com/nilzona/path2d-polyfill/commit/72d4228bd6c4dda64fa957ab80e49bd7c7677d8f))
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# path2d-polyfill
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
Polyfills Path2D api for rendering SVG paths in canvas
|
|
6
6
|
|
|
@@ -10,42 +10,26 @@ Use this to enable Path2D features in e.g. Internet Explorer.
|
|
|
10
10
|
|
|
11
11
|
Load from cdn
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```html
|
|
14
14
|
<script lang="javascript" src="https://unpkg.com/path2d-polyfill"></script>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
or install from npm
|
|
18
18
|
|
|
19
|
-
```
|
|
19
|
+
```shell
|
|
20
20
|
npm install --save path2d-polyfill
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```html
|
|
26
|
-
<html>
|
|
27
|
-
<head>
|
|
28
|
-
...
|
|
29
|
-
</head>
|
|
30
|
-
<body>
|
|
31
|
-
<script
|
|
32
|
-
lang="javascript"
|
|
33
|
-
src="node_modules/path2d-polyfill/path2d-polyfill.js"
|
|
34
|
-
></script>
|
|
35
|
-
</body>
|
|
36
|
-
</html>
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
or import with module bundler e.g. webpack _before_ you try to use the feature
|
|
23
|
+
and import with module bundler e.g. webpack _before_ you try to use the feature
|
|
40
24
|
|
|
41
25
|
```javascript
|
|
42
|
-
require(
|
|
26
|
+
require("path2d-polyfill");
|
|
43
27
|
```
|
|
44
28
|
|
|
45
|
-
or
|
|
29
|
+
or with es2015+ modules
|
|
46
30
|
|
|
47
31
|
```javascript
|
|
48
|
-
import
|
|
32
|
+
import "path2d-polyfill";
|
|
49
33
|
```
|
|
50
34
|
|
|
51
35
|
## Support table
|
|
@@ -66,20 +50,20 @@ import 'path2d-polyfill';
|
|
|
66
50
|
Example of usage
|
|
67
51
|
|
|
68
52
|
```javascript
|
|
69
|
-
ctx.fill(new Path2D(
|
|
70
|
-
ctx.stroke(new Path2D(
|
|
53
|
+
ctx.fill(new Path2D("M 80 80 A 45 45 0 0 0 125 125 L 125 80 Z"));
|
|
54
|
+
ctx.stroke(new Path2D("M 80 80 A 45 45 0 0 0 125 125 L 125 80 Z"));
|
|
71
55
|
```
|
|
72
56
|
|
|
73
57
|
## See it in action
|
|
74
58
|
|
|
75
59
|
Clone this repo and run the following
|
|
76
60
|
|
|
77
|
-
```
|
|
61
|
+
```shell
|
|
78
62
|
yarn
|
|
79
63
|
yarn start
|
|
80
64
|
```
|
|
81
65
|
|
|
82
|
-
open http://localhost:10001 to see the example page.
|
|
66
|
+
open <http://localhost:10001> to see the example page.
|
|
83
67
|
|
|
84
68
|
## Contributing
|
|
85
69
|
|
package/dist/index.esm.js
CHANGED
|
@@ -34,7 +34,7 @@ function parse(path) {
|
|
|
34
34
|
var data = [];
|
|
35
35
|
var p = String(path).trim(); // A path data segment (if there is one) must begin with a "moveto" command
|
|
36
36
|
|
|
37
|
-
if (p[0] !==
|
|
37
|
+
if (p[0] !== "M" && p[0] !== "m") {
|
|
38
38
|
return data;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -43,15 +43,15 @@ function parse(path) {
|
|
|
43
43
|
var theArgs = parseValues(args);
|
|
44
44
|
var theCommand = command; // overloaded moveTo
|
|
45
45
|
|
|
46
|
-
if (type ===
|
|
46
|
+
if (type === "m" && theArgs.length > 2) {
|
|
47
47
|
data.push([theCommand].concat(theArgs.splice(0, 2)));
|
|
48
|
-
type =
|
|
49
|
-
theCommand = theCommand ===
|
|
48
|
+
type = "l";
|
|
49
|
+
theCommand = theCommand === "m" ? "l" : "L";
|
|
50
50
|
} // Ignore invalid commands
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
if (theArgs.length < ARG_LENGTH[type]) {
|
|
54
|
-
return
|
|
54
|
+
return "";
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
data.push([theCommand].concat(theArgs.splice(0, ARG_LENGTH[type]))); // The command letter can be eliminated on subsequent commands if the
|
|
@@ -63,12 +63,12 @@ function parse(path) {
|
|
|
63
63
|
data.push([theCommand].concat(theArgs.splice(0, ARG_LENGTH[type])));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
return
|
|
66
|
+
return "";
|
|
67
67
|
});
|
|
68
68
|
return data;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
var parsePath = parse;
|
|
71
|
+
var parsePath$2 = parse;
|
|
72
72
|
|
|
73
73
|
function _classCallCheck(instance, Constructor) {
|
|
74
74
|
if (!(instance instanceof Constructor)) {
|
|
@@ -89,6 +89,9 @@ function _defineProperties(target, props) {
|
|
|
89
89
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
90
90
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
91
91
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
92
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
93
|
+
writable: false
|
|
94
|
+
});
|
|
92
95
|
return Constructor;
|
|
93
96
|
}
|
|
94
97
|
|
|
@@ -125,16 +128,17 @@ function _nonIterableSpread() {
|
|
|
125
128
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
var parsePath$1 = parsePath$2;
|
|
128
132
|
/**
|
|
129
133
|
* Work around for https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8438884/
|
|
130
134
|
* @ignore
|
|
131
135
|
*/
|
|
132
136
|
|
|
133
137
|
function supportsSvgPathArgument(window) {
|
|
134
|
-
var canvas = window.document.createElement(
|
|
135
|
-
var g = canvas.getContext(
|
|
136
|
-
var p = new window.Path2D(
|
|
137
|
-
g.strokeStyle =
|
|
138
|
+
var canvas = window.document.createElement("canvas");
|
|
139
|
+
var g = canvas.getContext("2d");
|
|
140
|
+
var p = new window.Path2D("M0 0 L1 1");
|
|
141
|
+
g.strokeStyle = "red";
|
|
138
142
|
g.lineWidth = 1;
|
|
139
143
|
g.stroke(p);
|
|
140
144
|
var imgData = g.getImageData(0, 0, 1, 1);
|
|
@@ -159,7 +163,7 @@ function scalePoint(point, s) {
|
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
function polyFillPath2D(window) {
|
|
162
|
-
if (typeof window ===
|
|
166
|
+
if (typeof window === "undefined" || !window.CanvasRenderingContext2D) {
|
|
163
167
|
return;
|
|
164
168
|
}
|
|
165
169
|
|
|
@@ -185,7 +189,7 @@ function polyFillPath2D(window) {
|
|
|
185
189
|
|
|
186
190
|
(_this$segments = this.segments).push.apply(_this$segments, _toConsumableArray(path.segments));
|
|
187
191
|
} else if (path) {
|
|
188
|
-
this.segments = parsePath(path);
|
|
192
|
+
this.segments = parsePath$1(path);
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
195
|
|
|
@@ -201,47 +205,47 @@ function polyFillPath2D(window) {
|
|
|
201
205
|
}, {
|
|
202
206
|
key: "moveTo",
|
|
203
207
|
value: function moveTo(x, y) {
|
|
204
|
-
this.segments.push([
|
|
208
|
+
this.segments.push(["M", x, y]);
|
|
205
209
|
}
|
|
206
210
|
}, {
|
|
207
211
|
key: "lineTo",
|
|
208
212
|
value: function lineTo(x, y) {
|
|
209
|
-
this.segments.push([
|
|
213
|
+
this.segments.push(["L", x, y]);
|
|
210
214
|
}
|
|
211
215
|
}, {
|
|
212
216
|
key: "arc",
|
|
213
217
|
value: function arc(x, y, r, start, end, ccw) {
|
|
214
|
-
this.segments.push([
|
|
218
|
+
this.segments.push(["AC", x, y, r, start, end, !!ccw]);
|
|
215
219
|
}
|
|
216
220
|
}, {
|
|
217
221
|
key: "arcTo",
|
|
218
222
|
value: function arcTo(x1, y1, x2, y2, r) {
|
|
219
|
-
this.segments.push([
|
|
223
|
+
this.segments.push(["AT", x1, y1, x2, y2, r]);
|
|
220
224
|
}
|
|
221
225
|
}, {
|
|
222
226
|
key: "ellipse",
|
|
223
227
|
value: function ellipse(x, y, rx, ry, angle, start, end, ccw) {
|
|
224
|
-
this.segments.push([
|
|
228
|
+
this.segments.push(["E", x, y, rx, ry, angle, start, end, !!ccw]);
|
|
225
229
|
}
|
|
226
230
|
}, {
|
|
227
231
|
key: "closePath",
|
|
228
232
|
value: function closePath() {
|
|
229
|
-
this.segments.push([
|
|
233
|
+
this.segments.push(["Z"]);
|
|
230
234
|
}
|
|
231
235
|
}, {
|
|
232
236
|
key: "bezierCurveTo",
|
|
233
237
|
value: function bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
234
|
-
this.segments.push([
|
|
238
|
+
this.segments.push(["C", cp1x, cp1y, cp2x, cp2y, x, y]);
|
|
235
239
|
}
|
|
236
240
|
}, {
|
|
237
241
|
key: "quadraticCurveTo",
|
|
238
242
|
value: function quadraticCurveTo(cpx, cpy, x, y) {
|
|
239
|
-
this.segments.push([
|
|
243
|
+
this.segments.push(["Q", cpx, cpy, x, y]);
|
|
240
244
|
}
|
|
241
245
|
}, {
|
|
242
246
|
key: "rect",
|
|
243
247
|
value: function rect(x, y, width, height) {
|
|
244
|
-
this.segments.push([
|
|
248
|
+
this.segments.push(["R", x, y, width, height]);
|
|
245
249
|
}
|
|
246
250
|
}]);
|
|
247
251
|
|
|
@@ -289,20 +293,20 @@ function polyFillPath2D(window) {
|
|
|
289
293
|
var s = segments[i];
|
|
290
294
|
pathType = s[0]; // Reset control point if command is not cubic
|
|
291
295
|
|
|
292
|
-
if (pathType !==
|
|
296
|
+
if (pathType !== "S" && pathType !== "s" && pathType !== "C" && pathType !== "c") {
|
|
293
297
|
cpx = null;
|
|
294
298
|
cpy = null;
|
|
295
299
|
}
|
|
296
300
|
|
|
297
|
-
if (pathType !==
|
|
301
|
+
if (pathType !== "T" && pathType !== "t" && pathType !== "Q" && pathType !== "q") {
|
|
298
302
|
qcpx = null;
|
|
299
303
|
qcpy = null;
|
|
300
304
|
}
|
|
301
305
|
|
|
302
306
|
switch (pathType) {
|
|
303
|
-
case
|
|
304
|
-
case
|
|
305
|
-
if (pathType ===
|
|
307
|
+
case "m":
|
|
308
|
+
case "M":
|
|
309
|
+
if (pathType === "m") {
|
|
306
310
|
x += s[1];
|
|
307
311
|
y += s[2];
|
|
308
312
|
} else {
|
|
@@ -310,7 +314,7 @@ function polyFillPath2D(window) {
|
|
|
310
314
|
y = s[2];
|
|
311
315
|
}
|
|
312
316
|
|
|
313
|
-
if (pathType ===
|
|
317
|
+
if (pathType === "M" || !startPoint) {
|
|
314
318
|
startPoint = {
|
|
315
319
|
x: x,
|
|
316
320
|
y: y
|
|
@@ -320,41 +324,41 @@ function polyFillPath2D(window) {
|
|
|
320
324
|
canvas.moveTo(x, y);
|
|
321
325
|
break;
|
|
322
326
|
|
|
323
|
-
case
|
|
327
|
+
case "l":
|
|
324
328
|
x += s[1];
|
|
325
329
|
y += s[2];
|
|
326
330
|
canvas.lineTo(x, y);
|
|
327
331
|
break;
|
|
328
332
|
|
|
329
|
-
case
|
|
333
|
+
case "L":
|
|
330
334
|
x = s[1];
|
|
331
335
|
y = s[2];
|
|
332
336
|
canvas.lineTo(x, y);
|
|
333
337
|
break;
|
|
334
338
|
|
|
335
|
-
case
|
|
339
|
+
case "H":
|
|
336
340
|
x = s[1];
|
|
337
341
|
canvas.lineTo(x, y);
|
|
338
342
|
break;
|
|
339
343
|
|
|
340
|
-
case
|
|
344
|
+
case "h":
|
|
341
345
|
x += s[1];
|
|
342
346
|
canvas.lineTo(x, y);
|
|
343
347
|
break;
|
|
344
348
|
|
|
345
|
-
case
|
|
349
|
+
case "V":
|
|
346
350
|
y = s[1];
|
|
347
351
|
canvas.lineTo(x, y);
|
|
348
352
|
break;
|
|
349
353
|
|
|
350
|
-
case
|
|
354
|
+
case "v":
|
|
351
355
|
y += s[1];
|
|
352
356
|
canvas.lineTo(x, y);
|
|
353
357
|
break;
|
|
354
358
|
|
|
355
|
-
case
|
|
356
|
-
case
|
|
357
|
-
if (pathType ===
|
|
359
|
+
case "a":
|
|
360
|
+
case "A":
|
|
361
|
+
if (pathType === "a") {
|
|
358
362
|
x += s[6];
|
|
359
363
|
y += s[7];
|
|
360
364
|
} else {
|
|
@@ -413,7 +417,7 @@ function polyFillPath2D(window) {
|
|
|
413
417
|
canvas.restore();
|
|
414
418
|
break;
|
|
415
419
|
|
|
416
|
-
case
|
|
420
|
+
case "C":
|
|
417
421
|
cpx = s[3]; // Last control point
|
|
418
422
|
|
|
419
423
|
cpy = s[4];
|
|
@@ -422,7 +426,7 @@ function polyFillPath2D(window) {
|
|
|
422
426
|
canvas.bezierCurveTo(s[1], s[2], cpx, cpy, x, y);
|
|
423
427
|
break;
|
|
424
428
|
|
|
425
|
-
case
|
|
429
|
+
case "c":
|
|
426
430
|
canvas.bezierCurveTo(s[1] + x, s[2] + y, s[3] + x, s[4] + y, s[5] + x, s[6] + y);
|
|
427
431
|
cpx = s[3] + x; // Last control point
|
|
428
432
|
|
|
@@ -431,7 +435,7 @@ function polyFillPath2D(window) {
|
|
|
431
435
|
y += s[6];
|
|
432
436
|
break;
|
|
433
437
|
|
|
434
|
-
case
|
|
438
|
+
case "S":
|
|
435
439
|
if (cpx === null || cpy === null) {
|
|
436
440
|
cpx = x;
|
|
437
441
|
cpy = y;
|
|
@@ -445,7 +449,7 @@ function polyFillPath2D(window) {
|
|
|
445
449
|
y = s[4];
|
|
446
450
|
break;
|
|
447
451
|
|
|
448
|
-
case
|
|
452
|
+
case "s":
|
|
449
453
|
if (cpx === null || cpy === null) {
|
|
450
454
|
cpx = x;
|
|
451
455
|
cpy = y;
|
|
@@ -459,7 +463,7 @@ function polyFillPath2D(window) {
|
|
|
459
463
|
y += s[4];
|
|
460
464
|
break;
|
|
461
465
|
|
|
462
|
-
case
|
|
466
|
+
case "Q":
|
|
463
467
|
qcpx = s[1]; // last control point
|
|
464
468
|
|
|
465
469
|
qcpy = s[2];
|
|
@@ -468,7 +472,7 @@ function polyFillPath2D(window) {
|
|
|
468
472
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
469
473
|
break;
|
|
470
474
|
|
|
471
|
-
case
|
|
475
|
+
case "q":
|
|
472
476
|
qcpx = s[1] + x; // last control point
|
|
473
477
|
|
|
474
478
|
qcpy = s[2] + y;
|
|
@@ -477,7 +481,7 @@ function polyFillPath2D(window) {
|
|
|
477
481
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
478
482
|
break;
|
|
479
483
|
|
|
480
|
-
case
|
|
484
|
+
case "T":
|
|
481
485
|
if (qcpx === null || qcpy === null) {
|
|
482
486
|
qcpx = x;
|
|
483
487
|
qcpy = y;
|
|
@@ -491,7 +495,7 @@ function polyFillPath2D(window) {
|
|
|
491
495
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
492
496
|
break;
|
|
493
497
|
|
|
494
|
-
case
|
|
498
|
+
case "t":
|
|
495
499
|
if (qcpx === null || qcpy === null) {
|
|
496
500
|
qcpx = x;
|
|
497
501
|
qcpy = y;
|
|
@@ -505,15 +509,15 @@ function polyFillPath2D(window) {
|
|
|
505
509
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
506
510
|
break;
|
|
507
511
|
|
|
508
|
-
case
|
|
509
|
-
case
|
|
512
|
+
case "z":
|
|
513
|
+
case "Z":
|
|
510
514
|
x = startPoint.x;
|
|
511
515
|
y = startPoint.y;
|
|
512
516
|
startPoint = undefined;
|
|
513
517
|
canvas.closePath();
|
|
514
518
|
break;
|
|
515
519
|
|
|
516
|
-
case
|
|
520
|
+
case "AC":
|
|
517
521
|
// arc
|
|
518
522
|
x = s[1];
|
|
519
523
|
y = s[2];
|
|
@@ -524,7 +528,7 @@ function polyFillPath2D(window) {
|
|
|
524
528
|
canvas.arc(x, y, r, startAngle, endAngle, ccw);
|
|
525
529
|
break;
|
|
526
530
|
|
|
527
|
-
case
|
|
531
|
+
case "AT":
|
|
528
532
|
// arcTo
|
|
529
533
|
x1 = s[1];
|
|
530
534
|
y1 = s[2];
|
|
@@ -534,7 +538,7 @@ function polyFillPath2D(window) {
|
|
|
534
538
|
canvas.arcTo(x1, y1, x, y, r);
|
|
535
539
|
break;
|
|
536
540
|
|
|
537
|
-
case
|
|
541
|
+
case "E":
|
|
538
542
|
// ellipse
|
|
539
543
|
x = s[1];
|
|
540
544
|
y = s[2];
|
|
@@ -552,7 +556,7 @@ function polyFillPath2D(window) {
|
|
|
552
556
|
canvas.restore();
|
|
553
557
|
break;
|
|
554
558
|
|
|
555
|
-
case
|
|
559
|
+
case "R":
|
|
556
560
|
// rect
|
|
557
561
|
x = s[1];
|
|
558
562
|
y = s[2];
|
|
@@ -580,9 +584,9 @@ function polyFillPath2D(window) {
|
|
|
580
584
|
args[_key] = arguments[_key];
|
|
581
585
|
}
|
|
582
586
|
|
|
583
|
-
var fillRule =
|
|
587
|
+
var fillRule = "nonzero";
|
|
584
588
|
|
|
585
|
-
if (args.length === 0 || args.length === 1 && typeof args[0] ===
|
|
589
|
+
if (args.length === 0 || args.length === 1 && typeof args[0] === "string") {
|
|
586
590
|
cFill.apply(this, args);
|
|
587
591
|
return;
|
|
588
592
|
}
|
|
@@ -614,11 +618,11 @@ function polyFillPath2D(window) {
|
|
|
614
618
|
}
|
|
615
619
|
|
|
616
620
|
// let fillRule = 'nonzero';
|
|
617
|
-
if (args[0].constructor.name ===
|
|
621
|
+
if (args[0].constructor.name === "Path2D") {
|
|
618
622
|
// first argument is a Path2D object
|
|
619
623
|
var x = args[1];
|
|
620
624
|
var y = args[2];
|
|
621
|
-
var fillRule = args[3] ||
|
|
625
|
+
var fillRule = args[3] || "nonzero";
|
|
622
626
|
var path = args[0];
|
|
623
627
|
buildPath(this, path.segments);
|
|
624
628
|
return cIsPointInPath.apply(this, [x, y, fillRule]);
|
|
@@ -630,9 +634,12 @@ function polyFillPath2D(window) {
|
|
|
630
634
|
window.Path2D = Path2D;
|
|
631
635
|
}
|
|
632
636
|
|
|
633
|
-
var path2dPolyfill = polyFillPath2D;
|
|
637
|
+
var path2dPolyfill$1 = polyFillPath2D;
|
|
638
|
+
|
|
639
|
+
var parsePath = parsePath$2;
|
|
640
|
+
var path2dPolyfill = path2dPolyfill$1;
|
|
634
641
|
|
|
635
|
-
if (typeof window !==
|
|
642
|
+
if (typeof window !== "undefined") {
|
|
636
643
|
path2dPolyfill(window);
|
|
637
644
|
}
|
|
638
645
|
|
|
@@ -641,5 +648,5 @@ var src = {
|
|
|
641
648
|
parsePath: parsePath
|
|
642
649
|
};
|
|
643
650
|
|
|
644
|
-
export default
|
|
651
|
+
export { src as default };
|
|
645
652
|
//# sourceMappingURL=index.esm.js.map
|