瀏覽代碼

Connected CTRLPainter to main.

dev-tmpl
Bryan Miller 6 年之前
父節點
當前提交
055d98a185
共有 2 個文件被更改,包括 21 次插入5 次删除
  1. +1
    -0
      app/js/main.js
  2. +20
    -5
      app/js/ui/CTRLPainter.js

+ 1
- 0
app/js/main.js 查看文件

@@ -2,6 +2,7 @@ import GlobalEvents from "/app/js/EventCaller.js";
import EmitterElements from "/app/js/ui/Emitters.js";
import Modal from "/app/js/ui/Modal.js";
import CTRLPalettes from "/app/js/ui/CTRLPalettes.js";
import CTRLPainter from "/app/js/ui/CTRLPainter.js";
//import {NESPainter} from "/app/js/NESPainter.js";
import {NESPalette} from "/app/js/NESPalette.js";


+ 20
- 5
app/js/ui/CTRLPainter.js 查看文件

@@ -1,17 +1,25 @@
import GlobalEvents from "/app/js/EventCaller.js";

export class NESPainter {
constructor(canvas){
const EL_CANVAS_ID = "painter";

// For reference...
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/stroke
class CTRLPainter {
constructor(){
this.__canvas = null;
this.__context = null;
this.__scale = 1.0; // This is the scale the painter will display source information.
this.__offset = [0.0, 0.0]; // This is the X,Y offset from origin to display source information.

if (!canvas)
throw new Error("Expected a canvas element.");
this.__canvas = canvas;
this.__canvas = document.getElementById(EL_CANVAS_ID);
if (!this.__canvas)
throw new Error("Failed to obtain the canvas element.");
this.__context = this.__canvas.getContext("2d");
if (!this.__context)
throw new Error("Failed to obtain canvas context.");

//var imgdata = this.__context.getImageData();
console.log(this.__canvas.width + ", " + this.__canvas.height);
}

get scale(){
@@ -32,3 +40,10 @@ export class NESPainter {
this.scale = this.scale - (amount*0.1);
}
}


const instance = new CTRLPainter();
export default instance;




Loading…
取消
儲存