Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7863549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:31:07+00:00 2026-06-02T23:31:07+00:00

How would one detect a mouse click inside of an arc drawn in a

  • 0

How would one detect a mouse click inside of an arc drawn in a HTML canvas element?

I am creating the arc like so:

ctx.beginPath();
ctx.arc(250, 250, outsideRadius, angle, angle + arc, false);
ctx.arc(250, 250, 0, 0, 0, true);
ctx.fill();

I did try to associate the context object for each arc that is drawn to then later use myArc.ctx.isPointInPath(mouseX, mouseY) – but that didn’t work – so I want to use basic trigonometry to figure out if the mouse click is inside the bounds or not.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:31:10+00:00Added an answer on June 2, 2026 at 11:31 pm

    You should use

    ctx.isPointInPath(x, y);

    What I did was that I moved the beginPath, path “drawing” into a function, and I called it also for drawing, and also for determining if the mouse hit the shape or not.

    function shape() {
        ctx.beginPath();
        ctx.arc(250, 250, outsideRadius, angle, angle + arc, false);
        ctx.arc(250, 250, 0, 0, 0, true);
    }
    
    function draw() {
        shape();
        ctx.fill();
    }
    
    function checkHit(x, y) {
        shape();
        return ctx.isPointInPath(x, y);
    }
    

    if you build your app like this, it will be easy to add other shapes as well

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would one detect a touch on a rotated CCSprite? I am familiar with
I would like to find a regular expression (regex) that does detect if you
We are using CRM 2011 w/ ADFS 2.0. Our users would like for one
Can the iphone detect its movement in terms of distance? Would one be able
I am working with a one dimensional array in PHP. I would like to
Using Xcodebuild directly from bash, how would one detect a failure? the exit code
How would one shorten the following using ternary operators? if ((pos - maxPos) ==
How would one insert an array full of smtp email addresses into an AD
How would one enumerate the installed browsers on an OS X system from a
How would one switch a public bool to true from a child form in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.