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

78 行
2.4KB

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