Skip to content

Instantly share code, notes, and snippets.

@jacius
Created August 29, 2010 08:43
Show Gist options
  • Save jacius/556112 to your computer and use it in GitHub Desktop.
Save jacius/556112 to your computer and use it in GitHub Desktop.
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 )
<!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 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