Groups | Blog | Home
all groups > dotnet drawing api > november 2004 >

dotnet drawing api : Erasing rectangles


Landley
11/9/2004 12:40:01 AM
I have a panel with a gradient filled background. I have drawn a rectangle
on top in a solid color and wish to cut a smaller rectangle out it,
revealing the gradient filled background.

I am having problems trying to find a method or brush that I can use that
will in effect perform as an eraser.

Can you help?

Landley
11/9/2004 1:00:47 AM
The problem is that the gradient on a third party control. So I do not have
the details that I require to redraw it. Sorry, I should have mentioned
this.


[quoted text, click to view]

Bob Powell [MVP]
11/9/2004 1:45:54 AM
You'll have to re-draw the background. Calculating the right gradient for
the rectangle is next to impossible.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml






[quoted text, click to view]

James Westgate
11/9/2004 2:43:08 AM
If you are drawing using a graphics object then you can use a GraphicsPath.
Add the larger then smaller rectangle to the same graphicspath then draw the
path.

James

--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net

Take the ERM Tour at http://www.flowchartcontrol.com

[quoted text, click to view]

Doug Forster
11/9/2004 2:17:36 PM
Hi Landley,

Look up Graphics.SetClip and CombineMode.Exclude and see if that helps.

Cheers

Doug Forster

[quoted text, click to view]

Peder Y
11/10/2004 9:24:32 PM
....or redefine the path that the gradient is painting inside, and do an
invalidate(...) call.

- Peder -


[quoted text, click to view]
AddThis Social Bookmark Button