When working with (contentless) SpriteKit nodes I bumped into an infinite rectangle
NSLog(@"%@", NSStringFromCGRect([node calculateAccumulatedFrame]));
which outputted
{{inf, inf}, {inf, inf}}
I thought to check for this with CGRectIsInfinite
, but that test failed, which lead me to trying the following check
CGRect rect = [node calculateAccumulatedFrame];
if (rect.origin.x == INFINITY && rect.origin.y == INFINITY &&
rect.size.width == INFINITY && rect.size.height == INFINITY) {
if (!CGRectIsInfinite(rect)) {
NSLog(@"I don't get it");
}
}
Which outputs: I don't get it
, which neatly summarises my position right now.
As pointed out by allestuetsmerweh
in an answer the function does return true for CGRectInfinite
, when I output this rectangle I get
{{-8.9884656743115785e+307, -8.9884656743115785e+307}, {1.7976931348623157e+308, 1.7976931348623157e+308}}
(the sizes are both DBL_MAX
)
What's the reasoning behind CGRectInfinite
being a rectangle with some values set to DBL_MAX i.s.o. a rectangle with all elements set to INFINITY
? (while the API does return CGRect with all members set to INFINITY)
Or rather, why doesn't a rectangle with the elements set to INFINITY
register as a CGRectIsInfinite
?