Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
How can I make objects appear at intervals that decrease over time in p5.js

I'll like to make some elements in an array appear at different times, the time will be decreasing over time (so the elements will appear faster and faster). I had tried with setTimeout and setInterval with no luck, I think it is because I'm looping through the array.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You cannot achieve that via intervals. Yet, it's possible with recursive timeouts. For example, let's say that the time is decreasing by 2x:

const initialDuration = 10000;

function someAnimation(duration) {
    // Your animation code here...

    setTimeout(() => someAnimation(duration / 2), duration);
}

someAnimation(initialDuration);
about 4 years ago · Juan Pablo Isaza Denunciar

0

Here's a simple p5.js example that should hopefully point you in the right direction.

I'm calling the setTimeout function for every object on initialisation. The delay of the timeout is incremented by a value incrementor which decreases each iteration.

let circles = [];
let count = 100;
let incrementor = 500;
let delay = 500;

function setup() {
  createCanvas(400, 400);
  
  for (let i = 0; i < count; i++) {
    let circle = {
      x: random(width),
      y: random(height),
      show: false,
      
    }
    incrementor *= 0.9;
    delay += incrementor;
    setTimeout(() => circle.show = true, delay);
    circles.push(circle);
    
  }
}

function draw() {
  background(220);
  noStroke()
  fill(0, 128, 128);
  for (let circle of circles) {
    if (circle.show) {
      ellipse(circle.x, circle.y, 10, 10);
    }
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"></script>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda