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 lines
1.8KB

  1. import GlobalEvents from "/app/js/EventCaller.js";
  2. import EmitterElements from "/app/js/ui/Emitters.js";
  3. import Modal from "/app/js/ui/Modal.js";
  4. import CTRLPalettes from "/app/js/ui/CTRLPalettes.js";
  5. import CTRLPainter from "/app/js/ui/CTRLPainter.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. var palette = new NESPalette();
  39. // TODO: This is just test code. I should remove this.
  40. palette.listen("palettes_changed", on_palette_changed);
  41. // TODO: At least define a more useful set of palettes. As it is, these are just random.
  42. palette.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(palette.to_asm());
  54. GlobalEvents.emit("set_app_palette", palette);
  55. }
  56. //console.log(document.getElementByID("painter"));
  57. initialize(document);