mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Move Uint32Array.fill polyfill to utils
This commit is contained in:
parent
3a2d837f5a
commit
0ec8036670
@ -58,14 +58,8 @@
|
||||
} else {
|
||||
pixels = _emptyPixelGridCache[key] = new Uint32Array(width * height);
|
||||
var transparentColorInt = pskl.utils.colorToInt(Constants.TRANSPARENT_COLOR);
|
||||
if (!pixels.fill) { // PhantomJS ='(
|
||||
for (var i = 0; i < width * height; i++) {
|
||||
pixels[i] = transparentColorInt;
|
||||
}
|
||||
} else {
|
||||
pixels.fill(transparentColorInt);
|
||||
}
|
||||
}
|
||||
|
||||
return new Uint32Array(pixels);
|
||||
};
|
||||
|
@ -38,6 +38,28 @@ if (!Function.prototype.bind) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Polyfill for typedarrays' fill method for PhantomJS
|
||||
*/
|
||||
if (!Uint32Array.prototype.fill) {
|
||||
Uint32Array.prototype.fill = function (value, start, end) {
|
||||
start = typeof start === 'undefined' ? 0 : start;
|
||||
end = typeof end === 'undefined' ? this.length : end;
|
||||
|
||||
if (start < 0) {
|
||||
start = this.length + start;
|
||||
}
|
||||
|
||||
if (end < 0) {
|
||||
end = this.length + end;
|
||||
}
|
||||
|
||||
for (var i = start; i < end; i++) {
|
||||
this[i] = value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @provide pskl.utils
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user