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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:48:36+00:00 2026-06-14T17:48:36+00:00

Here’s simplified version of my code: Paint p = new Paint(); p.setShader(borderShader); //use a

  • 0

Here’s simplified version of my code:

Paint p = new Paint();

p.setShader(borderShader); //use a bitmap as a texture to paint with
p.setFilterBitmap(true);
p.setShadowLayer(20, 20, 20, Color.BLACK);

canvas.clipRect(10,0,width-10,height);
canvas.drawCircle(width/2,height/2,1000/2,p);

So the image looks something like this:

enter image description here

A circle that’s clipped on both sides.

The problem is, since the shadow is ofset by 20 pixels down, and 20 pixels to the right. The right portion of the shadow is clipped by the clipRect and won’t show.

I have to use clipRect instead of simply drawing a white rectangle to clip the circle because the left and right of the circle needs to be transparent to display the background underneath.

  • 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-14T17:48:37+00:00Added an answer on June 14, 2026 at 5:48 pm

    I ended up using Path to draw the shape by using two arcs and two line segments instead of using rectangular clipping areas on a circle.

    A lot of trig and math later, it works perfectly.

    EDIT:

    Per request, here is a sample of the code I ended up using. Note that this is custom tailored to my application and will work to draw out a shape exactly like the one in my question.

    private void setupBorderShadow()
    {
        //Set up variables
        int h = SUI.WIDTH / 2; // x component of the center of the circle 
        int k = SUI.HEIGHT_CENTER; // y component of the center of the circle
    
        int x = SUI.WIDTH / 2 - 4 * SUI.CIRCLE_RADIUS_DIFFERENCE - SUI.BORDER_WIDTH; //left side of the rectangle
        int r = 6 * SUI.CIRCLE_RADIUS_DIFFERENCE + SUI.BORDER_WIDTH; //radius of circle
    
    
        //define a rectangle that circumscribes the circle
        RectF circle = new RectF(h - r, k - r, h + r, k + r);
    
        Path p = new Path();
        //draw a line that goes from the bottom left to the top left of the shape
        p.moveTo(x, (float) (k + Math.sqrt(-(h * h) + 2 * h * x + r * r - (x * x))));
        p.lineTo(x, (float) (k - Math.sqrt(-(h * h) + 2 * h * x + r * r - (x * x))));
    
        //calculate the angle that the top left of the shape represents in the circle
        float angle = (float) Math.toDegrees(Math.atan(Math.sqrt(-(h * h) + 2 * h * x + r * r
                - (x * x))
                / (h - x)));
    
        //draw an arc from the top left of shape to top right of shape 
        p.arcTo(circle, 180 + angle, (180 - angle * 2));
    
        // the x component of the right side of the shape
        x = SUI.WIDTH / 2 + 4 * SUI.CIRCLE_RADIUS_DIFFERENCE + SUI.BORDER_WIDTH;
    
        //draw line from top right to bottom right
        p.lineTo(x, (float) (k + Math.sqrt(-(h * h) + 2 * h * x + r * r - (x * x))));
    
        //draw arc back from bottom right to bottom left. 
        p.arcTo(circle, angle, (180 - angle * 2));
    
    
        //draw the path onto the canvas
        _borderCanvas.drawPath(p, SUI.borderShadowPaint);
    }
    

    Note that some of the variables that I use such as “CIRCLE_RADIUS_DIFFERENCE” might not make sense. Ignore these, they are app specific constants. All the variables that actually make a difference in the geometric calculations are labeled.

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

Sidebar

Related Questions

Here is my code, which takes two version identifiers in the form 1, 5,
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here's the code require_once 'functions.php'; require_once 'cfg.php'; $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $db);
here is my code, SiteMember class @OneToMany(mappedBy = member,cascade=CascadeType.ALL) private List<MemberThread> memberThread = new
Here a simple question : What do you think of code which use try
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is an example: I write html code inside of textarea, then I swap
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =

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.