(x, y, w, h)
| 293 | } |
| 294 | |
| 295 | get(x, y, w, h) { |
| 296 | const pd = this._pixelDensity; |
| 297 | const canvas = this.canvas; |
| 298 | |
| 299 | if (typeof x === 'undefined' && typeof y === 'undefined') { |
| 300 | // get() |
| 301 | x = y = 0; |
| 302 | w = this.width; |
| 303 | h = this.height; |
| 304 | } else { |
| 305 | x *= pd; |
| 306 | y *= pd; |
| 307 | |
| 308 | if (typeof w === 'undefined' && typeof h === 'undefined') { |
| 309 | // get(x,y) |
| 310 | if (x < 0 || y < 0 || x >= canvas.width || y >= canvas.height) { |
| 311 | return [0, 0, 0, 0]; |
| 312 | } |
| 313 | |
| 314 | return this._getPixel(x, y); |
| 315 | } |
| 316 | // get(x,y,w,h) |
| 317 | } |
| 318 | |
| 319 | const region = new Image(w*pd, h*pd); |
| 320 | region.pixelDensity(pd); |
| 321 | region.canvas |
| 322 | .getContext('2d') |
| 323 | .drawImage(canvas, x, y, w * pd, h * pd, 0, 0, w*pd, h*pd); |
| 324 | |
| 325 | return region; |
| 326 | } |
| 327 | |
| 328 | scale(x, y){ |
| 329 |
no test coverage detected