A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {NESPainter} from "/app/js/NESPainter.js";
  2. import {NESPalette} from "/app/js/NESPalette.js";
  3. function on_palette_changed(e){
  4. if (e.type == "ALL"){
  5. console.log("ALL");
  6. } else if (e.type == "TILE"){
  7. console.log("TILE Palette:", e.pindex, " | Color:", e.cindex);
  8. } else if (e.type == "SPRITE"){
  9. console.log("SPRITE Palette:", e.pindex, " | Color:", e.cindex);
  10. }
  11. }
  12. function initialize(DOC){
  13. var nespainter = new NESPainter(DOC.getElementById("painter"));
  14. //if (!canvas){
  15. // throw new Error("DOM Missing painter canvas.");
  16. //}
  17. //var ctx = canvas.getContext("2d");
  18. //if (!ctx){
  19. // throw new Error("Failed to obtain canvas context.");
  20. //}
  21. console.log(nespainter.scale);
  22. nespainter.scale_up(5);
  23. console.log(nespainter.scale);
  24. var nespal = new NESPalette();
  25. nespal.listen("palettes_changed", on_palette_changed);
  26. nespal.set_palette([
  27. 44,
  28. 11,12,13,
  29. 54,23,43,
  30. 23,18,11,
  31. 4,8,60,
  32. 63,0,11,
  33. 0,15,14,
  34. 9,0,32,
  35. 5,10,20
  36. ]);
  37. console.log(nespal.to_asm());
  38. }
  39. //console.log(document.getElementByID("painter"));
  40. initialize(document);