Skip to content

Instantly share code, notes, and snippets.

@pyrou
Created March 18, 2016 09:26
Show Gist options
  • Save pyrou/5cf1faeb85df4bb36fa0 to your computer and use it in GitHub Desktop.
Save pyrou/5cf1faeb85df4bb36fa0 to your computer and use it in GitHub Desktop.
#ifndef __CGRECT_MACROS__
#define __CGRECT_MACROS__
#define CGRectX(rect) rect.origin.x
#define CGRectY(rect) rect.origin.y
#define CGRectWidth(rect) rect.size.width
#define CGRectHeight(rect) rect.size.height
#define CGRectSetSize(rect, w, h) CGRectMake(CGRectX(rect), CGRectY(rect), w, h)
#define CGRectSetOrigin(rect, x, y) CGRectMake(x, y, CGRectWidth(rect), CGRectHeight(rect))
#define CGRectSetWidth(rect, w) CGRectSetSize(rect, w, CGRectHeight(rect))
#define CGRectSetHeight(rect, h) CGRectSetSize(rect, CGRectWidth(rect), h)
#define CGRectSetX(rect, x) CGRectSetOrigin(rect, x, CGRectY(rect))
#define CGRectSetY(rect, y) CGRectSetOrigin(rect, CGRectX(rect), y)
#endif /* __CGRECT_MACROS__ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment