Skip to content

Instantly share code, notes, and snippets.

@crongro
Created March 24, 2014 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crongro/9736027 to your computer and use it in GitHub Desktop.
Save crongro/9736027 to your computer and use it in GitHub Desktop.
A Pen by younjisu.
<canvas id="myCanvas" width=500 height=500></canvas>
var oDraw = {
init : function() {
this.elCanvas.addEventListener("click", this.changePos.bind(this));
},
elCanvas : document.getElementById("myCanvas"),
style : "magenta",
pos : { x : 40, y : 40, width : 100, height : 100},
draw : function(o) {
this.context = this.elCanvas.getContext('2d');
this.context.fillRect(this.pos.x, this.pos.y , this.pos.width , this.pos.height);
//this.changeColor();
},
changePos : function() {
console.log("call changeColor Function");
this.context.fillRect(this.pos.x, this.pos.y+100, this.pos.width, this.pos.height);
}
};
oDraw.init();
oDraw.draw();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment