Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Some functions for dealing with CGRects
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