Browse Source

Added .getColorIndex() method to ISurface and extending classes.

dev-tmpl
Bryan Miller 5 years ago
parent
commit
20fa69bcc3
2 changed files with 13 additions and 0 deletions
  1. +4
    -0
      app/js/ifaces/ISurface.js
  2. +9
    -0
      app/js/models/NESBank.js

+ 4
- 0
app/js/ifaces/ISurface.js View File

return this.__default_pi[4]; return this.__default_pi[4];
} }


getColorIndex(x, y){
return 0;
}

setColorIndex(x, y, ci, pi){ setColorIndex(x, y, ci, pi){
return this; return this;
} }

+ 9
- 0
app/js/models/NESBank.js View File

return this.__default_pi[ci]; return this.__default_pi[ci];
} }


getColorIndex(x, y){
var res = LRIdx2TileIdxCo((y*256)+x);
var list = (res.lid === 0) ? this.__LP : this.__RP;
return {
pi: list[res.index].paletteIndex,
ci: list[res.index].getPixelIndex(res.x, res.y);
};
}

setColorIndex(x, y, ci, pi){ setColorIndex(x, y, ci, pi){
if (x < 0 || x >= 256 || y < 0 || y > 128) if (x < 0 || x >= 256 || y < 0 || y > 128)
throw new RangeError("Coordinates out of bounds."); throw new RangeError("Coordinates out of bounds.");

Loading…
Cancel
Save