Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
P5.JS - Action every few seconds

I am quite new to p5 and would need some advice.

Is it possible to trigger an action only every few seconds? For example: After two seconds i++;

If I use draw() or an own loop function it just goes way to fast.

Thanks a lot. Max

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can make use of setInterval(function, delay) as shown below:

let counter = 0;

function increment() {
  counter++;
}

function setup() {
  createCanvas(400, 400);
  setInterval(increment, 2000); // 2000 ms = every 2 seconds
  fill(0);
}

function draw() {
  background(220);
  text(counter, 100, 100);
}

I have set up an Example Sketch for you here.

You can read more about setInterval on MDN

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!