• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CGRectUnion with one empty Rectangle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGRectUnion with one empty Rectangle


  • Subject: CGRectUnion with one empty Rectangle
  • From: Andreas Grosam <email@hidden>
  • Date: Wed, 20 May 2009 17:31:24 +0200

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 (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


  • Follow-Ups:
    • Re: CGRectUnion with one empty Rectangle
      • From: Shawn Erickson <email@hidden>
    • Re: CGRectUnion with one empty Rectangle
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: Sensible way to extend base class?
  • Next by Date: Re: CGRectUnion with one empty Rectangle
  • Previous by thread: Re: Sensible way to extend base class?
  • Next by thread: Re: CGRectUnion with one empty Rectangle
  • Index(es):
    • Date
    • Thread