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

66 行
1.7KB

  1. import GlobalEvents from "/app/js/EventCaller.js";
  2. //import EventWindow from "/app/js/ui/EventWindow.js";
  3. import EmitterElements from "/app/js/ui/Emitters.js";
  4. import Modal from "/app/js/ui/Modal.js";
  5. import {NESPainter} from "/app/js/NESPainter.js";
  6. import {NESPalette} from "/app/js/NESPalette.js";
  7. function on_palette_changed(e){
  8. if (e.type == "ALL"){
  9. console.log("ALL");
  10. } else if (e.type == "TILE"){
  11. console.log("TILE Palette:", e.pindex, " | Color:", e.cindex);
  12. } else if (e.type == "SPRITE"){
  13. console.log("SPRITE Palette:", e.pindex, " | Color:", e.cindex);
  14. }
  15. }
  16. function handle_emitted(){
  17. console.log("EMITTED EVENT!");
  18. }
  19. function TitlePainter(pal){
  20. var elist = document.querySelectorAll(".color-NES-random");
  21. if (elist){
  22. elist.forEach(function(el){
  23. var ca = Math.floor(Math.random() * 11) + 1;
  24. var cb = Math.floor(Math.random() * 3);
  25. var index = (cb*16)+ca;
  26. el.style.color = pal[index];
  27. el.style["background-color"] = "#000";
  28. });
  29. }
  30. }
  31. function initialize(DOC){
  32. TitlePainter(NESPalette.SystemColor);
  33. EmitterElements.initialize();
  34. //EventWindow.enable_emitter_attributes();
  35. GlobalEvents.listen("emitted-event", handle_emitted);
  36. var nespainter = new NESPainter(DOC.getElementById("painter"));
  37. console.log(nespainter.scale);
  38. nespainter.scale_up(5);
  39. console.log(nespainter.scale);
  40. var nespal = new NESPalette();
  41. nespal.listen("palettes_changed", on_palette_changed);
  42. nespal.set_palette([
  43. 44,
  44. 11,12,13,
  45. 54,23,43,
  46. 23,18,11,
  47. 4,8,60,
  48. 63,0,11,
  49. 0,15,14,
  50. 9,0,32,
  51. 5,10,20
  52. ]);
  53. console.log(nespal.to_asm());
  54. }
  55. //console.log(document.getElementByID("painter"));
  56. initialize(document);