A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

69 行
1.6KB

  1. import Utils from "/app/js/common/Utils.js"
  2. import {EventCaller} from "/app/js/common/EventCaller.js"
  3. export default class ISurface extends EventCaller{
  4. constructor(){
  5. super();
  6. this.__historyLength = 10;
  7. }
  8. get width(){return 0;}
  9. get height(){return 0;}
  10. get length(){return 0;}
  11. get historyLength(){return this.__historyLength;}
  12. get undos(){return 0;}
  13. get redos(){return 0;}
  14. get coloridx(){
  15. return new Proxy(this, {
  16. get: function(obj, prop){
  17. if (prop === "length")
  18. return 0;
  19. if (!Utils.isInt(prop))
  20. throw new TypeError("Expected integer index.");
  21. if (prop < 0)
  22. throw new RangeError("Index is out of bounds.");
  23. return this.getColor(-1,-1);
  24. },
  25. set: function(obj, prop, value){
  26. if (!Utils.isInt(prop))
  27. throw new TypeError("Expected integer index.");
  28. if (prop < 0)
  29. throw new RangeError("Index out of bounds.");
  30. if (!Utils.isInt(value))
  31. throw new TypeError("Color index expected to be an integer.");
  32. if (value < 0 || value >= 4)
  33. throw new RangeError("Color index is out of bounds.");
  34. return true;
  35. }
  36. });
  37. }
  38. copy(b){return this;}
  39. clone(){return new ISurface();}
  40. snapshot(){return this;}
  41. undo(){return this;}
  42. redo(){return this;}
  43. clearUndos(){return this;}
  44. clearRedos(){return this;}
  45. clearHistory(){
  46. return this.clearUndos().clearRedos();
  47. }
  48. getColor(x, y){
  49. return this.__default_pi[4];
  50. }
  51. getColorIndex(x, y){
  52. return {pi:-1, ci:-1};
  53. }
  54. setColorIndex(x, y, ci, pi){
  55. return this;
  56. }
  57. }