discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with NSGeometry


From: Lloyd Dupont
Subject: problem with NSGeometry
Date: Wed, 29 Mar 2006 10:15:35 +1000

I have some condition which create rect like that {{x, y}. {width, height}}
{{10, 10},{10, 0}} & {{20, 20}, {10, 10}}

I want to "merge" this 2 rect, that is I want the smallest enclosing rect, that is: {{10, 10}, {20, 20}}
I was using NSUnionRect
unfortunately due to the way NSUnionRect is implemented I get {{20, 20}, {10, 10}}

looking at the orinigal code, it's because NSUnionRect dismiss any rectangle which as either a 0 height or width.

I "fixed" what I think is a critical bug with this new version of NSUnionRect which DON'T dismiss any rect in any case:

line 352, new version:
GS_GEOM_SCOPE NSRect
NSUnionRect(NSRect aRect, NSRect bRect)
{
 float minX = MIN(NSMinX(aRect), NSMinX(bRect));
 float maxX = MAX(NSMaxX(aRect), NSMaxX(bRect));

 float minY = MIN(NSMinY(aRect), NSMinY(bRect));
 float maxY = MAX(NSMaxY(aRect), NSMaxY(bRect));

 return NSMakeRect(minX, minY, maxX - minX, maxY - minY);
}

what do you think?
(except for the fact it might break some code...)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]