Skip to content

Instantly share code, notes, and snippets.

@aegzorz
Created June 17, 2013 14:35
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save aegzorz/5797337 to your computer and use it in GitHub Desktop.
Save aegzorz/5797337 to your computer and use it in GitHub Desktop.
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