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个字符

80 行
2.5KB

  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. import EmitterElements from "/app/js/ui/Emitters.js";
  3. import Input from "/app/js/ui/Input.js";
  4. import Modal from "/app/js/ui/Modal.js";
  5. import Tabs from "/app/js/ui/Tabs.js";
  6. import CTRLPalettes from "/app/js/ctrls/CTRLPalettes.js";
  7. import CTRLPainter from "/app/js/ctrls/CTRLPainter.js";
  8. import CTRLPalettesStore from "/app/js/ctrls/CTRLPalettesStore.js";
  9. import NESPalette from "/app/js/models/NESPalette.js";
  10. import NESTile from "/app/js/models/NESTile.js";
  11. import NESBank from "/app/js/models/NESBank.js";
  12. function TitlePainter(pal){
  13. var elist = document.querySelectorAll(".color-NES-random");
  14. if (elist){
  15. elist.forEach(function(el){
  16. var ca = Math.floor(Math.random() * 11) + 1;
  17. var cb = Math.floor(Math.random() * 3);
  18. var index = (cb*16)+ca;
  19. el.style.color = pal[index];
  20. el.style["background-color"] = "#000";
  21. });
  22. }
  23. }
  24. function initialize(DOC){
  25. TitlePainter(NESPalette.SystemColor);
  26. EmitterElements.initialize();
  27. Tabs.initialize();
  28. //GlobalEvents.listen("emitted-event", handle_emitted);
  29. //var nespainter = new NESPainter(DOC.getElementById("painter"));
  30. CTRLPainter.initialize();
  31. CTRLPalettesStore.initialize();
  32. //console.log(palette.to_asm());
  33. //GlobalEvents.emit("set_app_palette", palette);
  34. // TODO: Drop all of this below test code... or put it in a dedicated test app.
  35. var TileA = new NESTile();
  36. var TileB = new NESTile();
  37. TileB.setPixelIndex(0,0,2);
  38. var TileC = TileB.clone().flip(1);
  39. var TileD = TileB.clone().flip(3);
  40. //var TileC = TileB.clone();
  41. //TileC.flip(1);
  42. for (var i=0; i < 64; i++){
  43. console.log(TileC.pixels[i]);
  44. }
  45. console.log("TileA does NOT match TileB: ", TileA.isEq(TileB) == -1);
  46. console.log("TileA does NOT match TileC: ", TileA.isEq(TileC) == -1);
  47. console.log("TileB DOES match TileC with Flag 1: ", TileB.isEq(TileC) == 1);
  48. console.log("TileB DOES match TileD with Flag 3: ", TileB.isEq(TileD) == 3);
  49. console.log(TileC);
  50. console.log(TileC.dataArray);
  51. console.log(TileC.pixels[7]);
  52. var bnk = new NESBank();
  53. bnk.lp[1] = TileB;
  54. bnk.lp[0] = TileC;
  55. bnk.rp[16] = TileD;
  56. console.log(bnk.chr);
  57. console.log("Bank color at coordinates (8,0): ", bnk.getColor(8,0));
  58. console.log("Bank color at coordinates (7,0): ", bnk.getColor(7,0));
  59. console.log("Bank color at coordinates (135, 15): ", bnk.getColor(135,15));
  60. bnk.access_mode = 0;
  61. GlobalEvents.emit("change_surface", bnk);
  62. }
  63. //console.log(document.getElementByID("painter"));
  64. initialize(document);