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 8491567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:27:49+00:00 2026-06-10T22:27:49+00:00

So following on from this question here: Rounded buttons , I think I need

  • 0

So following on from this question here: Rounded buttons, I think I need to create a kind of map of the edges of the view, lets say I have a view that looks like this:

enter image description here

The button isn’t going to be blue or any specific colour so we can’t check if where the user touched is blue, suggested by one of the answers in the last question.

Lets say I receive a touch event, and I get the position of the touch inside this view, the view is rect and I only want to take in input if they press on the part that is blue. How can I figure out this?

  • 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-10T22:27:51+00:00Added an answer on June 10, 2026 at 10:27 pm

    Let’s assume that the bounding box for the graphic exactly fills the view. We can proceed as follows. The area of interest is bounded by two concentric circles and by the view. (The circle center is the bottom right corner of the view.) When we get a touch, we just need to compute the distance from the touch coordinate to the bottom right corner and compare that to the two circle radii. (You can avoid a square root by comparing the squared distance to the squared radii.) If the distance falls between the radii, the touch is in the blue (or whatever color). We don’t need to compute whether the touch is within the bounding box; we already know that since the event was delivered to the view.

    Here’s some sample code. It’s for a detector that determines whether a point is within two concentric circles (an annulus) and, if it is, which quadrant it hit.

    public class ArcHitDetector {
        public enum Quadrant {
            TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT
        }
        private int xCenter, yCenter, innerR2, outerR2;
        /**
         * Construct an ArcHitDetector for an annulus centered at given
         * points and with given inner and outer radii.
         *
         * @param xCenter the horizontal center coordinate
         * @param yCenter the vertical center coordinate
         * @param outerR the outer radius of the annulus
         * @param innerR the inner radius of the annulus
         */
        public ArcHitDetector(int xCenter, int yCenter, int outerR, int innerR) {
            this.xCenter = xCenter;
            this.yCenter = yCenter;
            this.outerR2 = outerR * outerR;
            this.innerR2 = innerR * innerR;
        }
    
        /**
         * Classify a point with respect to the annulus. It assumes
         * screen coordinates (x increases to the right; y increases
         * down).
         *
         * @param x the x coordinate of the point to test
         * @param y the y coordinate of the point to test
         *
         * @return the Quadrant of the annulus in which the point falls,
         *    or null if the point does not lie in the annulus
         */
        public Quadrant classifyHit(int x, int y) {
            int dx = x - xCenter;
            int dy = y - yCenter;
            int d2 = dx * dx + dy * dy;
            if (d2 <= outerR2 && d2 >= innerR2) {
                if (x >= xCenter) {
                    return y <= yCenter ? TOP_RIGHT : BOTTOM_RIGHT;
                } else {
                    return y <= yCenter ? TOP_LEFT : BOTTOM_LEFT;
                }
            } else {
                return null;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following the CSS style trick from this question I was able to create a
Following on from my question here , I'm trying to create a generic value
Ok, following on from my question here . Lets say my pages are now
Following on from this question here: Entity Framework Reverse Engineer using Power Tools -
I am following up from this question here The problem I have is that
(This question is following on from my previous problem which has been fixed (Here)
Following on from this question , I am interested in finding out how you
following on from this question (Developing to an interface with TDD), I'm still having
Following on from this question...I'm trying to unit test the following scenario: I have
Following on from this question... What to do when you’ve really screwed up the

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.