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

90
Views
Los vértices en p5.beginShape() no se conectan

Esencialmente, me gustaría que todas estas líneas dispares estuvieran conectadas en un solo camino. Estoy usando vector.add() porque me gustaría un resultado acumulativo. ¿Quizás ese es el problema? ¿O tal vez es cómo estoy accediendo al elemento anterior de la matriz?

Por favor, eche un vistazo a este fragmento:

 let lifespan = 200; let genes = []; let previous; let prevpos; function setup(){ createCanvas(window.innerWidth, window.innerHeight); background(255); genes[0] = createVector(50,50); stroke(0); strokeWeight(1); beginShape(LINES) vertex(genes[0].x, genes[0].y); for (let i = 1; i < lifespan; i++) { previous = genes[i-1]; genes[i] = previous.add(createVector(random(-10,10),random(-10,10))); // vertex(previous.x, previous.y); vertex(genes[i].x, genes[i].y); } endShape() } function draw(){ }
 <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> <link rel="stylesheet" href="style.css"> </head> <body> <div id='sketch'> </div> <script language="javascript" type="text/javascript" src="https://cdn.jsdelivr.net/npm/p5@1.4.0/lib/p5.min.js"></script> <script src="sketch.js"></script> <script> </script> </body> </html>

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

0

Pensé que ya había intentado esto, pero solo necesitaba descomentar una línea.

 beginShape(LINES) vertex(genes[0].x, genes[0].y); for (let i = 1; i < lifespan; i++) { previous = genes[i-1]; genes[i] = previous.add(createVector(random(-10,10),random(-10,10))); vertex(previous.x, previous.y); //<-- uncomment this vertex(genes[i].x, genes[i].y); } endShape()
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!