File tree 1 file changed +9
-10
lines changed
1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change 1
1
export default function ( width , height , options ) {
2
- var scale = devicePixelRatio ;
2
+ let scale ;
3
3
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 ;
8
8
} else {
9
- if ( options . scale ) scale = + options . scale ;
10
- delete options . scale ;
9
+ ( { scale, ...options } = options ) ;
11
10
}
12
- var canvas = document . createElement ( "canvas" ) ;
11
+ if ( scale === undefined ) scale = devicePixelRatio ;
12
+ const canvas = document . createElement ( "canvas" ) ;
13
13
canvas . width = width * scale ;
14
14
canvas . height = height * scale ;
15
15
canvas . style . width = width + "px" ;
16
- var context ;
17
- context = canvas . getContext ( "2d" , options ) ;
16
+ const context = canvas . getContext ( "2d" , options ) ;
18
17
context . scale ( scale , scale ) ;
19
18
return context ;
20
19
}
You can’t perform that action at this time.
0 commit comments