Skip to content

Commit

Permalink
Hey, docstrings!
Browse files Browse the repository at this point in the history
  • Loading branch information
kreeger committed Jan 2, 2013
1 parent f5e3af1 commit d49d3e0
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
80 changes: 80 additions & 0 deletions BDKGeometry.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,93 @@
/*
* BDKGeometry.h
* Written by Ben Kreeger.
*/

/** Gives a rect a new size.
* @param rect the rect on which to operate.
* @param size a new CGSize to assign to `rect`.
* @return a new rect with the given size.
*/
CGRect CGRectAdjustSize(CGRect rect, CGSize size);

/** Gives a rect a new origin.
* @param rect the rect on which to operate.
* @param origin a new origin CGPoint to assign to `rect`.
* @return a new rect with the given origin.
*/
CGRect CGRectAdjustOrigin(CGRect rect, CGPoint origin);

/** Gives a rect's size a new width.
* @param rect the rect on which to operate.
* @param width a new width CGFloat to assign to `rect`.
* @return a new rect with the given width.
*/
CGRect CGRectAdjustWidth(CGRect rect, CGFloat width);

/** Gives a rect a new height.
* @param rect the rect on which to operate.
* @param size a new height CGFloat to assign to `rect`.
* @return a new rect with the given height.
*/
CGRect CGRectAdjustHeight(CGRect rect, CGFloat height);

/** Gives a rect a new y-origin.
* @param rect the rect on which to operate.
* @param size a new y-origin CGFloat to assign to `rect`.
* @return a new rect with the given y-origin.
*/
CGRect CGRectAdjustYOrigin(CGRect rect, CGFloat yOrigin);

/** Gives a rect a new x-origin.
* @param rect the rect on which to operate.
* @param size a new x-origin CGFloat to assign to `rect`.
* @return a new rect with the given x-origin.
*/
CGRect CGRectAdjustXOrigin(CGRect rect, CGFloat xOrigin);

/** Centers a child (sub) rect inside of a parent (master) rect, using both width and height.
* @param subRect the child rect, which will be altered and returned.
* @param masterRect the parent rect in which to center `subRect`.
* @return the modified `subRect`.
*/
CGRect CGRectCenterRectInRect(CGRect subRect, CGRect masterRect);

/** Centers a child (sub) rect inside of a parent (master) rect horizontally (only modifies x-origin).
* @param subRect the child rect, which will be altered and returned.
* @param masterRect the parent rect in which to center `subRect` horizontally.
* @return the modified `subRect`.
*/
CGRect CGRectCenterRectInRectHorizontally(CGRect subRect, CGRect masterRect);

/** Centers a child (sub) rect inside of a parent (master) rect vertically (only modifies y-origin).
* @param subRect the child rect, which will be altered and returned.
* @param masterRect the parent rect in which to center `subRect` vertically.
* @return the modified `subRect`.
*/
CGRect CGRectCenterRectInRectVertically(CGRect subRect, CGRect masterRect);

/** Calls `CGRectInset` on a given rect, and multiplies inset by the percentage given for both width and height.
* @param rect the rect which will be altered and returned.
* @param xPercent the percentage by which to multiply the `rect`'s width.
* @param yPercent the percentage by which to multiply the `rect`'s height.
* @return the modified `rect`.
*/
CGRect CGRectInsetByPercent(CGRect rect, CGFloat xPercent, CGFloat yPercent);

/** Modifies a given view's frame by calling `-[UIView sizeToFit]` on itself, and then ensuring it's integral by
* calling `CGRectIntegral` on the view's new frame.
* @param view the view on which to operate.
*/
void CGRectIntegralSizeToFit(UIView *view);

/** Doubles the size of a given size by multiplying width and height by a factor of 2.
* @param size the size to double.
* @return a new doubled size.
*/
CGSize CGSizeByDoubling(CGSize size);

/** Doubles the size of a given rect by multiplying width and height by a factor of 2, keeping the same origin.
* @param rect the rect whose size to double.
* @return a new doubled-size rect.
*/
CGRect CGRectByDoublingSize(CGRect rect);
5 changes: 5 additions & 0 deletions BDKGeometry.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* BDKGeometry.m
* Written by Ben Kreeger.
*/

CGRect CGRectAdjustSize(CGRect rect, CGSize size) {
rect.size = size;
return rect;
Expand Down

0 comments on commit d49d3e0

Please sign in to comment.