summaryrefslogtreecommitdiff
path: root/core/util/cursor.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/util/cursor.js')
-rw-r--r--core/util/cursor.js19
1 files changed, 3 insertions, 16 deletions
diff --git a/core/util/cursor.js b/core/util/cursor.js
index 18aa7be..7997194 100644
--- a/core/util/cursor.js
+++ b/core/util/cursor.js
@@ -79,25 +79,12 @@ export default class Cursor {
this._target = null;
}
- change(pixels, mask, hotx, hoty, w, h) {
+ change(rgba, hotx, hoty, w, h) {
if ((w === 0) || (h === 0)) {
this.clear();
return;
}
- let cur = []
- for (let y = 0; y < h; y++) {
- for (let x = 0; x < w; x++) {
- let idx = y * Math.ceil(w / 8) + Math.floor(x / 8);
- let alpha = (mask[idx] << (x % 8)) & 0x80 ? 255 : 0;
- idx = ((w * y) + x) * 4;
- cur.push(pixels[idx + 2]); // red
- cur.push(pixels[idx + 1]); // green
- cur.push(pixels[idx]); // blue
- cur.push(alpha); // alpha
- }
- }
-
this._position.x = this._position.x + this._hotSpot.x - hotx;
this._position.y = this._position.y + this._hotSpot.y - hoty;
this._hotSpot.x = hotx;
@@ -111,10 +98,10 @@ export default class Cursor {
let img;
try {
// IE doesn't support this
- img = new ImageData(new Uint8ClampedArray(cur), w, h);
+ img = new ImageData(new Uint8ClampedArray(rgba), w, h);
} catch (ex) {
img = ctx.createImageData(w, h);
- img.data.set(new Uint8ClampedArray(cur));
+ img.data.set(new Uint8ClampedArray(rgba));
}
ctx.clearRect(0, 0, w, h);
ctx.putImageData(img, 0, 0);