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

131
Views
Animación de galería de imágenes P5

Estoy tratando de cargar dinámicamente un conjunto de imágenes y traducirlas en la dirección Z a una velocidad constante mientras tengo valores aleatorios para X e Y

Estoy trabajando con el siguiente código y no sé cómo usar la propiedad de texture de imagen.

Obtengo un lienzo negro en blanco al renderizar el siguiente código con el que trabajé. Cualquier ayuda será apreciada.

 let imgs = []; let imgs_arr = []; let num = 15; function preload() { for (let i = 0; i < num; i++) { imgs[i] = loadImage("https://picsum.photos/400/400/?image=" + i * 10); } } function setup() { createCanvas(windowWidth, windowHeight, WEBGL); colorMode(HSB, 360, 100, 100, 100); for (let i = 0; i < num; i++) { let x = random(-width / 2, width / 2); let y = random(-height / 2, height / 2); let z = random(-width*5, width/2); let texture = new Type(imgs[i], x, y, z) imgs_arr.push(texture); } } function draw() { background(0,0,0); orbitControl(); for (let i = 0; i < num; i++) { imgs_arr[i].update(); imgs_arr[i].display(); } } class Type { constructor(_img, _x, _y, _z) { this.img = _img; this.x = _x; this.y = _y; this.z = _z; } update() { this.z += 10; if(this.z > width/2){ this.z = -width*5; } } display() { push(); translate(this.x, this.y, this.z); texture(this.img) pop(); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Con solo leer los documentos , parece que te falta un componente clave. Digamos que desea dibujar la imagen en un cuadro, debe agregar lo siguiente después de su textura:

 box(width / 2);

Aquí está el ejemplo en ejecución:

 let imgs = []; let imgs_arr = []; let num = 15; function preload() { for (let i = 0; i < num; i++) { imgs[i] = loadImage("https://picsum.photos/400/400/?image=" + i * 10); } } function setup() { createCanvas(windowWidth, windowHeight, WEBGL); colorMode(HSB, 360, 100, 100, 100); for (let i = 0; i < num; i++) { let x = random(-width / 2, width / 2); let y = random(-height / 2, height / 2); let z = random(-width*5, width/2); let texture = new Type(imgs[i], x, y, z) imgs_arr.push(texture); } } function draw() { background(0,0,0); orbitControl(); for (let i = 0; i < num; i++) { imgs_arr[i].update(); imgs_arr[i].display(); } } class Type { constructor(_img, _x, _y, _z) { this.img = _img; this.x = _x; this.y = _y; this.z = _z; } update() { this.z += 10; if(this.z > width/2){ this.z = -width*5; } } display() { push(); translate(this.x, this.y, this.z); texture(this.img) box(width / 2); pop(); } }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js" integrity="sha512-N4kV7GkNv7QR7RX9YF/olywyIgIwNvfEe2nZtfyj73HdjCUkAfOBDbcuJ/cTaN04JKRnw1YG1wnUyNKMsNgg3g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

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!