Ticket #2262: contrastingColor.diff
| File contrastingColor.diff, 2.9 kB (added by freakman, 3 years ago) |
|---|
-
Frameworks/AIUtilities
old new 259 259 return ([[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] brightnessComponent] < 0.5); 260 260 } 261 261 262 - (BOOL)colorIsMedium 263 { 264 float brightness = [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] brightnessComponent]; 265 return (0.35 < brightness && brightness < 0.65); 266 } 267 262 268 //Percent should be -1.0 to 1.0 (negatives will make the color brighter) 263 269 - (NSColor *)darkenBy:(float)amount 264 270 { … … 313 319 return [NSColor colorWithCalibratedHue:h luminance:l saturation:s alpha:1.0]; 314 320 } 315 321 322 //Returns a color that contrasts well with this one 323 - (NSColor *)contrastingColor 324 { 325 if ([self colorIsMedium]) { 326 if ([self colorIsDark]) 327 return [NSColor whiteColor]; 328 else 329 return [NSColor blackColor]; 330 } else { 331 return [NSColor colorWithCalibratedRed:1.0 - [self redComponent] 332 green:1.0 - [self greenComponent] 333 blue:1.0 - [self blueComponent] 334 alpha:1.0]; 335 } 336 } 337 316 338 - (void)getHue:(float *)hue luminance:(float *)luminance saturation:(float *)saturation 317 339 { 318 340 NSColor *rgbColor; -
Frameworks/AIUtilities
old new 39 39 + (NSControlTint)currentControlTintSupportingJag; 40 40 - (BOOL)equalToRGBColor:(NSColor *)inColor; 41 41 - (BOOL)colorIsDark; 42 - (BOOL)colorIsMedium; 42 43 - (NSColor *)darkenBy:(float)amount; 43 44 - (NSColor *)darkenAndAdjustSaturationBy:(float)amount; 44 45 - (NSString *)hexString; … … 46 47 - (void)getHue:(float *)hue luminance:(float *)luminance saturation:(float *)saturation; 47 48 + (NSColor *)colorWithCalibratedHue:(float)hue luminance:(float)luminance saturation:(float)saturation alpha:(float)alpha; 48 49 - (NSColor *)colorWithInvertedLuminance; 50 - (NSColor *)contrastingColor; 49 51 - (NSColor *)adjustHue:(float)dHue saturation:(float)dSat brightness:(float)dBrit; 50 52 51 53 //these use arc4random() for their random numbers. there is no need to seed anything. -
Frameworks/Adium
old new 354 354 [self setBackgroundColor:cachedWhiteColor]; 355 355 } 356 356 357 [self setInsertionPointColor:[backgroundColor co lorWithInvertedLuminance]];357 [self setInsertionPointColor:[backgroundColor contrastingColor]]; 358 358 } 359 359 360 360 //Paste as rich text without altering our typing attributes