Skip to content

Instantly share code, notes, and snippets.

@novi novi/test.m
Created May 28, 2011

Embed
What would you like to do?
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
You can’t perform that action at this time.