Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Added random color class method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Ruegenberg committed Oct 18, 2012
1 parent 834200a commit a67b4a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions UIKit/Drawing/UIColor+HelperAdditions.h
Expand Up @@ -26,6 +26,11 @@
*/ */
- (UIColor *)colorMultipliedByScalar:(CGFloat)scalar withMinimum:(CGFloat)min; - (UIColor *)colorMultipliedByScalar:(CGFloat)scalar withMinimum:(CGFloat)min;


/**
A fully saturated random color. use this for debugging your drawing code.
*/
+ (UIColor *)randomColor;

@end @end


#define RGB(rVal, gVal, bVal) [UIColor colorWithRed:rVal green:gVal blue:bVal alpha:1.0] #define RGB(rVal, gVal, bVal) [UIColor colorWithRed:rVal green:gVal blue:bVal alpha:1.0]
Expand Down
4 changes: 4 additions & 0 deletions UIKit/Drawing/UIColor+HelperAdditions.m
Expand Up @@ -40,4 +40,8 @@ - (UIColor *)colorMultipliedByScalar:(CGFloat)scalar {
return [self colorMultipliedByScalar:scalar withMinimum:0.0]; return [self colorMultipliedByScalar:scalar withMinimum:0.0];
} }


+ (UIColor *)randomColor {
return [UIColor colorWithHue:(rand() / (CGFloat)RAND_MAX) saturation:1.0 brightness:1.0 alpha:1.0];
}

@end @end

0 comments on commit a67b4a6

Please sign in to comment.