Skip to content

Commit 017a548

Browse files
committed
cleaner
1 parent 96fa21a commit 017a548

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Diff for: src/dom/context2d.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
export default function(width, height, options) {
2-
var scale = devicePixelRatio;
2+
let scale;
33
if (options == null) {
4-
options = {};
5-
} else if (options == +options) {
6-
scale = +options;
7-
options = {};
4+
options = undefined;
5+
} else if (typeof options === "number") {
6+
scale = options;
7+
options = undefined;
88
} else {
9-
if (options.scale) scale = +options.scale;
10-
delete options.scale;
9+
({scale, ...options} = options);
1110
}
12-
var canvas = document.createElement("canvas");
11+
if (scale === undefined) scale = devicePixelRatio;
12+
const canvas = document.createElement("canvas");
1313
canvas.width = width * scale;
1414
canvas.height = height * scale;
1515
canvas.style.width = width + "px";
16-
var context;
17-
context = canvas.getContext("2d", options);
16+
const context = canvas.getContext("2d", options);
1817
context.scale(scale, scale);
1918
return context;
2019
}

0 commit comments

Comments
 (0)