Created
March 24, 2014 07:59
-
-
Save crongro/9736027 to your computer and use it in GitHub Desktop.
A Pen by younjisu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="myCanvas" width=500 height=500></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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