Changeset 2133
- Timestamp:
- 11/21/04 12:10:34 (4 years ago)
- Files:
-
- trunk/NSColorAdditions.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/NSColorAdditions.m
r1823 r2133 134 134 - (NSString *) HTMLAttributeValue { 135 135 float red = 0., green = 0., blue = 0.; 136 [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:NULL]; 136 NSColor *color = self; 137 if( ! [[self colorSpaceName] isEqualToString:NSCalibratedRGBColorSpace] && ! [[self colorSpaceName] isEqualToString:NSDeviceRGBColorSpace] ) 138 color = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; // we need to convert to RGB space 139 [color getRed:&red green:&green blue:&blue alpha:NULL]; 137 140 return [NSString stringWithFormat:@"#%02x%02x%02x", (int)(red * 255), (int)(green * 255), (int)(blue * 255)]; 138 141 } … … 140 143 - (NSString *) CSSAttributeValue { 141 144 float red = 0., green = 0., blue = 0., alpha = 0.; 142 [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha]; 145 NSColor *color = self; 146 if( ! [[self colorSpaceName] isEqualToString:NSCalibratedRGBColorSpace] && ! [[self colorSpaceName] isEqualToString:NSDeviceRGBColorSpace] ) 147 color = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; // we need to convert to RGB space 148 [color getRed:&red green:&green blue:&blue alpha:&alpha]; 143 149 if( alpha < 1. ) return [NSString stringWithFormat:@"rgba( %d, %d, %d, %.3f )", (int)(red * 255), (int)(green * 255), (int)(blue * 255), alpha]; 144 150 return [NSString stringWithFormat:@"#%02x%02x%02x", (int)(red * 255), (int)(green * 255), (int)(blue * 255)];
