let totalPts = 3000; let steps = totalPts + 1; function setup() { createCanvas(710, 400); stroke(255); frameRate(1); setTimeout(drawPoints, 5000); // Llamar a la función drawPoints después de 5 segundos } function drawPoints() { background(0); let rand = 0; for (let i = 1; i < steps; i++) { // Generar un color aleatorio let col = color(random(255), random(255), random(255)); stroke(col); // Establecer el color de trazo como el color aleatorio // Dibujar un punto con el color aleatorio y un tamaño más grande let size = random(1, 2); // Tamaño del punto aleatorio strokeWeight(size); // Establecer el grosor del trazo como el tamaño del punto point((width / steps) * i, height / 2 + random(-rand, rand)); rand += random(-5, 5); } setTimeout(drawPoints, 5000); // Llamar a la función drawPoints nuevamente después de 5 segundos }
Dibujando puntos aleatorios con p5.js (JavaScript, Gráficos)
Except where otherwise noted, Jesusninoc by Jesús N. is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.