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

50 行
1.3KB

  1. import GlobalEvents from "/app/js/EventCaller.js";
  2. const EL_CANVAS_ID = "painter";
  3. // For reference...
  4. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/stroke
  5. class CTRLPainter {
  6. constructor(){
  7. this.__canvas = null;
  8. this.__context = null;
  9. this.__scale = 1.0; // This is the scale the painter will display source information.
  10. this.__offset = [0.0, 0.0]; // This is the X,Y offset from origin to display source information.
  11. this.__canvas = document.getElementById(EL_CANVAS_ID);
  12. if (!this.__canvas)
  13. throw new Error("Failed to obtain the canvas element.");
  14. this.__context = this.__canvas.getContext("2d");
  15. if (!this.__context)
  16. throw new Error("Failed to obtain canvas context.");
  17. //var imgdata = this.__context.getImageData();
  18. console.log(this.__canvas.width + ", " + this.__canvas.height);
  19. }
  20. get scale(){
  21. return this.__scale;
  22. }
  23. set scale(s){
  24. if (typeof(s) !== 'number')
  25. throw new TypeError("Expected number value.");
  26. this.__scale = Math.max(0.1, Math.min(100.0, s));
  27. }
  28. scale_up(amount=1){
  29. this.scale = this.scale + (amount*0.1);
  30. }
  31. scale_down(amount=1){
  32. this.scale = this.scale - (amount*0.1);
  33. }
  34. }
  35. const instance = new CTRLPainter();
  36. export default instance;