Adium

Ticket #2262: contrastingColor.diff

File contrastingColor.diff, 2.9 kB (added by freakman, 3 years ago)

The newest one

  • Frameworks/AIUtilities

    old new  
    259259    return ([[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] brightnessComponent] < 0.5); 
    260260} 
    261261 
     262- (BOOL)colorIsMedium 
     263{ 
     264        float brightness = [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] brightnessComponent]; 
     265        return (0.35 < brightness && brightness < 0.65); 
     266} 
     267 
    262268//Percent should be -1.0 to 1.0 (negatives will make the color brighter) 
    263269- (NSColor *)darkenBy:(float)amount 
    264270{ 
     
    313319    return [NSColor colorWithCalibratedHue:h luminance:l saturation:s alpha:1.0]; 
    314320} 
    315321 
     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 
    316338- (void)getHue:(float *)hue luminance:(float *)luminance saturation:(float *)saturation 
    317339{ 
    318340    NSColor     *rgbColor; 
  • Frameworks/AIUtilities

    old new  
    3939+ (NSControlTint)currentControlTintSupportingJag; 
    4040- (BOOL)equalToRGBColor:(NSColor *)inColor; 
    4141- (BOOL)colorIsDark; 
     42- (BOOL)colorIsMedium; 
    4243- (NSColor *)darkenBy:(float)amount; 
    4344- (NSColor *)darkenAndAdjustSaturationBy:(float)amount; 
    4445- (NSString *)hexString; 
     
    4647- (void)getHue:(float *)hue luminance:(float *)luminance saturation:(float *)saturation; 
    4748+ (NSColor *)colorWithCalibratedHue:(float)hue luminance:(float)luminance saturation:(float)saturation alpha:(float)alpha; 
    4849- (NSColor *)colorWithInvertedLuminance; 
     50- (NSColor *)contrastingColor; 
    4951- (NSColor *)adjustHue:(float)dHue saturation:(float)dSat brightness:(float)dBrit; 
    5052 
    5153//these use arc4random() for their random numbers. there is no need to seed anything. 
  • Frameworks/Adium

    old new  
    354354                [self setBackgroundColor:cachedWhiteColor]; 
    355355        } 
    356356         
    357         [self setInsertionPointColor:[backgroundColor colorWithInvertedLuminance]]; 
     357        [self setInsertionPointColor:[backgroundColor contrastingColor]]; 
    358358} 
    359359 
    360360//Paste as rich text without altering our typing attributes