| this.__paletteIndex = 0; | this.__paletteIndex = 0; | ||||
| this.__data = new Uint8Array(16); | this.__data = new Uint8Array(16); | ||||
| var self = this; | |||||
| this.__pixels = new Proxy(this.__data, { | |||||
| this.__pixels = new Proxy(this, { | |||||
| get: function(obj, prop){ | get: function(obj, prop){ | ||||
| if (prop === "length") | if (prop === "length") | ||||
| return 64; | return 64; | ||||
| throw new RangeError("Index out of bounds."); | throw new RangeError("Index out of bounds."); | ||||
| var dindex = Math.floor(prop*0.125); | var dindex = Math.floor(prop*0.125); | ||||
| var bitoffset = 7 - (prop%8); | var bitoffset = 7 - (prop%8); | ||||
| var v = (obj[dindex] & (1 << bitoffset)) >> bitoffset; | |||||
| v += 2*((obj[8+dindex] & (1 << bitoffset)) >> bitoffset); | |||||
| var v = (obj.__data[dindex] & (1 << bitoffset)) >> bitoffset; | |||||
| v += 2*((obj.__data[8+dindex] & (1 << bitoffset)) >> bitoffset); | |||||
| return v; | return v; | ||||
| }, | }, | ||||
| var dindex = Math.floor(prop*0.125); | var dindex = Math.floor(prop*0.125); | ||||
| var bitoffset = (prop % 8); | var bitoffset = (prop % 8); | ||||
| if (value == 1 || value == 3){ | if (value == 1 || value == 3){ | ||||
| obj[dindex] |= BitMask(bitoffset); | |||||
| obj.__data[dindex] |= BitMask(bitoffset); | |||||
| } else { | } else { | ||||
| obj[dindex] &= BitMask(bitoffset, true); | |||||
| obj.__data[dindex] &= BitMask(bitoffset, true); | |||||
| } | } | ||||
| if (value == 2 || value == 3){ | if (value == 2 || value == 3){ | ||||
| obj[8+dindex] |= BitMask(bitoffset); | |||||
| obj.__data[8+dindex] |= BitMask(bitoffset); | |||||
| } else { | } else { | ||||
| obj[8+dindex] &= BitMask(bitoffset, true); | |||||
| obj.__data[8+dindex] &= BitMask(bitoffset, true); | |||||
| } | } | ||||
| if (!BLOCK_CHANGE_EMIT) | if (!BLOCK_CHANGE_EMIT) | ||||
| self.emit("data_changed"); | |||||
| obj.emit("data_changed"); | |||||
| return true; | return true; | ||||
| } | } | ||||
| }); | }); |