mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-04-23 06:28:39 +00:00
37 lines
755 B
JavaScript
37 lines
755 B
JavaScript
class ImageData {
|
|
|
|
// var imageData = new ImageData(array, width, height);
|
|
// var imageData = new ImageData(width, height);
|
|
constructor(array, width, height) {
|
|
if (typeof array === 'number' && typeof width == 'number') {
|
|
height = width;
|
|
width = array;
|
|
array = null;
|
|
}
|
|
if (array === null) {
|
|
this._data = new Uint8ClampedArray(width * height * 4);
|
|
}
|
|
else {
|
|
this._data = array;
|
|
}
|
|
this._width = width;
|
|
this._height = height;
|
|
}
|
|
|
|
|
|
get data() {
|
|
return this._data;
|
|
}
|
|
|
|
get width() {
|
|
return this._width;
|
|
}
|
|
|
|
get height() {
|
|
return this._height;
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = ImageData;
|