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

67 行
1.8KB

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