Re: Hillegass, Third Edition, Chapter 18
Re: Hillegass, Third Edition, Chapter 18
- Subject: Re: Hillegass, Third Edition, Chapter 18
- From: Antonio Nunes <email@hidden>
- Date: Tue, 15 Jul 2008 14:16:02 +0100
On 15 Jul 2008, at 12:25, Jon Buys wrote:
Thanks for your help, I'm going through your code now, comparing it
to my old code and reading the documentation. NSUnionRect doesn't
seem to be much help in the docs though:
"Returns the smallest rectangle that completely encloses both aRect
and bRect. If one of the rectangles has 0 (or negative) width or
height, a copy of the other rectangle is returned; but if both have
0 (or negative) width or height, the returned rectangle has its
origin at (0.0, 0.0) and has 0 width and height."
-http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#/
/apple_ref/c/func/NSUnionRect
Can you explain a little more why this results in the ghosting I saw
in the view earlier?
The constant ghosting you saw when you first ran my code unmodified
has very little to do with the NSUnionRect function. If you then
swapped the commenting in
- (void)updateWithOldRect:(NSRect)oldRect
{
[self setNeedsDisplayInRect:NSUnionRect(oldRect, currentRect)];
//[self setNeedsDisplayInRect:NSInsetRect(NSUnionRect(oldRect,
currentRect), -1, -1)];
}
... so that the second line gets executed instead of the first, you
would see that the ghosting has as good as disappeared. However: if
you narrow down an oval either horizontally or vertically to the
thinnest possible width, and then drag straight into the visible line,
you should still get some ghosting. If you setup to watch the values
of oldRect and currentRect in the console (use a breakpoint that you
edit to autocontinue and that logs these values to the console), then
play around dragging extremely thin ovals, you should see an
interesting pattern logged whenever the ghosting is triggered. The
NSUnionRect documentation quoted above really provides the clue. It
points to an edge case and you will want to find out if, and if so,
why, that edge case happens.
António
-----------------------------------------
Accepting others as they are
brings a wonderful freedom
to your own mind.
--The Peace Formula
-----------------------------------------
_______________________________________________
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