Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Clipping region
Clipping region [message #36953] Fri, 27 July 2012 15:09 Go to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
AFAIK, Painter::Clip() clips drawing done outside a given region. Is there a way of clipping anything drawn inside the region instead?
Similar to
Painter sw;
...
sw.Circle(x, y, radius).Clip();
, which clips any drawing made outside Circle,
but clipping off anything drawn inside Circle instead?

Tks.
Re: Clipping region [message #36955 is a reply to message #36953] Fri, 27 July 2012 16:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
kropniczki wrote on Fri, 27 July 2012 09:09

AFAIK, Painter::Clip() clips drawing done outside a given region. Is there a way of clipping anything drawn inside the region instead?
Similar to
Painter sw;
...
sw.Circle(x, y, radius).Clip();
, which clips any drawing made outside Circle,
but clipping off anything drawn inside Circle instead?

Tks.


Well, as you can turn any shape into Clip, it is only a matter of drawing a rectangle with hole Wink

Mirek
Re: Clipping region [message #36956 is a reply to message #36955] Sun, 29 July 2012 03:41 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Quote:

Well, as you can turn any shape into Clip, it is only a matter of drawing a rectangle with hole

I'm afraid I don't follow you. This probably explains why I haven't figure out yet a way of doing it myself. So, may I ask you, how do I draw a rectangle with a hole and then clip off anything drawn outside the rectangle and inside the hole (=circle?)?

Thank you Mirek!
Re: Clipping region [message #36957 is a reply to message #36956] Sun, 29 July 2012 09:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
	void Paint(Draw& w) {
		Size sz = GetSize();
		DrawPainter sw(w, GetSize());
		sw.Clear(White());
		sw.Rectangle(-10000, -10000, 20000, 20000)
		  .Circle(300, 100, 95)
		  .EvenOdd().Clip();
		sw.DrawText(0, 0, "XXXXXXXXXX", Arial(300));
	}
Re: Clipping region [message #36959 is a reply to message #36957] Mon, 30 July 2012 01:27 Go to previous messageGo to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
I'd done it basically just like you suggest, except that I never thought of including the EvenOdd() call in the code, since I honestly do not know what it does yet. Anyway, the code surely works now, which is great!
Ok, great help, thanks!!
Re: Clipping region [message #36960 is a reply to message #36959] Mon, 30 July 2012 06:00 Go to previous message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
kropniczki wrote on Sun, 29 July 2012 19:27

I'd done it basically just like you suggest, except that I never thought of including the EvenOdd()


Google for "winding rule".

Mirek
Previous Topic: PNG in Draw
Next Topic: How must Alpha be managed ??
Goto Forum:
  


Current Time: Wed Nov 20 02:38:57 CET 2019

Total time taken to generate the page: 0.01737 seconds