0

How can I get a delay per every draw point in this programm? Btw. i am using p5.js

function points_oben() {
    for (let a = 0; a < koords.length; a++) {
    setTimeout(function() {    
    for (var i = 0; i < koords.length; i++) {  
    strokeWeight(10);   
    stroke('blue');   
    point(koords[i].xkoord, koords[i].ykoord);   } 
      }, 3000); 
     }   
    } 

When the function run it delays 3s and then all points and not only point by point are drawn.

karel
  • 5,489
  • 46
  • 45
  • 50
  • There's no `setTimeout` in your script. Please add a [mcve] of the code that _"doesn't work"_ and explain what _"doesn't work"_ means exactly. – Andreas Jun 19 '20 at 09:37
  • Sorry my fault. I taught this might work like this: `function points_oben() { for (let a = 0; a < koords.length; a++) { setTimeout(function() { for (var i = 0; i < koords.length; i++) { strokeWeight(10); stroke('blue'); point(koords[i].xkoord, koords[i].ykoord); } }, 3000); } }` But when the function run it delays 3s and then all points and not only point by point are drawn. – Sebastian Lauss Jun 19 '20 at 10:20
  • Please [edit](https://stackoverflow.com/posts/62467362/edit) your question instead of adding it as a comment (for future questions) – Andreas Jun 19 '20 at 10:26
  • Done, its my first questions sorry for this. – Sebastian Lauss Jun 19 '20 at 10:39

0 Answers0