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

84 行
2.3KB

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