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

76 行
2.1KB

  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 {NESPainter} from "/app/js/NESPainter.js";
  8. import {NESPalette} from "/app/js/models/NESPalette.js";
  9. function on_palette_changed(e){
  10. if (e.type == "ALL"){
  11. console.log("ALL");
  12. } else if (e.type == "TILE"){
  13. console.log("TILE Palette:", e.pindex, " | Color:", e.cindex);
  14. } else if (e.type == "SPRITE"){
  15. console.log("SPRITE Palette:", e.pindex, " | Color:", e.cindex);
  16. }
  17. }
  18. function handle_emitted(){
  19. console.log("EMITTED EVENT!");
  20. }
  21. function handle_keyevent(e){
  22. console.log(e);
  23. };
  24. function TitlePainter(pal){
  25. var elist = document.querySelectorAll(".color-NES-random");
  26. if (elist){
  27. elist.forEach(function(el){
  28. var ca = Math.floor(Math.random() * 11) + 1;
  29. var cb = Math.floor(Math.random() * 3);
  30. var index = (cb*16)+ca;
  31. el.style.color = pal[index];
  32. el.style["background-color"] = "#000";
  33. });
  34. }
  35. }
  36. function initialize(DOC){
  37. TitlePainter(NESPalette.SystemColor);
  38. EmitterElements.initialize();
  39. //EventWindow.enable_emitter_attributes();
  40. GlobalEvents.listen("emitted-event", handle_emitted);
  41. //var nespainter = new NESPainter(DOC.getElementById("painter"));
  42. var palette = new NESPalette();
  43. // TODO: This is just test code. I should remove this.
  44. palette.listen("palettes_changed", on_palette_changed);
  45. // TODO: At least define a more useful set of palettes. As it is, these are just random.
  46. palette.set_palette([
  47. 44,
  48. 11,12,13,
  49. 54,23,43,
  50. 23,18,11,
  51. 4,8,60,
  52. 63,0,11,
  53. 0,15,14,
  54. 9,0,32,
  55. 5,10,20
  56. ]);
  57. console.log(palette.to_asm());
  58. GlobalEvents.emit("set_app_palette", palette);
  59. var input = new Input();
  60. input.listen("keydown", handle_keyevent);
  61. input.listen("keyup", handle_keyevent);
  62. input.listen("keypress", handle_keyevent);
  63. }
  64. //console.log(document.getElementByID("painter"));
  65. initialize(document);