Created
June 17, 2013 14:35
-
-
Save aegzorz/5797337 to your computer and use it in GitHub Desktop.
Some functions for dealing with CGRects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static __inline__ CGRect CGRectFromCGSize( CGSize size ) { | |
return CGRectMake( 0, 0, size.width, size.height ); | |
}; | |
static __inline__ CGRect CGRectMakeWithCenterAndSize( CGPoint center, CGSize size ) { | |
return CGRectMake( center.x - size.width * 0.5, center.y - size.height * 0.5, size.width, size.height ); | |
}; | |
static __inline__ CGRect CGRectMakeWithOriginAndSize( CGPoint origin, CGSize size ) { | |
return CGRectMake( origin.x, origin.y, size.width, size.height ); | |
}; | |
static __inline__ CGPoint CGRectCenter( CGRect rect ) { | |
return CGPointMake( CGRectGetMidX( rect ), CGRectGetMidY( rect ) ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment