I just stumbled over this issue with CGRectUnion when one operand is an empty rect, or has negative width or hight:

    CGRect r1 = CGRectZero;
    CGRect r2 = CGRectMake(100.0, 100.0, 300.0, 300.0);
    CGRect r3 = CGRectUnion(r1, r2);

the result for r3 is actually :
r3.origin: (0, 0)
r3.size: (300, 300)



However, according the docs:
"if one of the rectangles has 0 (or negative) width or height, a copy of the other rectangle is returned; "

which should yield:
r3.origin: (100, 100)
r3.size: (300, 300)


If the width or height of rectangle r1 has negative values, it too merges the two extents. So it seems, an empty rect or an "invalid" rect (negative width or height) contributes to the resulting extent.


I'm wondering if this is intended behavior and the docs are wrong, or vice versa.


Regards
Andreas


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to