Advertisement
Guest User

UIColor-Expanded.h

a guest
Dec 25th, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <UIKit/UIKit.h>
  2.  
  3. #define SUPPORTS_UNDOCUMENTED_API   0
  4.  
  5. @interface UIColor (BGSCMYKAdditions)
  6.  
  7. - (NSDictionary *)cmykValues;
  8.  
  9. @end
  10.  
  11. @interface UIColor (UIColor_Expanded)
  12. @property (nonatomic, readonly) CGColorSpaceModel colorSpaceModel;
  13. @property (nonatomic, readonly) BOOL canProvideRGBComponents;
  14.  
  15. // With the exception of -alpha, these properties will function
  16. // correctly only if this color is an RGB or white color.
  17. // In these cases, canProvideRGBComponents returns YES.
  18. @property (nonatomic, readonly) CGFloat red;
  19. @property (nonatomic, readonly) CGFloat green;
  20. @property (nonatomic, readonly) CGFloat blue;
  21. @property (nonatomic, readonly) CGFloat white;
  22. @property (nonatomic, readonly) CGFloat hue;
  23. @property (nonatomic, readonly) CGFloat saturation;
  24. @property (nonatomic, readonly) CGFloat brightness;
  25. @property (nonatomic, readonly) CGFloat alpha;
  26. @property (nonatomic, readonly) CGFloat luminance;
  27. @property (nonatomic, readonly) UInt32 rgbHex;
  28.  
  29. - (NSString *)colorSpaceString;
  30. - (NSArray *)arrayFromRGBAComponents;
  31.  
  32. // Bulk access to RGB and HSB components of the color
  33. // HSB components are converted from the RGB components
  34. - (BOOL)red:(CGFloat *)r green:(CGFloat *)g blue:(CGFloat *)b alpha:(CGFloat *)a;
  35. - (BOOL)hue:(CGFloat *)h saturation:(CGFloat *)s brightness:(CGFloat *)b alpha:(CGFloat *)a;
  36.  
  37. // Return a grey-scale representation of the color
  38. - (UIColor *)colorByLuminanceMapping;
  39.  
  40. // Arithmetic operations on the color
  41. - (UIColor *)colorByMultiplyingByRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
  42. - (UIColor *)       colorByAddingRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
  43. - (UIColor *) colorByLighteningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
  44. - (UIColor *)  colorByDarkeningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
  45.  
  46. - (UIColor *)colorByMultiplyingBy:(CGFloat)f;
  47. - (UIColor *)       colorByAdding:(CGFloat)f;
  48. - (UIColor *) colorByLighteningTo:(CGFloat)f;
  49. - (UIColor *)  colorByDarkeningTo:(CGFloat)f;
  50.  
  51. - (UIColor *)colorByMultiplyingByColor:(UIColor *)color;
  52. - (UIColor *)       colorByAddingColor:(UIColor *)color;
  53. - (UIColor *) colorByLighteningToColor:(UIColor *)color;
  54. - (UIColor *)  colorByDarkeningToColor:(UIColor *)color;
  55.  
  56. // Related colors
  57. - (UIColor *)contrastingColor;          // A good contrasting color: will be either black or white
  58. - (UIColor *)complementaryColor;        // A complementary color that should look good with this color
  59. - (NSArray*)triadicColors;              // Two colors that should look good with this color
  60. - (NSArray*)analogousColorsWithStepAngle:(CGFloat)stepAngle pairCount:(int)pairs;   // Multiple pairs of colors
  61.  
  62. // String representations of the color
  63. - (NSString *)stringFromColor;
  64. - (NSString *)hexStringFromColor;
  65.  
  66. // The named color that matches this one most closely
  67. - (NSString *)closestColorName;
  68. - (NSString *)closestCrayonName;
  69.  
  70. // Color builders
  71. + (UIColor *)randomColor;
  72. + (UIColor *)colorWithString:(NSString *)stringToConvert;
  73. + (UIColor *)colorWithRGBHex:(UInt32)hex;
  74. + (UIColor *)colorWithHexString:(NSString *)stringToConvert;
  75. + (UIColor *)colorWithName:(NSString *)cssColorName;
  76. + (UIColor *)crayonWithName:(NSString *)crayonColorName;
  77.  
  78. // Return a dictionary mapping color names to colors.
  79. // The named are from the css3 color specification.
  80. + (NSDictionary *)namedColors;
  81.  
  82. // Return a dictionary mapping color names to colors
  83. // The named are standard Crayola style colors
  84. + (NSDictionary *)namedCrayons;
  85.  
  86. // Build a color with the given HSB values
  87. + (UIColor *)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha;
  88.  
  89. // Low level conversions between RGB and HSL spaces
  90. + (void)hue:(CGFloat)h saturation:(CGFloat)s brightness:(CGFloat)v toRed:(CGFloat *)r green:(CGFloat *)g blue:(CGFloat *)b;
  91. + (void)red:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b toHue:(CGFloat *)h saturation:(CGFloat *)s brightness:(CGFloat *)v;
  92.  
  93. @end
  94.  
  95. #if SUPPORTS_UNDOCUMENTED_API
  96. // UIColor_Undocumented_Expanded
  97. // Methods which rely on undocumented methods of UIColor
  98. @interface UIColor (UIColor_Undocumented_Expanded)
  99. - (NSString *)fetchStyleString;
  100. - (UIColor *)rgbColor; // Via Poltras
  101. @end
  102. #endif // SUPPORTS_UNDOCUMENTED_API
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement