Last Updated: November 13, 2017
·
1.393K
· medo100s

my circle in canvas animation doesn't want to move on

i m trying my first practice in canvas js/html but it doesn't work with me here is my code :
html :
<html lang="us">

<head>
<style type="text/css">
canvas {
border: black solid 2px;
}
body{
margin: 0px;
}
</style>

</head>
<body>
<canvas > </canvas>
<script src="animateC.js"></script>

</body>

</html>

//here is my code JS
var canvas = document.querySelector('canvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
var c = canvas.getContext('2d');

var x = 200;
function animate()
{ requestAnimationFrame(animate);
c.beginPath();
c.arc(x,200,30,0,Math.PI * 2, false);
c.strokeStyle = "red";
c.stroke();
x+=1;

}

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside