diff --git a/CTGradient-IOS/AppDelegate.h b/CTGradient-IOS/AppDelegate.h new file mode 100644 index 0000000..3dc538d --- /dev/null +++ b/CTGradient-IOS/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// CTGradient-IOS +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/CTGradient-IOS/AppDelegate.m b/CTGradient-IOS/AppDelegate.m new file mode 100644 index 0000000..a347907 --- /dev/null +++ b/CTGradient-IOS/AppDelegate.m @@ -0,0 +1,46 @@ +// +// AppDelegate.m +// CTGradient-IOS +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/CTGradient-IOS/CTGradient-IOS-Info.plist b/CTGradient-IOS/CTGradient-IOS-Info.plist new file mode 100644 index 0000000..cf58404 --- /dev/null +++ b/CTGradient-IOS/CTGradient-IOS-Info.plist @@ -0,0 +1,59 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + info.pich.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main_iPhone + UIMainStoryboardFile~ipad + Main_iPad + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarTintParameters + + UINavigationBar + + Style + UIBarStyleBlack + Translucent + + + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CTGradient-IOS/CTGradient-IOS-Prefix.pch b/CTGradient-IOS/CTGradient-IOS-Prefix.pch new file mode 100644 index 0000000..82a2bb4 --- /dev/null +++ b/CTGradient-IOS/CTGradient-IOS-Prefix.pch @@ -0,0 +1,16 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/CTGradient-IOS/FlipsideViewController.h b/CTGradient-IOS/FlipsideViewController.h new file mode 100644 index 0000000..b88cb5e --- /dev/null +++ b/CTGradient-IOS/FlipsideViewController.h @@ -0,0 +1,23 @@ +// +// FlipsideViewController.h +// CTGradient-IOS +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import + +@class FlipsideViewController; + +@protocol FlipsideViewControllerDelegate +- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller; +@end + +@interface FlipsideViewController : UIViewController + +@property (weak, nonatomic) id delegate; + +- (IBAction)done:(id)sender; + +@end diff --git a/CTGradient-IOS/FlipsideViewController.m b/CTGradient-IOS/FlipsideViewController.m new file mode 100644 index 0000000..d6b04be --- /dev/null +++ b/CTGradient-IOS/FlipsideViewController.m @@ -0,0 +1,42 @@ +// +// FlipsideViewController.m +// CTGradient-IOS +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import "FlipsideViewController.h" + +@interface FlipsideViewController () + +@end + +@implementation FlipsideViewController + +- (void)awakeFromNib +{ + self.preferredContentSize = CGSizeMake(320.0, 480.0); + [super awakeFromNib]; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Actions + +- (IBAction)done:(id)sender +{ + [self.delegate flipsideViewControllerDidFinish:self]; +} + +@end diff --git a/CTGradient-IOS/Images.xcassets/AppIcon.appiconset/Contents.json b/CTGradient-IOS/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..91bf9c1 --- /dev/null +++ b/CTGradient-IOS/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,53 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CTGradient-IOS/Images.xcassets/LaunchImage.launchimage/Contents.json b/CTGradient-IOS/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..6f870a4 --- /dev/null +++ b/CTGradient-IOS/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,51 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CTGradient-IOS/MainViewController.h b/CTGradient-IOS/MainViewController.h new file mode 100644 index 0000000..4e0173e --- /dev/null +++ b/CTGradient-IOS/MainViewController.h @@ -0,0 +1,22 @@ +// +// MainViewController.h +// CTGradient-IOS +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import "FlipsideViewController.h" +#import "CTGradientView.h" + +@interface MainViewController : UIViewController + +@property (strong, nonatomic) UIPopoverController *flipsidePopoverController; + +@property (assign) IBOutlet CTGradientView *gradientView; + +//- (IBAction)changeType:(id)sender; +//- (IBAction)changeAngle:(id)sender; +//- (IBAction)changeStyle:(id)sender; + +@end diff --git a/CTGradient-IOS/MainViewController.m b/CTGradient-IOS/MainViewController.m new file mode 100644 index 0000000..2ecbc0a --- /dev/null +++ b/CTGradient-IOS/MainViewController.m @@ -0,0 +1,133 @@ +// +// MainViewController.m +// CTGradient-IOS +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import "MainViewController.h" + +@interface MainViewController () + +@end + +@implementation MainViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. + + self.gradientView.angle = 45; + self.gradientView.radial = NO; + self.gradientView.gradient = [CTGradient rainbowGradient]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Flipside View Controller + +- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller +{ + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + [self dismissViewControllerAnimated:YES completion:nil]; + } else { + [self.flipsidePopoverController dismissPopoverAnimated:YES]; + } +} + +- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController +{ + self.flipsidePopoverController = nil; +} + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + if ([[segue identifier] isEqualToString:@"showAlternate"]) { + [[segue destinationViewController] setDelegate:self]; + + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + UIPopoverController *popoverController = [(UIStoryboardPopoverSegue *)segue popoverController]; + self.flipsidePopoverController = popoverController; + popoverController.delegate = self; + } + } +} + +- (IBAction)togglePopover:(id)sender +{ + if (self.flipsidePopoverController) { + [self.flipsidePopoverController dismissPopoverAnimated:YES]; + self.flipsidePopoverController = nil; + } else { + [self performSegueWithIdentifier:@"showAlternate" sender:sender]; + } +} + +#pragma mark - + +//- (IBAction)changeAngle:(id)sender { +// self.gradientView.angle = 90.0 - [sender floatValue]; +//} +// +//- (IBAction)changeType:(id)sender { +// BOOL isRadial; +// +// if ([[[sender selectedCell] title] isEqualToString:@"Axial"]) +// isRadial = NO; +// else +// isRadial = YES; +// +// self.gradientView.radial = isRadial; +//} +// +//- (IBAction)changeStyle:(id)sender { +// CTGradient *myGradient; +// +// switch ([sender indexOfSelectedItem]) { +// case 0: myGradient = [CTGradient rainbowGradient]; +// break; +// +// case 1: myGradient = [CTGradient aquaSelectedGradient]; +// break; +// +// case 2: myGradient = [CTGradient aquaNormalGradient]; +// break; +// +// case 3: myGradient = [CTGradient aquaPressedGradient]; +// break; +// +// case 4: myGradient = [CTGradient unifiedSelectedGradient]; +// break; +// +// case 5: myGradient = [CTGradient unifiedNormalGradient]; +// break; +// +// case 6: myGradient = [CTGradient unifiedPressedGradient]; +// break; +// +// case 7: myGradient = [CTGradient unifiedDarkGradient]; +// break; +// +// case 8: myGradient = [CTGradient sourceListSelectedGradient]; +// break; +// +// case 9: myGradient = [CTGradient sourceListUnselectedGradient]; +// break; +// +// case 10: myGradient = [CTGradient hydrogenSpectrumGradient]; +// break; +// +// default: myGradient = [CTGradient gradientWithBeginningColor:[NSColor blackColor] +// endingColor:[NSColor whiteColor]]; +// } +// +// self.gradientView.gradient = myGradient; +//} + +@end diff --git a/CTGradient-IOS/Main_iPad.storyboard b/CTGradient-IOS/Main_iPad.storyboard new file mode 100644 index 0000000..c1a14a4 --- /dev/null +++ b/CTGradient-IOS/Main_iPad.storyboard @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CTGradient-IOS/Main_iPhone.storyboard b/CTGradient-IOS/Main_iPhone.storyboard new file mode 100644 index 0000000..e135980 --- /dev/null +++ b/CTGradient-IOS/Main_iPhone.storyboard @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CTGradient-IOS/main.m b/CTGradient-IOS/main.m new file mode 100644 index 0000000..03ac110 --- /dev/null +++ b/CTGradient-IOS/main.m @@ -0,0 +1,18 @@ +// +// main.m +// CTGradient-IOS +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/CTGradient-OSX/AppDelegate.h b/CTGradient-OSX/AppDelegate.h new file mode 100644 index 0000000..70b15a5 --- /dev/null +++ b/CTGradient-OSX/AppDelegate.h @@ -0,0 +1,20 @@ +// +// AppDelegate.h +// CTGradient-OSX +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import +#import "CTGradientView.h" + +@interface AppDelegate : NSObject + +@property (assign) IBOutlet CTGradientView *gradientView; + +- (IBAction)changeType:(id)sender; +- (IBAction)changeAngle:(id)sender; +- (IBAction)changeStyle:(id)sender; + +@end diff --git a/CTGradient-OSX/AppDelegate.m b/CTGradient-OSX/AppDelegate.m new file mode 100644 index 0000000..8d985d9 --- /dev/null +++ b/CTGradient-OSX/AppDelegate.m @@ -0,0 +1,81 @@ +// +// AppDelegate.m +// CTGradient-OSX +// +// Created by Dominik Pich on 03/05/14. +// +// + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +{ + [[NSNotificationCenter defaultCenter] addObserverForName:NSWindowWillCloseNotification object:nil queue:nil usingBlock:^(NSNotification *note) { + [NSApp terminate:nil]; + }]; +} + +#pragma mark - + +- (IBAction)changeAngle:(id)sender { + self.gradientView.angle = 90.0 - [sender floatValue]; +} + +- (IBAction)changeType:(id)sender { + BOOL isRadial; + + if ([[[sender selectedCell] title] isEqualToString:@"Axial"]) + isRadial = NO; + else + isRadial = YES; + + self.gradientView.radial = isRadial; +} + +- (IBAction)changeStyle:(id)sender { + CTGradient *myGradient; + + switch ([sender indexOfSelectedItem]) { + case 0: myGradient = [CTGradient rainbowGradient]; + break; + + case 1: myGradient = [CTGradient aquaSelectedGradient]; + break; + + case 2: myGradient = [CTGradient aquaNormalGradient]; + break; + + case 3: myGradient = [CTGradient aquaPressedGradient]; + break; + + case 4: myGradient = [CTGradient unifiedSelectedGradient]; + break; + + case 5: myGradient = [CTGradient unifiedNormalGradient]; + break; + + case 6: myGradient = [CTGradient unifiedPressedGradient]; + break; + + case 7: myGradient = [CTGradient unifiedDarkGradient]; + break; + + case 8: myGradient = [CTGradient sourceListSelectedGradient]; + break; + + case 9: myGradient = [CTGradient sourceListUnselectedGradient]; + break; + + case 10: myGradient = [CTGradient hydrogenSpectrumGradient]; + break; + + default: myGradient = [CTGradient gradientWithBeginningColor:[NSColor blackColor] + endingColor:[NSColor whiteColor]]; + } + + self.gradientView.gradient = myGradient; +} + +@end diff --git a/Info.plist b/CTGradient-OSX/CTGradient-OSX-Info.plist similarity index 65% rename from Info.plist rename to CTGradient-OSX/CTGradient-OSX-Info.plist index 072d7cb..cc31078 100644 --- a/Info.plist +++ b/CTGradient-OSX/CTGradient-OSX-Info.plist @@ -1,25 +1,29 @@ - + CFBundleDevelopmentRegion - English + en CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIconFile - TieDye + CFBundleIdentifier - com.cotingent.CTGradient + info.pich.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName ${PRODUCT_NAME} CFBundlePackageType APPL + CFBundleShortVersionString + 1.0 CFBundleSignature ???? CFBundleVersion - 1.0 + 1 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} NSMainNibFile MainMenu NSPrincipalClass diff --git a/CTGradient-OSX/CTGradient-OSX-Prefix.pch b/CTGradient-OSX/CTGradient-OSX-Prefix.pch new file mode 100644 index 0000000..35d7640 --- /dev/null +++ b/CTGradient-OSX/CTGradient-OSX-Prefix.pch @@ -0,0 +1,9 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#ifdef __OBJC__ + #import +#endif diff --git a/CTGradient-OSX/MainMenu.nib/designable.nib b/CTGradient-OSX/MainMenu.nib/designable.nib new file mode 100644 index 0000000..b15168b --- /dev/null +++ b/CTGradient-OSX/MainMenu.nib/designable.nib @@ -0,0 +1,2258 @@ + + + + 1090 + 13C1021 + 5056 + 1265.19 + 697.40 + + com.apple.InterfaceBuilder.CocoaPlugin + 5056 + + + NSButtonCell + NSCustomObject + NSCustomView + NSMatrix + NSMenu + NSMenuItem + NSPopUpButton + NSPopUpButtonCell + NSSlider + NSSliderCell + NSTextField + NSTextFieldCell + NSView + NSWindowTemplate + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + + NSApplication + + + + FirstResponder + + + NSApplication + + + 15 + 2 + {{702, 602}, {198, 64}} + 1886914560 + CTGradient + NSWindow + + View + + + + + 256 + + + + 274 + {198, 64} + + CTGradientView + NSView + + + {198, 64} + + + {{0, 0}, {1680, 1028}} + {10000000000000, 10000000000000} + YES + + + MainMenu + + + + NewApplication + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + + NewApplication + + + + About CTGradient + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + + + Services + + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide CTGradient + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit NewApplication + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + + + File + + + + + New + n + 1048576 + 2147483647 + + + + + + Open... + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + + + Open Recent + + + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save + s + 1048576 + 2147483647 + + + + + + Save As… + S + 1048576 + 2147483647 + + + + + + Revert + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup… + P + 1048576 + 2147483647 + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + + + Edit + + + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Paste and Match Style + V + 1572864 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + + + Find + + + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1048576 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling + + 1048576 + 2147483647 + + + submenuAction: + + + Spelling + + + + Spelling… + : + 1048576 + 2147483647 + + + + + + Check Spelling + ; + 1048576 + 2147483647 + + + + + + Check Spelling as You Type + + 1048576 + 2147483647 + + + + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + + + Window + + + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + _NSMainMenu + + + 145 + 2 + {{702, 488}, {198, 81}} + -260569088 + Settings + NSPanel + + View + + + + + 256 + + + + 256 + {{59, 6}, {18, 20}} + + YES + + 67371264 + 131072 + + + + + Helvetica + 12 + 16 + + + 360 + 0.0 + 0.0 + 0.0 + 0 + 1 + YES + NO + 1 + + NO + + + + 256 + {{17, 10}, {39, 14}} + + + YES + + 67108864 + 71434240 + Angle: + + .LucidaGrandeUI + 11 + 3100 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + NO + 1 + + + + 256 + {{58, 52}, {123, 22}} + + + YES + + -2076180416 + 133120 + + + 109199360 + 1 + + LucidaGrande + 11 + 16 + + + + + + 400 + 75 + + YES + + + OtherViews + + + + + rainbow + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + AquaSelected + + 1048576 + 2147483647 + + + _popUpItemAction: + 2 + + + + + AquaNormal + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + AquaPressed + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + UnifiedSelected + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + UnifiedNormal + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + UnifiedPressed + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + UnifiedDark + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + sourceListSelected + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + sourceListUnselected + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + hydrogenSpectrum + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + -1 + 3 + YES + YES + 1 + + NO + + + + 256 + {{17, 57}, {39, 14}} + + + YES + + 67108864 + 71434240 + Style: + + + + + + NO + 1 + + + + 256 + {{17, 33}, {39, 14}} + + + YES + + 67108864 + 71434240 + Type: + + + + + + NO + 1 + + + + 256 + {{57, 32}, {114, 16}} + + + YES + NO + 1 + 2 + + + -2080374784 + 131072 + Axial + + + 1211912448 + 2 + + NSImage + NSRadioButton + + + NSRadioButton + + + + + + 200 + 25 + + + 67108864 + 131072 + Radial + + + 1211912448 + 0 + + 549453824 + {14, 15} + + + + + + TU0AKgAAA1AAAAAAAAAAAAAAAAAAAAAhDAwMdicnJ8krKyvwNTU18CMjI8kaGhp2AgICIQAAAAAAAAAA +AAAAAAAAAAAAAAAABAQEOD4+PsKhoaH/4ODg//7+/v/+/v7/39/f/6SkpP9JSUnCBgYGOAAAAAAAAAAA +AAAAAAMDAypHR0fIsrKy//n5+f///////////////////////////7+/v/9XV1fIBgYGKgAAAAAAAAAJ +NjY2kKKiov/b29v/+/v7//v7+//6+vr/+fn5//r6+v/7+/v/5+fn/6ysrP9CQkKQAAAACQEBASF5eXnb +w8PD/9fX1//q6ur/8fHx//Hx8f/x8fH/8fHx/+7u7v/b29v/xsbG/35+ftsBAQEhAwMDNqurq/zR0dH/ +29vb/+Li4v/m5ub/6Ojo/+np6f/m5ub/4+Pj/9ra2v/T09P/sbGx/AMDAzYEBARAvr6+/9ra2v/h4eH/ +5+fn/+rq6v/r6+v/6enp/+np6f/l5eX/4uLi/93d3f/BwcH/BAQEQAMDAz6vr6/z5ubm/+fn5//t7e3/ +8PDw//Hx8f/x8fH/8PDw/+7u7v/o6Oj/5+fn/6ysrPMDAwM+AQEBLX5+ftXr6+v/7e3t//Ly8v/39/f/ ++/v7//r6+v/5+fn/9vb2/+/v7//s7Oz/enp61QEBAS0AAAAUJycnkczMzP/8/Pz/+/v7//7+/v////// +///////////8/Pz//////87Ozv8mJiaRAAAAFAAAAAIAAAA5QEBAvtnZ2f////////////////////// +///////////d3d3/QEBAvgAAADkAAAACAAAAAAAAAAgAAABHLi4uuJubm/XZ2dn////////////Z2dn/ +m5ub9TAwMLgAAABHAAAACAAAAAAAAAAAAAAAAAAAAAkAAAA4BwcHgAAAAJ8AAACzAAAAswAAAJ8HBweA +AAAAOAAAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAATAAAAJwAAADUAAAA1AAAAJwAAABMAAAAD +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAADgEAAAMAAAABAA4AAAEBAAMAAAABAA8AAAECAAMAAAAEAAAD/gEDAAMAAAABAAEAAAEG +AAMAAAABAAIAAAERAAQAAAABAAAACAESAAMAAAABAAEAAAEVAAMAAAABAAQAAAEWAAMAAAABAA8AAAEX +AAQAAAABAAADSAEcAAMAAAABAAEAAAFSAAMAAAABAAEAAAFTAAMAAAAEAAAEBodzAAcAAAPUAAAEDgAA +AAAACAAIAAgACAABAAEAAQABAAAD1GFwcGwCAAAAbW50clJHQiBYWVogB9UADAAeABAAOwAYYWNzcEFQ +UEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBs9BXCfMSz7rlhs/vpvGnUSQAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOclhZWgAAASwAAAAUZ1hZWgAAAUAAAAAUYlhZWgAA +AVQAAAAUd3RwdAAAAWgAAAAUY2hhZAAAAXwAAAAsclRSQwAAAagAAAAOZ1RSQwAAAbgAAAAOYlRSQwAA +AcgAAAAOdmNndAAAAdgAAAAwbmRpbgAAAggAAAA4ZGVzYwAAAkAAAABvZHNjbQAAArAAAADMbW1vZAAA +A3wAAAAoY3BydAAAA6QAAAAtWFlaIAAAAAAAAHObAAA8xgAAAl5YWVogAAAAAAAAWtQAAKmoAAAWo1hZ +WiAAAAAAAAAoZwAAGacAALolWFlaIAAAAAAAAPPYAAEAAAABFghzZjMyAAAAAAABC7cAAAWW///zVwAA +BykAAP3X///7t////aYAAAPaAADA9mN1cnYAAAAAAAAAAQHNAABjdXJ2AAAAAAAAAAEBzQAAY3VydgAA +AAAAAAABAc0AAHZjZ3QAAAAAAAAAAQAA0XQAAAAAAAEAAAAA0XQAAAAAAAEAAAAA0XQAAAAAAAEAAG5k +aW4AAAAAAAAAMAAApAAAAFcAAABNAAAAmcAAACcXAAAWuwAAUEAAAFRAAAIzMwACMzMAAjMzZGVzYwAA +AAAAAAAVQXBwbGUgQ2luZW1hIERpc3BsYXkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG1sdWMAAAAAAAAABAAA +AAxlc0VTAAAAOgAAAEBlblVTAAAAKAAAAHpmckZSAAAAKgAAAKJkZURFAAAAKAAAAHoAUABhAG4AdABh +AGwAbABhACAAQQBwAHAAbABlACAAQwBpAG4AZQBtAGEAIABEAGkAcwBwAGwAYQB5AEEAcABwAGwAZQAg +AEMAaQBuAGUAbQBhACAARABpAHMAcABsAGEAeQBNAG8AbgBpAHQAZQB1AHIAIABBAHAAcABsAGUAIABD +AGkAbgBlAG0AYW1tb2QAAAAAAAAGEAAAkhICAAAmtK6jgAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENv +cHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA + + + + + + 3 + MCAwAA + + + + + 400 + 75 + + + {55, 16} + {4, 2} + 1143472128 + NSActionCell + + 67108864 + 131072 + bla + + 1211912448 + 0 + + + + 400 + 75 + + + + + 3 + MQA + + + .LucidaGrandeUI + 13 + 1044 + + + + {198, 81} + + + {{0, 0}, {1680, 1028}} + {10000000000000, 10000000000000} + YES + + + AppDelegate + + + + + + + delegate + + + + 286 + + + + terminate: + + + + 139 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + hideOtherApplications: + + + + 146 + + + + hide: + + + + 152 + + + + unhideAllApplications: + + + + 153 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + cut: + + + + 175 + + + + paste: + + + + 176 + + + + redo: + + + + 178 + + + + selectAll: + + + + 179 + + + + undo: + + + + 180 + + + + copy: + + + + 181 + + + + showGuessPanel: + + + + 188 + + + + checkSpelling: + + + + 190 + + + + toggleContinuousSpellChecking: + + + + 192 + + + + performClose: + + + + 193 + + + + delete: + + + + 195 + + + + performZoom: + + + + 198 + + + + performFindPanelAction: + + + + 199 + + + + performFindPanelAction: + + + + 200 + + + + performFindPanelAction: + + + + 201 + + + + performFindPanelAction: + + + + 202 + + + + centerSelectionInVisibleArea: + + + + 203 + + + + pasteAsPlainText: + + + + 205 + + + + delegate + + + + 285 + + + + changeStyle: + + + + 287 + + + + changeType: + + + + 288 + + + + changeAngle: + + + + 289 + + + + gradientView + + + + 290 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + 29 + + + + + + + + + MainMenu + + + 19 + + + + + + + + 24 + + + + + + + + + + + 5 + + + + + 23 + + + + + 92 + + + + + 197 + + + + + 56 + + + + + + + + 57 + + + + + + + + + + + + + + + + + + 58 + + + + + 129 + + + + + 131 + + + + + + + + 130 + + + + + 134 + + + + + 136 + + + + + 143 + + + + + 144 + + + + + 145 + + + + + 149 + + + + + 150 + + + + + 196 + + + + + 83 + + + + + + + + 81 + + + + + + + + + + + + + + + + + + 72 + + + + + 73 + + + + + 74 + + + + + 75 + + + + + 77 + + + + + 78 + + + + + 79 + + + + + 80 + + + + + 82 + + + + + 112 + + + + + 124 + + + + + + + + 125 + + + + + + + + 126 + + + + + 163 + + + + + + + + 169 + + + + + + + + + + + + + + + + + + + 156 + + + + + 157 + + + + + 158 + + + + + 160 + + + + + 164 + + + + + 168 + + + + + + + + 159 + + + + + + + + + + + + 154 + + + + + 155 + + + + + 161 + + + + + 162 + + + + + 167 + + + + + 171 + + + + + 172 + + + + + 173 + + + + + 174 + + + + + 184 + + + + + + + + 185 + + + + + + + + + + 187 + + + + + 189 + + + + + 191 + + + + + 204 + + + + + 209 + + + + + + Panel + + + 210 + + + + + + + + + + + + + 211 + + + + + + + + 213 + + + + + + + + 218 + + + + + + + + 227 + + + + + + + + 259 + + + + + + + + 263 + + + + + + + + + + 267 + + + + + 268 + + + + + 278 + + + + + 279 + + + + + 280 + + + + + + + + 281 + + + + + 282 + + + + + 283 + + + + + 219 + + + + + + + + + + + + + + + + + + 275 + + + + + 274 + + + + + 273 + + + + + 272 + + + + + 226 + + + + + 225 + + + + + 224 + + + + + 223 + + + + + 222 + + + + + 221 + + + + + 220 + + + + + -3 + + + Application + + + 284 + + + + + 214 + + + + + + Window + + + 215 + + + + + + + + 246 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 290 + + + + + AppDelegate + NSObject + + id + id + id + + + + changeAngle: + id + + + changeStyle: + id + + + changeType: + id + + + + CTGradientView + UIWindow + + + + gradientView + CTGradientView + + + window + UIWindow + + + + IBProjectSource + ./Classes/AppDelegate.h + + + + CTGradientView + NSView + + IBProjectSource + ./Classes/CTGradientView.h + + + + NSDocument + + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + browseDocumentVersions: + id + + + duplicateDocument: + id + + + lockDocument: + id + + + moveDocument: + id + + + moveDocumentToUbiquityContainer: + id + + + printDocument: + id + + + renameDocument: + id + + + revertDocumentToSaved: + id + + + runPageLayout: + id + + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id + + + saveDocumentToPDF: + id + + + unlockDocument: + id + + + + IBProjectSource + ./Classes/NSDocument.h + + + + UIResponder + NSObject + + IBProjectSource + ./Classes/UIResponder.h + + + + UIView + UIResponder + + IBProjectSource + ./Classes/UIView.h + + + + UIWindow + UIView + + IBProjectSource + ./Classes/UIWindow.h + + + + + 0 + IBCocoaFramework + YES + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + {11, 11} + {10, 3} + {16, 15} + + + diff --git a/CTGradient-OSX/MainMenu.nib/keyedobjects.nib b/CTGradient-OSX/MainMenu.nib/keyedobjects.nib new file mode 100644 index 0000000..3ee2c2b Binary files /dev/null and b/CTGradient-OSX/MainMenu.nib/keyedobjects.nib differ diff --git a/main.m b/CTGradient-OSX/main.m similarity index 100% rename from main.m rename to CTGradient-OSX/main.m diff --git a/CTGradient.h b/CTGradient.h old mode 100644 new mode 100755 index ffb7883..5a94854 --- a/CTGradient.h +++ b/CTGradient.h @@ -5,36 +5,68 @@ // Writtin by Chad Weider. // // Released into public domain on 4/10/08. -// +// // Version: 1.8 - +#if !__has_feature(objc_arc) +#error This class requires automatic reference counting +#endif + +#if TARGET_OS_IPHONE +#import + +#define Color UIColor +#define Rect CGRect +#define BezierPath UIBezierPath + +#define MinX CGRectGetMinX +#define MidX CGRectGetMidX +#define MaxX CGRectGetMaxX +#define MinY CGRectGetMinY +#define MidY CGRectGetMidY +#define MaxY CGRectGetMaxY +#define Width CGRectGetWidth +#define Height CGRectGetHeight +#else #import -typedef struct _CTGradientElement - { +#define Color NSColor +#define Rect NSRect +#define BezierPath NSBezierPath + +#define MinX NSMinX +#define MidX NSMidX +#define MaxX NSMaxX +#define MinY NSMinY +#define MidY NSMidY +#define MaxY NSMaxY +#define Width NSWidth +#define Height NSHeight +#endif + +typedef struct _CTGradientElement +{ CGFloat red, green, blue, alpha; CGFloat position; - + struct _CTGradientElement *nextElement; - } CTGradientElement; +} CTGradientElement; -typedef enum _CTBlendingMode - { +typedef enum _CTBlendingMode { CTLinearBlendingMode, CTChromaticBlendingMode, CTInverseChromaticBlendingMode - } CTGradientBlendingMode; +} CTGradientBlendingMode; @interface CTGradient : NSObject - { - CTGradientElement* elementList; +{ + CTGradientElement *elementList; CTGradientBlendingMode blendingMode; - + CGFunctionRef gradientFunction; - } +} -+ (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end; ++ (id)gradientWithBeginningColor:(Color *)begin endingColor:(Color *)end; + (id)aquaSelectedGradient; + (id)aquaNormalGradient; @@ -51,23 +83,23 @@ typedef enum _CTBlendingMode + (id)rainbowGradient; + (id)hydrogenSpectrumGradient; -- (CTGradient *)gradientWithAlphaComponent:(float)alpha; +- (CTGradient *)gradientWithAlphaComponent:(CGFloat)alpha; -- (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position; //positions given relative to [0,1] -- (CTGradient *)removeColorStopAtIndex:(unsigned)index; -- (CTGradient *)removeColorStopAtPosition:(float)position; +- (CTGradient *)addColorStop:(Color *)color atPosition:(CGFloat)position; //positions given relative to [0,1] +- (CTGradient *)removeColorStopAtIndex:(NSUInteger)index; +- (CTGradient *)removeColorStopAtPosition:(CGFloat)position; - (CTGradientBlendingMode)blendingMode; -- (NSColor *)colorStopAtIndex:(unsigned)index; -- (NSColor *)colorAtPosition:(float)position; +- (Color *)colorStopAtIndex:(NSUInteger)index; +- (Color *)colorAtPosition:(CGFloat)position; -- (void)drawSwatchInRect:(NSRect)rect; -- (void)fillRect:(NSRect)rect angle:(float)angle; //fills rect with axial gradient - // angle in degrees -- (void)radialFillRect:(NSRect)rect; //fills rect with radial gradient - // gradient from center outwards -- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle; -- (void)radialFillBezierPath:(NSBezierPath *)path; +- (void)drawSwatchInRect:(Rect)rect; +- (void)fillRect:(Rect)rect angle:(CGFloat)angle; //fills rect with axial gradient +// angle in degrees +- (void)radialFillRect:(Rect)rect; //fills rect with radial gradient +// gradient from center outwards +- (void)fillBezierPath:(BezierPath *)path angle:(CGFloat)angle; +- (void)radialFillBezierPath:(BezierPath *)path; @end diff --git a/CTGradient.m b/CTGradient.m old mode 100644 new mode 100755 index 7057e64..aecff8d --- a/CTGradient.m +++ b/CTGradient.m @@ -13,1014 +13,990 @@ @interface CTGradient (Private) - (void)_commonInit; - (void)setBlendingMode:(CTGradientBlendingMode)mode; -- (void)addElement:(CTGradientElement*)newElement; +- (void)addElement:(CTGradientElement *)newElement; -- (CTGradientElement *)elementAtIndex:(unsigned)index; +- (CTGradientElement *)elementAtIndex:(NSUInteger)index; -- (CTGradientElement)removeElementAtIndex:(unsigned)index; -- (CTGradientElement)removeElementAtPosition:(float)position; +- (CTGradientElement)removeElementAtIndex:(NSUInteger)index; +- (CTGradientElement)removeElementAtPosition:(CGFloat)position; @end //C Fuctions for color blending -static void linearEvaluation (void *info, const float *in, float *out); -static void chromaticEvaluation(void *info, const float *in, float *out); -static void inverseChromaticEvaluation(void *info, const float *in, float *out); -static void transformRGB_HSV(float *components); -static void transformHSV_RGB(float *components); -static void resolveHSV(float *color1, float *color2); +static void linearEvaluation(void *info, const CGFloat *in, CGFloat *out); +static void chromaticEvaluation(void *info, const CGFloat *in, CGFloat *out); +static void inverseChromaticEvaluation(void *info, const CGFloat *in, CGFloat *out); +static void transformRGB_HSV(CGFloat *components); +static void transformHSV_RGB(CGFloat *components); +static void resolveHSV(CGFloat *color1, CGFloat *color2); @implementation CTGradient /////////////////////////////////////Initialization Type Stuff -- (id)init - { - self = [super init]; - - if (self != nil) - { - [self _commonInit]; - [self setBlendingMode:CTLinearBlendingMode]; - } - return self; - } - -- (void)_commonInit - { - elementList = nil; - } - -- (void)dealloc - { - CGFunctionRelease(gradientFunction); - - CTGradientElement *elementToRemove = elementList; - while(elementList != nil) - { - elementToRemove = elementList; - elementList = elementList->nextElement; - free(elementToRemove); - } - - [super dealloc]; - } - -- (id)copyWithZone:(NSZone *)zone - { - CTGradient *copy = [[[self class] allocWithZone:zone] init]; - - //now just copy my elementlist - CTGradientElement *currentElement = elementList; - while(currentElement != nil) - { - [copy addElement:currentElement]; - currentElement = currentElement->nextElement; +- (id)init { + self = [super init]; + + if (self != nil) { + [self _commonInit]; + [self setBlendingMode:CTLinearBlendingMode]; } - - [copy setBlendingMode:blendingMode]; - - return copy; - } - -- (void)encodeWithCoder:(NSCoder *)coder - { - if([coder allowsKeyedCoding]) - { - unsigned count = 0; + return self; +} + +- (void)_commonInit { + elementList = nil; +} + +- (void)dealloc { + CGFunctionRelease(gradientFunction); + + CTGradientElement *elementToRemove; + while (elementList != nil) { + elementToRemove = elementList; + elementList = elementList->nextElement; + free(elementToRemove); + } +} + +- (id)copyWithZone:(NSZone *)zone { + CTGradient *copy = [[[self class] allocWithZone:zone] init]; + + //now just copy my elementlist CTGradientElement *currentElement = elementList; - while(currentElement != nil) - { - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->red)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->green)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->blue)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->alpha)]; - [coder encodeValueOfObjCType:@encode(float) at:&(currentElement->position)]; - - count++; + while (currentElement != nil) { + [copy addElement:currentElement]; currentElement = currentElement->nextElement; + } + + [copy setBlendingMode:blendingMode]; + + return copy; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + if ([coder allowsKeyedCoding]) { + NSUInteger count = 0; + CTGradientElement *currentElement = elementList; + while (currentElement != nil) { + [coder encodeValueOfObjCType:@encode(CGFloat) at:&(currentElement->red)]; + [coder encodeValueOfObjCType:@encode(CGFloat) at:&(currentElement->green)]; + [coder encodeValueOfObjCType:@encode(CGFloat) at:&(currentElement->blue)]; + [coder encodeValueOfObjCType:@encode(CGFloat) at:&(currentElement->alpha)]; + [coder encodeValueOfObjCType:@encode(CGFloat) at:&(currentElement->position)]; + + count++; + currentElement = currentElement->nextElement; } - [coder encodeInt:count forKey:@"CTGradientElementCount"]; - [coder encodeInt:blendingMode forKey:@"CTGradientBlendingMode"]; + [coder encodeInteger:count forKey:@"CTGradientElementCount"]; + [coder encodeInteger:blendingMode forKey:@"CTGradientBlendingMode"]; } - else - [NSException raise:NSInvalidArchiveOperationException format:@"Only supports NSKeyedArchiver coders"]; - } - -- (id)initWithCoder:(NSCoder *)coder - { - [self _commonInit]; - - [self setBlendingMode:[coder decodeIntForKey:@"CTGradientBlendingMode"]]; - unsigned count = [coder decodeIntForKey:@"CTGradientElementCount"]; - - while(count != 0) - { - CTGradientElement newElement; - - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.red)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.green)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.blue)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.alpha)]; - [coder decodeValueOfObjCType:@encode(float) at:&(newElement.position)]; - - count--; - [self addElement:&newElement]; + else + [NSException raise:NSInvalidArchiveOperationException format:@"Only supports NSKeyedArchiver coders"]; +} + +- (id)initWithCoder:(NSCoder *)coder { + [self _commonInit]; + + [self setBlendingMode:[coder decodeIntForKey:@"CTGradientBlendingMode"]]; + NSUInteger count = [coder decodeIntForKey:@"CTGradientElementCount"]; + + while (count != 0) { + CTGradientElement newElement; + + [coder decodeValueOfObjCType:@encode(CGFloat) at:&(newElement.red)]; + [coder decodeValueOfObjCType:@encode(CGFloat) at:&(newElement.green)]; + [coder decodeValueOfObjCType:@encode(CGFloat) at:&(newElement.blue)]; + [coder decodeValueOfObjCType:@encode(CGFloat) at:&(newElement.alpha)]; + [coder decodeValueOfObjCType:@encode(CGFloat) at:&(newElement.position)]; + + count--; + [self addElement:&newElement]; } - return self; - } + return self; +} + #pragma mark - #pragma mark Creation -+ (id)gradientWithBeginningColor:(NSColor *)begin endingColor:(NSColor *)end - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - CTGradientElement color2; - - [[begin colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&color1.red - green:&color1.green - blue:&color1.blue - alpha:&color1.alpha]; - - [[end colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&color2.red - green:&color2.green - blue:&color2.blue - alpha:&color2.alpha]; - color1.position = 0; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)aquaSelectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 0.58; - color1.green = 0.86; - color1.blue = 0.98; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = 0.42; - color2.green = 0.68; - color2.blue = 0.90; - color2.alpha = 1.00; - color2.position = 11.5/23; - - CTGradientElement color3; - color3.red = 0.64; - color3.green = 0.80; - color3.blue = 0.94; - color3.alpha = 1.00; - color3.position = 11.5/23; - - CTGradientElement color4; - color4.red = 0.56; - color4.green = 0.70; - color4.blue = 0.90; - color4.alpha = 1.00; - color4.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - [newInstance addElement:&color3]; - [newInstance addElement:&color4]; - - return [newInstance autorelease]; - } - -+ (id)aquaNormalGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.95; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.83; - color2.alpha = 1.00; - color2.position = 11.5/23; - - CTGradientElement color3; - color3.red = color3.green = color3.blue = 0.95; - color3.alpha = 1.00; - color3.position = 11.5/23; - - CTGradientElement color4; - color4.red = color4.green = color4.blue = 0.92; - color4.alpha = 1.00; - color4.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - [newInstance addElement:&color3]; - [newInstance addElement:&color4]; - - return [newInstance autorelease]; - } - -+ (id)aquaPressedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.80; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.64; - color2.alpha = 1.00; - color2.position = 11.5/23; - - CTGradientElement color3; - color3.red = color3.green = color3.blue = 0.80; - color3.alpha = 1.00; - color3.position = 11.5/23; - - CTGradientElement color4; - color4.red = color4.green = color4.blue = 0.77; - color4.alpha = 1.00; - color4.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - [newInstance addElement:&color3]; - [newInstance addElement:&color4]; - - return [newInstance autorelease]; - } - -+ (id)unifiedSelectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.85; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.95; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)unifiedNormalGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.75; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.90; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)unifiedPressedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.60; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.75; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)unifiedDarkGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = color1.green = color1.blue = 0.68; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = color2.green = color2.blue = 0.83; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)sourceListSelectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 0.06; - color1.green = 0.37; - color1.blue = 0.85; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = 0.30; - color2.green = 0.60; - color2.blue = 0.92; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)sourceListUnselectedGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 0.43; - color1.green = 0.43; - color1.blue = 0.43; - color1.alpha = 1.00; - color1.position = 0; - - CTGradientElement color2; - color2.red = 0.60; - color2.green = 0.60; - color2.blue = 0.60; - color2.alpha = 1.00; - color2.position = 1; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - return [newInstance autorelease]; - } - -+ (id)rainbowGradient - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement color1; - color1.red = 1.00; - color1.green = 0.00; - color1.blue = 0.00; - color1.alpha = 1.00; - color1.position = 0.0; - - CTGradientElement color2; - color2.red = 0.54; - color2.green = 0.00; - color2.blue = 1.00; - color2.alpha = 1.00; - color2.position = 1.0; - - [newInstance addElement:&color1]; - [newInstance addElement:&color2]; - - [newInstance setBlendingMode:CTChromaticBlendingMode]; - - return [newInstance autorelease]; - } - -+ (id)hydrogenSpectrumGradient - { - id newInstance = [[[self class] alloc] init]; - - struct {float hue; float position; float width;} colorBands[4]; - - colorBands[0].hue = 22; - colorBands[0].position = .145; - colorBands[0].width = .01; - - colorBands[1].hue = 200; - colorBands[1].position = .71; - colorBands[1].width = .008; - - colorBands[2].hue = 253; - colorBands[2].position = .885; - colorBands[2].width = .005; - - colorBands[3].hue = 275; - colorBands[3].position = .965; - colorBands[3].width = .003; - - int i; - ///////////////////////////// - for(i = 0; i < 4; i++) - { - float color[4]; - color[0] = colorBands[i].hue - 180*colorBands[i].width; - color[1] = 1; - color[2] = 0.001; - color[3] = 1; - transformHSV_RGB(color); - CTGradientElement fadeIn; - fadeIn.red = color[0]; - fadeIn.green = color[1]; - fadeIn.blue = color[2]; - fadeIn.alpha = color[3]; - fadeIn.position = colorBands[i].position - colorBands[i].width; - - - color[0] = colorBands[i].hue; - color[1] = 1; - color[2] = 1; - color[3] = 1; - transformHSV_RGB(color); - CTGradientElement band; - band.red = color[0]; - band.green = color[1]; - band.blue = color[2]; - band.alpha = color[3]; - band.position = colorBands[i].position; - - color[0] = colorBands[i].hue + 180*colorBands[i].width; - color[1] = 1; - color[2] = 0.001; - color[3] = 1; - transformHSV_RGB(color); - CTGradientElement fadeOut; - fadeOut.red = color[0]; - fadeOut.green = color[1]; - fadeOut.blue = color[2]; - fadeOut.alpha = color[3]; - fadeOut.position = colorBands[i].position + colorBands[i].width; - - - [newInstance addElement:&fadeIn]; - [newInstance addElement:&band]; - [newInstance addElement:&fadeOut]; ++ (id)gradientWithBeginningColor:(Color *)begin endingColor:(Color *)end { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + CTGradientElement color2; + +#if TARGET_OS_IPHONE + //if it isnt RGB we are screwed +#else + begin = [begin colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + end = [end colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; +#endif + + [begin getRed:&color1.red + green:&color1.green + blue:&color1.blue + alpha:&color1.alpha]; + + [end getRed:&color2.red + green:&color2.green + blue:&color2.blue + alpha:&color2.alpha]; + color1.position = 0; + color2.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + return newInstance; +} + ++ (id)aquaSelectedGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = 0.58; + color1.green = 0.86; + color1.blue = 0.98; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = 0.42; + color2.green = 0.68; + color2.blue = 0.90; + color2.alpha = 1.00; + color2.position = 11.5 / 23; + + CTGradientElement color3; + color3.red = 0.64; + color3.green = 0.80; + color3.blue = 0.94; + color3.alpha = 1.00; + color3.position = 11.5 / 23; + + CTGradientElement color4; + color4.red = 0.56; + color4.green = 0.70; + color4.blue = 0.90; + color4.alpha = 1.00; + color4.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + [newInstance addElement:&color3]; + [newInstance addElement:&color4]; + + return newInstance; +} + ++ (id)aquaNormalGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = color1.green = color1.blue = 0.95; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = color2.green = color2.blue = 0.83; + color2.alpha = 1.00; + color2.position = 11.5 / 23; + + CTGradientElement color3; + color3.red = color3.green = color3.blue = 0.95; + color3.alpha = 1.00; + color3.position = 11.5 / 23; + + CTGradientElement color4; + color4.red = color4.green = color4.blue = 0.92; + color4.alpha = 1.00; + color4.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + [newInstance addElement:&color3]; + [newInstance addElement:&color4]; + + return newInstance; +} + ++ (id)aquaPressedGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = color1.green = color1.blue = 0.80; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = color2.green = color2.blue = 0.64; + color2.alpha = 1.00; + color2.position = 11.5 / 23; + + CTGradientElement color3; + color3.red = color3.green = color3.blue = 0.80; + color3.alpha = 1.00; + color3.position = 11.5 / 23; + + CTGradientElement color4; + color4.red = color4.green = color4.blue = 0.77; + color4.alpha = 1.00; + color4.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + [newInstance addElement:&color3]; + [newInstance addElement:&color4]; + + return newInstance; +} + ++ (id)unifiedSelectedGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = color1.green = color1.blue = 0.85; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = color2.green = color2.blue = 0.95; + color2.alpha = 1.00; + color2.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + return newInstance; +} + ++ (id)unifiedNormalGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = color1.green = color1.blue = 0.75; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = color2.green = color2.blue = 0.90; + color2.alpha = 1.00; + color2.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + return newInstance; +} + ++ (id)unifiedPressedGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = color1.green = color1.blue = 0.60; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = color2.green = color2.blue = 0.75; + color2.alpha = 1.00; + color2.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + return newInstance; +} + ++ (id)unifiedDarkGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = color1.green = color1.blue = 0.68; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = color2.green = color2.blue = 0.83; + color2.alpha = 1.00; + color2.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + return newInstance; +} + ++ (id)sourceListSelectedGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = 0.06; + color1.green = 0.37; + color1.blue = 0.85; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = 0.30; + color2.green = 0.60; + color2.blue = 0.92; + color2.alpha = 1.00; + color2.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + return newInstance; +} + ++ (id)sourceListUnselectedGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = 0.43; + color1.green = 0.43; + color1.blue = 0.43; + color1.alpha = 1.00; + color1.position = 0; + + CTGradientElement color2; + color2.red = 0.60; + color2.green = 0.60; + color2.blue = 0.60; + color2.alpha = 1.00; + color2.position = 1; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + return newInstance; +} + ++ (id)rainbowGradient { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement color1; + color1.red = 1.00; + color1.green = 0.00; + color1.blue = 0.00; + color1.alpha = 1.00; + color1.position = 0.0; + + CTGradientElement color2; + color2.red = 0.54; + color2.green = 0.00; + color2.blue = 1.00; + color2.alpha = 1.00; + color2.position = 1.0; + + [newInstance addElement:&color1]; + [newInstance addElement:&color2]; + + [newInstance setBlendingMode:CTChromaticBlendingMode]; + + return newInstance; +} + ++ (id)hydrogenSpectrumGradient { + id newInstance = [[[self class] alloc] init]; + + struct { CGFloat hue; CGFloat position; CGFloat width; } colorBands[4]; + + colorBands[0].hue = 22; + colorBands[0].position = .145; + colorBands[0].width = .01; + + colorBands[1].hue = 200; + colorBands[1].position = .71; + colorBands[1].width = .008; + + colorBands[2].hue = 253; + colorBands[2].position = .885; + colorBands[2].width = .005; + + colorBands[3].hue = 275; + colorBands[3].position = .965; + colorBands[3].width = .003; + + int i; + ///////////////////////////// + for (i = 0; i < 4; i++) { + CGFloat color[4]; + color[0] = colorBands[i].hue - 180 * colorBands[i].width; + color[1] = 1; + color[2] = 0.001; + color[3] = 1; + transformHSV_RGB(color); + CTGradientElement fadeIn; + fadeIn.red = color[0]; + fadeIn.green = color[1]; + fadeIn.blue = color[2]; + fadeIn.alpha = color[3]; + fadeIn.position = colorBands[i].position - colorBands[i].width; + + + color[0] = colorBands[i].hue; + color[1] = 1; + color[2] = 1; + color[3] = 1; + transformHSV_RGB(color); + CTGradientElement band; + band.red = color[0]; + band.green = color[1]; + band.blue = color[2]; + band.alpha = color[3]; + band.position = colorBands[i].position; + + color[0] = colorBands[i].hue + 180 * colorBands[i].width; + color[1] = 1; + color[2] = 0.001; + color[3] = 1; + transformHSV_RGB(color); + CTGradientElement fadeOut; + fadeOut.red = color[0]; + fadeOut.green = color[1]; + fadeOut.blue = color[2]; + fadeOut.alpha = color[3]; + fadeOut.position = colorBands[i].position + colorBands[i].width; + + + [newInstance addElement:&fadeIn]; + [newInstance addElement:&band]; + [newInstance addElement:&fadeOut]; } - - [newInstance setBlendingMode:CTChromaticBlendingMode]; - - return [newInstance autorelease]; - } + + [newInstance setBlendingMode:CTChromaticBlendingMode]; + + return newInstance; +} #pragma mark - #pragma mark Modification -- (CTGradient *)gradientWithAlphaComponent:(float)alpha - { - id newInstance = [[[self class] alloc] init]; - - CTGradientElement *curElement = elementList; - CTGradientElement tempElement; - - while(curElement != nil) - { - tempElement = *curElement; - tempElement.alpha = alpha; - [newInstance addElement:&tempElement]; - - curElement = curElement->nextElement; +- (CTGradient *)gradientWithAlphaComponent:(CGFloat)alpha { + id newInstance = [[[self class] alloc] init]; + + CTGradientElement *curElement = elementList; + CTGradientElement tempElement; + + while (curElement != nil) { + tempElement = *curElement; + tempElement.alpha = alpha; + [newInstance addElement:&tempElement]; + + curElement = curElement->nextElement; } - - return [newInstance autorelease]; - } - -- (CTGradient *)gradientWithBlendingMode:(CTGradientBlendingMode)mode - { - CTGradient *newGradient = [self copy]; - - [newGradient setBlendingMode:mode]; - - return [newGradient autorelease]; - } + + return newInstance; +} +- (CTGradient *)gradientWithBlendingMode:(CTGradientBlendingMode)mode { + CTGradient *newGradient = [self copy]; + + [newGradient setBlendingMode:mode]; + + return newGradient; +} //Adds a color stop with at in elementList //(if two elements are at the same position then added imediatly after the one that was there already) -- (CTGradient *)addColorStop:(NSColor *)color atPosition:(float)position - { - CTGradient *newGradient = [self copy]; - CTGradientElement newGradientElement; - - //put the components of color into the newGradientElement - must make sure it is a RGB color (not Gray or CMYK) - [[color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&newGradientElement.red - green:&newGradientElement.green - blue:&newGradientElement.blue - alpha:&newGradientElement.alpha]; - newGradientElement.position = position; - - //Pass it off to addElement to take care of adding it to the elementList - [newGradient addElement:&newGradientElement]; - - return [newGradient autorelease]; - } - +- (CTGradient *)addColorStop:(Color *)color atPosition:(CGFloat)position { + CTGradient *newGradient = [self copy]; + CTGradientElement newGradientElement; + + //put the components of color into the newGradientElement - must make sure it is a RGB color (not Gray or CMYK) +#if TARGET_OS_IPHONE + //if it isnt RGB we are screwed +#else + color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; +#endif + + [color getRed:&newGradientElement.red + green:&newGradientElement.green + blue:&newGradientElement.blue + alpha:&newGradientElement.alpha]; + newGradientElement.position = position; + + //Pass it off to addElement to take care of adding it to the elementList + [newGradient addElement:&newGradientElement]; + + return newGradient; +} //Removes the color stop at from elementList -- (CTGradient *)removeColorStopAtPosition:(float)position - { - CTGradient *newGradient = [self copy]; - CTGradientElement removedElement = [newGradient removeElementAtPosition:position]; - - if(isnan(removedElement.position)) - [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtPosition:]: no such colorStop at position (%f)", [self class], position]; - - return [newGradient autorelease]; - } - -- (CTGradient *)removeColorStopAtIndex:(unsigned)index - { - CTGradient *newGradient = [self copy]; - CTGradientElement removedElement = [newGradient removeElementAtIndex:index]; - - if(isnan(removedElement.position)) - [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtIndex:]: index (%i) beyond bounds", [self class], index]; - - return [newGradient autorelease]; - } +- (CTGradient *)removeColorStopAtPosition:(CGFloat)position { + CTGradient *newGradient = [self copy]; + CTGradientElement removedElement = [newGradient removeElementAtPosition:position]; + + if (isnan(removedElement.position)) + [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtPosition:]: no such colorStop at position (%f)", [self class], position]; + + return newGradient; +} + +- (CTGradient *)removeColorStopAtIndex:(NSUInteger)index { + CTGradient *newGradient = [self copy]; + CTGradientElement removedElement = [newGradient removeElementAtIndex:index]; + + if (isnan(removedElement.position)) + [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtIndex:]: index (%lu) beyond bounds", [self class], (unsigned long)index]; + + return newGradient; +} + #pragma mark - #pragma mark Information -- (CTGradientBlendingMode)blendingMode - { - return blendingMode; - } +- (CTGradientBlendingMode)blendingMode { + return blendingMode; +} //Returns color at in gradient -- (NSColor *)colorStopAtIndex:(unsigned)index - { - CTGradientElement *element = [self elementAtIndex:index]; - - if(element != nil) - return [NSColor colorWithCalibratedRed:element->red - green:element->green - blue:element->blue - alpha:element->alpha]; - - [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtIndex:]: index (%i) beyond bounds", [self class], index]; - - return nil; - } - -- (NSColor *)colorAtPosition:(float)position - { - float components[4]; - - switch(blendingMode) - { - case CTLinearBlendingMode: - linearEvaluation(&elementList, &position, components); break; - case CTChromaticBlendingMode: - chromaticEvaluation(&elementList, &position, components); break; - case CTInverseChromaticBlendingMode: - inverseChromaticEvaluation(&elementList, &position, components); break; +- (Color *)colorStopAtIndex:(NSUInteger)index { + CTGradientElement *element = [self elementAtIndex:index]; + + if (element != nil) +#if TARGET_OS_IPHONE + return [Color colorWithRed:element->red + green:element->green + blue:element->blue + alpha:element->alpha]; +#else + return [Color colorWithCalibratedRed:element->red + green:element->green + blue:element->blue + alpha:element->alpha]; +#endif + + [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtIndex:]: index (%lu) beyond bounds", [self class], (unsigned long)index]; + + return nil; +} + +- (Color *)colorAtPosition:(CGFloat)position { + CGFloat components[4]; + + switch (blendingMode) { + case CTLinearBlendingMode: + linearEvaluation(&elementList, &position, components); + break; + + case CTChromaticBlendingMode: + chromaticEvaluation(&elementList, &position, components); + break; + + case CTInverseChromaticBlendingMode: + inverseChromaticEvaluation(&elementList, &position, components); + break; } - - - return [NSColor colorWithCalibratedRed:components[0]/components[3] //undo premultiplication that CG requires - green:components[1]/components[3] - blue:components[2]/components[3] - alpha:components[3]]; - } + + +#if TARGET_OS_IPHONE + return [Color colorWithRed:components[0] / components[3] //undo premultiplication that CG requires + green:components[1] / components[3] + blue:components[2] / components[3] + alpha:components[3]]; +#else + return [Color colorWithCalibratedRed:components[0] / components[3] //undo premultiplication that CG requires + green:components[1] / components[3] + blue:components[2] / components[3] + alpha:components[3]]; +#endif +} + #pragma mark - #pragma mark Drawing -- (void)drawSwatchInRect:(NSRect)rect - { - [self fillRect:rect angle:45]; - } - -- (void)fillRect:(NSRect)rect angle:(float)angle - { - //First Calculate where the beginning and ending points should be - CGPoint startPoint; - CGPoint endPoint; - - if(angle == 0) //screw the calculations - we know the answer - { - startPoint = CGPointMake(NSMinX(rect), NSMinY(rect)); //right of rect - endPoint = CGPointMake(NSMaxX(rect), NSMinY(rect)); //left of rect - } - else if(angle == 90) //same as above - { - startPoint = CGPointMake(NSMinX(rect), NSMinY(rect)); //bottom of rect - endPoint = CGPointMake(NSMinX(rect), NSMaxY(rect)); //top of rect - } - else //ok, we'll do the calculations now - { - float x,y; - float sina, cosa, tana; - - float length; - float deltax, - deltay; - - float rangle = angle * pi/180; //convert the angle to radians - - if(fabsf(tan(rangle))<=1) //for range [-45,45], [135,225] - { - x = NSWidth(rect); - y = NSHeight(rect); - - sina = sin(rangle); - cosa = cos(rangle); - tana = tan(rangle); - - length = x/fabsf(cosa)+(y-x*fabsf(tana))*fabsf(sina); - - deltax = length*cosa/2; - deltay = length*sina/2; +- (void)drawSwatchInRect:(Rect)rect { + [self fillRect:rect angle:45]; +} + +- (void)fillRect:(Rect)rect angle:(CGFloat)angle { + //First Calculate where the beginning and ending points should be + CGPoint startPoint; + CGPoint endPoint; + + if (angle == 0) { //screw the calculations - we know the answer + startPoint = CGPointMake(MinX(rect), MinY(rect)); //right of rect + endPoint = CGPointMake(MaxX(rect), MinY(rect)); //left of rect + } + else if (angle == 90) { //same as above + startPoint = CGPointMake(MinX(rect), MinY(rect)); //bottom of rect + endPoint = CGPointMake(MinX(rect), MaxY(rect)); //top of rect + } + else { //ok, we'll do the calculations now + CGFloat x, y; + CGFloat sina, cosa, tana; + + CGFloat length; + CGFloat deltax, + deltay; + + CGFloat rangle = angle * M_PI / 180; //convert the angle to radians + + if (fabsf(tan(rangle)) <= 1) { //for range [-45,45], [135,225] + x = Width(rect); + y = Height(rect); + + sina = sin(rangle); + cosa = cos(rangle); + tana = tan(rangle); + + length = x / fabsf(cosa) + (y - x * fabsf(tana)) * fabsf(sina); + + deltax = length * cosa / 2; + deltay = length * sina / 2; } - else //for range [45,135], [225,315] - { - x = NSHeight(rect); - y = NSWidth(rect); - - sina = sin(rangle - 90*pi/180); - cosa = cos(rangle - 90*pi/180); - tana = tan(rangle - 90*pi/180); - - length = x/fabsf(cosa)+(y-x*fabsf(tana))*fabsf(sina); - - deltax =-length*sina/2; - deltay = length*cosa/2; + else { //for range [45,135], [225,315] + x = Height(rect); + y = Width(rect); + + sina = sin(rangle - 90 * M_PI / 180); + cosa = cos(rangle - 90 * M_PI / 180); + tana = tan(rangle - 90 * M_PI / 180); + + length = x / fabsf(cosa) + (y - x * fabsf(tana)) * fabsf(sina); + + deltax = -length * sina / 2; + deltay = length * cosa / 2; } - - startPoint = CGPointMake(NSMidX(rect)-deltax, NSMidY(rect)-deltay); - endPoint = CGPointMake(NSMidX(rect)+deltax, NSMidY(rect)+deltay); + + startPoint = CGPointMake(MidX(rect) - deltax, MidY(rect) - deltay); + endPoint = CGPointMake(MidX(rect) + deltax, MidY(rect) + deltay); } - - //Calls to CoreGraphics - CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - CGContextSaveGState(currentContext); - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 - CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); - #else - CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); - #endif - CGShadingRef myCGShading = CGShadingCreateAxial(colorspace, startPoint, endPoint, gradientFunction, false, false); - - CGContextClipToRect (currentContext, *(CGRect *)&rect); //This is where the action happens - CGContextDrawShading(currentContext, myCGShading); - - CGShadingRelease(myCGShading); - CGColorSpaceRelease(colorspace ); - CGContextRestoreGState(currentContext); - } - -- (void)radialFillRect:(NSRect)rect - { - CGPoint startPoint, endPoint; - float startRadius, endRadius; - float scalex, scaley, transx, transy; - - startPoint = endPoint = CGPointMake(NSMidX(rect), NSMidY(rect)); - - startRadius = -1; - if(NSHeight(rect)>NSWidth(rect)) - { - scalex = NSWidth(rect)/NSHeight(rect); - transx = (NSHeight(rect)-NSWidth(rect))/2; - scaley = 1; - transy = 1; - endRadius = NSHeight(rect)/2; + +#if TARGET_OS_IPHONE + //Calls to CoreGraphics + CGContextRef currentContext = UIGraphicsGetCurrentContext(); + CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); +#else + //Calls to CoreGraphics + CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); +#else + CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); +#endif +#endif + CGShadingRef myCGShading = CGShadingCreateAxial(colorspace, startPoint, endPoint, gradientFunction, false, false); + CGContextSaveGState(currentContext); + + CGContextClipToRect(currentContext, *(CGRect *)&rect); //This is where the action happens + CGContextDrawShading(currentContext, myCGShading); + + CGContextRestoreGState(currentContext); + CGShadingRelease(myCGShading); + CGColorSpaceRelease(colorspace); +} + +- (void)radialFillRect:(Rect)rect { + CGPoint startPoint, endPoint; + CGFloat startRadius, endRadius; + CGFloat scalex, scaley, transx, transy; + + startPoint = endPoint = CGPointMake(MidX(rect), MidY(rect)); + + startRadius = -1; + if (Height(rect) > Width(rect)) { + scalex = Width(rect) / Height(rect); + transx = (Height(rect) - Width(rect)) / 2; + scaley = 1; + transy = 1; + endRadius = Height(rect) / 2; } - else - { - scalex = 1; - transx = 1; - scaley = NSHeight(rect)/NSWidth(rect); - transy = (NSWidth(rect)-NSHeight(rect))/2; - endRadius = NSWidth(rect)/2; + else { + scalex = 1; + transx = 1; + scaley = Height(rect) / Width(rect); + transy = (Width(rect) - Height(rect)) / 2; + endRadius = Width(rect) / 2; } - - //Calls to CoreGraphics - CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - CGContextSaveGState(currentContext); - #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 - CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); - #else - CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); - #endif - CGShadingRef myCGShading = CGShadingCreateRadial(colorspace, startPoint, startRadius, endPoint, endRadius, gradientFunction, true, true); - - CGContextClipToRect (currentContext, *(CGRect *)&rect); - CGContextScaleCTM (currentContext, scalex, scaley); - CGContextTranslateCTM(currentContext, transx, transy); - CGContextDrawShading (currentContext, myCGShading); //This is where the action happens - - CGShadingRelease(myCGShading); - CGColorSpaceRelease(colorspace); - CGContextRestoreGState(currentContext); - } - -- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle - { - NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; - [currentContext saveGraphicsState]; - NSAffineTransform *transform = [[NSAffineTransform alloc] init]; - - [transform rotateByDegrees:-angle]; - [path transformUsingAffineTransform:transform]; - [transform invert]; - [transform concat]; - + +#if TARGET_OS_IPHONE + CGContextRef currentContext = UIGraphicsGetCurrentContext(); + CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); +#else + CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); +#else + CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); +#endif +#endif + CGShadingRef myCGShading = CGShadingCreateRadial(colorspace, startPoint, startRadius, endPoint, endRadius, gradientFunction, true, true); + CGContextSaveGState(currentContext); + + CGContextClipToRect(currentContext, *(CGRect *)&rect); + CGContextScaleCTM(currentContext, scalex, scaley); + CGContextTranslateCTM(currentContext, transx, transy); + CGContextDrawShading(currentContext, myCGShading); //This is where the action happens + + CGShadingRelease(myCGShading); + CGColorSpaceRelease(colorspace); + CGContextRestoreGState(currentContext); +} + +- (void)fillBezierPath:(BezierPath *)path angle:(CGFloat)angle { +#if TARGET_OS_IPHONE + CGContextRef currentContext = UIGraphicsGetCurrentContext(); +#else + CGContextRef currentContext = [[NSGraphicsContext currentContext] graphicsPort]; +#endif + CGContextSaveGState(currentContext); + [path addClip]; - [self fillRect:[path bounds] angle:0]; - [path transformUsingAffineTransform:transform]; - [transform release]; - [currentContext restoreGraphicsState]; - } -- (void)radialFillBezierPath:(NSBezierPath *)path - { - NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; - [currentContext saveGraphicsState]; + [self fillRect:path.bounds angle:angle]; + + CGContextRestoreGState(currentContext); +} + +- (void)radialFillBezierPath:(BezierPath *)path { +#if TARGET_OS_IPHONE + CGContextRef currentContext = UIGraphicsGetCurrentContext(); +#else + CGContextRef currentContext = [[NSGraphicsContext currentContext] graphicsPort]; +#endif + CGContextSaveGState(currentContext); + [path addClip]; [self radialFillRect:[path bounds]]; - [currentContext restoreGraphicsState]; - } + + CGContextRestoreGState(currentContext); +} + #pragma mark - #pragma mark Private Methods - (void)setBlendingMode:(CTGradientBlendingMode)mode; - { - blendingMode = mode; - - //Choose what blending function to use - void *evaluationFunction; - switch(blendingMode) - { - case CTLinearBlendingMode: - evaluationFunction = &linearEvaluation; break; - case CTChromaticBlendingMode: - evaluationFunction = &chromaticEvaluation; break; - case CTInverseChromaticBlendingMode: - evaluationFunction = &inverseChromaticEvaluation; break; +{ + blendingMode = mode; + + //Choose what blending function to use + void *evaluationFunction; + switch (blendingMode) { + case CTLinearBlendingMode: + evaluationFunction = &linearEvaluation; + break; + + case CTChromaticBlendingMode: + evaluationFunction = &chromaticEvaluation; + break; + + case CTInverseChromaticBlendingMode: + evaluationFunction = &inverseChromaticEvaluation; + break; } - - //replace the current CoreGraphics Function with new one - if(gradientFunction != NULL) - CGFunctionRelease(gradientFunction); - - CGFunctionCallbacks evaluationCallbackInfo = {0 , evaluationFunction, NULL}; //Version, evaluator function, cleanup function - - static const CGFloat input_value_range [2] = { 0, 1 }; //range for the evaluator input - static const CGFloat output_value_ranges [8] = { 0, 1, 0, 1, 0, 1, 0, 1 }; //ranges for the evaluator output (4 returned values) - - gradientFunction = CGFunctionCreate(&elementList, //the two transition colors - 1, input_value_range , //number of inputs (just fraction of progression) - 4, output_value_ranges, //number of outputs (4 - RGBa) - &evaluationCallbackInfo); //info for using the evaluator function - } - -- (void)addElement:(CTGradientElement *)newElement - { - if(elementList == nil || newElement->position < elementList->position) //inserting at beginning of list - { - CTGradientElement *tmpNext = elementList; - elementList = malloc(sizeof(CTGradientElement)); - *elementList = *newElement; - elementList->nextElement = tmpNext; + + //replace the current CoreGraphics Function with new one + if (gradientFunction != NULL) + CGFunctionRelease(gradientFunction); + + CGFunctionCallbacks evaluationCallbackInfo = { 0, evaluationFunction, NULL }; //Version, evaluator function, cleanup function + + static const CGFloat input_value_range[2] = { 0, 1 }; //range for the evaluator input + static const CGFloat output_value_ranges[8] = { 0, 1, 0, 1, 0, 1, 0, 1 }; //ranges for the evaluator output (4 returned values) + + gradientFunction = CGFunctionCreate(&elementList, //the two transition colors + 1, input_value_range, //number of inputs (just fraction of progression) + 4, output_value_ranges, //number of outputs (4 - RGBa) + &evaluationCallbackInfo); //info for using the evaluator function +} + +- (void)addElement:(CTGradientElement *)newElement { + if (elementList == nil || newElement->position < elementList->position) { //inserting at beginning of list + CTGradientElement *tmpNext = elementList; + elementList = malloc(sizeof(CTGradientElement)); + *elementList = *newElement; + elementList->nextElement = tmpNext; } - else //inserting somewhere inside list - { - CTGradientElement *curElement = elementList; - - while(curElement->nextElement != nil && !((curElement->position <= newElement->position) && (newElement->position < curElement->nextElement->position))) - { - curElement = curElement->nextElement; + else { //inserting somewhere inside list + CTGradientElement *curElement = elementList; + + while (curElement->nextElement != nil && !((curElement->position <= newElement->position) && (newElement->position < curElement->nextElement->position))) { + curElement = curElement->nextElement; } - - CTGradientElement *tmpNext = curElement->nextElement; - curElement->nextElement = malloc(sizeof(CTGradientElement)); - *(curElement->nextElement) = *newElement; - curElement->nextElement->nextElement = tmpNext; + + CTGradientElement *tmpNext = curElement->nextElement; + curElement->nextElement = malloc(sizeof(CTGradientElement)); + *(curElement->nextElement) = *newElement; + curElement->nextElement->nextElement = tmpNext; } - } - -- (CTGradientElement)removeElementAtIndex:(unsigned)index - { - CTGradientElement removedElement; - - if(elementList != nil) - { - if(index == 0) - { - CTGradientElement *tmpNext = elementList; - elementList = elementList->nextElement; - - removedElement = *tmpNext; - free(tmpNext); - - return removedElement; - } - - unsigned count = 1; //we want to start one ahead - CTGradientElement *currentElement = elementList; - while(currentElement->nextElement != nil) - { - if(count == index) - { - CTGradientElement *tmpNext = currentElement->nextElement; - currentElement->nextElement = currentElement->nextElement->nextElement; - +} + +- (CTGradientElement)removeElementAtIndex:(NSUInteger)index { + CTGradientElement removedElement; + + if (elementList != nil) { + if (index == 0) { + CTGradientElement *tmpNext = elementList; + elementList = elementList->nextElement; + removedElement = *tmpNext; free(tmpNext); - + return removedElement; - } - - count++; - currentElement = currentElement->nextElement; } - } - - //element is not found, return empty element - removedElement.red = 0.0; - removedElement.green = 0.0; - removedElement.blue = 0.0; - removedElement.alpha = 0.0; - removedElement.position = NAN; - removedElement.nextElement = nil; - - return removedElement; - } - -- (CTGradientElement)removeElementAtPosition:(float)position - { - CTGradientElement removedElement; - - if(elementList != nil) - { - if(elementList->position == position) - { - CTGradientElement *tmpNext = elementList; - elementList = elementList->nextElement; - - removedElement = *tmpNext; - free(tmpNext); - - return removedElement; - } - else - { - CTGradientElement *curElement = elementList; - while(curElement->nextElement != nil) - { - if(curElement->nextElement->position == position) - { - CTGradientElement *tmpNext = curElement->nextElement; - curElement->nextElement = curElement->nextElement->nextElement; - + + NSUInteger count = 1; //we want to start one ahead + CTGradientElement *currentElement = elementList; + while (currentElement->nextElement != nil) { + if (count == index) { + CTGradientElement *tmpNext = currentElement->nextElement; + currentElement->nextElement = currentElement->nextElement->nextElement; + removedElement = *tmpNext; free(tmpNext); - + return removedElement; + } + + count++; + currentElement = currentElement->nextElement; + } + } + + //element is not found, return empty element + removedElement.red = 0.0; + removedElement.green = 0.0; + removedElement.blue = 0.0; + removedElement.alpha = 0.0; + removedElement.position = NAN; + removedElement.nextElement = nil; + + return removedElement; +} + +- (CTGradientElement)removeElementAtPosition:(CGFloat)position { + CTGradientElement removedElement; + + if (elementList != nil) { + if (elementList->position == position) { + CTGradientElement *tmpNext = elementList; + elementList = elementList->nextElement; + + removedElement = *tmpNext; + free(tmpNext); + + return removedElement; + } + else { + CTGradientElement *curElement = elementList; + while (curElement->nextElement != nil) { + if (curElement->nextElement->position == position) { + CTGradientElement *tmpNext = curElement->nextElement; + curElement->nextElement = curElement->nextElement->nextElement; + + removedElement = *tmpNext; + free(tmpNext); + + return removedElement; } } } } - - //element is not found, return empty element - removedElement.red = 0.0; - removedElement.green = 0.0; - removedElement.blue = 0.0; - removedElement.alpha = 0.0; - removedElement.position = NAN; - removedElement.nextElement = nil; - - return removedElement; - } - - -- (CTGradientElement *)elementAtIndex:(unsigned)index; - { - unsigned count = 0; - CTGradientElement *currentElement = elementList; - - while(currentElement != nil) - { - if(count == index) - return currentElement; - - count++; - currentElement = currentElement->nextElement; + + //element is not found, return empty element + removedElement.red = 0.0; + removedElement.green = 0.0; + removedElement.blue = 0.0; + removedElement.alpha = 0.0; + removedElement.position = NAN; + removedElement.nextElement = nil; + + return removedElement; +} + +- (CTGradientElement *)elementAtIndex:(NSUInteger)index; +{ + NSUInteger count = 0; + CTGradientElement *currentElement = elementList; + + while (currentElement != nil) { + if (count == index) + return currentElement; + + count++; + currentElement = currentElement->nextElement; } - - return nil; - } + + return nil; +} #pragma mark - #pragma mark Core Graphics //////////////////////////////////////Blending Functions///////////////////////////////////// -void linearEvaluation (void *info, const float *in, float *out) - { - float position = *in; - - if(*(CTGradientElement **)info == nil) //if elementList is empty return clear color - { - out[0] = out[1] = out[2] = out[3] = 1; - return; +void linearEvaluation(void *info, const CGFloat *in, CGFloat *out) { + CGFloat position = *in; + + if (*(CTGradientElement **)info == nil) { //if elementList is empty return clear color + out[0] = out[1] = out[2] = out[3] = 1; + return; } - - //This grabs the first two colors in the sequence - CTGradientElement *color1 = *(CTGradientElement **)info; - CTGradientElement *color2 = color1->nextElement; - - //make sure first color and second color are on other sides of position - while(color2 != nil && color2->position < position) - { - color1 = color2; - color2 = color1->nextElement; - } - //if we don't have another color then make next color the same color - if(color2 == nil) - { - color2 = color1; - } - - //----------FailSafe settings---------- - //color1->red = 1; color2->red = 0; - //color1->green = 1; color2->green = 0; - //color1->blue = 1; color2->blue = 0; - //color1->alpha = 1; color2->alpha = 1; - //color1->position = .5; - //color2->position = .5; - //------------------------------------- - - if(position <= color1->position) //Make all below color color1's position equal to color1 - { - out[0] = color1->red; - out[1] = color1->green; - out[2] = color1->blue; - out[3] = color1->alpha; - } - else if (position >= color2->position) //Make all above color color2's position equal to color2 - { - out[0] = color2->red; - out[1] = color2->green; - out[2] = color2->blue; - out[3] = color2->alpha; - } - else //Interpolate color at postions between color1 and color1 - { - //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position - position = (position-color1->position)/(color2->position - color1->position); - - out[0] = (color2->red - color1->red )*position + color1->red; - out[1] = (color2->green - color1->green)*position + color1->green; - out[2] = (color2->blue - color1->blue )*position + color1->blue; - out[3] = (color2->alpha - color1->alpha)*position + color1->alpha; + + //This grabs the first two colors in the sequence + CTGradientElement *color1 = *(CTGradientElement **)info; + CTGradientElement *color2 = color1->nextElement; + + //make sure first color and second color are on other sides of position + while (color2 != nil && color2->position < position) { + color1 = color2; + color2 = color1->nextElement; } - - //Premultiply the color by the alpha. - out[0] *= out[3]; - out[1] *= out[3]; - out[2] *= out[3]; - } - - - - -//Chromatic Evaluation - -// This blends colors by their Hue, Saturation, and Value(Brightness) right now I just + //if we don't have another color then make next color the same color + if (color2 == nil) { + color2 = color1; + } + + //----------FailSafe settings---------- + //color1->red = 1; color2->red = 0; + //color1->green = 1; color2->green = 0; + //color1->blue = 1; color2->blue = 0; + //color1->alpha = 1; color2->alpha = 1; + //color1->position = .5; + //color2->position = .5; + //------------------------------------- + + if (position <= color1->position) { //Make all below color color1's position equal to color1 + out[0] = color1->red; + out[1] = color1->green; + out[2] = color1->blue; + out[3] = color1->alpha; + } + else if (position >= color2->position) { //Make all above color color2's position equal to color2 + out[0] = color2->red; + out[1] = color2->green; + out[2] = color2->blue; + out[3] = color2->alpha; + } + else { //Interpolate color at postions between color1 and color1 + //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position + position = (position - color1->position) / (color2->position - color1->position); + + out[0] = (color2->red - color1->red) * position + color1->red; + out[1] = (color2->green - color1->green) * position + color1->green; + out[2] = (color2->blue - color1->blue) * position + color1->blue; + out[3] = (color2->alpha - color1->alpha) * position + color1->alpha; + } + + //Premultiply the color by the alpha. + out[0] *= out[3]; + out[1] *= out[3]; + out[2] *= out[3]; +} + +//Chromatic Evaluation - +// This blends colors by their Hue, Saturation, and Value(Brightness) right now I just // transform the RGB values stored in the CTGradientElements to HSB, in the future I may // streamline it to avoid transforming in and out of HSB colorspace *for later* // @@ -1028,241 +1004,232 @@ void linearEvaluation (void *info, const float *in, float *out) // this we will add to the hue's angle (if we subtract we'll be doing the inverse // chromatic...scroll down more for that). All we need to do is keep adding to the hue // until we wrap around the colorwheel and get to color2. -void chromaticEvaluation(void *info, const float *in, float *out) - { - float position = *in; - - if(*(CTGradientElement **)info == nil) //if elementList is empty return clear color - { - out[0] = out[1] = out[2] = out[3] = 1; - return; +void chromaticEvaluation(void *info, const CGFloat *in, CGFloat *out) { + CGFloat position = *in; + + if (*(CTGradientElement **)info == nil) { //if elementList is empty return clear color + out[0] = out[1] = out[2] = out[3] = 1; + return; } - - //This grabs the first two colors in the sequence - CTGradientElement *color1 = *(CTGradientElement **)info; - CTGradientElement *color2 = color1->nextElement; - - float c1[4]; - float c2[4]; - - //make sure first color and second color are on other sides of position - while(color2 != nil && color2->position < position) - { - color1 = color2; - color2 = color1->nextElement; - } - //if we don't have another color then make next color the same color - if(color2 == nil) - { - color2 = color1; - } - - - c1[0] = color1->red; - c1[1] = color1->green; - c1[2] = color1->blue; - c1[3] = color1->alpha; - - c2[0] = color2->red; - c2[1] = color2->green; - c2[2] = color2->blue; - c2[3] = color2->alpha; - - transformRGB_HSV(c1); - transformRGB_HSV(c2); - resolveHSV(c1,c2); - - if(c1[0] > c2[0]) //if color1's hue is higher than color2's hue then - c2[0] += 360; // we need to move c2 one revolution around the wheel - - - if(position <= color1->position) //Make all below color color1's position equal to color1 - { - out[0] = c1[0]; - out[1] = c1[1]; - out[2] = c1[2]; - out[3] = c1[3]; - } - else if (position >= color2->position) //Make all above color color2's position equal to color2 - { - out[0] = c2[0]; - out[1] = c2[1]; - out[2] = c2[2]; - out[3] = c2[3]; - } - else //Interpolate color at postions between color1 and color1 - { - //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position - position = (position-color1->position)/(color2->position - color1->position); - - out[0] = (c2[0] - c1[0])*position + c1[0]; - out[1] = (c2[1] - c1[1])*position + c1[1]; - out[2] = (c2[2] - c1[2])*position + c1[2]; - out[3] = (c2[3] - c1[3])*position + c1[3]; - } - - transformHSV_RGB(out); - - //Premultiply the color by the alpha. - out[0] *= out[3]; - out[1] *= out[3]; - out[2] *= out[3]; - } - - - -//Inverse Chromatic Evaluation - + + //This grabs the first two colors in the sequence + CTGradientElement *color1 = *(CTGradientElement **)info; + CTGradientElement *color2 = color1->nextElement; + + CGFloat c1[4]; + CGFloat c2[4]; + + //make sure first color and second color are on other sides of position + while (color2 != nil && color2->position < position) { + color1 = color2; + color2 = color1->nextElement; + } + //if we don't have another color then make next color the same color + if (color2 == nil) { + color2 = color1; + } + + + c1[0] = color1->red; + c1[1] = color1->green; + c1[2] = color1->blue; + c1[3] = color1->alpha; + + c2[0] = color2->red; + c2[1] = color2->green; + c2[2] = color2->blue; + c2[3] = color2->alpha; + + transformRGB_HSV(c1); + transformRGB_HSV(c2); + resolveHSV(c1, c2); + + if (c1[0] > c2[0]) //if color1's hue is higher than color2's hue then + c2[0] += 360; // we need to move c2 one revolution around the wheel + + + if (position <= color1->position) { //Make all below color color1's position equal to color1 + out[0] = c1[0]; + out[1] = c1[1]; + out[2] = c1[2]; + out[3] = c1[3]; + } + else if (position >= color2->position) { //Make all above color color2's position equal to color2 + out[0] = c2[0]; + out[1] = c2[1]; + out[2] = c2[2]; + out[3] = c2[3]; + } + else { //Interpolate color at postions between color1 and color1 + //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position + position = (position - color1->position) / (color2->position - color1->position); + + out[0] = (c2[0] - c1[0]) * position + c1[0]; + out[1] = (c2[1] - c1[1]) * position + c1[1]; + out[2] = (c2[2] - c1[2]) * position + c1[2]; + out[3] = (c2[3] - c1[3]) * position + c1[3]; + } + + transformHSV_RGB(out); + + //Premultiply the color by the alpha. + out[0] *= out[3]; + out[1] *= out[3]; + out[2] *= out[3]; +} + +//Inverse Chromatic Evaluation - // Inverse Chromatic is about the same story as Chromatic Blend, but here the Hue // is strictly decreasing, that is we need to get from color1 to color2 by decreasing // the 'angle' (i.e. 90¼ -> 180¼ would be done by subtracting 270¼ and getting -180¼... // which is equivalent to 180¼ mod 360¼ -void inverseChromaticEvaluation(void *info, const float *in, float *out) - { - float position = *in; - - if(*(CTGradientElement **)info == nil) //if elementList is empty return clear color - { - out[0] = out[1] = out[2] = out[3] = 1; - return; +void inverseChromaticEvaluation(void *info, const CGFloat *in, CGFloat *out) { + CGFloat position = *in; + + if (*(CTGradientElement **)info == nil) { //if elementList is empty return clear color + out[0] = out[1] = out[2] = out[3] = 1; + return; } - - //This grabs the first two colors in the sequence - CTGradientElement *color1 = *(CTGradientElement **)info; - CTGradientElement *color2 = color1->nextElement; - - float c1[4]; - float c2[4]; - - //make sure first color and second color are on other sides of position - while(color2 != nil && color2->position < position) - { - color1 = color2; - color2 = color1->nextElement; - } - //if we don't have another color then make next color the same color - if(color2 == nil) - { - color2 = color1; - } - - c1[0] = color1->red; - c1[1] = color1->green; - c1[2] = color1->blue; - c1[3] = color1->alpha; - - c2[0] = color2->red; - c2[1] = color2->green; - c2[2] = color2->blue; - c2[3] = color2->alpha; - - transformRGB_HSV(c1); - transformRGB_HSV(c2); - resolveHSV(c1,c2); - - if(c1[0] < c2[0]) //if color1's hue is higher than color2's hue then - c1[0] += 360; // we need to move c2 one revolution back on the wheel - - - if(position <= color1->position) //Make all below color color1's position equal to color1 - { - out[0] = c1[0]; - out[1] = c1[1]; - out[2] = c1[2]; - out[3] = c1[3]; - } - else if (position >= color2->position) //Make all above color color2's position equal to color2 - { - out[0] = c2[0]; - out[1] = c2[1]; - out[2] = c2[2]; - out[3] = c2[3]; - } - else //Interpolate color at postions between color1 and color1 - { - //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position - position = (position-color1->position)/(color2->position - color1->position); - - out[0] = (c2[0] - c1[0])*position + c1[0]; - out[1] = (c2[1] - c1[1])*position + c1[1]; - out[2] = (c2[2] - c1[2])*position + c1[2]; - out[3] = (c2[3] - c1[3])*position + c1[3]; - } - - transformHSV_RGB(out); - - //Premultiply the color by the alpha. - out[0] *= out[3]; - out[1] *= out[3]; - out[2] *= out[3]; - } - - -void transformRGB_HSV(float *components) //H,S,B -> R,G,B - { - float H, S, V; - float R = components[0], - G = components[1], - B = components[2]; - - float MAX = R > G ? (R > B ? R : B) : (G > B ? G : B), - MIN = R < G ? (R < B ? R : B) : (G < B ? G : B); - - if(MAX == MIN) + + //This grabs the first two colors in the sequence + CTGradientElement *color1 = *(CTGradientElement **)info; + CTGradientElement *color2 = color1->nextElement; + + CGFloat c1[4]; + CGFloat c2[4]; + + //make sure first color and second color are on other sides of position + while (color2 != nil && color2->position < position) { + color1 = color2; + color2 = color1->nextElement; + } + //if we don't have another color then make next color the same color + if (color2 == nil) { + color2 = color1; + } + + c1[0] = color1->red; + c1[1] = color1->green; + c1[2] = color1->blue; + c1[3] = color1->alpha; + + c2[0] = color2->red; + c2[1] = color2->green; + c2[2] = color2->blue; + c2[3] = color2->alpha; + + transformRGB_HSV(c1); + transformRGB_HSV(c2); + resolveHSV(c1, c2); + + if (c1[0] < c2[0]) //if color1's hue is higher than color2's hue then + c1[0] += 360; // we need to move c2 one revolution back on the wheel + + + if (position <= color1->position) { //Make all below color color1's position equal to color1 + out[0] = c1[0]; + out[1] = c1[1]; + out[2] = c1[2]; + out[3] = c1[3]; + } + else if (position >= color2->position) { //Make all above color color2's position equal to color2 + out[0] = c2[0]; + out[1] = c2[1]; + out[2] = c2[2]; + out[3] = c2[3]; + } + else { //Interpolate color at postions between color1 and color1 + //adjust position so that it goes from 0 to 1 in the range from color 1 & 2's position + position = (position - color1->position) / (color2->position - color1->position); + + out[0] = (c2[0] - c1[0]) * position + c1[0]; + out[1] = (c2[1] - c1[1]) * position + c1[1]; + out[2] = (c2[2] - c1[2]) * position + c1[2]; + out[3] = (c2[3] - c1[3]) * position + c1[3]; + } + + transformHSV_RGB(out); + + //Premultiply the color by the alpha. + out[0] *= out[3]; + out[1] *= out[3]; + out[2] *= out[3]; +} + +void transformRGB_HSV(CGFloat *components) { //H,S,B -> R,G,B + CGFloat H=0, S=0, V=0; + CGFloat R = components[0], + G = components[1], + B = components[2]; + + CGFloat MAX = R > G ? (R > B ? R : B) : (G > B ? G : B), + MIN = R < G ? (R < B ? R : B) : (G < B ? G : B); + + if (MAX == MIN) H = NAN; - else if(MAX == R) - if(G >= B) - H = 60*(G-B)/(MAX-MIN)+0; + else if (MAX == R) + if (G >= B) + H = 60 * (G - B) / (MAX - MIN) + 0; else - H = 60*(G-B)/(MAX-MIN)+360; - else if(MAX == G) - H = 60*(B-R)/(MAX-MIN)+120; - else if(MAX == B) - H = 60*(R-G)/(MAX-MIN)+240; - - S = MAX == 0 ? 0 : 1 - MIN/MAX; + H = 60 * (G - B) / (MAX - MIN) + 360; + else if (MAX == G) + H = 60 * (B - R) / (MAX - MIN) + 120; + else if (MAX == B) + H = 60 * (R - G) / (MAX - MIN) + 240; + + S = MAX == 0 ? 0 : 1 - MIN / MAX; V = MAX; - + components[0] = H; components[1] = S; components[2] = V; - } +} -void transformHSV_RGB(float *components) //H,S,B -> R,G,B - { - float R, G, B; - float H = fmodf(components[0],359), //map to [0,360) - S = components[1], - V = components[2]; - - int Hi = (int)floorf(H/60.) % 6; - float f = H/60-Hi, - p = V*(1-S), - q = V*(1-f*S), - t = V*(1-(1-f)*S); - - switch (Hi) - { - case 0: R=V;G=t;B=p; break; - case 1: R=q;G=V;B=p; break; - case 2: R=p;G=V;B=t; break; - case 3: R=p;G=q;B=V; break; - case 4: R=t;G=p;B=V; break; - case 5: R=V;G=p;B=q; break; - } - +void transformHSV_RGB(CGFloat *components) { //H,S,B -> R,G,B + CGFloat R = 0, G = 0, B = 0; + CGFloat H = fmodf(components[0], 359), //map to [0,360) + S = components[1], + V = components[2]; + + int Hi = (int)floorf(H / 60.) % 6; + CGFloat f = H / 60 - Hi, + p = V * (1 - S), + q = V * (1 - f * S), + t = V * (1 - (1 - f) * S); + + switch (Hi) { + case 0: R = V; G = t; B = p; + break; + + case 1: R = q; G = V; B = p; + break; + + case 2: R = p; G = V; B = t; + break; + + case 3: R = p; G = q; B = V; + break; + + case 4: R = t; G = p; B = V; + break; + + case 5: R = V; G = p; B = q; + break; + } + components[0] = R; components[1] = G; components[2] = B; - } +} -void resolveHSV(float *color1, float *color2) //H value may be undefined (i.e. graycale color) - { // we want to fill it with a sensible value - if(isnan(color1[0]) && isnan(color2[0])) +void resolveHSV(CGFloat *color1, CGFloat *color2) { //H value may be undefined (i.e. graycale color) + // we want to fill it with a sensible value + if (isnan(color1[0]) && isnan(color2[0])) color1[0] = color2[0] = 0; - else if(isnan(color1[0])) + else if (isnan(color1[0])) color1[0] = color2[0]; - else if(isnan(color2[0])) + else if (isnan(color2[0])) color2[0] = color1[0]; - } +} @end diff --git a/CTGradient.xcodeproj/project.pbxproj b/CTGradient.xcodeproj/project.pbxproj index 00f0fb0..dfc01d3 100644 --- a/CTGradient.xcodeproj/project.pbxproj +++ b/CTGradient.xcodeproj/project.pbxproj @@ -3,144 +3,201 @@ archiveVersion = 1; classes = { }; - objectVersion = 42; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ - 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; - 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; - 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; - A89BD8D4097A55BA00104C29 /* CTGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = A89BD8D3097A55BA00104C29 /* CTGradient.m */; }; - A89BD8D7097A55C400104C29 /* CTGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = A89BD8D6097A55C400104C29 /* CTGradientView.m */; }; - A8F011870A7375B6000A0400 /* TieDye.icns in Resources */ = {isa = PBXBuildFile; fileRef = A8F011860A7375B6000A0400 /* TieDye.icns */; }; + B427FC0119158C3600077A59 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B427FC0019158C3600077A59 /* Cocoa.framework */; }; + B427FC3A19158C7800077A59 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC3319158C7800077A59 /* AppDelegate.m */; }; + B427FC3D19158C7800077A59 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC3719158C7800077A59 /* main.m */; }; + B427FC3E19158C7800077A59 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = B427FC3819158C7800077A59 /* MainMenu.nib */; }; + B427FC4419158C9000077A59 /* CTGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC4119158C9000077A59 /* CTGradient.m */; }; + B427FC4519158C9000077A59 /* CTGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC4319158C9000077A59 /* CTGradientView.m */; }; + B427FC4C19158F0E00077A59 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B427FC4B19158F0E00077A59 /* Foundation.framework */; }; + B427FC4E19158F0E00077A59 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B427FC4D19158F0E00077A59 /* CoreGraphics.framework */; }; + B427FC5019158F0E00077A59 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B427FC4F19158F0E00077A59 /* UIKit.framework */; }; + B427FC5C19158F0E00077A59 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC5B19158F0E00077A59 /* AppDelegate.m */; }; + B427FC6519158F0E00077A59 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC6419158F0E00077A59 /* MainViewController.m */; }; + B427FC6819158F0E00077A59 /* FlipsideViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC6719158F0E00077A59 /* FlipsideViewController.m */; }; + B427FC6A19158F0E00077A59 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B427FC6919158F0E00077A59 /* Images.xcassets */; }; + B427FC83191592E100077A59 /* CTGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC4119158C9000077A59 /* CTGradient.m */; }; + B427FC84191592E100077A59 /* CTGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC4319158C9000077A59 /* CTGradientView.m */; }; + B427FC8B191594E700077A59 /* Main_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B427FC87191594E700077A59 /* Main_iPad.storyboard */; }; + B427FC8C191594E700077A59 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B427FC88191594E700077A59 /* Main_iPhone.storyboard */; }; + B427FC8D191594E700077A59 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B427FC89191594E700077A59 /* main.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; - 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; }; - 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; - 8D1107320486CEB800E47090 /* CTGradient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CTGradient.app; sourceTree = BUILT_PRODUCTS_DIR; }; - A89BD8D2097A55BA00104C29 /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTGradient.h; sourceTree = ""; }; - A89BD8D3097A55BA00104C29 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = CTGradient.m; sourceTree = ""; }; - A89BD8D5097A55C400104C29 /* CTGradientView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CTGradientView.h; sourceTree = ""; }; - A89BD8D6097A55C400104C29 /* CTGradientView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = CTGradientView.m; sourceTree = ""; }; - A8F011860A7375B6000A0400 /* TieDye.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = TieDye.icns; sourceTree = ""; }; + B427FBFD19158C3600077A59 /* CTGradient-OSX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CTGradient-OSX.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + B427FC0019158C3600077A59 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; + B427FC0319158C3600077A59 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + B427FC0419158C3600077A59 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + B427FC0519158C3600077A59 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + B427FC1F19158C3600077A59 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + B427FC3219158C7800077A59 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + B427FC3319158C7800077A59 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + B427FC3419158C7800077A59 /* CTGradient-OSX-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "CTGradient-OSX-Info.plist"; sourceTree = ""; }; + B427FC3519158C7800077A59 /* CTGradient-OSX-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CTGradient-OSX-Prefix.pch"; sourceTree = ""; }; + B427FC3719158C7800077A59 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + B427FC3819158C7800077A59 /* MainMenu.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = MainMenu.nib; sourceTree = ""; }; + B427FC4019158C9000077A59 /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTGradient.h; sourceTree = ""; }; + B427FC4119158C9000077A59 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CTGradient.m; sourceTree = ""; }; + B427FC4219158C9000077A59 /* CTGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTGradientView.h; sourceTree = ""; }; + B427FC4319158C9000077A59 /* CTGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CTGradientView.m; sourceTree = ""; }; + B427FC4A19158F0E00077A59 /* CTGradient-IOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CTGradient-IOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + B427FC4B19158F0E00077A59 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + B427FC4D19158F0E00077A59 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; + B427FC4F19158F0E00077A59 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + B427FC5A19158F0E00077A59 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + B427FC5B19158F0E00077A59 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + B427FC6319158F0E00077A59 /* MainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; + B427FC6419158F0E00077A59 /* MainViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; + B427FC6619158F0E00077A59 /* FlipsideViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FlipsideViewController.h; sourceTree = ""; }; + B427FC6719158F0E00077A59 /* FlipsideViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlipsideViewController.m; sourceTree = ""; }; + B427FC6919158F0E00077A59 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + B427FC85191594E700077A59 /* CTGradient-IOS-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "CTGradient-IOS-Info.plist"; sourceTree = ""; }; + B427FC86191594E700077A59 /* CTGradient-IOS-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CTGradient-IOS-Prefix.pch"; sourceTree = ""; }; + B427FC87191594E700077A59 /* Main_iPad.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main_iPad.storyboard; sourceTree = ""; }; + B427FC88191594E700077A59 /* Main_iPhone.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main_iPhone.storyboard; sourceTree = ""; }; + B427FC89191594E700077A59 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 8D11072E0486CEB800E47090 /* Frameworks */ = { + B427FBFA19158C3600077A59 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + B427FC0119158C3600077A59 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B427FC4719158F0E00077A59 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + B427FC4E19158F0E00077A59 /* CoreGraphics.framework in Frameworks */, + B427FC5019158F0E00077A59 /* UIKit.framework in Frameworks */, + B427FC4C19158F0E00077A59 /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 080E96DDFE201D6D7F000001 /* Classes */ = { - isa = PBXGroup; - children = ( - A89BD8D2097A55BA00104C29 /* CTGradient.h */, - A89BD8D3097A55BA00104C29 /* CTGradient.m */, - A89BD8D5097A55C400104C29 /* CTGradientView.h */, - A89BD8D6097A55C400104C29 /* CTGradientView.m */, - ); - name = Classes; - sourceTree = ""; - }; - 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { - isa = PBXGroup; - children = ( - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, - ); - name = "Linked Frameworks"; - sourceTree = ""; - }; - 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { + 29B97314FDCFA39411CA2CEA /* CTGradient */ = { isa = PBXGroup; children = ( - 29B97324FDCFA39411CA2CEA /* AppKit.framework */, - 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, - 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + B427FC4019158C9000077A59 /* CTGradient.h */, + B427FC4119158C9000077A59 /* CTGradient.m */, + B427FC4219158C9000077A59 /* CTGradientView.h */, + B427FC4319158C9000077A59 /* CTGradientView.m */, + B427FC0619158C3600077A59 /* CTGradient-OSX */, + B427FC5119158F0E00077A59 /* CTGradient-IOS */, + B427FBFF19158C3600077A59 /* Frameworks */, + B427FBFE19158C3600077A59 /* Products */, ); - name = "Other Frameworks"; + name = CTGradient; sourceTree = ""; }; - 19C28FACFE9D520D11CA2CBB /* Products */ = { + B427FBFE19158C3600077A59 /* Products */ = { isa = PBXGroup; children = ( - 8D1107320486CEB800E47090 /* CTGradient.app */, + B427FBFD19158C3600077A59 /* CTGradient-OSX.app */, + B427FC4A19158F0E00077A59 /* CTGradient-IOS.app */, ); name = Products; sourceTree = ""; }; - 29B97314FDCFA39411CA2CEA /* CTGradient */ = { + B427FBFF19158C3600077A59 /* Frameworks */ = { isa = PBXGroup; children = ( - 080E96DDFE201D6D7F000001 /* Classes */, - 29B97315FDCFA39411CA2CEA /* Other Sources */, - 29B97317FDCFA39411CA2CEA /* Resources */, - 29B97323FDCFA39411CA2CEA /* Frameworks */, - 19C28FACFE9D520D11CA2CBB /* Products */, + B427FC0019158C3600077A59 /* Cocoa.framework */, + B427FC1F19158C3600077A59 /* XCTest.framework */, + B427FC4B19158F0E00077A59 /* Foundation.framework */, + B427FC4D19158F0E00077A59 /* CoreGraphics.framework */, + B427FC4F19158F0E00077A59 /* UIKit.framework */, + B427FC0219158C3600077A59 /* Other Frameworks */, ); - name = CTGradient; + name = Frameworks; sourceTree = ""; }; - 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + B427FC0219158C3600077A59 /* Other Frameworks */ = { isa = PBXGroup; children = ( - 29B97316FDCFA39411CA2CEA /* main.m */, + B427FC0319158C3600077A59 /* AppKit.framework */, + B427FC0419158C3600077A59 /* CoreData.framework */, + B427FC0519158C3600077A59 /* Foundation.framework */, ); - name = "Other Sources"; + name = "Other Frameworks"; sourceTree = ""; }; - 29B97317FDCFA39411CA2CEA /* Resources */ = { + B427FC0619158C3600077A59 /* CTGradient-OSX */ = { isa = PBXGroup; children = ( - A8F011860A7375B6000A0400 /* TieDye.icns */, - 8D1107310486CEB800E47090 /* Info.plist */, - 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, - 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, + B427FC3419158C7800077A59 /* CTGradient-OSX-Info.plist */, + B427FC3519158C7800077A59 /* CTGradient-OSX-Prefix.pch */, + B427FC3819158C7800077A59 /* MainMenu.nib */, + B427FC3719158C7800077A59 /* main.m */, + B427FC3219158C7800077A59 /* AppDelegate.h */, + B427FC3319158C7800077A59 /* AppDelegate.m */, ); - name = Resources; + path = "CTGradient-OSX"; sourceTree = ""; }; - 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + B427FC5119158F0E00077A59 /* CTGradient-IOS */ = { isa = PBXGroup; children = ( - 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, - 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, + B427FC85191594E700077A59 /* CTGradient-IOS-Info.plist */, + B427FC86191594E700077A59 /* CTGradient-IOS-Prefix.pch */, + B427FC87191594E700077A59 /* Main_iPad.storyboard */, + B427FC88191594E700077A59 /* Main_iPhone.storyboard */, + B427FC89191594E700077A59 /* main.m */, + B427FC5A19158F0E00077A59 /* AppDelegate.h */, + B427FC5B19158F0E00077A59 /* AppDelegate.m */, + B427FC6319158F0E00077A59 /* MainViewController.h */, + B427FC6419158F0E00077A59 /* MainViewController.m */, + B427FC6619158F0E00077A59 /* FlipsideViewController.h */, + B427FC6719158F0E00077A59 /* FlipsideViewController.m */, + B427FC6919158F0E00077A59 /* Images.xcassets */, ); - name = Frameworks; + path = "CTGradient-IOS"; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 8D1107260486CEB800E47090 /* CTGradient */ = { + B427FBFC19158C3600077A59 /* CTGradient-OSX */ = { isa = PBXNativeTarget; - buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "CTGradient" */; + buildConfigurationList = B427FC2C19158C3600077A59 /* Build configuration list for PBXNativeTarget "CTGradient-OSX" */; buildPhases = ( - 8D1107290486CEB800E47090 /* Resources */, - 8D11072C0486CEB800E47090 /* Sources */, - 8D11072E0486CEB800E47090 /* Frameworks */, + B427FBF919158C3600077A59 /* Sources */, + B427FBFA19158C3600077A59 /* Frameworks */, + B427FBFB19158C3600077A59 /* Resources */, ); buildRules = ( ); dependencies = ( ); - name = CTGradient; - productInstallPath = "$(HOME)/Applications"; - productName = CTGradient; - productReference = 8D1107320486CEB800E47090 /* CTGradient.app */; + name = "CTGradient-OSX"; + productName = "CTGradient-OSX"; + productReference = B427FBFD19158C3600077A59 /* CTGradient-OSX.app */; + productType = "com.apple.product-type.application"; + }; + B427FC4919158F0E00077A59 /* CTGradient-IOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = B427FC7D19158F0E00077A59 /* Build configuration list for PBXNativeTarget "CTGradient-IOS" */; + buildPhases = ( + B427FC4619158F0E00077A59 /* Sources */, + B427FC4719158F0E00077A59 /* Frameworks */, + B427FC4819158F0E00077A59 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "CTGradient-IOS"; + productName = "CTGradient-IOS"; + productReference = B427FC4A19158F0E00077A59 /* CTGradient-IOS.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -148,90 +205,255 @@ /* Begin PBXProject section */ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "CTGradient" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + en, + Base, + ); mainGroup = 29B97314FDCFA39411CA2CEA /* CTGradient */; + productRefGroup = B427FBFE19158C3600077A59 /* Products */; projectDirPath = ""; + projectRoot = ""; targets = ( - 8D1107260486CEB800E47090 /* CTGradient */, + B427FBFC19158C3600077A59 /* CTGradient-OSX */, + B427FC4919158F0E00077A59 /* CTGradient-IOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 8D1107290486CEB800E47090 /* Resources */ = { + B427FBFB19158C3600077A59 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, - 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, - A8F011870A7375B6000A0400 /* TieDye.icns in Resources */, + B427FC3E19158C7800077A59 /* MainMenu.nib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B427FC4819158F0E00077A59 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B427FC8C191594E700077A59 /* Main_iPhone.storyboard in Resources */, + B427FC8B191594E700077A59 /* Main_iPad.storyboard in Resources */, + B427FC6A19158F0E00077A59 /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 8D11072C0486CEB800E47090 /* Sources */ = { + B427FBF919158C3600077A59 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8D11072D0486CEB800E47090 /* main.m in Sources */, - A89BD8D4097A55BA00104C29 /* CTGradient.m in Sources */, - A89BD8D7097A55C400104C29 /* CTGradientView.m in Sources */, + B427FC4419158C9000077A59 /* CTGradient.m in Sources */, + B427FC3D19158C7800077A59 /* main.m in Sources */, + B427FC3A19158C7800077A59 /* AppDelegate.m in Sources */, + B427FC4519158C9000077A59 /* CTGradientView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 089C165DFE840E0CC02AAC07 /* English */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; - 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = { - isa = PBXVariantGroup; - children = ( - 29B97319FDCFA39411CA2CEA /* English */, + B427FC4619158F0E00077A59 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B427FC5C19158F0E00077A59 /* AppDelegate.m in Sources */, + B427FC6519158F0E00077A59 /* MainViewController.m in Sources */, + B427FC6819158F0E00077A59 /* FlipsideViewController.m in Sources */, + B427FC83191592E100077A59 /* CTGradient.m in Sources */, + B427FC8D191594E700077A59 /* main.m in Sources */, + B427FC84191592E100077A59 /* CTGradientView.m in Sources */, ); - name = MainMenu.nib; - sourceTree = ""; + runOnlyForDeploymentPostprocessing = 0; }; -/* End PBXVariantGroup section */ +/* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ - C01FCF4B08A954540054247B /* Debug */ = { + B427FC2D19158C3600077A59 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CTGradient-OSX/CTGradient-OSX-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = "CTGradient-OSX/CTGradient-OSX-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.9; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + B427FC2E19158C3600077A59 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CTGradient-OSX/CTGradient-OSX-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = "CTGradient-OSX/CTGradient-OSX-Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.9; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + B427FC7E19158F0E00077A59 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Applications"; - PRODUCT_NAME = CTGradient; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CTGradient-IOS/CTGradient-IOS-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = "CTGradient-IOS/CTGradient-IOS-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; - ZERO_LINK = YES; }; name = Debug; }; - C01FCF4C08A954540054247B /* Release */ = { + B427FC7F19158F0E00077A59 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - ppc, - i386, + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", ); - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Applications"; - PRODUCT_NAME = CTGradient; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CTGradient-IOS/CTGradient-IOS-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = "CTGradient-IOS/CTGradient-IOS-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; WRAPPER_EXTENSION = app; }; name = Release; @@ -241,8 +463,9 @@ buildSettings = { GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; }; name = Debug; }; @@ -252,18 +475,27 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "CTGradient" */ = { + B427FC2C19158C3600077A59 /* Build configuration list for PBXNativeTarget "CTGradient-OSX" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B427FC2D19158C3600077A59 /* Debug */, + B427FC2E19158C3600077A59 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B427FC7D19158F0E00077A59 /* Build configuration list for PBXNativeTarget "CTGradient-IOS" */ = { isa = XCConfigurationList; buildConfigurations = ( - C01FCF4B08A954540054247B /* Debug */, - C01FCF4C08A954540054247B /* Release */, + B427FC7E19158F0E00077A59 /* Debug */, + B427FC7F19158F0E00077A59 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/CTGradient.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CTGradient.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..c7d59eb --- /dev/null +++ b/CTGradient.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CTGradient.xcodeproj/project.xcworkspace/xcshareddata/CTGradient.xccheckout b/CTGradient.xcodeproj/project.xcworkspace/xcshareddata/CTGradient.xccheckout new file mode 100644 index 0000000..ce1472d --- /dev/null +++ b/CTGradient.xcodeproj/project.xcworkspace/xcshareddata/CTGradient.xccheckout @@ -0,0 +1,41 @@ + + + + + IDESourceControlProjectFavoriteDictionaryKey + + IDESourceControlProjectIdentifier + BBECC365-35CD-41BD-9026-CC7F66C5D7E6 + IDESourceControlProjectName + CTGradient + IDESourceControlProjectOriginsDictionary + + 34357E4B-D2EF-43BD-92F3-28DC0E83FD1D + ssh://github.com/Daij-Djan/CTGradient.git + + IDESourceControlProjectPath + CTGradient.xcodeproj/project.xcworkspace + IDESourceControlProjectRelativeInstallPathDictionary + + 34357E4B-D2EF-43BD-92F3-28DC0E83FD1D + ../.. + + IDESourceControlProjectURL + ssh://github.com/Daij-Djan/CTGradient.git + IDESourceControlProjectVersion + 110 + IDESourceControlProjectWCCIdentifier + 34357E4B-D2EF-43BD-92F3-28DC0E83FD1D + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + 34357E4B-D2EF-43BD-92F3-28DC0E83FD1D + IDESourceControlWCCName + CTGradient + + + + diff --git a/CTGradient.xcodeproj/project.xcworkspace/xcuserdata/dominik.xcuserdatad/UserInterfaceState.xcuserstate b/CTGradient.xcodeproj/project.xcworkspace/xcuserdata/dominik.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..861febe Binary files /dev/null and b/CTGradient.xcodeproj/project.xcworkspace/xcuserdata/dominik.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CTGradient.xcodeproj/project.xcworkspace/xcuserdata/dominik.xcuserdatad/WorkspaceSettings.xcsettings b/CTGradient.xcodeproj/project.xcworkspace/xcuserdata/dominik.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..bfffcfe --- /dev/null +++ b/CTGradient.xcodeproj/project.xcworkspace/xcuserdata/dominik.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,10 @@ + + + + + HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges + + SnapshotAutomaticallyBeforeSignificantChanges + + + diff --git a/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/CTGradient-IOS.xcscheme b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/CTGradient-IOS.xcscheme new file mode 100644 index 0000000..7a1f55e --- /dev/null +++ b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/CTGradient-IOS.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/CTGradient-OSX.xcscheme b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/CTGradient-OSX.xcscheme new file mode 100644 index 0000000..71384f0 --- /dev/null +++ b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/CTGradient-OSX.xcscheme @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/xcschememanagement.plist b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..c8fc45f --- /dev/null +++ b/CTGradient.xcodeproj/xcuserdata/dominik.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,47 @@ + + + + + SchemeUserState + + CTGradient-IOS.xcscheme + + orderHint + 1 + + CTGradient-OSX.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 8D1107260486CEB800E47090 + + primary + + + B427FBFC19158C3600077A59 + + primary + + + B427FC1D19158C3600077A59 + + primary + + + B427FC4919158F0E00077A59 + + primary + + + B427FC6E19158F0E00077A59 + + primary + + + + + diff --git a/CTGradientView.h b/CTGradientView.h index 58d1edd..0623ea9 100644 --- a/CTGradientView.h +++ b/CTGradientView.h @@ -6,19 +6,29 @@ // Some rights reserved: // +#if !__has_feature(objc_arc) +#error This class requires automatic reference counting +#endif + +#if TARGET_OS_IPHONE +#import +@class CTGradient; +#define View UIView +#define Rect CGRect +#define setNeedsDisplay [self setNeedsDisplay] +#else #import +#define View NSView +#define Rect NSRect +#define setNeedsDisplay [self setNeedsDisplay:YES] +#endif + #import "CTGradient.h" -@interface CTGradientView : NSView - { - CTGradient *myGradient; - - float angle; - bool isRadial; - } +@interface CTGradientView : View -- (IBAction)changeType :(id)sender; -- (IBAction)changeAngle:(id)sender; -- (IBAction)changeStyle:(id)sender; +@property(nonatomic, retain) CTGradient *gradient; +@property(nonatomic, assign) CGFloat angle; +@property(nonatomic, assign, getter = isRadial) BOOL radial; @end diff --git a/CTGradientView.m b/CTGradientView.m index 5401d9a..82e4241 100644 --- a/CTGradientView.m +++ b/CTGradientView.m @@ -10,93 +10,45 @@ @implementation CTGradientView -- (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self) - { - myGradient = [[CTGradient aquaSelectedGradient] retain]; - - angle = 90; - isRadial = NO; - } - return self; +- (id)initWithFrame:(Rect)frame { + self = [super initWithFrame:frame]; + if (self) { + _gradient = [CTGradient rainbowGradient]; + _angle = 90; + _radial = NO; + } + return self; } -- (void)dealloc - { - [myGradient release]; - [super dealloc]; - } - -- (bool)isOpaque - { - return NO; - } - -- (void)drawRect:(NSRect)rect - { - CTGradient *aGradient = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:myGradient]]; - - if(isRadial) - [aGradient radialFillRect:rect]; - else - [aGradient fillRect:rect angle:angle]; - //{ - //rect = NSMakeRect(346,-300,50,600); - //NSAffineTransform *transform = [[NSAffineTransform alloc] init]; - //[transform rotateByDegrees:45]; - //NSBezierPath *path = [transform transformBezierPath:[NSBezierPath bezierPathWithOvalInRect:rect]]; - //[aGradient fillBezierPath:path angle:angle]; - //} - } +#if TARGET_OS_IPHONE +#else +- (BOOL)isOpaque { + return NO; +} +#endif -- (IBAction)changeAngle:(id)sender - { - angle = 90.0 - [sender floatValue]; - - [self setNeedsDisplay:YES]; - } +- (void)drawRect:(Rect)rect { + if (self.isRadial) { + [self.gradient radialFillRect:rect]; + } + else { + [self.gradient fillRect:rect angle:self.angle]; + } +} -- (IBAction)changeType:(id)sender - { - if([[[sender selectedCell] title] isEqualToString:@"Axial"]) - isRadial = NO; - else - isRadial = YES; - - [self setNeedsDisplay:YES]; - } +- (void)setGradient:(CTGradient *)gradient { + _gradient = gradient; + setNeedsDisplay; +} -- (IBAction)changeStyle:(id)sender - { - [myGradient release]; - - switch([sender indexOfSelectedItem]) - { - case 1: myGradient = [CTGradient aquaSelectedGradient]; break; - case 2: myGradient = [CTGradient aquaNormalGradient ]; break; - case 3: myGradient = [CTGradient aquaPressedGradient ]; break; - case 4: myGradient = [CTGradient unifiedSelectedGradient]; break; - case 5: myGradient = [CTGradient unifiedNormalGradient ]; break; - case 6: myGradient = [CTGradient unifiedPressedGradient ]; break; - case 7: myGradient = [CTGradient unifiedDarkGradient ]; break; - case 8: myGradient = [CTGradient sourceListSelectedGradient ]; break; - case 9: myGradient = [CTGradient sourceListUnselectedGradient]; break; - case 10: myGradient = [CTGradient rainbowGradient]; break; - case 11: myGradient = [CTGradient hydrogenSpectrumGradient]; break; - - default: myGradient = [CTGradient gradientWithBeginningColor:[NSColor blackColor] - endingColor:[NSColor whiteColor]]; - } - - [myGradient retain]; - - [self setNeedsDisplay:YES]; - } +- (void)setAngle:(CGFloat)angle { + _angle = angle; + setNeedsDisplay; +} -- (void)windowWillClose:(NSNotification *)aNotification - { - [NSApp terminate:self]; - } +- (void)setRadial:(BOOL)radial { + _radial = radial; + setNeedsDisplay; +} @end diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings deleted file mode 100644 index d2170da..0000000 Binary files a/English.lproj/InfoPlist.strings and /dev/null differ diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib deleted file mode 100644 index f0fe0fa..0000000 --- a/English.lproj/MainMenu.nib/classes.nib +++ /dev/null @@ -1,12 +0,0 @@ -{ - IBClasses = ( - { - ACTIONS = {changeAngle = id; changeStyle = id; changeType = id; }; - CLASS = CTGradientView; - LANGUAGE = ObjC; - SUPERCLASS = NSView; - }, - {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } - ); - IBVersion = 1; -} \ No newline at end of file diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib deleted file mode 100644 index 716f2ed..0000000 --- a/English.lproj/MainMenu.nib/info.nib +++ /dev/null @@ -1,23 +0,0 @@ - - - - - IBDocumentLocation - 154 178 356 240 0 0 1440 878 - IBEditorPositions - - 29 - 110 299 291 44 0 0 1440 878 - - IBFramework Version - 446.1 - IBOpenObjects - - 214 - 209 - 29 - - IBSystem Version - 8L2127 - - diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib deleted file mode 100644 index 1174aba..0000000 Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and /dev/null differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d18f60 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +CTGradient +========== + +fork that does ios & osx + +also features arc support, some style improvments AND two demos diff --git a/TieDye.icns b/TieDye.icns deleted file mode 100644 index 40d5d8b..0000000 Binary files a/TieDye.icns and /dev/null differ