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

303
Views
For loop no funciona en p5js y no sé por qué

 function setup() { createCanvas(400, 400); noLoop(); } function draw() { background(220); translate(width / 2, height / 2) let amount = 12; for (let a = 0; a < amount; a += (360 / amount)) { xm = cos(a) * 100; ym = sin(a) * 100; strokeWeight(4); fill(255); ellipse(xm, ym, 10); console.log(a) } }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>

Intento hacer 12 puntos en un círculo (esta será la esfera de un reloj). No sé por qué esto no funciona, por favor ayúdenme.

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

0

Debe agregar angleMode(DEGREES) para poder usar grados en lugar de radianes (más información aquí: https://p5js.org/reference/#/p5/angleMode ) También desea pasar de 0 a 360 en lugar de 12 (cantidad) Creé una var para contener el 360 para evitar confusiones. ¡Ahí tienes!

 function setup() { createCanvas(400, 400); angleMode(DEGREES); noLoop(); } function draw() { let totalCircle = 360; background(220); translate(width / 2, height / 2) let amount = 12; for (let a = 0; a < totalCircle; a += (totalCircle / amount)) { xm = cos(a) * 100; ym = sin(a) * 100; strokeWeight(4); fill(255); ellipse(xm, ym, 10); console.log(a) } }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></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!