A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

35 linhas
893B

  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. }