C
C
Cheizer2019-06-11 13:43:28
JavaScript
Cheizer, 2019-06-11 13:43:28

How to make CANVAS animation?

Friends, I need help with CANVAS, the animation is simple, a circle with a percentage stroke.

Animation

5cff84de3dd9d239897252.gif


I am extremely new to canvas, and it seems that I have cut out the code that is responsible for this animation, but it still does not work, tell me what's wrong? In which direction to dig?

My code

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
A person from Kazakhstan, 2019-06-11
@Cheizer

https://www.youtube.com/watch?v=JFdguwXoeuw

C
Cheizer, 2019-06-11
@Cheizer

Found a similar implementation https://codepen.io/egorava/pen/wGmmJW

A
Alexander Shpak, 2019-06-11
@shpaker

There are methods for drawing arcs.
arc(x, y, radius, startAngle, endAngle, anticlockwise)
arcTo(x1, y1, x2, y2, radius)
This is how you can sketch a circle:

ctx.beginPath();
    ctx.arc(75,75,50,0,Math.PI*2,true);
    ctx.stroke();

Like this arc:
ctx.beginPath();
    ctx.arc(75,75,35,0,Math.PI,false);  // рот (по часовой стрелке)
    ctx.stroke();

Dare ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question