|
|
|
|
|
|
|
|
|
|
|
import Utils from "/app/js/common/Utils.js"; |
|
|
import NESPalette from "/app/js/models/NESPalette.js"; |
|
|
import NESPalette from "/app/js/models/NESPalette.js"; |
|
|
|
|
|
|
|
|
function BitMask(offset){ |
|
|
function BitMask(offset){ |
|
|
|
|
|
|
|
|
get pixels(){ |
|
|
get pixels(){ |
|
|
return new Proxy(this, { |
|
|
return new Proxy(this, { |
|
|
get: function(obj, prop){ |
|
|
get: function(obj, prop){ |
|
|
if (!Number.isInt(prop)) |
|
|
|
|
|
|
|
|
console.log(prop); |
|
|
|
|
|
if (!Utils.isInt(prop)) |
|
|
throw new TypeError("Expected integer index."); |
|
|
throw new TypeError("Expected integer index."); |
|
|
if (prop < 0 || prop >= 64) |
|
|
if (prop < 0 || prop >= 64) |
|
|
throw new RangeError("Index out of bounds."); |
|
|
throw new RangeError("Index out of bounds."); |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
set: function(obj, prop, value){ |
|
|
set: function(obj, prop, value){ |
|
|
if (!Number.isInt(prop)) |
|
|
|
|
|
|
|
|
if (!Utils.isInt(prop)) |
|
|
throw new TypeError("Expected integer index."); |
|
|
throw new TypeError("Expected integer index."); |
|
|
if (!Number.isInt(value)) |
|
|
|
|
|
|
|
|
if (!Utils.isInt(value)) |
|
|
throw new TypeError("Color index expected to be integer."); |
|
|
throw new TypeError("Color index expected to be integer."); |
|
|
if (prop < 0 || prop >= 64) |
|
|
if (prop < 0 || prop >= 64) |
|
|
throw new RangeError("Index out of bounds."); |
|
|
throw new RangeError("Index out of bounds."); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get dataArray(){ |
|
|
get dataArray(){ |
|
|
var d = []; |
|
|
var d = []; |
|
|
for (var x = 0; x < 8; x++){ |
|
|
|
|
|
for (var y = 0; y < 8; y++){ |
|
|
|
|
|
|
|
|
for (var y = 0; y < 8; y++){ |
|
|
|
|
|
for (var x = 0; x < 8; x++){ |
|
|
d.push(this.getPixelIndex(x, y)); |
|
|
d.push(this.getPixelIndex(x, y)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |