Created
April 3, 2012 06:38
-
-
Save lanhed/2289812 to your computer and use it in GitHub Desktop.
Simple Canvas test with EaselJS
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
<!doctype html> | |
<html> | |
<head> | |
<title>Canvas</title> | |
<script type="text/javascript" src="easeljs-0.4.1.min.js"></script> | |
<script type="text/javascript"> | |
var stage; | |
var logo; | |
var g; | |
function init() { | |
stage = new Stage(document.getElementById('canvas')); | |
g = new Graphics(); | |
g.setStrokeStyle(1); | |
g.beginStroke(Graphics.getRGB(0,0,0)); | |
var s = new Shape(g); | |
s.width = 640; | |
s.height = 480; | |
stage.addChild(s); | |
logo = new Bitmap('html5_logo_small.png'); | |
logo.regX = logo.image.width * 0.5; | |
logo.regY = logo.image.height * 0.5; | |
stage.addChild(logo); | |
Ticker.setFPS(60); | |
Ticker.addListener(window); | |
} | |
function tick() { | |
logo.x += (stage.mouseX - logo.x) * 0.1; | |
logo.y += (stage.mouseY - logo.y) * 0.1; | |
g.lineTo(logo.x, logo.y); | |
stage.update(); | |
} | |
</script> | |
</head> | |
<body onload="init()"> | |
<canvas width="640" height="480" id="canvas"></canvas> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment