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

129
Views
La función clear.canvas() draw2d no borra el lienzo exactamente como se necesita

Tengo dos botones de radio en mi código html,

 <div> <h1>Select Your View</h1> <input type="radio" id="first_view" name="first_view" value="first_view" onclick="CreateCanvas('first_view')"> <label for="first_view">first_view</label> <input type="radio" id="second_view" name="second_view" value="second_view" onclick="CreateCanvas('second_view')"> <label for="second_view">second_view</label><br> </div>

Aquí está el código js en otro archivo. el canvas.clear no borra el lienzo.

 function CreateCanvas(view){ var canvas = new draw2d.Canvas("gfx_holder"); if(view == "first_view") { canvas.clear(); canvas.add(rect2); } else { canvas.clear(); canvas.add(rect1); } };

pero si agrego algo como en el siguiente código, el lienzo transparente funciona perfectamente.

función CreateCanvas (vista) {

 var canvas = new draw2d.Canvas("gfx_holder"); if(view == "first_view") { canvas.add(rect1) canvas.clear(); canvas.add(rect2); } else { canvas.add(rect2) canvas.clear(); canvas.add(rect1); }

};

¿Por qué agregar algo antes de borrar funciona en ciertas condiciones? ¿Cuál es la forma correcta de codificar aquí? No quiero agregar cosas innecesarias a mi lienzo.

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!