0

I want to draw a path on canvas after a specific time delay, i have checked this link Draw a Path as animation on canvas but it does not explain the problem i am looking for.

i just want a delay before i draw a path.

private void OnPainSurface(object sender, SKPaintSurfaceEventArgs args)
 {
      canvas = args.Surface.Canvas;
      canvas.Clear();


      foreach (SKPath path in inProgressPaths.Values)
      {
           //Delay before drawing a path, ex: 5 seconds
           canvas.DrawPath(path, paint);
      }

}
VINNUSAURUS
  • 1,518
  • 3
  • 18
  • 38

1 Answers1

0

You can use postInvalidateDelayed method on a View

In your example that would be

foreach (SKPath path in inProgressPaths.Values)
  {
       //Delay before drawing a path, ex: 5 seconds
       TimeUnit.SECONDS.sleep(5);
       canvas.DrawPath(path, paint);
  }

EDIT

You can just use Handler to give a delay in each iteration, in Kotlin it's done like this

Handler().postDelayed({
    canvas.DrawPath(path, paint);
}, 5000)

EDIT 2

You can try this

Handler handler = new Handler();
Action action = () => 
{
   canvas.DrawPath(path, paint);
};

handler.postDelayed(action, 5000);
Amine
  • 2,241
  • 2
  • 19
  • 41