Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Empty rect contributes to bounding box



Hello list,

I was calculating a bounding box and thought I would initialize the box to zero.
However, this gives the wrong result!

HIRect hiRect1 = {{0.0}};
HIRect hiRect2 = {{1.0}};

hiRect1 = CGRectUnion( hiRect1, hiRect2 );


// Now hiRect1 = {{0.0,0.0},{2.0,2.0}} !

So one has to write

if ( !<x-tad-bigger>CGRectIsEmpty</x-tad-bigger>(hiRect1)) hiRect1 = CGRectUnion( hiRect1, hiRect2 );
else
hiRect1 = hiRect2;

OTOH this means you can calculate the bounding box of a number of points with
CGRectUnion!

Jan.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.