(rgba, hotx, hoty, w, h)
| 78 | } |
| 79 | |
| 80 | change(rgba, hotx, hoty, w, h) { |
| 81 | if ((w === 0) || (h === 0)) { |
| 82 | this.clear(); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | this._position.x = this._position.x + this._hotSpot.x - hotx; |
| 87 | this._position.y = this._position.y + this._hotSpot.y - hoty; |
| 88 | this._hotSpot.x = hotx; |
| 89 | this._hotSpot.y = hoty; |
| 90 | |
| 91 | let ctx = this._canvas.getContext('2d'); |
| 92 | |
| 93 | this._canvas.width = w; |
| 94 | this._canvas.height = h; |
| 95 | |
| 96 | let img = new ImageData(new Uint8ClampedArray(rgba), w, h); |
| 97 | ctx.clearRect(0, 0, w, h); |
| 98 | ctx.putImageData(img, 0, 0); |
| 99 | |
| 100 | if (useFallback) { |
| 101 | this._updatePosition(); |
| 102 | } else { |
| 103 | let url = this._canvas.toDataURL(); |
| 104 | this._target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default'; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | clear() { |
| 109 | this._target.style.cursor = 'none'; |
no test coverage detected