Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: f41913bcaf
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 86 lines (59 sloc) 2.378 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
//
// SSDrawingUtilities.h
// SSToolkit
//
// Created by Sam Soffes on 4/22/10.
// Copyright 2010-2011 Sam Soffes. All rights reserved.
//

#ifndef SSDRAWINGUTILITIES
#define SSDRAWINGUTILITIES

///-----------------------------------
/// @name Degree and Radian Conversion
///-----------------------------------

/**
A macro that converts a number from degress to radians.
@param d number in degrees
@return The number converted to radians.
*/
#define DEGREES_TO_RADIANS(d) ((d) * 0.0174532925199432958f)

/**
A macro that converts a number from radians to degrees.
@param r number in radians
@return The number converted to degrees.
*/
#define RADIANS_TO_DEGREES(r) ((r) * 57.29577951308232f)

#endif

/**
Limits a float to the `min` or `max` value. The float is between `min` and `max` it will be returned unchanged.
@param f The float to limit.
@param min The minumum value for the float.
@param max The minumum value for the float.
@return A float limited to the `min` or `max` value.
*/
extern CGFloat SSFLimit(CGFloat f, CGFloat min, CGFloat max);


///-----------------------------
/// @name Rectangle Manipulation
///-----------------------------

extern CGRect CGRectSetX(CGRect rect, CGFloat x);
extern CGRect CGRectSetY(CGRect rect, CGFloat y);
extern CGRect CGRectSetWidth(CGRect rect, CGFloat width);
extern CGRect CGRectSetHeight(CGRect rect, CGFloat height);
extern CGRect CGRectSetOrigin(CGRect rect, CGPoint origin);
extern CGRect CGRectSetSize(CGRect rect, CGSize size);
extern CGRect CGRectSetZeroOrigin(CGRect rect);
extern CGRect CGRectSetZeroSize(CGRect rect);
extern CGSize CGSizeAspectScaleToSize(CGSize size, CGSize toSize);
extern CGRect CGRectAddPoint(CGRect rect, CGPoint point);


///---------------------------------
/// @name Drawing Rounded Rectangles
///---------------------------------

extern void SSDrawRoundedRect(CGContextRef context, CGRect rect, CGFloat cornerRadius);


///-------------------------
/// @name Creating Gradients
///-------------------------

extern CGGradientRef SSCreateGradientWithColors(NSArray *colors);
extern CGGradientRef SSCreateGradientWithColorsAndLocations(NSArray *colors, NSArray *locations);


///------------------------
/// @name Drawing Gradients
///------------------------

extern void SSDrawGradientInRect(CGContextRef context, CGGradientRef gradient, CGRect rect);
Something went wrong with that request. Please try again.