Answer the question
In order to leave comments, you need to log in
Is there a library for slow animation of drawing shapes in Canvas?
For example, in canvas we can draw a line using the moveTo and lineTo functions. But at the same time, when you call stroke, this line will be drawn instantly. Is there a library that can make this line, and in general any shape on the canvas, draw slowly, over some given period of time?
In general, I am writing a program that renders a binary search tree and I would like the animation of drawing nodes and edges to them to be smooth.
PS I already tried to write a separate function that would draw lines and circles in small parts with slowdown. Here is an example for a circle
async function drawAnimaneCircle(x, y)
{
let i = 0;
while(i < (Math.PI * 2))
{
await sleep(15);
context.beginPath();
context.strokeStyle = "red";
context.arc(x, y + R, R, -Math.PI / 2, i);
i += Math.PI / 24;
context.stroke();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question