A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import GlobalEvents from "/app/js/common/EventCaller.js";
  2. import Utils from "/app/js/common/Utils.js";
  3. import NESBank from "/app/js/models/NESBank.js";
  4. import NESPalette from "/app/js/models/NESPalette.js";
  5. import CTRLPalettesStore from "/app/js/ctrls/CTRLPalettesStore.js";
  6. import CTRLBanksStore from "/app/js/ctrls/CTRLBanksStore.js";
  7. var SURF = null;
  8. function LoadFile(file){
  9. if (SURF !== null){
  10. var reader = new FileReader();
  11. if (SURF instanceof NESBank){
  12. reader.onload = function(e){
  13. try {
  14. SURF.chr = new Uint8Array(e.target.result);
  15. } catch (e) {
  16. console.log(e.toString());
  17. }
  18. }
  19. reader.readAsArrayBuffer(file);
  20. }
  21. }
  22. }
  23. function HANDLE_DragOver(e){
  24. e.stopPropagation();
  25. e.preventDefault();
  26. e.dataTransfer.dropEffect = 'copy';
  27. };
  28. function HANDLE_FileDrop(e){
  29. e.stopPropagation();
  30. e.preventDefault();
  31. var files = e.dataTransfer.files;
  32. for (let i=0; i < files.length; i++){
  33. LoadFile(files[i]);
  34. }
  35. }
  36. function HANDLE_SurfChange(surf){
  37. if (surf instanceof NESBank){
  38. SURF = surf;
  39. } else {
  40. SURF = null;
  41. }
  42. }
  43. class CTRLIO{
  44. constructor(){
  45. GlobalEvents.listen("change_surface", HANDLE_SurfChange);
  46. }
  47. initialize(){
  48. var e = document.querySelectorAll(".drop-zone");
  49. for (let i=0; i < e.length; e++){
  50. e[i].addEventListener("dragover", HANDLE_DragOver);
  51. e[i].addEventListener("drop", HANDLE_FileDrop);
  52. }
  53. CTRLPalettesStore.initialize();
  54. CTRLBanksStore.initialize();
  55. }
  56. }
  57. const instance = new CTRLIO();
  58. export default instance;