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

  • Home
  • SEARCH
  • 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 8866741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:52:09+00:00 2026-06-14T16:52:09+00:00

How do I draw a Rect that basically creates a hole in the canvas?

  • 0

How do I draw a Rect that basically creates a hole in the canvas? For example, say I have an image editing application that’s made for Pixel art. The user touches an area of the screen, and draws a purple rectangle. Oops, he put the rectangle in the wrong spot. The user needs to make this purple square turn transparent again so that he can re-draw it in the right position.

How do I do this? I’ve used PorterDuff.Mode.Clear, myPaintColor.setColor(Color.TRANSPARENT) etc. but all give the same result. An ugly black square where it should be transparent. My canvas starts out as transparent, and can be saved via getDrawingCache to a transparent .PNG, so I know the canvas starts off as transparent. But how do I help my user who drew the purple square to make his canvas transparent again? Thanks. I’ve been trying to figure this out all day, reading all the documentation on this, but I can’t figure it out.

Here’s what I have:

            Rect square = new Rect();
            Paint drawColor = new Paint();
            //drawColor.setColor(UserColor.get(i));
            drawColor.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
            square.set(CanvasFractionWidth * UserX.get(i), CanvasFractionHeight * UserY.get(i), (CanvasFractionWidth * UserX.get(i)) + (CanvasFractionWidth), (CanvasFractionHeight * UserY.get(i)) + CanvasFractionHeight);
            canvas.drawRect(square, drawColor);
  • 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-14T16:52:10+00:00Added an answer on June 14, 2026 at 4:52 pm

    In RoboDemo, I use this :

            Paint p = new Paint();
            p.setXfermode( new PorterDuffXfermode( Mode.CLEAR ) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Flex application in which I draw a rectangle using: <s:Rect height=20
I'm trying to debug an issue that is really stumping me. Basically, I have
basically, I have a program that has a class to create a basic GUI,
I have a button that uses a stretchable PNG as the background image, like
I have following components - ColorButton, that represents single button that is basically colored
I have a simple test application that I am having problems with. the UI
I have 4 points say (x1,y1), (x2,y2), (x2,y3) and (x4,y4). I need a draw
Im trying to rotate an image, that i want to draw on a image
I can fill rectangle with canvas draw rect: Rect rt = new Rect(0, 0,
I have a basic Cocoa app with a custom NSCollectionView that overrides drawRect: to

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.