|
@@ -59,279 +59,279 @@
|
|
|
// SKAddInstanceMethodImplementationFromSelector(self, @selector(CGColor), @selector(fallback_CGColor));
|
|
|
//}
|
|
|
|
|
|
-+ (NSColor *)keySourceListViewHighlightColor {
|
|
|
- static NSColor *color = nil;
|
|
|
- static NSColor *graphiteColor = nil;
|
|
|
- if ([NSColor currentControlTint] == NSGraphiteControlTint) {
|
|
|
- if (graphiteColor == nil)
|
|
|
- graphiteColor = [NSColor colorWithCalibratedRed:0.390 green:0.453 blue:0.534 alpha:1.0];
|
|
|
- return graphiteColor;
|
|
|
- } else {
|
|
|
- if (color == nil)
|
|
|
- color = [NSColor colorWithCalibratedRed:0.251 green:0.487 blue:0.780 alpha:1.0];
|
|
|
- return color;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSColor *)mainSourceListViewHighlightColor {
|
|
|
- static NSColor *color = nil;
|
|
|
- static NSColor *graphiteColor = nil;
|
|
|
- if ([NSColor currentControlTint] == NSGraphiteControlTint) {
|
|
|
- if (graphiteColor == nil)
|
|
|
- graphiteColor = [NSColor colorWithCalibratedRed:0.572 green:0.627 blue:0.680 alpha:1.0];
|
|
|
- return graphiteColor;
|
|
|
- } else {
|
|
|
- if (color == nil)
|
|
|
- color = [NSColor colorWithCalibratedRed:0.556 green:0.615 blue:0.748 alpha:1.0];
|
|
|
- return color;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSColor *)disabledSourceListViewHighlightColor {
|
|
|
- static NSColor *color = nil;
|
|
|
- static NSColor *graphiteColor = nil;
|
|
|
- if ([NSColor currentControlTint] == NSGraphiteControlTint) {
|
|
|
- if (graphiteColor == nil)
|
|
|
- graphiteColor = [NSColor colorWithCalibratedRed:0.576 green:0.576 blue:0.576 alpha:1.0];
|
|
|
- return graphiteColor;
|
|
|
- } else {
|
|
|
- if (color == nil)
|
|
|
- color = [NSColor colorWithCalibratedRed:0.576 green:0.576 blue:0.576 alpha:1.0];
|
|
|
- return color;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSColor *)mainSourceListBackgroundColor {
|
|
|
- static NSColor *color = nil;
|
|
|
- if (color == nil)
|
|
|
- color = [NSColor colorWithCalibratedRed:0.839216 green:0.866667 blue:0.898039 alpha:1.0];
|
|
|
- return color;
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSColor *)sourceListHighlightColorForView:(NSView *)view {
|
|
|
- NSWindow *window = [view window];
|
|
|
- if ([window isKeyWindow] && [window firstResponder] == view)
|
|
|
- return [self keySourceListViewHighlightColor];
|
|
|
- else if ([window isMainWindow] || [window isKeyWindow])
|
|
|
- return [self mainSourceListViewHighlightColor];
|
|
|
- else
|
|
|
- return [self disabledSourceListViewHighlightColor];
|
|
|
-}
|
|
|
-
|
|
|
-- (uint32_t)km_uint32HSBAValue {
|
|
|
- NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
- if (rgbColor) {
|
|
|
- CGFloat h = 0.0, s = 0.0, b = 0.0, a = 0.0;
|
|
|
- [rgbColor getHue:&h saturation:&s brightness:&b alpha:&a];
|
|
|
- union _ {
|
|
|
- struct {
|
|
|
- uint8_t h;
|
|
|
- uint8_t s;
|
|
|
- uint8_t b;
|
|
|
- uint8_t a;
|
|
|
- } hsba;
|
|
|
- uint32_t uintValue;
|
|
|
- } u;
|
|
|
- u.hsba.h = (uint8_t)(h * 255);
|
|
|
- u.hsba.s = (uint8_t)(s * 255);
|
|
|
- u.hsba.b = (uint8_t)(b * 255);
|
|
|
- u.hsba.a = (uint8_t)(a * 255);
|
|
|
- return CFSwapInt32HostToBig(u.uintValue);
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSComparisonResult)colorCompare:(NSColor *)aColor {
|
|
|
- uint32_t value1 = [self km_uint32HSBAValue];
|
|
|
- uint32_t value2 = [aColor km_uint32HSBAValue];
|
|
|
- if (value1 < value2)
|
|
|
- return NSOrderedAscending;
|
|
|
- else if (value1 > value2)
|
|
|
- return NSOrderedDescending;
|
|
|
- else
|
|
|
- return NSOrderedSame;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)drawSwatchInRoundedRect:(NSRect)rect {
|
|
|
- NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:3.0 yRadius:3.0];
|
|
|
- [path setLineWidth:2.0];
|
|
|
- [path addClip];
|
|
|
- [self drawSwatchInRect:rect];
|
|
|
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.3] setStroke];
|
|
|
- [path stroke];
|
|
|
-}
|
|
|
-
|
|
|
-+ (id)scriptingRgbaColorWithDescriptor:(NSAppleEventDescriptor *)descriptor {
|
|
|
- if ([descriptor numberOfItems] > 0) {
|
|
|
- CGFloat red, green, blue, alpha;
|
|
|
- red = green = blue = (CGFloat)[[descriptor descriptorAtIndex:1] int32Value] / 65535.0f;
|
|
|
- if ([descriptor numberOfItems] > 2) {
|
|
|
- green = (CGFloat)[[descriptor descriptorAtIndex:2] int32Value] / 65535.0f;
|
|
|
- blue = (CGFloat)[[descriptor descriptorAtIndex:3] int32Value] / 65535.0f;
|
|
|
- }
|
|
|
- if ([descriptor numberOfItems] == 2)
|
|
|
- alpha = (CGFloat)[[descriptor descriptorAtIndex:2] int32Value] / 65535.0f;
|
|
|
- else if ([descriptor numberOfItems] > 3)
|
|
|
- alpha = (CGFloat)[[descriptor descriptorAtIndex:4] int32Value] / 65535.0f;
|
|
|
- else
|
|
|
- alpha= 1.0;
|
|
|
- return [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:alpha];
|
|
|
- } else {
|
|
|
- switch ([descriptor enumCodeValue]) {
|
|
|
- case SKScriptingColorRed: return [NSColor redColor];
|
|
|
- case SKScriptingColorGreen: return [NSColor greenColor];
|
|
|
- case SKScriptingColorBlue: return [NSColor blueColor];
|
|
|
- case SKScriptingColorYellow: return [NSColor yellowColor];
|
|
|
- case SKScriptingColorMagenta: return [NSColor magentaColor];
|
|
|
- case SKScriptingColorCyan: return [NSColor cyanColor];
|
|
|
- case SKScriptingColorDarkRed: return [NSColor colorWithCalibratedRed:0.5 green:0.0 blue:0.0 alpha:1.0];
|
|
|
- case SKScriptingColorDarkGreen: return [NSColor colorWithCalibratedRed:0.0 green:0.5 blue:0.0 alpha:1.0];
|
|
|
- case SKScriptingColorDarkBlue: return [NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.5 alpha:1.0];
|
|
|
- case SKScriptingColorBanana: return [NSColor colorWithCalibratedRed:1.0 green:1.0 blue:0.5 alpha:1.0];
|
|
|
- case SKScriptingColorTurquoise: return [NSColor colorWithCalibratedRed:1.0 green:0.5 blue:1.0 alpha:1.0];
|
|
|
- case SKScriptingColorViolet: return [NSColor colorWithCalibratedRed:0.5 green:1.0 blue:1.0 alpha:1.0];
|
|
|
- case SKScriptingColorOrange: return [NSColor orangeColor];
|
|
|
- case SKScriptingColorDeepPink: return [NSColor colorWithCalibratedRed:1.0 green:0.0 blue:0.5 alpha:1.0];
|
|
|
- case SKScriptingColorSpringGreen: return [NSColor colorWithCalibratedRed:0.0 green:1.0 blue:0.5 alpha:1.0];
|
|
|
- case SKScriptingColorAqua: return [NSColor colorWithCalibratedRed:0.0 green:0.5 blue:1.0 alpha:1.0];
|
|
|
- case SKScriptingColorLime: return [NSColor colorWithCalibratedRed:0.5 green:1.0 blue:0.0 alpha:1.0];
|
|
|
- case SKScriptingColorDarkViolet: return [NSColor colorWithCalibratedRed:0.5 green:0.0 blue:1.0 alpha:1.0];
|
|
|
- case SKScriptingColorPurple: return [NSColor purpleColor];
|
|
|
- case SKScriptingColorTeal: return [NSColor colorWithCalibratedRed:0.0 green:0.5 blue:0.5 alpha:1.0];
|
|
|
- case SKScriptingColorOlive: return [NSColor colorWithCalibratedRed:0.5 green:0.5 blue:0.0 alpha:1.0];
|
|
|
- case SKScriptingColorBrown: return [NSColor brownColor];
|
|
|
- case SKScriptingColorBlack: return [NSColor blackColor];
|
|
|
- case SKScriptingColorWhite: return [NSColor whiteColor];
|
|
|
- case SKScriptingColorGray: return [NSColor grayColor];
|
|
|
- case SKScriptingColorDarkGray: return [NSColor darkGrayColor];
|
|
|
- case SKScriptingColorLightGray: return [NSColor lightGrayColor];
|
|
|
- case SKScriptingColorClear: return [NSColor clearColor];
|
|
|
- default:
|
|
|
- {
|
|
|
- // Cocoa Scripting defines coercions from string to color for some standard color names
|
|
|
- NSString *string = [descriptor stringValue];
|
|
|
- if (string) {
|
|
|
- NSColor *color = [[NSScriptCoercionHandler sharedCoercionHandler] coerceValue:string toClass:[NSColor class]];
|
|
|
- // We should check the return value, because NSScriptCoercionHandler returns the input when it fails rather than nil, stupid
|
|
|
- return [color isKindOfClass:[NSColor class]] ? color : nil;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return nil;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (id)scriptingRgbaColorDescriptor;
|
|
|
-{
|
|
|
- CGFloat red, green, blue, alpha;
|
|
|
- [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
-
|
|
|
- NSAppleEventDescriptor *descriptor = [NSAppleEventDescriptor listDescriptor];
|
|
|
- [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * red)] atIndex:1];
|
|
|
- [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * green)] atIndex:2];
|
|
|
- [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * blue)] atIndex:3];
|
|
|
- [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * alpha)] atIndex:4];
|
|
|
-
|
|
|
- return descriptor;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)accessibilityValue {
|
|
|
- static NSColorWell *colorWell = nil;
|
|
|
- if (colorWell == nil)
|
|
|
- colorWell = [[NSColorWell alloc] init];
|
|
|
- [colorWell setColor:self];
|
|
|
- return [colorWell accessibilityAttributeValue:NSAccessibilityValueAttribute];
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)hexString {
|
|
|
- NSColor *rgbColor = [self colorUsingColorSpace:[NSColorSpace sRGBColorSpace]];
|
|
|
- if (rgbColor) {
|
|
|
- CGFloat r = 0.0, g = 0.0, b = 0.0, a = 0.0;
|
|
|
- [rgbColor getRed:&r green:&g blue:&b alpha:&a];
|
|
|
- return [NSString stringWithFormat:@"#%02x%02x%02x", (unsigned int)(r * 255), (unsigned int)(g * 255), (unsigned int)(b * 255)];
|
|
|
- }
|
|
|
- return nil;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)rgbString {
|
|
|
- NSColor *rgbColor = [self colorUsingColorSpace:[NSColorSpace sRGBColorSpace]];
|
|
|
- if (rgbColor) {
|
|
|
- CGFloat r = 0.0, g = 0.0, b = 0.0, a = 0.0;
|
|
|
- [rgbColor getRed:&r green:&g blue:&b alpha:&a];
|
|
|
- return [NSString stringWithFormat:@"(%u, %u, %u)", (unsigned int)(r * 255), (unsigned int)(g * 255), (unsigned int)(b * 255)];
|
|
|
- }
|
|
|
- return nil;
|
|
|
-}
|
|
|
-
|
|
|
-- (BOOL)isTheSameColor:(NSColor *)color2 {
|
|
|
- const CGFloat *component = CGColorGetComponents(self.CGColor);
|
|
|
- const CGFloat *component1 = CGColorGetComponents(color2.CGColor);
|
|
|
- if (![self km_compareSize:component[0] :component1[0]]) {
|
|
|
- return NO;
|
|
|
- }
|
|
|
-
|
|
|
- if (![self km_compareSize:component[1] :component1[1]]) {
|
|
|
- return NO;
|
|
|
- }
|
|
|
-
|
|
|
- if (![self km_compareSize:component[2] :component1[2]]) {
|
|
|
- return NO;
|
|
|
- }
|
|
|
-
|
|
|
- if (![self km_compareSize:component[3] :component1[3]]) {
|
|
|
- return NO;
|
|
|
- }
|
|
|
- return YES;
|
|
|
-}
|
|
|
-
|
|
|
--(BOOL)km_compareSize:(CGFloat)floa1 :(CGFloat)floa2
|
|
|
-{
|
|
|
- CGFloat t1 = [[NSString stringWithFormat:@"%.3f", floa1] floatValue];
|
|
|
- CGFloat t2 = [[NSString stringWithFormat:@"%.3f", floa2] floatValue];
|
|
|
- if (fabs(t1-t2)>1e-6) return NO;
|
|
|
-
|
|
|
- return YES;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)red {
|
|
|
- NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
- if (rgbColor) {
|
|
|
- CGFloat red,green,blue,alpha;
|
|
|
- [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
- return red;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)green {
|
|
|
- NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
- if (rgbColor) {
|
|
|
- CGFloat red,green,blue,alpha;
|
|
|
- [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
- return green;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)blue {
|
|
|
- NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
- if (rgbColor) {
|
|
|
- CGFloat red,green,blue,alpha;
|
|
|
- [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
- return blue;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)alpha {
|
|
|
- NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
- if (rgbColor) {
|
|
|
- CGFloat red,green,blue,alpha;
|
|
|
- [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
- return alpha;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
+//+ (NSColor *)keySourceListViewHighlightColor {
|
|
|
+// static NSColor *color = nil;
|
|
|
+// static NSColor *graphiteColor = nil;
|
|
|
+// if ([NSColor currentControlTint] == NSGraphiteControlTint) {
|
|
|
+// if (graphiteColor == nil)
|
|
|
+// graphiteColor = [NSColor colorWithCalibratedRed:0.390 green:0.453 blue:0.534 alpha:1.0];
|
|
|
+// return graphiteColor;
|
|
|
+// } else {
|
|
|
+// if (color == nil)
|
|
|
+// color = [NSColor colorWithCalibratedRed:0.251 green:0.487 blue:0.780 alpha:1.0];
|
|
|
+// return color;
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|
|
|
+//+ (NSColor *)mainSourceListViewHighlightColor {
|
|
|
+// static NSColor *color = nil;
|
|
|
+// static NSColor *graphiteColor = nil;
|
|
|
+// if ([NSColor currentControlTint] == NSGraphiteControlTint) {
|
|
|
+// if (graphiteColor == nil)
|
|
|
+// graphiteColor = [NSColor colorWithCalibratedRed:0.572 green:0.627 blue:0.680 alpha:1.0];
|
|
|
+// return graphiteColor;
|
|
|
+// } else {
|
|
|
+// if (color == nil)
|
|
|
+// color = [NSColor colorWithCalibratedRed:0.556 green:0.615 blue:0.748 alpha:1.0];
|
|
|
+// return color;
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|
|
|
+//+ (NSColor *)disabledSourceListViewHighlightColor {
|
|
|
+// static NSColor *color = nil;
|
|
|
+// static NSColor *graphiteColor = nil;
|
|
|
+// if ([NSColor currentControlTint] == NSGraphiteControlTint) {
|
|
|
+// if (graphiteColor == nil)
|
|
|
+// graphiteColor = [NSColor colorWithCalibratedRed:0.576 green:0.576 blue:0.576 alpha:1.0];
|
|
|
+// return graphiteColor;
|
|
|
+// } else {
|
|
|
+// if (color == nil)
|
|
|
+// color = [NSColor colorWithCalibratedRed:0.576 green:0.576 blue:0.576 alpha:1.0];
|
|
|
+// return color;
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|
|
|
+//+ (NSColor *)mainSourceListBackgroundColor {
|
|
|
+// static NSColor *color = nil;
|
|
|
+// if (color == nil)
|
|
|
+// color = [NSColor colorWithCalibratedRed:0.839216 green:0.866667 blue:0.898039 alpha:1.0];
|
|
|
+// return color;
|
|
|
+//}
|
|
|
+//
|
|
|
+//+ (NSColor *)sourceListHighlightColorForView:(NSView *)view {
|
|
|
+// NSWindow *window = [view window];
|
|
|
+// if ([window isKeyWindow] && [window firstResponder] == view)
|
|
|
+// return [self keySourceListViewHighlightColor];
|
|
|
+// else if ([window isMainWindow] || [window isKeyWindow])
|
|
|
+// return [self mainSourceListViewHighlightColor];
|
|
|
+// else
|
|
|
+// return [self disabledSourceListViewHighlightColor];
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (uint32_t)km_uint32HSBAValue {
|
|
|
+// NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+// if (rgbColor) {
|
|
|
+// CGFloat h = 0.0, s = 0.0, b = 0.0, a = 0.0;
|
|
|
+// [rgbColor getHue:&h saturation:&s brightness:&b alpha:&a];
|
|
|
+// union _ {
|
|
|
+// struct {
|
|
|
+// uint8_t h;
|
|
|
+// uint8_t s;
|
|
|
+// uint8_t b;
|
|
|
+// uint8_t a;
|
|
|
+// } hsba;
|
|
|
+// uint32_t uintValue;
|
|
|
+// } u;
|
|
|
+// u.hsba.h = (uint8_t)(h * 255);
|
|
|
+// u.hsba.s = (uint8_t)(s * 255);
|
|
|
+// u.hsba.b = (uint8_t)(b * 255);
|
|
|
+// u.hsba.a = (uint8_t)(a * 255);
|
|
|
+// return CFSwapInt32HostToBig(u.uintValue);
|
|
|
+// }
|
|
|
+// return 0;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (NSComparisonResult)colorCompare:(NSColor *)aColor {
|
|
|
+// uint32_t value1 = [self km_uint32HSBAValue];
|
|
|
+// uint32_t value2 = [aColor km_uint32HSBAValue];
|
|
|
+// if (value1 < value2)
|
|
|
+// return NSOrderedAscending;
|
|
|
+// else if (value1 > value2)
|
|
|
+// return NSOrderedDescending;
|
|
|
+// else
|
|
|
+// return NSOrderedSame;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (void)drawSwatchInRoundedRect:(NSRect)rect {
|
|
|
+// NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:3.0 yRadius:3.0];
|
|
|
+// [path setLineWidth:2.0];
|
|
|
+// [path addClip];
|
|
|
+// [self drawSwatchInRect:rect];
|
|
|
+// [[NSColor colorWithCalibratedWhite:0.0 alpha:0.3] setStroke];
|
|
|
+// [path stroke];
|
|
|
+//}
|
|
|
+//
|
|
|
+//+ (id)scriptingRgbaColorWithDescriptor:(NSAppleEventDescriptor *)descriptor {
|
|
|
+// if ([descriptor numberOfItems] > 0) {
|
|
|
+// CGFloat red, green, blue, alpha;
|
|
|
+// red = green = blue = (CGFloat)[[descriptor descriptorAtIndex:1] int32Value] / 65535.0f;
|
|
|
+// if ([descriptor numberOfItems] > 2) {
|
|
|
+// green = (CGFloat)[[descriptor descriptorAtIndex:2] int32Value] / 65535.0f;
|
|
|
+// blue = (CGFloat)[[descriptor descriptorAtIndex:3] int32Value] / 65535.0f;
|
|
|
+// }
|
|
|
+// if ([descriptor numberOfItems] == 2)
|
|
|
+// alpha = (CGFloat)[[descriptor descriptorAtIndex:2] int32Value] / 65535.0f;
|
|
|
+// else if ([descriptor numberOfItems] > 3)
|
|
|
+// alpha = (CGFloat)[[descriptor descriptorAtIndex:4] int32Value] / 65535.0f;
|
|
|
+// else
|
|
|
+// alpha= 1.0;
|
|
|
+// return [NSColor colorWithCalibratedRed:red green:green blue:blue alpha:alpha];
|
|
|
+// } else {
|
|
|
+// switch ([descriptor enumCodeValue]) {
|
|
|
+// case SKScriptingColorRed: return [NSColor redColor];
|
|
|
+// case SKScriptingColorGreen: return [NSColor greenColor];
|
|
|
+// case SKScriptingColorBlue: return [NSColor blueColor];
|
|
|
+// case SKScriptingColorYellow: return [NSColor yellowColor];
|
|
|
+// case SKScriptingColorMagenta: return [NSColor magentaColor];
|
|
|
+// case SKScriptingColorCyan: return [NSColor cyanColor];
|
|
|
+// case SKScriptingColorDarkRed: return [NSColor colorWithCalibratedRed:0.5 green:0.0 blue:0.0 alpha:1.0];
|
|
|
+// case SKScriptingColorDarkGreen: return [NSColor colorWithCalibratedRed:0.0 green:0.5 blue:0.0 alpha:1.0];
|
|
|
+// case SKScriptingColorDarkBlue: return [NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.5 alpha:1.0];
|
|
|
+// case SKScriptingColorBanana: return [NSColor colorWithCalibratedRed:1.0 green:1.0 blue:0.5 alpha:1.0];
|
|
|
+// case SKScriptingColorTurquoise: return [NSColor colorWithCalibratedRed:1.0 green:0.5 blue:1.0 alpha:1.0];
|
|
|
+// case SKScriptingColorViolet: return [NSColor colorWithCalibratedRed:0.5 green:1.0 blue:1.0 alpha:1.0];
|
|
|
+// case SKScriptingColorOrange: return [NSColor orangeColor];
|
|
|
+// case SKScriptingColorDeepPink: return [NSColor colorWithCalibratedRed:1.0 green:0.0 blue:0.5 alpha:1.0];
|
|
|
+// case SKScriptingColorSpringGreen: return [NSColor colorWithCalibratedRed:0.0 green:1.0 blue:0.5 alpha:1.0];
|
|
|
+// case SKScriptingColorAqua: return [NSColor colorWithCalibratedRed:0.0 green:0.5 blue:1.0 alpha:1.0];
|
|
|
+// case SKScriptingColorLime: return [NSColor colorWithCalibratedRed:0.5 green:1.0 blue:0.0 alpha:1.0];
|
|
|
+// case SKScriptingColorDarkViolet: return [NSColor colorWithCalibratedRed:0.5 green:0.0 blue:1.0 alpha:1.0];
|
|
|
+// case SKScriptingColorPurple: return [NSColor purpleColor];
|
|
|
+// case SKScriptingColorTeal: return [NSColor colorWithCalibratedRed:0.0 green:0.5 blue:0.5 alpha:1.0];
|
|
|
+// case SKScriptingColorOlive: return [NSColor colorWithCalibratedRed:0.5 green:0.5 blue:0.0 alpha:1.0];
|
|
|
+// case SKScriptingColorBrown: return [NSColor brownColor];
|
|
|
+// case SKScriptingColorBlack: return [NSColor blackColor];
|
|
|
+// case SKScriptingColorWhite: return [NSColor whiteColor];
|
|
|
+// case SKScriptingColorGray: return [NSColor grayColor];
|
|
|
+// case SKScriptingColorDarkGray: return [NSColor darkGrayColor];
|
|
|
+// case SKScriptingColorLightGray: return [NSColor lightGrayColor];
|
|
|
+// case SKScriptingColorClear: return [NSColor clearColor];
|
|
|
+// default:
|
|
|
+// {
|
|
|
+// // Cocoa Scripting defines coercions from string to color for some standard color names
|
|
|
+// NSString *string = [descriptor stringValue];
|
|
|
+// if (string) {
|
|
|
+// NSColor *color = [[NSScriptCoercionHandler sharedCoercionHandler] coerceValue:string toClass:[NSColor class]];
|
|
|
+// // We should check the return value, because NSScriptCoercionHandler returns the input when it fails rather than nil, stupid
|
|
|
+// return [color isKindOfClass:[NSColor class]] ? color : nil;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return nil;
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (id)scriptingRgbaColorDescriptor;
|
|
|
+//{
|
|
|
+// CGFloat red, green, blue, alpha;
|
|
|
+// [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
+//
|
|
|
+// NSAppleEventDescriptor *descriptor = [NSAppleEventDescriptor listDescriptor];
|
|
|
+// [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * red)] atIndex:1];
|
|
|
+// [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * green)] atIndex:2];
|
|
|
+// [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * blue)] atIndex:3];
|
|
|
+// [descriptor insertDescriptor:[NSAppleEventDescriptor descriptorWithInt32:round(65535 * alpha)] atIndex:4];
|
|
|
+//
|
|
|
+// return descriptor;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (NSString *)accessibilityValue {
|
|
|
+// static NSColorWell *colorWell = nil;
|
|
|
+// if (colorWell == nil)
|
|
|
+// colorWell = [[NSColorWell alloc] init];
|
|
|
+// [colorWell setColor:self];
|
|
|
+// return [colorWell accessibilityAttributeValue:NSAccessibilityValueAttribute];
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (NSString *)hexString {
|
|
|
+// NSColor *rgbColor = [self colorUsingColorSpace:[NSColorSpace sRGBColorSpace]];
|
|
|
+// if (rgbColor) {
|
|
|
+// CGFloat r = 0.0, g = 0.0, b = 0.0, a = 0.0;
|
|
|
+// [rgbColor getRed:&r green:&g blue:&b alpha:&a];
|
|
|
+// return [NSString stringWithFormat:@"#%02x%02x%02x", (unsigned int)(r * 255), (unsigned int)(g * 255), (unsigned int)(b * 255)];
|
|
|
+// }
|
|
|
+// return nil;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (NSString *)rgbString {
|
|
|
+// NSColor *rgbColor = [self colorUsingColorSpace:[NSColorSpace sRGBColorSpace]];
|
|
|
+// if (rgbColor) {
|
|
|
+// CGFloat r = 0.0, g = 0.0, b = 0.0, a = 0.0;
|
|
|
+// [rgbColor getRed:&r green:&g blue:&b alpha:&a];
|
|
|
+// return [NSString stringWithFormat:@"(%u, %u, %u)", (unsigned int)(r * 255), (unsigned int)(g * 255), (unsigned int)(b * 255)];
|
|
|
+// }
|
|
|
+// return nil;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (BOOL)isTheSameColor:(NSColor *)color2 {
|
|
|
+// const CGFloat *component = CGColorGetComponents(self.CGColor);
|
|
|
+// const CGFloat *component1 = CGColorGetComponents(color2.CGColor);
|
|
|
+// if (![self km_compareSize:component[0] :component1[0]]) {
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (![self km_compareSize:component[1] :component1[1]]) {
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (![self km_compareSize:component[2] :component1[2]]) {
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (![self km_compareSize:component[3] :component1[3]]) {
|
|
|
+// return NO;
|
|
|
+// }
|
|
|
+// return YES;
|
|
|
+//}
|
|
|
+//
|
|
|
+//-(BOOL)km_compareSize:(CGFloat)floa1 :(CGFloat)floa2
|
|
|
+//{
|
|
|
+// CGFloat t1 = [[NSString stringWithFormat:@"%.3f", floa1] floatValue];
|
|
|
+// CGFloat t2 = [[NSString stringWithFormat:@"%.3f", floa2] floatValue];
|
|
|
+// if (fabs(t1-t2)>1e-6) return NO;
|
|
|
+//
|
|
|
+// return YES;
|
|
|
+//
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (CGFloat)red {
|
|
|
+// NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+// if (rgbColor) {
|
|
|
+// CGFloat red,green,blue,alpha;
|
|
|
+// [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
+// return red;
|
|
|
+// }
|
|
|
+// return 0;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (CGFloat)green {
|
|
|
+// NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+// if (rgbColor) {
|
|
|
+// CGFloat red,green,blue,alpha;
|
|
|
+// [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
+// return green;
|
|
|
+// }
|
|
|
+// return 0;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (CGFloat)blue {
|
|
|
+// NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+// if (rgbColor) {
|
|
|
+// CGFloat red,green,blue,alpha;
|
|
|
+// [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
+// return blue;
|
|
|
+// }
|
|
|
+// return 0;
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (CGFloat)alpha {
|
|
|
+// NSColor *rgbColor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
|
+// if (rgbColor) {
|
|
|
+// CGFloat red,green,blue,alpha;
|
|
|
+// [rgbColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
+// return alpha;
|
|
|
+// }
|
|
|
+// return 0;
|
|
|
+//}
|
|
|
|
|
|
@end
|