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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:58:32+00:00 2026-05-30T03:58:32+00:00

Here is how to create a clipping area the shape of a circle: Path

  • 0

Here is how to create a clipping area the shape of a circle:

Path path = new Path();
path.addCircle(200,200,100,Direction.CW);
c.clipPath(path); // c is a Canvas

Now there’s a clipping area on the Canvas which prevents drawing anything outside the bounds of that circle. But, what if I want to have the clipping area be shaped like a donut (or whatever)?

I tried playing around with creating a second Path and using toggleInverseFillType on it and then adding that to the original path, but that doesn’t seem to work.

Alternatively, instead of using a Path, is it possible to just create a Bitmap to use as a mask and set it as a clipping mask on the Canvas somehow?

EDIT: The answer is exactly what I needed with one small addition. When doing multiple operations on a canvas, always use Op.REPLACE on the first clipPath call. That will replace any existing clipPath on that Canvas.

For reference, here is what I discovered what the 6 different Region.Op values mean. Imagine a venn diagram with 2 circles. “B” is the part where the 2 circles overlap. “A” is the non-overlapping left circle. “C” is the non-overlapping right circle.

c.clipPath(a,Region.Op.REPLACE);
c.clipPath(b,???);

Region.Op.DIFFERENCE         -> A..            
Region.Op.INTERSECT          -> .B.            
Region.Op.REPLACE            -> .BC            
Region.Op.REVERSE_DIFFERENCE -> ..C            
Region.Op.UNION              -> ABC
Region.Op.XOR                -> A.C

The “.” indicates the part that isn’t drawn. Sorry if that’s not particularly clear. It’s hard to describe well without graphics.

  • 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-05-30T03:58:33+00:00Added an answer on May 30, 2026 at 3:58 am

    From the Canvas javadoc:

    Canvas#clipPath(Path path, Region.Op op) – Modify the current clip with the specified path.

    So, for your donut example:

    1. Create 2 Paths. One for the larger circle, one for the smaller circle.
    2. Canvas#clipPath( Path ) with larger circle Path.
    3. Call the Canvas#clipPath( Path, Region.Op ) method on your canvas with the smaller circle Path for the first argument and the appropriate Region.Op enum value for the second argument.

      Path largePath = new Path();
      largePath.addCircle(200,200,100,Direction.CW);
      Path smallPath = new Path();
      smallPath.addCircle(200,200,40,Direction.CW);
      c.clipPath(largePath); // c is a Canvas
      c.clipPath(smallPath, Region.Op.DIFFERENCE);
      

    Again, modify the Region.Op enum value to get different effects…

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

Sidebar

Related Questions

I am using git configuration mentioned here If I create a new tab and
Here now create a WordPress category drop down menu, then this category menu display
There are instructions here to create a C# assembly using the SimMetrics library. The
I am creating a web application using zend, here I create an interface from
Here it is Create a thread in suspended state. hThrd1 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)
My goal here is to create a very simple template language. At the moment,
I have two tables: entitytype and project . Here are the create table statements:
Here's my table: CREATE TABLE `alums_alumphoto` ( `id` int(11) NOT NULL auto_increment, `alum_id` int(11)
Here is my problem: Create a constructor for a telephone number given a string
Here's my situation: I'm trying to create a SSL certificate that will be installed

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.