Skip to content

Instantly share code, notes, and snippets.

@novi
Created May 28, 2011 16:34
Show Gist options
  • Save novi/997013 to your computer and use it in GitHub Desktop.
Save novi/997013 to your computer and use it in GitHub Desktop.
CGRectIntegralの謎
-(void)testRect
{
CGRect r = CGRectMake(1.222, 1.3333, 1, 1.000);
NSLog(@"%@", NSStringFromCGRect(r));
NSLog(@"%@", NSStringFromCGRect(CGRectIntegral(r)));
NSLog(@"%@", NSStringFromCGRect(CGRectMake(floorf(r.origin.x), floorf(r.origin.y), floorf(r.size.width), floorf(r.size.height))));
NSLog(@"%@", NSStringFromCGRect(CGRectMake(ceilf(r.origin.x), ceilf(r.origin.y), ceilf(r.size.width), ceilf(r.size.height))));
STAssertTrue(CGRectEqualToRect(r, CGRectIntegral(r)), nil, nil);
}
// http://svn.gna.org/svn/gnustep/libs/opal/trunk/Source/OpalGraphics/CGGeometry.m
// GNUStep曰く結果はこれで正しい
/*
{{1.222, 1.3333}, {1, 1}}
{{1, 1}, {2, 2}}
{{1, 1}, {1, 1}}
{{2, 2}, {2, 1}}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment