Created
August 29, 2010 08:43
-
-
Save jacius/556112 to your computer and use it in GitHub Desktop.
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
window.onload = -> | |
paper = Raphael 0, 0, 320, 200 | |
circle = paper.circle 50, 40, 10 | |
circle.attr "fill", "#f00" | |
circle.node.onclick = -> alert "Stop poking me!" | |
window.onkeypress = (ev) -> | |
ev = window.event || ev | |
switch ev.keyCode | |
when 37 then circle.attr( "cx", circle.attr("cx") - 5 ) | |
when 38 then circle.attr( "cy", circle.attr("cy") - 5 ) | |
when 39 then circle.attr( "cx", circle.attr("cx") + 5 ) | |
when 40 then circle.attr( "cy", circle.attr("cy") + 5 ) |
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 lang="en"> | |
<head> | |
<script src="http://github.com/DmitryBaranovskiy/raphael/blob/master/raphael-min.js?raw=true"></script> | |
<script src="circle.js"></script> | |
</head> | |
</html> |
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
/* This was compiled from circle.coffee */ | |
(function() { | |
window.onload = function() { | |
var circle, paper; | |
paper = Raphael(0, 0, 320, 200); | |
circle = paper.circle(50, 40, 10); | |
circle.attr("fill", "#f00"); | |
circle.node.onclick = function() { | |
return alert("Stop poking me!"); | |
}; | |
return (window.onkeypress = function(ev) { | |
var _a; | |
ev = window.event || ev; | |
if ((_a = ev.keyCode) === 37) { | |
return circle.attr("cx", circle.attr("cx") - 5); | |
} else if (_a === 38) { | |
return circle.attr("cy", circle.attr("cy") - 5); | |
} else if (_a === 39) { | |
return circle.attr("cx", circle.attr("cx") + 5); | |
} else if (_a === 40) { | |
return circle.attr("cy", circle.attr("cy") + 5); | |
} | |
}); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment