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

229
Views
¿Ctx.stroke() y ctx.fill() cierran automáticamente la ruta en el lienzo?

¿Es necesario incluir ctx.closePath() si voy a usar ctx.fill() o ctx.stroke() al dibujar rutas en el lienzo?
Aquí hay un ejemplo a continuación:

 ctx.beginPath() // point 1 ctx.moveTo(x+0.5,y+0.5) // point2 ctx.lineTo(x2+0.5, y2+0.5) // point 3 ctx.lineTo(x3+0.5, y3+0.5) ctx.closePath() // <--- IS THIS NECESSARY ? ctx.stroke()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La función hace lo que dice, cierra la ruta, si desea un triángulo cerrado en su ejemplo, entonces se requiere closepath(), si desea dos líneas, entonces no lo es.

Entonces, la respuesta a su pregunta es: No, stroke() y fill() no cierran su ruta.

 var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); let x = 10; let y = 10; ctx.beginPath() // point 1 ctx.moveTo(x/2+0.5,y/2+0.5) // point2 ctx.lineTo(x*2+0.5, y*4+0.5) // point 3 ctx.lineTo(x*3+0.5, y*2+0.5) ctx.closePath() // <--- IS THIS NECESSARY ? ctx.stroke() // New path x = 50; y = 20; ctx.beginPath() // point 1 ctx.moveTo(x+0.5,y+0.5) // point2 ctx.lineTo(x*2+0.5, y*4+0.5) // point 3 ctx.lineTo(x*3+0.5, y*2+0.5) ctx.stroke()
 <canvas id="myCanvas" width="200" height="100" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML canvas tag.</canvas>

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!