executing a function for only 5 seconds.

I am trying to do a loading bar in p5.js where I have a bar on the top like YouTube loading bar.

like so

var x = 0; function setup() { createCanvas(400, 400); x = width; } function draw() { background(220); stroke(255,0,0); strokeWeight(10); line(0,0,x,0); }

I want to use the map() function where I can reduce the width of the line. map(x, 0 , width , second(),second()+5);

This is not working,can someone tell me how can I achieve this?

Answers

Sign In or Register to comment.