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

102
Views
Cómo arreglar la línea gráfica en una calculadora matemática con escala inicial [Resuelto]

Actualmente estoy construyendo una calculadora gráfica matemática en discord.js, la gráfica funciona bien en una escala de 1.0x, pero cuando cambio la escala, la línea gráfica no comienza bien con los ejes, vi que se movía hacia abajo a la izquierda para no ser el centro de la grafica

 function draw(tree) { var i = 0; dx = 1 / global_scale; var y; variables.x = minX; var width = canvas.width; while (isNaN((y = eval(tree))) && i < width) { variables.x = minX + i * dx; i++; } let previousY = (y - minY) * global_scale; for (; i < width; i++) { variables.x = minX + i * dx; y = eval(tree); if (isNaN(y)) { console.log(`discontinuity at x = ${x}`); while ((y = eval(tree)) === NaN && i < width) { variables.x = minX + i * dx; i++; } previousY = (y - minY) * global_scale; continue; } y = (y - minY) * global_scale; ctx.beginPath(); ctx.moveTo(i - 1, previousY); ctx.lineTo(i, y); ctx.lineWidth = 2; ctx.stroke(); previousY = y; } }``` [The graphing when i do x^2 with 0.01 initial scale][1] [The graphing when i do sin(x) with 0.01 initial scale][2] and i wanna it to be something like this : [The graphing when i do x^2 with 1.0 initial scale][3] [1]: https://i.stack.imgur.com/WTTl6.png [2]: https://i.stack.imgur.com/8fH4n.png [3]: https://i.stack.imgur.com/hefWl.png
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!