Skip to content

Instantly share code, notes, and snippets.

@thaibui
Created October 18, 2016 03:38
Show Gist options
  • Save thaibui/617914cfe10552ff5a048114a446373e to your computer and use it in GitHub Desktop.
Save thaibui/617914cfe10552ff5a048114a446373e to your computer and use it in GitHub Desktop.
Pulsing Circle
<html>
<head>
</head>
<body>
<canvas id="canvas" width="600px" height="600px"></canvas>
<script>
var c = document.getElementById("canvas");
var deltas = [];
for(var i = 1; i <= 10; i++) {
deltas[i-1] = i;
}
for(var i = 10, j = 10; i > 0; i--, j++) {
deltas[j] = i;
}
var index = 0;
var radius = 40;
setInterval(draw, 100);
function draw() {
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.clearRect(0,0,600,600);
var k = i++ % deltas.length;
ctx.arc(95,50,40+deltas[k],0,2*Math.PI);
ctx.stroke();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment