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文字以内のものにしてください。

main.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 {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. var palette = new NESPalette();
  38. // TODO: This is just test code. I should remove this.
  39. palette.listen("palettes_changed", on_palette_changed);
  40. // TODO: At least define a more useful set of palettes. As it is, these are just random.
  41. palette.set_palette([
  42. 44,
  43. 11,12,13,
  44. 54,23,43,
  45. 23,18,11,
  46. 4,8,60,
  47. 63,0,11,
  48. 0,15,14,
  49. 9,0,32,
  50. 5,10,20
  51. ]);
  52. console.log(palette.to_asm());
  53. GlobalEvents.emit("set_app_palette", palette);
  54. }
  55. //console.log(document.getElementByID("painter"));
  56. initialize(document);