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...)


_______________________________________________
Discuss-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to