Permalink
Browse files

Initial version

  • Loading branch information...
1 parent d71b5ed commit cb91482bc60d6049e9d1bdeb9022812d3f6656f7 @alexrestrepo committed Sep 2, 2012
Showing with 2,350 additions and 0 deletions.
  1. +113 −0 KZColorPicker.xcodeproj/project.pbxproj
  2. +7 −0 KZColorPicker/AppDelegate.m
  3. +73 −0 KZColorPicker/ColorPicker/HSV.c
  4. +25 −0 KZColorPicker/ColorPicker/HSV.h
  5. +18 −0 KZColorPicker/ColorPicker/KZColorCompareView.h
  6. +246 −0 KZColorPicker/ColorPicker/KZColorCompareView.m
  7. +32 −0 KZColorPicker/ColorPicker/KZColorPicker.h
  8. +365 −0 KZColorPicker/ColorPicker/KZColorPicker.m
  9. +20 −0 KZColorPicker/ColorPicker/KZColorPickerAlphaSlider.h
  10. +88 −0 KZColorPicker/ColorPicker/KZColorPickerAlphaSlider.m
  11. +19 −0 KZColorPicker/ColorPicker/KZColorPickerBrightnessSlider.h
  12. +77 −0 KZColorPicker/ColorPicker/KZColorPickerBrightnessSlider.m
  13. +23 −0 KZColorPicker/ColorPicker/KZColorPickerHSWheel.h
  14. +140 −0 KZColorPicker/ColorPicker/KZColorPickerHSWheel.m
  15. +20 −0 KZColorPicker/ColorPicker/KZColorPickerSwatchView.h
  16. +210 −0 KZColorPicker/ColorPicker/KZColorPickerSwatchView.m
  17. +21 −0 KZColorPicker/ColorPicker/KZUnitSlider.h
  18. +108 −0 KZColorPicker/ColorPicker/KZUnitSlider.m
  19. +61 −0 KZColorPicker/ColorPicker/UIColor-Expanded.h
  20. +544 −0 KZColorPicker/ColorPicker/UIColor-Expanded.m
  21. BIN KZColorPicker/ColorPicker/checkerboard.png
  22. BIN KZColorPicker/ColorPicker/checkerboard@2x.png
  23. BIN KZColorPicker/ColorPicker/colorPickerKnob.png
  24. BIN KZColorPicker/ColorPicker/colorPickerKnob@2x.png
  25. BIN KZColorPicker/ColorPicker/pickerColorWheel.png
  26. BIN KZColorPicker/ColorPicker/pickerColorWheel@2x.png
  27. +2 −0 KZColorPicker/KZColorPicker-Prefix.pch
  28. +26 −0 KZColorPicker/KZDefaultColorViewController.h
  29. +92 −0 KZColorPicker/KZDefaultColorViewController.m
  30. +15 −0 License
  31. +5 −0 Readme.markdown
@@ -13,6 +13,25 @@
FA4CE70315F2E99000544934 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE70115F2E99000544934 /* InfoPlist.strings */; };
FA4CE70515F2E99000544934 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE70415F2E99000544934 /* main.m */; };
FA4CE70915F2E99000544934 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE70815F2E99000544934 /* AppDelegate.m */; };
+ FA4CE71115F2E9CB00544934 /* KZDefaultColorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE71015F2E9CB00544934 /* KZDefaultColorViewController.m */; };
+ FA4CE72B15F2E9D700544934 /* checkerboard.png in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE71315F2E9D700544934 /* checkerboard.png */; };
+ FA4CE72C15F2E9D700544934 /* checkerboard@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE71415F2E9D700544934 /* checkerboard@2x.png */; };
+ FA4CE72D15F2E9D700544934 /* KZColorCompareView.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE71615F2E9D700544934 /* KZColorCompareView.m */; };
+ FA4CE72E15F2E9D700544934 /* KZColorPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE71815F2E9D700544934 /* KZColorPicker.m */; };
+ FA4CE72F15F2E9D700544934 /* KZColorPickerAlphaSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE71A15F2E9D700544934 /* KZColorPickerAlphaSlider.m */; };
+ FA4CE73015F2E9D700544934 /* KZColorPickerBrightnessSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE71C15F2E9D700544934 /* KZColorPickerBrightnessSlider.m */; };
+ FA4CE73115F2E9D700544934 /* KZColorPickerHSWheel.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE71E15F2E9D700544934 /* KZColorPickerHSWheel.m */; };
+ FA4CE73215F2E9D700544934 /* KZColorPickerSwatchView.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE72015F2E9D700544934 /* KZColorPickerSwatchView.m */; };
+ FA4CE73315F2E9D700544934 /* KZUnitSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE72215F2E9D700544934 /* KZUnitSlider.m */; };
+ FA4CE73415F2E9D700544934 /* colorPickerKnob.png in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE72315F2E9D700544934 /* colorPickerKnob.png */; };
+ FA4CE73515F2E9D700544934 /* colorPickerKnob@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE72415F2E9D700544934 /* colorPickerKnob@2x.png */; };
+ FA4CE73615F2E9D700544934 /* HSV.c in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE72515F2E9D700544934 /* HSV.c */; };
+ FA4CE73715F2E9D700544934 /* pickerColorWheel.png in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE72715F2E9D700544934 /* pickerColorWheel.png */; };
+ FA4CE73815F2E9D700544934 /* pickerColorWheel@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE72815F2E9D700544934 /* pickerColorWheel@2x.png */; };
+ FA4CE73915F2E9D700544934 /* UIColor-Expanded.m in Sources */ = {isa = PBXBuildFile; fileRef = FA4CE72A15F2E9D700544934 /* UIColor-Expanded.m */; };
+ FA4CE73C15F2EA7D00544934 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA4CE73B15F2EA7D00544934 /* QuartzCore.framework */; };
+ FA4CE74715F2EAC500544934 /* License in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE74515F2EAC500544934 /* License */; };
+ FA4CE74815F2EAC500544934 /* Readme.markdown in Resources */ = {isa = PBXBuildFile; fileRef = FA4CE74615F2EAC500544934 /* Readme.markdown */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -26,13 +45,43 @@
FA4CE70615F2E99000544934 /* KZColorPicker-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KZColorPicker-Prefix.pch"; sourceTree = "<group>"; };
FA4CE70715F2E99000544934 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
FA4CE70815F2E99000544934 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ FA4CE70F15F2E9CB00544934 /* KZDefaultColorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZDefaultColorViewController.h; sourceTree = "<group>"; };
+ FA4CE71015F2E9CB00544934 /* KZDefaultColorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZDefaultColorViewController.m; sourceTree = "<group>"; };
+ FA4CE71315F2E9D700544934 /* checkerboard.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = checkerboard.png; sourceTree = "<group>"; };
+ FA4CE71415F2E9D700544934 /* checkerboard@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "checkerboard@2x.png"; sourceTree = "<group>"; };
+ FA4CE71515F2E9D700544934 /* KZColorCompareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZColorCompareView.h; sourceTree = "<group>"; };
+ FA4CE71615F2E9D700544934 /* KZColorCompareView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZColorCompareView.m; sourceTree = "<group>"; };
+ FA4CE71715F2E9D700544934 /* KZColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZColorPicker.h; sourceTree = "<group>"; };
+ FA4CE71815F2E9D700544934 /* KZColorPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZColorPicker.m; sourceTree = "<group>"; };
+ FA4CE71915F2E9D700544934 /* KZColorPickerAlphaSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZColorPickerAlphaSlider.h; sourceTree = "<group>"; };
+ FA4CE71A15F2E9D700544934 /* KZColorPickerAlphaSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZColorPickerAlphaSlider.m; sourceTree = "<group>"; };
+ FA4CE71B15F2E9D700544934 /* KZColorPickerBrightnessSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZColorPickerBrightnessSlider.h; sourceTree = "<group>"; };
+ FA4CE71C15F2E9D700544934 /* KZColorPickerBrightnessSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZColorPickerBrightnessSlider.m; sourceTree = "<group>"; };
+ FA4CE71D15F2E9D700544934 /* KZColorPickerHSWheel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZColorPickerHSWheel.h; sourceTree = "<group>"; };
+ FA4CE71E15F2E9D700544934 /* KZColorPickerHSWheel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZColorPickerHSWheel.m; sourceTree = "<group>"; };
+ FA4CE71F15F2E9D700544934 /* KZColorPickerSwatchView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZColorPickerSwatchView.h; sourceTree = "<group>"; };
+ FA4CE72015F2E9D700544934 /* KZColorPickerSwatchView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZColorPickerSwatchView.m; sourceTree = "<group>"; };
+ FA4CE72115F2E9D700544934 /* KZUnitSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KZUnitSlider.h; sourceTree = "<group>"; };
+ FA4CE72215F2E9D700544934 /* KZUnitSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KZUnitSlider.m; sourceTree = "<group>"; };
+ FA4CE72315F2E9D700544934 /* colorPickerKnob.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = colorPickerKnob.png; sourceTree = "<group>"; };
+ FA4CE72415F2E9D700544934 /* colorPickerKnob@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "colorPickerKnob@2x.png"; sourceTree = "<group>"; };
+ FA4CE72515F2E9D700544934 /* HSV.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = HSV.c; sourceTree = "<group>"; };
+ FA4CE72615F2E9D700544934 /* HSV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HSV.h; sourceTree = "<group>"; };
+ FA4CE72715F2E9D700544934 /* pickerColorWheel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pickerColorWheel.png; sourceTree = "<group>"; };
+ FA4CE72815F2E9D700544934 /* pickerColorWheel@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pickerColorWheel@2x.png"; sourceTree = "<group>"; };
+ FA4CE72915F2E9D700544934 /* UIColor-Expanded.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor-Expanded.h"; sourceTree = "<group>"; };
+ FA4CE72A15F2E9D700544934 /* UIColor-Expanded.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor-Expanded.m"; sourceTree = "<group>"; };
+ FA4CE73B15F2EA7D00544934 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ FA4CE74515F2EAC500544934 /* License */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = License; sourceTree = SOURCE_ROOT; };
+ FA4CE74615F2EAC500544934 /* Readme.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Readme.markdown; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
FA4CE6F115F2E99000544934 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ FA4CE73C15F2EA7D00544934 /* QuartzCore.framework in Frameworks */,
FA4CE6F915F2E99000544934 /* UIKit.framework in Frameworks */,
FA4CE6FB15F2E99000544934 /* Foundation.framework in Frameworks */,
FA4CE6FD15F2E99000544934 /* CoreGraphics.framework in Frameworks */,
@@ -62,6 +111,7 @@
FA4CE6F715F2E99000544934 /* Frameworks */ = {
isa = PBXGroup;
children = (
+ FA4CE73B15F2EA7D00544934 /* QuartzCore.framework */,
FA4CE6F815F2E99000544934 /* UIKit.framework */,
FA4CE6FA15F2E99000544934 /* Foundation.framework */,
FA4CE6FC15F2E99000544934 /* CoreGraphics.framework */,
@@ -72,6 +122,11 @@
FA4CE6FE15F2E99000544934 /* KZColorPicker */ = {
isa = PBXGroup;
children = (
+ FA4CE74515F2EAC500544934 /* License */,
+ FA4CE74615F2EAC500544934 /* Readme.markdown */,
+ FA4CE71215F2E9D700544934 /* ColorPicker */,
+ FA4CE70F15F2E9CB00544934 /* KZDefaultColorViewController.h */,
+ FA4CE71015F2E9CB00544934 /* KZDefaultColorViewController.m */,
FA4CE70715F2E99000544934 /* AppDelegate.h */,
FA4CE70815F2E99000544934 /* AppDelegate.m */,
FA4CE6FF15F2E99000544934 /* Supporting Files */,
@@ -90,6 +145,45 @@
name = "Supporting Files";
sourceTree = "<group>";
};
+ FA4CE71215F2E9D700544934 /* ColorPicker */ = {
+ isa = PBXGroup;
+ children = (
+ FA4CE73A15F2E9DF00544934 /* Images */,
+ FA4CE71515F2E9D700544934 /* KZColorCompareView.h */,
+ FA4CE71615F2E9D700544934 /* KZColorCompareView.m */,
+ FA4CE71715F2E9D700544934 /* KZColorPicker.h */,
+ FA4CE71815F2E9D700544934 /* KZColorPicker.m */,
+ FA4CE71915F2E9D700544934 /* KZColorPickerAlphaSlider.h */,
+ FA4CE71A15F2E9D700544934 /* KZColorPickerAlphaSlider.m */,
+ FA4CE71B15F2E9D700544934 /* KZColorPickerBrightnessSlider.h */,
+ FA4CE71C15F2E9D700544934 /* KZColorPickerBrightnessSlider.m */,
+ FA4CE71D15F2E9D700544934 /* KZColorPickerHSWheel.h */,
+ FA4CE71E15F2E9D700544934 /* KZColorPickerHSWheel.m */,
+ FA4CE71F15F2E9D700544934 /* KZColorPickerSwatchView.h */,
+ FA4CE72015F2E9D700544934 /* KZColorPickerSwatchView.m */,
+ FA4CE72115F2E9D700544934 /* KZUnitSlider.h */,
+ FA4CE72215F2E9D700544934 /* KZUnitSlider.m */,
+ FA4CE72615F2E9D700544934 /* HSV.h */,
+ FA4CE72515F2E9D700544934 /* HSV.c */,
+ FA4CE72915F2E9D700544934 /* UIColor-Expanded.h */,
+ FA4CE72A15F2E9D700544934 /* UIColor-Expanded.m */,
+ );
+ path = ColorPicker;
+ sourceTree = "<group>";
+ };
+ FA4CE73A15F2E9DF00544934 /* Images */ = {
+ isa = PBXGroup;
+ children = (
+ FA4CE71315F2E9D700544934 /* checkerboard.png */,
+ FA4CE71415F2E9D700544934 /* checkerboard@2x.png */,
+ FA4CE72315F2E9D700544934 /* colorPickerKnob.png */,
+ FA4CE72415F2E9D700544934 /* colorPickerKnob@2x.png */,
+ FA4CE72715F2E9D700544934 /* pickerColorWheel.png */,
+ FA4CE72815F2E9D700544934 /* pickerColorWheel@2x.png */,
+ );
+ name = Images;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -142,6 +236,14 @@
buildActionMask = 2147483647;
files = (
FA4CE70315F2E99000544934 /* InfoPlist.strings in Resources */,
+ FA4CE72B15F2E9D700544934 /* checkerboard.png in Resources */,
+ FA4CE72C15F2E9D700544934 /* checkerboard@2x.png in Resources */,
+ FA4CE73415F2E9D700544934 /* colorPickerKnob.png in Resources */,
+ FA4CE73515F2E9D700544934 /* colorPickerKnob@2x.png in Resources */,
+ FA4CE73715F2E9D700544934 /* pickerColorWheel.png in Resources */,
+ FA4CE73815F2E9D700544934 /* pickerColorWheel@2x.png in Resources */,
+ FA4CE74715F2EAC500544934 /* License in Resources */,
+ FA4CE74815F2EAC500544934 /* Readme.markdown in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -154,6 +256,16 @@
files = (
FA4CE70515F2E99000544934 /* main.m in Sources */,
FA4CE70915F2E99000544934 /* AppDelegate.m in Sources */,
+ FA4CE71115F2E9CB00544934 /* KZDefaultColorViewController.m in Sources */,
+ FA4CE72D15F2E9D700544934 /* KZColorCompareView.m in Sources */,
+ FA4CE72E15F2E9D700544934 /* KZColorPicker.m in Sources */,
+ FA4CE72F15F2E9D700544934 /* KZColorPickerAlphaSlider.m in Sources */,
+ FA4CE73015F2E9D700544934 /* KZColorPickerBrightnessSlider.m in Sources */,
+ FA4CE73115F2E9D700544934 /* KZColorPickerHSWheel.m in Sources */,
+ FA4CE73215F2E9D700544934 /* KZColorPickerSwatchView.m in Sources */,
+ FA4CE73315F2E9D700544934 /* KZUnitSlider.m in Sources */,
+ FA4CE73615F2E9D700544934 /* HSV.c in Sources */,
+ FA4CE73915F2E9D700544934 /* UIColor-Expanded.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -259,6 +371,7 @@
FA4CE70E15F2E99000544934 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -7,6 +7,7 @@
//
#import "AppDelegate.h"
+#import "KZDefaultColorViewController.h"
@implementation AppDelegate
@@ -19,6 +20,12 @@ - (void)dealloc
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+
+ KZDefaultColorViewController *pickerController = [[KZDefaultColorViewController alloc] initWithNibName:nil bundle:nil];
+ self.window.rootViewController = pickerController;
+ pickerController.selectedColor = [UIColor whiteColor];
+ [pickerController release];
+
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
@@ -0,0 +1,73 @@
+/*
+ * HSV.c
+ * colorPickerTest
+ *
+ * Created by Alex Restrepo on 4/26/10.
+ * Copyright 2010 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include <math.h>
+#include "HSV.h"
+
+inline RGBType RGBTypeMake(float r, float g, float b)
+{
+ RGBType rgb = {r, g, b};
+ return rgb;
+}
+
+inline HSVType HSVTypeMake(float h, float s, float v)
+{
+ HSVType hsv = {h, s, v};
+ return hsv;
+}
+
+HSVType RGB_to_HSV( RGBType RGB )
+{
+ // RGB are each on [0, 1]. S and V are returned on [0, 1] and H is
+ // returned on [0, 1]. Exception: H is returned UNDEFINED if S==0.
+ float R = RGB.r, G = RGB.g, B = RGB.b, v, x, f;
+ int i;
+
+ x = fminf(R, G);
+ x = fminf(x, B);
+
+ v = fmaxf(R, G);
+ v = fmaxf(v, B);
+
+ if(v == x)
+ return HSVTypeMake(UNDEFINED, 0, v);
+
+ f = (R == x) ? G - B : ((G == x) ? B - R : R - G);
+ i = (R == x) ? 3 : ((G == x) ? 5 : 1);
+
+ return HSVTypeMake(((i - f /(v - x))/6), (v - x)/v, v);
+}
+
+RGBType HSV_to_RGB( HSVType HSV )
+{
+ // H is given on [0, 1] or UNDEFINED. S and V are given on [0, 1].
+ // RGB are each returned on [0, 1].
+ float h = HSV.h * 6, s = HSV.s, v = HSV.v, m, n, f;
+ int i;
+
+ if (h == 0) h=.01;
+ if(h == UNDEFINED)
+ return RGBTypeMake(v, v, v);
+ i = floorf(h);
+ f = h - i;
+ if(!(i & 1)) f = 1 - f; // if i is even
+ m = v * (1 - s);
+ n = v * (1 - s * f);
+ switch (i)
+ {
+ case 6:
+ case 0: return RGBTypeMake(v, n, m);
+ case 1: return RGBTypeMake(n, v, m);
+ case 2: return RGBTypeMake(m, v, n);
+ case 3: return RGBTypeMake(m, n, v);
+ case 4: return RGBTypeMake(n, m, v);
+ case 5: return RGBTypeMake(v, m, n);
+ }
+ return RGBTypeMake(0, 0, 0);
+}
@@ -0,0 +1,25 @@
+/*
+ * HSV.h
+ * colorPickerTest
+ *
+ * Created by Alex Restrepo on 4/26/10.
+ * Copyright 2010 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+
+
+//code from http://www.cocoabuilder.com/archive/cocoa/198570-here-is-code-to-convert-rgb-hsb.html
+#define UNDEFINED 0
+
+typedef struct {float r, g, b;} RGBType;
+typedef struct {float h, s, v;} HSVType;
+
+// Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure
+// red always maps to 6 in this implementation. Therefore UNDEFINED can be
+// defined as 0 in situations where only unsigned numbers are desired.
+RGBType RGBTypeMake(float r, float g, float b);
+HSVType HSVTypeMake(float h, float s, float v);
+
+HSVType RGB_to_HSV( RGBType RGB );
+RGBType HSV_to_RGB( HSVType HSV );
@@ -0,0 +1,18 @@
+//
+// KZColorCompareView.h
+//
+// Created by Alex Restrepo on 5/11/11.
+// Copyright 2011 KZLabs http://kzlabs.me
+// All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface KZColorCompareView : UIControl {
+
+}
+
+@property (nonatomic, retain) UIColor *oldColor;
+@property (nonatomic, retain) UIColor *currentColor;
+@end
Oops, something went wrong.

0 comments on commit cb91482

Please sign in to comment.