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

98
Views
Javascipt Canvas, Remove a circle after I click on it

In this code I create a circle and put it where I want on canvas; I want to remove it after clicking on it and if I click again than display it. How I can do this?

var createCircle = new ShootyController();
createCircle.x;
createCircle.y;
createCircle.radius = 10;
createCircle.color = "red";

canvas.addEventListener(
  "click",
  function (e) {
    createCircle.x = e.clientX;
    createCircle.y = e.clientY;

    createCircle.x -= canvas.offsetLeft;
    createCircle.y -= canvas.offsetTop;
  },
  {once: true}
);
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You have to clear the canvas part where your circle is drawing

let canvas = document.getElementById("myCanvasID");
let context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
about 4 years ago · Santiago Gelvez 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!