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

125
Views
La función de recursión llamada terdragon en Code Maven es incomprensible
 var n = 8; var l = 5; var angle = 120 * Math.PI / 180; c.translate(300, 200); terdragon(n); function terdragon(n) { if (n <= 1) { drawLine(l); } else { terdragon(n-1); c.rotate(angle); terdragon(n-1); c.rotate(-angle); terdragon(n-1); } } function drawLine(l) { c.beginPath(); c.moveTo(0, 0); c.lineTo(l, 0); c.stroke(); // Finish at the end of the line we drew c.translate(l, 0); }

No entiendo cómo dibuja las líneas como lo hace, cuando la variable n es 8. Como se establece que si n <= 1, llame a la función dibujarLínea, hasta entonces no hace nada más que llamarse a sí mismo y restar 1 cada vez y cambia de ángulo, pero no puedo ver cómo dibuja, cuando no es igual a 1.

El código es de Crunchzilla Code Maven. Capítulo 40 - Fractales

about 4 years ago · Juan Pablo Isaza
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!