Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawCircle() {
- // color in the background
- context.fillStyle = "#EEEEEE";
- context.fillRect(0, 0, canvas.width, canvas.height);
- // draw the circle
- context.beginPath();
- var radius = 25 + 20 * Math.abs(Math.cos(angle)); //radius of circle
- context.arc(25, 25, radius, 0, Math.PI * 2, false); //position on canvas
- context.closePath();
- // color in the circle
- context.fillStyle = "#006699";
- context.fill();
- //'pulse'
- angle += Math.PI / 220;
- requestAnimationFrame(drawCircle);
- }
- drawCircle();
- function drawTriangle() {
- // draw the triangle
- context.beginPath();
- context.moveTo(75, 50);
- context.lineTo(100, 75);
- context.lineTo(100, 25);
- context.fill();
- context.rect(215, 100, Math.PI * 2, false); //position on canvas
- context.closePath();
- // color in the triangle
- context.fillStyle = "#3f007f";
- context.fill();
- //'pulse'
- angle += Math.PI / 280;
- requestAnimationFrame(drawTriangle);
- }
- drawTriangle();
Add Comment
Please, Sign In to add comment