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.

35 lines
894B

  1. export class NESPainter {
  2. constructor(canvas){
  3. this.__canvas = null;
  4. this.__context = null;
  5. this.__scale = 1.0; // This is the scale the painter will display source information.
  6. this.__offset = [0.0, 0.0]; // This is the X,Y offset from origin to display source information.
  7. if (!canvas)
  8. throw new Error("Expected a canvas element.");
  9. this.__canvas = canvas;
  10. this.__context = this.__canvas.getContext("2d");
  11. if (!this.__context)
  12. throw new Error("Failed to obtain canvas context.");
  13. }
  14. get scale(){
  15. return this.__scale;
  16. }
  17. set scale(s){
  18. if (typeof(s) !== 'number')
  19. throw new TypeError("Expected number value.");
  20. this.__scale = Math.max(0.1, Math.min(100.0, s));
  21. }
  22. scale_up(amount=1){
  23. this.scale = this.scale + (amount*0.1);
  24. }
  25. scale_down(amount=1){
  26. this.scale = this.scale - (amount*0.1);
  27. }
  28. }