path2d-polyfill 1.1.5 → 1.2.0
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 +73 -0
- package/README.md +11 -27
- package/dist/index.esm.js +62 -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 +24 -14
- 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,73 @@
|
|
|
1
|
+
## [1.2.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2021-10-30)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- fixup lint and build ([94be3cd](https://github.com/nilzona/path2d-polyfill/commit/94be3cd38a58f83efc403a58380ff3c23b4f18bf))
|
|
6
|
+
- sync version in package.json with tags ([e12e852](https://github.com/nilzona/path2d-polyfill/commit/e12e852ffb13034fa13efd5112c59b6b13a46013))
|
|
7
|
+
|
|
8
|
+
### [1.1.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2021-05-04)
|
|
9
|
+
|
|
10
|
+
### [1.1.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2020-11-16)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- support for isPointInPath ([605f5d1](https://github.com/nilzona/path2d-polyfill/commit/605f5d188812e472575ccbaba351b9bbc58d3677))
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- documentation readme ([5a0abaa](https://github.com/nilzona/path2d-polyfill/commit/5a0abaab6976f10c57ac83e6f6481ed425ac940e))
|
|
19
|
+
|
|
20
|
+
### [1.0.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2020-08-27)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- remove unused css rule ([54e5174](https://github.com/nilzona/path2d-polyfill/commit/54e5174c64f6e84ef891d8830c828efc45c73b93))
|
|
25
|
+
- update badge in README.md ([483afe2](https://github.com/nilzona/path2d-polyfill/commit/483afe2b3440083bbb0c3dae74510959055d0f86))
|
|
26
|
+
|
|
27
|
+
## [1.0.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2020-05-27)
|
|
28
|
+
|
|
29
|
+
### [0.4.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2019-08-28)
|
|
30
|
+
|
|
31
|
+
### [0.4.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2019-04-15)
|
|
32
|
+
|
|
33
|
+
## [0.4.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2019-04-12)
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
- support ellipse commands ([#7](https://github.com/nilzona/path2d-polyfill/issues/7)) ([02af6d5](https://github.com/nilzona/path2d-polyfill/commit/02af6d55365b8ef70b8eecad88b913e71ae191b2))
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
- 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))
|
|
42
|
+
|
|
43
|
+
### [0.3.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-09-26)
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
- better checks if polyfill is needed ([bd65468](https://github.com/nilzona/path2d-polyfill/commit/bd654681662530d19a0958db22c5990424fb77f2))
|
|
48
|
+
|
|
49
|
+
## [0.3.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-09-25)
|
|
50
|
+
|
|
51
|
+
### [0.2.2](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-09-04)
|
|
52
|
+
|
|
53
|
+
### [0.2.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-06-05)
|
|
54
|
+
|
|
55
|
+
## [0.2.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-06-04)
|
|
56
|
+
|
|
57
|
+
### [0.1.3](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-05-22)
|
|
58
|
+
|
|
59
|
+
### Bug Fixes
|
|
60
|
+
|
|
61
|
+
- Avoid reference to global window ([9d3e742](https://github.com/nilzona/path2d-polyfill/commit/9d3e74241eb0652afe22d34523f10f3a3837e179))
|
|
62
|
+
- Remove wrong removeChild call ([123db85](https://github.com/nilzona/path2d-polyfill/commit/123db8571ff8b1b6c2fa917b513c74f8215acc37))
|
|
63
|
+
- Update README.md ([bcb01e1](https://github.com/nilzona/path2d-polyfill/commit/bcb01e153add2dccf95adaced13646e871086a3a))
|
|
64
|
+
|
|
65
|
+
### [0.1.1](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-05-18)
|
|
66
|
+
|
|
67
|
+
## [0.1.0](https://github.com/nilzona/path2d-polyfill/compare/v1.1.8...v1.2.0) (2018-05-18)
|
|
68
|
+
|
|
69
|
+
### Features
|
|
70
|
+
|
|
71
|
+
- Added examples ([261165c](https://github.com/nilzona/path2d-polyfill/commit/261165cfb0ea3a9910624f719a34a3596f1791d0))
|
|
72
|
+
- First version of Path2D polyfill ([a660f19](https://github.com/nilzona/path2d-polyfill/commit/a660f194f416785a40d8d7f5ad451bb54cec15c3))
|
|
73
|
+
- 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)) {
|
|
@@ -125,16 +125,17 @@ function _nonIterableSpread() {
|
|
|
125
125
|
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
126
|
}
|
|
127
127
|
|
|
128
|
+
var parsePath$1 = parsePath$2;
|
|
128
129
|
/**
|
|
129
130
|
* Work around for https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8438884/
|
|
130
131
|
* @ignore
|
|
131
132
|
*/
|
|
132
133
|
|
|
133
134
|
function supportsSvgPathArgument(window) {
|
|
134
|
-
var canvas = window.document.createElement(
|
|
135
|
-
var g = canvas.getContext(
|
|
136
|
-
var p = new window.Path2D(
|
|
137
|
-
g.strokeStyle =
|
|
135
|
+
var canvas = window.document.createElement("canvas");
|
|
136
|
+
var g = canvas.getContext("2d");
|
|
137
|
+
var p = new window.Path2D("M0 0 L1 1");
|
|
138
|
+
g.strokeStyle = "red";
|
|
138
139
|
g.lineWidth = 1;
|
|
139
140
|
g.stroke(p);
|
|
140
141
|
var imgData = g.getImageData(0, 0, 1, 1);
|
|
@@ -159,7 +160,7 @@ function scalePoint(point, s) {
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
function polyFillPath2D(window) {
|
|
162
|
-
if (typeof window ===
|
|
163
|
+
if (typeof window === "undefined" || !window.CanvasRenderingContext2D) {
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
166
|
|
|
@@ -185,7 +186,7 @@ function polyFillPath2D(window) {
|
|
|
185
186
|
|
|
186
187
|
(_this$segments = this.segments).push.apply(_this$segments, _toConsumableArray(path.segments));
|
|
187
188
|
} else if (path) {
|
|
188
|
-
this.segments = parsePath(path);
|
|
189
|
+
this.segments = parsePath$1(path);
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
|
|
@@ -201,47 +202,47 @@ function polyFillPath2D(window) {
|
|
|
201
202
|
}, {
|
|
202
203
|
key: "moveTo",
|
|
203
204
|
value: function moveTo(x, y) {
|
|
204
|
-
this.segments.push([
|
|
205
|
+
this.segments.push(["M", x, y]);
|
|
205
206
|
}
|
|
206
207
|
}, {
|
|
207
208
|
key: "lineTo",
|
|
208
209
|
value: function lineTo(x, y) {
|
|
209
|
-
this.segments.push([
|
|
210
|
+
this.segments.push(["L", x, y]);
|
|
210
211
|
}
|
|
211
212
|
}, {
|
|
212
213
|
key: "arc",
|
|
213
214
|
value: function arc(x, y, r, start, end, ccw) {
|
|
214
|
-
this.segments.push([
|
|
215
|
+
this.segments.push(["AC", x, y, r, start, end, !!ccw]);
|
|
215
216
|
}
|
|
216
217
|
}, {
|
|
217
218
|
key: "arcTo",
|
|
218
219
|
value: function arcTo(x1, y1, x2, y2, r) {
|
|
219
|
-
this.segments.push([
|
|
220
|
+
this.segments.push(["AT", x1, y1, x2, y2, r]);
|
|
220
221
|
}
|
|
221
222
|
}, {
|
|
222
223
|
key: "ellipse",
|
|
223
224
|
value: function ellipse(x, y, rx, ry, angle, start, end, ccw) {
|
|
224
|
-
this.segments.push([
|
|
225
|
+
this.segments.push(["E", x, y, rx, ry, angle, start, end, !!ccw]);
|
|
225
226
|
}
|
|
226
227
|
}, {
|
|
227
228
|
key: "closePath",
|
|
228
229
|
value: function closePath() {
|
|
229
|
-
this.segments.push([
|
|
230
|
+
this.segments.push(["Z"]);
|
|
230
231
|
}
|
|
231
232
|
}, {
|
|
232
233
|
key: "bezierCurveTo",
|
|
233
234
|
value: function bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
234
|
-
this.segments.push([
|
|
235
|
+
this.segments.push(["C", cp1x, cp1y, cp2x, cp2y, x, y]);
|
|
235
236
|
}
|
|
236
237
|
}, {
|
|
237
238
|
key: "quadraticCurveTo",
|
|
238
239
|
value: function quadraticCurveTo(cpx, cpy, x, y) {
|
|
239
|
-
this.segments.push([
|
|
240
|
+
this.segments.push(["Q", cpx, cpy, x, y]);
|
|
240
241
|
}
|
|
241
242
|
}, {
|
|
242
243
|
key: "rect",
|
|
243
244
|
value: function rect(x, y, width, height) {
|
|
244
|
-
this.segments.push([
|
|
245
|
+
this.segments.push(["R", x, y, width, height]);
|
|
245
246
|
}
|
|
246
247
|
}]);
|
|
247
248
|
|
|
@@ -289,20 +290,20 @@ function polyFillPath2D(window) {
|
|
|
289
290
|
var s = segments[i];
|
|
290
291
|
pathType = s[0]; // Reset control point if command is not cubic
|
|
291
292
|
|
|
292
|
-
if (pathType !==
|
|
293
|
+
if (pathType !== "S" && pathType !== "s" && pathType !== "C" && pathType !== "c") {
|
|
293
294
|
cpx = null;
|
|
294
295
|
cpy = null;
|
|
295
296
|
}
|
|
296
297
|
|
|
297
|
-
if (pathType !==
|
|
298
|
+
if (pathType !== "T" && pathType !== "t" && pathType !== "Q" && pathType !== "q") {
|
|
298
299
|
qcpx = null;
|
|
299
300
|
qcpy = null;
|
|
300
301
|
}
|
|
301
302
|
|
|
302
303
|
switch (pathType) {
|
|
303
|
-
case
|
|
304
|
-
case
|
|
305
|
-
if (pathType ===
|
|
304
|
+
case "m":
|
|
305
|
+
case "M":
|
|
306
|
+
if (pathType === "m") {
|
|
306
307
|
x += s[1];
|
|
307
308
|
y += s[2];
|
|
308
309
|
} else {
|
|
@@ -310,7 +311,7 @@ function polyFillPath2D(window) {
|
|
|
310
311
|
y = s[2];
|
|
311
312
|
}
|
|
312
313
|
|
|
313
|
-
if (pathType ===
|
|
314
|
+
if (pathType === "M" || !startPoint) {
|
|
314
315
|
startPoint = {
|
|
315
316
|
x: x,
|
|
316
317
|
y: y
|
|
@@ -320,41 +321,41 @@ function polyFillPath2D(window) {
|
|
|
320
321
|
canvas.moveTo(x, y);
|
|
321
322
|
break;
|
|
322
323
|
|
|
323
|
-
case
|
|
324
|
+
case "l":
|
|
324
325
|
x += s[1];
|
|
325
326
|
y += s[2];
|
|
326
327
|
canvas.lineTo(x, y);
|
|
327
328
|
break;
|
|
328
329
|
|
|
329
|
-
case
|
|
330
|
+
case "L":
|
|
330
331
|
x = s[1];
|
|
331
332
|
y = s[2];
|
|
332
333
|
canvas.lineTo(x, y);
|
|
333
334
|
break;
|
|
334
335
|
|
|
335
|
-
case
|
|
336
|
+
case "H":
|
|
336
337
|
x = s[1];
|
|
337
338
|
canvas.lineTo(x, y);
|
|
338
339
|
break;
|
|
339
340
|
|
|
340
|
-
case
|
|
341
|
+
case "h":
|
|
341
342
|
x += s[1];
|
|
342
343
|
canvas.lineTo(x, y);
|
|
343
344
|
break;
|
|
344
345
|
|
|
345
|
-
case
|
|
346
|
+
case "V":
|
|
346
347
|
y = s[1];
|
|
347
348
|
canvas.lineTo(x, y);
|
|
348
349
|
break;
|
|
349
350
|
|
|
350
|
-
case
|
|
351
|
+
case "v":
|
|
351
352
|
y += s[1];
|
|
352
353
|
canvas.lineTo(x, y);
|
|
353
354
|
break;
|
|
354
355
|
|
|
355
|
-
case
|
|
356
|
-
case
|
|
357
|
-
if (pathType ===
|
|
356
|
+
case "a":
|
|
357
|
+
case "A":
|
|
358
|
+
if (pathType === "a") {
|
|
358
359
|
x += s[6];
|
|
359
360
|
y += s[7];
|
|
360
361
|
} else {
|
|
@@ -413,7 +414,7 @@ function polyFillPath2D(window) {
|
|
|
413
414
|
canvas.restore();
|
|
414
415
|
break;
|
|
415
416
|
|
|
416
|
-
case
|
|
417
|
+
case "C":
|
|
417
418
|
cpx = s[3]; // Last control point
|
|
418
419
|
|
|
419
420
|
cpy = s[4];
|
|
@@ -422,7 +423,7 @@ function polyFillPath2D(window) {
|
|
|
422
423
|
canvas.bezierCurveTo(s[1], s[2], cpx, cpy, x, y);
|
|
423
424
|
break;
|
|
424
425
|
|
|
425
|
-
case
|
|
426
|
+
case "c":
|
|
426
427
|
canvas.bezierCurveTo(s[1] + x, s[2] + y, s[3] + x, s[4] + y, s[5] + x, s[6] + y);
|
|
427
428
|
cpx = s[3] + x; // Last control point
|
|
428
429
|
|
|
@@ -431,7 +432,7 @@ function polyFillPath2D(window) {
|
|
|
431
432
|
y += s[6];
|
|
432
433
|
break;
|
|
433
434
|
|
|
434
|
-
case
|
|
435
|
+
case "S":
|
|
435
436
|
if (cpx === null || cpy === null) {
|
|
436
437
|
cpx = x;
|
|
437
438
|
cpy = y;
|
|
@@ -445,7 +446,7 @@ function polyFillPath2D(window) {
|
|
|
445
446
|
y = s[4];
|
|
446
447
|
break;
|
|
447
448
|
|
|
448
|
-
case
|
|
449
|
+
case "s":
|
|
449
450
|
if (cpx === null || cpy === null) {
|
|
450
451
|
cpx = x;
|
|
451
452
|
cpy = y;
|
|
@@ -459,7 +460,7 @@ function polyFillPath2D(window) {
|
|
|
459
460
|
y += s[4];
|
|
460
461
|
break;
|
|
461
462
|
|
|
462
|
-
case
|
|
463
|
+
case "Q":
|
|
463
464
|
qcpx = s[1]; // last control point
|
|
464
465
|
|
|
465
466
|
qcpy = s[2];
|
|
@@ -468,7 +469,7 @@ function polyFillPath2D(window) {
|
|
|
468
469
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
469
470
|
break;
|
|
470
471
|
|
|
471
|
-
case
|
|
472
|
+
case "q":
|
|
472
473
|
qcpx = s[1] + x; // last control point
|
|
473
474
|
|
|
474
475
|
qcpy = s[2] + y;
|
|
@@ -477,7 +478,7 @@ function polyFillPath2D(window) {
|
|
|
477
478
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
478
479
|
break;
|
|
479
480
|
|
|
480
|
-
case
|
|
481
|
+
case "T":
|
|
481
482
|
if (qcpx === null || qcpy === null) {
|
|
482
483
|
qcpx = x;
|
|
483
484
|
qcpy = y;
|
|
@@ -491,7 +492,7 @@ function polyFillPath2D(window) {
|
|
|
491
492
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
492
493
|
break;
|
|
493
494
|
|
|
494
|
-
case
|
|
495
|
+
case "t":
|
|
495
496
|
if (qcpx === null || qcpy === null) {
|
|
496
497
|
qcpx = x;
|
|
497
498
|
qcpy = y;
|
|
@@ -505,15 +506,15 @@ function polyFillPath2D(window) {
|
|
|
505
506
|
canvas.quadraticCurveTo(qcpx, qcpy, x, y);
|
|
506
507
|
break;
|
|
507
508
|
|
|
508
|
-
case
|
|
509
|
-
case
|
|
509
|
+
case "z":
|
|
510
|
+
case "Z":
|
|
510
511
|
x = startPoint.x;
|
|
511
512
|
y = startPoint.y;
|
|
512
513
|
startPoint = undefined;
|
|
513
514
|
canvas.closePath();
|
|
514
515
|
break;
|
|
515
516
|
|
|
516
|
-
case
|
|
517
|
+
case "AC":
|
|
517
518
|
// arc
|
|
518
519
|
x = s[1];
|
|
519
520
|
y = s[2];
|
|
@@ -524,7 +525,7 @@ function polyFillPath2D(window) {
|
|
|
524
525
|
canvas.arc(x, y, r, startAngle, endAngle, ccw);
|
|
525
526
|
break;
|
|
526
527
|
|
|
527
|
-
case
|
|
528
|
+
case "AT":
|
|
528
529
|
// arcTo
|
|
529
530
|
x1 = s[1];
|
|
530
531
|
y1 = s[2];
|
|
@@ -534,7 +535,7 @@ function polyFillPath2D(window) {
|
|
|
534
535
|
canvas.arcTo(x1, y1, x, y, r);
|
|
535
536
|
break;
|
|
536
537
|
|
|
537
|
-
case
|
|
538
|
+
case "E":
|
|
538
539
|
// ellipse
|
|
539
540
|
x = s[1];
|
|
540
541
|
y = s[2];
|
|
@@ -552,7 +553,7 @@ function polyFillPath2D(window) {
|
|
|
552
553
|
canvas.restore();
|
|
553
554
|
break;
|
|
554
555
|
|
|
555
|
-
case
|
|
556
|
+
case "R":
|
|
556
557
|
// rect
|
|
557
558
|
x = s[1];
|
|
558
559
|
y = s[2];
|
|
@@ -580,9 +581,9 @@ function polyFillPath2D(window) {
|
|
|
580
581
|
args[_key] = arguments[_key];
|
|
581
582
|
}
|
|
582
583
|
|
|
583
|
-
var fillRule =
|
|
584
|
+
var fillRule = "nonzero";
|
|
584
585
|
|
|
585
|
-
if (args.length === 0 || args.length === 1 && typeof args[0] ===
|
|
586
|
+
if (args.length === 0 || args.length === 1 && typeof args[0] === "string") {
|
|
586
587
|
cFill.apply(this, args);
|
|
587
588
|
return;
|
|
588
589
|
}
|
|
@@ -614,11 +615,11 @@ function polyFillPath2D(window) {
|
|
|
614
615
|
}
|
|
615
616
|
|
|
616
617
|
// let fillRule = 'nonzero';
|
|
617
|
-
if (args[0].constructor.name ===
|
|
618
|
+
if (args[0].constructor.name === "Path2D") {
|
|
618
619
|
// first argument is a Path2D object
|
|
619
620
|
var x = args[1];
|
|
620
621
|
var y = args[2];
|
|
621
|
-
var fillRule = args[3] ||
|
|
622
|
+
var fillRule = args[3] || "nonzero";
|
|
622
623
|
var path = args[0];
|
|
623
624
|
buildPath(this, path.segments);
|
|
624
625
|
return cIsPointInPath.apply(this, [x, y, fillRule]);
|
|
@@ -630,9 +631,12 @@ function polyFillPath2D(window) {
|
|
|
630
631
|
window.Path2D = Path2D;
|
|
631
632
|
}
|
|
632
633
|
|
|
633
|
-
var path2dPolyfill = polyFillPath2D;
|
|
634
|
+
var path2dPolyfill$1 = polyFillPath2D;
|
|
634
635
|
|
|
635
|
-
|
|
636
|
+
var parsePath = parsePath$2;
|
|
637
|
+
var path2dPolyfill = path2dPolyfill$1;
|
|
638
|
+
|
|
639
|
+
if (typeof window !== "undefined") {
|
|
636
640
|
path2dPolyfill(window);
|
|
637
641
|
}
|
|
638
642
|
|
|
@@ -641,5 +645,5 @@ var src = {
|
|
|
641
645
|
parsePath: parsePath
|
|
642
646
|
};
|
|
643
647
|
|
|
644
|
-
export default
|
|
648
|
+
export { src as default };
|
|
645
649
|
//# sourceMappingURL=index.esm.js.map
|