Another graphical challenge...
Another graphical challenge...
- Subject: Another graphical challenge...
- From: Graham Cox <email@hidden>
- Date: Fri, 18 Apr 2008 18:36:36 +1000
This is not really a Cocoa-specific problem, but before I embark on a
long-winded quest, I just wonder if there's a solution out there
already.
Given two rectangles that overlap in some way, I need to create a list
of all the rectangles that make up the non-overlapping areas. In other
words it's the exclusive-OR of the two inputs, but broken down into a
list of rects (preferably the smallest number needed to make up the
result).
At first this seems quite trivial, but a quick exercise on paper
suggests that there are 15 separate cases yielding between 0 and 4
separate pieces per input rectangle. A brute force solution is
probably not that hard but is there a more elegant way? A google
search turns up some promising papers, but so far they all need some
stupid subscription to read them (whatever happened to sharing
knowledge for the good of mankind?)
What it's for: given a "before" update rect and an "after" update
rect, the idea is only mark for refresh the difference. The case of
before and after being equal or non-intersecting is trivial, but all
the other possible intersecting cases are less obvious. The benefit of
doing this should be much less drawing needed (at present I invalidate
both before and after rects, i.e. the union).
I guess a prototype for the function might look something like:
NSSet* NSExorRects( const NSRect a, const NSRect b );
------
S.O.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden