├── ColorPicker.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── ColorPicker ├── ColorPicker-Info.plist ├── ColorPicker-Prefix.pch ├── ColorPickerAppDelegate.h ├── ColorPickerAppDelegate.m ├── ColorPickerController.h ├── ColorPickerController.mm ├── CrosshairSelector.png ├── CrosshairSelector@2x.png ├── Default-Landscape.png ├── Default-Portrait.png ├── Default.png ├── Default@2x.png ├── GradientView.h ├── GradientView.mm ├── HorizontalSelector.png ├── HorizontalSelector@2x.png ├── HueSaturationGradient.png ├── Icon-72.png ├── Icon.png ├── Icon@2x.png ├── IconSmall-50.png ├── IconSmall.png ├── IconSmall@2x.png ├── en.lproj │ └── Localizable.strings ├── iPad │ ├── ColorPickerAppDelegate_iPad.h │ ├── ColorPickerAppDelegate_iPad.m │ └── en.lproj │ │ └── MainWindow_iPad.xib ├── iPhone │ ├── ColorPickerAppDelegate_iPhone.h │ ├── ColorPickerAppDelegate_iPhone.m │ └── en.lproj │ │ └── MainWindow_iPhone.xib └── main.m └── README /ColorPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C620B5BB142E329100C3250B /* Default-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B1142E329100C3250B /* Default-Landscape.png */; }; 11 | C620B5BC142E329100C3250B /* Default-Portrait.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B2142E329100C3250B /* Default-Portrait.png */; }; 12 | C620B5BD142E329100C3250B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B3142E329100C3250B /* Default.png */; }; 13 | C620B5BE142E329100C3250B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B4142E329100C3250B /* Default@2x.png */; }; 14 | C620B5BF142E329100C3250B /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B5142E329100C3250B /* Icon-72.png */; }; 15 | C620B5C0142E329100C3250B /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B6142E329100C3250B /* Icon.png */; }; 16 | C620B5C1142E329100C3250B /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B7142E329100C3250B /* Icon@2x.png */; }; 17 | C620B5C2142E329100C3250B /* IconSmall-50.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B8142E329100C3250B /* IconSmall-50.png */; }; 18 | C620B5C3142E329100C3250B /* IconSmall.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5B9142E329100C3250B /* IconSmall.png */; }; 19 | C620B5C4142E329100C3250B /* IconSmall@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C620B5BA142E329100C3250B /* IconSmall@2x.png */; }; 20 | C6900110142CC7F400095285 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C690010F142CC7F400095285 /* UIKit.framework */; }; 21 | C6900112142CC7F400095285 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6900111142CC7F400095285 /* Foundation.framework */; }; 22 | C6900114142CC7F400095285 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6900113142CC7F400095285 /* CoreGraphics.framework */; }; 23 | C690011C142CC7F400095285 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C690011B142CC7F400095285 /* main.m */; }; 24 | C6900120142CC7F400095285 /* ColorPickerAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C690011F142CC7F400095285 /* ColorPickerAppDelegate.m */; }; 25 | C6900124142CC7F400095285 /* ColorPickerAppDelegate_iPhone.m in Sources */ = {isa = PBXBuildFile; fileRef = C6900123142CC7F400095285 /* ColorPickerAppDelegate_iPhone.m */; }; 26 | C6900127142CC7F400095285 /* MainWindow_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = C6900125142CC7F400095285 /* MainWindow_iPhone.xib */; }; 27 | C690012B142CC7F400095285 /* ColorPickerAppDelegate_iPad.m in Sources */ = {isa = PBXBuildFile; fileRef = C690012A142CC7F400095285 /* ColorPickerAppDelegate_iPad.m */; }; 28 | C690012E142CC7F400095285 /* MainWindow_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = C690012C142CC7F400095285 /* MainWindow_iPad.xib */; }; 29 | C6900136142CC8C800095285 /* ColorPickerController.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6900135142CC8C800095285 /* ColorPickerController.mm */; }; 30 | C690014C142CD3AC00095285 /* CrosshairSelector.png in Resources */ = {isa = PBXBuildFile; fileRef = C6900147142CD3AC00095285 /* CrosshairSelector.png */; }; 31 | C690014D142CD3AC00095285 /* CrosshairSelector@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6900148142CD3AC00095285 /* CrosshairSelector@2x.png */; }; 32 | C690014E142CD3AC00095285 /* HorizontalSelector.png in Resources */ = {isa = PBXBuildFile; fileRef = C6900149142CD3AC00095285 /* HorizontalSelector.png */; }; 33 | C690014F142CD3AC00095285 /* HorizontalSelector@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C690014A142CD3AC00095285 /* HorizontalSelector@2x.png */; }; 34 | C6900153142CD89700095285 /* GradientView.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6900152142CD89700095285 /* GradientView.mm */; }; 35 | C6900155142CE83200095285 /* HueSaturationGradient.png in Resources */ = {isa = PBXBuildFile; fileRef = C6900154142CE83200095285 /* HueSaturationGradient.png */; }; 36 | C690016B142E235300095285 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C6900169142E235300095285 /* Localizable.strings */; }; 37 | /* End PBXBuildFile section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | C620B5B1142E329100C3250B /* Default-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape.png"; sourceTree = ""; }; 41 | C620B5B2142E329100C3250B /* Default-Portrait.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait.png"; sourceTree = ""; }; 42 | C620B5B3142E329100C3250B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 43 | C620B5B4142E329100C3250B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 44 | C620B5B5142E329100C3250B /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; 45 | C620B5B6142E329100C3250B /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; 46 | C620B5B7142E329100C3250B /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; }; 47 | C620B5B8142E329100C3250B /* IconSmall-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "IconSmall-50.png"; sourceTree = ""; }; 48 | C620B5B9142E329100C3250B /* IconSmall.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = IconSmall.png; sourceTree = ""; }; 49 | C620B5BA142E329100C3250B /* IconSmall@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "IconSmall@2x.png"; sourceTree = ""; }; 50 | C690010B142CC7F400095285 /* ColorPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ColorPicker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | C690010F142CC7F400095285 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 52 | C6900111142CC7F400095285 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 53 | C6900113142CC7F400095285 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 54 | C6900117142CC7F400095285 /* ColorPicker-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ColorPicker-Info.plist"; sourceTree = ""; }; 55 | C690011B142CC7F400095285 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 56 | C690011D142CC7F400095285 /* ColorPicker-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ColorPicker-Prefix.pch"; sourceTree = ""; }; 57 | C690011E142CC7F400095285 /* ColorPickerAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorPickerAppDelegate.h; sourceTree = ""; }; 58 | C690011F142CC7F400095285 /* ColorPickerAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ColorPickerAppDelegate.m; sourceTree = ""; }; 59 | C6900122142CC7F400095285 /* ColorPickerAppDelegate_iPhone.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ColorPickerAppDelegate_iPhone.h; path = iPhone/ColorPickerAppDelegate_iPhone.h; sourceTree = ""; }; 60 | C6900123142CC7F400095285 /* ColorPickerAppDelegate_iPhone.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ColorPickerAppDelegate_iPhone.m; path = iPhone/ColorPickerAppDelegate_iPhone.m; sourceTree = ""; }; 61 | C6900126142CC7F400095285 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = iPhone/en.lproj/MainWindow_iPhone.xib; sourceTree = ""; }; 62 | C6900129142CC7F400095285 /* ColorPickerAppDelegate_iPad.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ColorPickerAppDelegate_iPad.h; path = iPad/ColorPickerAppDelegate_iPad.h; sourceTree = ""; }; 63 | C690012A142CC7F400095285 /* ColorPickerAppDelegate_iPad.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ColorPickerAppDelegate_iPad.m; path = iPad/ColorPickerAppDelegate_iPad.m; sourceTree = ""; }; 64 | C690012D142CC7F400095285 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = iPad/en.lproj/MainWindow_iPad.xib; sourceTree = ""; }; 65 | C6900134142CC8C800095285 /* ColorPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorPickerController.h; sourceTree = ""; }; 66 | C6900135142CC8C800095285 /* ColorPickerController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColorPickerController.mm; sourceTree = ""; }; 67 | C6900147142CD3AC00095285 /* CrosshairSelector.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CrosshairSelector.png; sourceTree = ""; }; 68 | C6900148142CD3AC00095285 /* CrosshairSelector@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "CrosshairSelector@2x.png"; sourceTree = ""; }; 69 | C6900149142CD3AC00095285 /* HorizontalSelector.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HorizontalSelector.png; sourceTree = ""; }; 70 | C690014A142CD3AC00095285 /* HorizontalSelector@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "HorizontalSelector@2x.png"; sourceTree = ""; }; 71 | C6900151142CD89700095285 /* GradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GradientView.h; sourceTree = ""; }; 72 | C6900152142CD89700095285 /* GradientView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GradientView.mm; sourceTree = ""; }; 73 | C6900154142CE83200095285 /* HueSaturationGradient.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HueSaturationGradient.png; sourceTree = ""; }; 74 | C690016A142E235300095285 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 75 | /* End PBXFileReference section */ 76 | 77 | /* Begin PBXFrameworksBuildPhase section */ 78 | C6900108142CC7F400095285 /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | C6900110142CC7F400095285 /* UIKit.framework in Frameworks */, 83 | C6900112142CC7F400095285 /* Foundation.framework in Frameworks */, 84 | C6900114142CC7F400095285 /* CoreGraphics.framework in Frameworks */, 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | /* End PBXFrameworksBuildPhase section */ 89 | 90 | /* Begin PBXGroup section */ 91 | C6900100142CC7F400095285 = { 92 | isa = PBXGroup; 93 | children = ( 94 | C6900115142CC7F400095285 /* ColorPicker */, 95 | C690010E142CC7F400095285 /* Frameworks */, 96 | C690010C142CC7F400095285 /* Products */, 97 | ); 98 | sourceTree = ""; 99 | }; 100 | C690010C142CC7F400095285 /* Products */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | C690010B142CC7F400095285 /* ColorPicker.app */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | C690010E142CC7F400095285 /* Frameworks */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | C690010F142CC7F400095285 /* UIKit.framework */, 112 | C6900111142CC7F400095285 /* Foundation.framework */, 113 | C6900113142CC7F400095285 /* CoreGraphics.framework */, 114 | ); 115 | name = Frameworks; 116 | sourceTree = ""; 117 | }; 118 | C6900115142CC7F400095285 /* ColorPicker */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | C690011E142CC7F400095285 /* ColorPickerAppDelegate.h */, 122 | C690011F142CC7F400095285 /* ColorPickerAppDelegate.m */, 123 | C6900134142CC8C800095285 /* ColorPickerController.h */, 124 | C6900135142CC8C800095285 /* ColorPickerController.mm */, 125 | C6900151142CD89700095285 /* GradientView.h */, 126 | C6900152142CD89700095285 /* GradientView.mm */, 127 | C6900121142CC7F400095285 /* iPhone */, 128 | C6900128142CC7F400095285 /* iPad */, 129 | C6900116142CC7F400095285 /* Supporting Files */, 130 | C690013B142CC91900095285 /* Resources */, 131 | ); 132 | path = ColorPicker; 133 | sourceTree = ""; 134 | }; 135 | C6900116142CC7F400095285 /* Supporting Files */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | C6900117142CC7F400095285 /* ColorPicker-Info.plist */, 139 | C6900169142E235300095285 /* Localizable.strings */, 140 | C690011B142CC7F400095285 /* main.m */, 141 | C690011D142CC7F400095285 /* ColorPicker-Prefix.pch */, 142 | ); 143 | name = "Supporting Files"; 144 | sourceTree = ""; 145 | }; 146 | C6900121142CC7F400095285 /* iPhone */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | C6900122142CC7F400095285 /* ColorPickerAppDelegate_iPhone.h */, 150 | C6900123142CC7F400095285 /* ColorPickerAppDelegate_iPhone.m */, 151 | C6900125142CC7F400095285 /* MainWindow_iPhone.xib */, 152 | ); 153 | name = iPhone; 154 | sourceTree = ""; 155 | }; 156 | C6900128142CC7F400095285 /* iPad */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | C6900129142CC7F400095285 /* ColorPickerAppDelegate_iPad.h */, 160 | C690012A142CC7F400095285 /* ColorPickerAppDelegate_iPad.m */, 161 | C690012C142CC7F400095285 /* MainWindow_iPad.xib */, 162 | ); 163 | name = iPad; 164 | sourceTree = ""; 165 | }; 166 | C690013B142CC91900095285 /* Resources */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | C6900147142CD3AC00095285 /* CrosshairSelector.png */, 170 | C6900148142CD3AC00095285 /* CrosshairSelector@2x.png */, 171 | C6900149142CD3AC00095285 /* HorizontalSelector.png */, 172 | C690014A142CD3AC00095285 /* HorizontalSelector@2x.png */, 173 | C6900154142CE83200095285 /* HueSaturationGradient.png */, 174 | C620B5B1142E329100C3250B /* Default-Landscape.png */, 175 | C620B5B2142E329100C3250B /* Default-Portrait.png */, 176 | C620B5B3142E329100C3250B /* Default.png */, 177 | C620B5B4142E329100C3250B /* Default@2x.png */, 178 | C620B5B5142E329100C3250B /* Icon-72.png */, 179 | C620B5B6142E329100C3250B /* Icon.png */, 180 | C620B5B7142E329100C3250B /* Icon@2x.png */, 181 | C620B5B8142E329100C3250B /* IconSmall-50.png */, 182 | C620B5B9142E329100C3250B /* IconSmall.png */, 183 | C620B5BA142E329100C3250B /* IconSmall@2x.png */, 184 | ); 185 | name = Resources; 186 | sourceTree = ""; 187 | }; 188 | /* End PBXGroup section */ 189 | 190 | /* Begin PBXNativeTarget section */ 191 | C690010A142CC7F400095285 /* ColorPicker */ = { 192 | isa = PBXNativeTarget; 193 | buildConfigurationList = C6900131142CC7F400095285 /* Build configuration list for PBXNativeTarget "ColorPicker" */; 194 | buildPhases = ( 195 | C6900107142CC7F400095285 /* Sources */, 196 | C6900108142CC7F400095285 /* Frameworks */, 197 | C6900109142CC7F400095285 /* Resources */, 198 | ); 199 | buildRules = ( 200 | ); 201 | dependencies = ( 202 | ); 203 | name = ColorPicker; 204 | productName = ColorPicker; 205 | productReference = C690010B142CC7F400095285 /* ColorPicker.app */; 206 | productType = "com.apple.product-type.application"; 207 | }; 208 | /* End PBXNativeTarget section */ 209 | 210 | /* Begin PBXProject section */ 211 | C6900102142CC7F400095285 /* Project object */ = { 212 | isa = PBXProject; 213 | attributes = { 214 | ORGANIZATIONNAME = "ThinkFlood Inc"; 215 | }; 216 | buildConfigurationList = C6900105142CC7F400095285 /* Build configuration list for PBXProject "ColorPicker" */; 217 | compatibilityVersion = "Xcode 3.2"; 218 | developmentRegion = English; 219 | hasScannedForEncodings = 0; 220 | knownRegions = ( 221 | en, 222 | ); 223 | mainGroup = C6900100142CC7F400095285; 224 | productRefGroup = C690010C142CC7F400095285 /* Products */; 225 | projectDirPath = ""; 226 | projectRoot = ""; 227 | targets = ( 228 | C690010A142CC7F400095285 /* ColorPicker */, 229 | ); 230 | }; 231 | /* End PBXProject section */ 232 | 233 | /* Begin PBXResourcesBuildPhase section */ 234 | C6900109142CC7F400095285 /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | C6900127142CC7F400095285 /* MainWindow_iPhone.xib in Resources */, 239 | C690012E142CC7F400095285 /* MainWindow_iPad.xib in Resources */, 240 | C690014C142CD3AC00095285 /* CrosshairSelector.png in Resources */, 241 | C690014D142CD3AC00095285 /* CrosshairSelector@2x.png in Resources */, 242 | C690014E142CD3AC00095285 /* HorizontalSelector.png in Resources */, 243 | C690014F142CD3AC00095285 /* HorizontalSelector@2x.png in Resources */, 244 | C6900155142CE83200095285 /* HueSaturationGradient.png in Resources */, 245 | C690016B142E235300095285 /* Localizable.strings in Resources */, 246 | C620B5BB142E329100C3250B /* Default-Landscape.png in Resources */, 247 | C620B5BC142E329100C3250B /* Default-Portrait.png in Resources */, 248 | C620B5BD142E329100C3250B /* Default.png in Resources */, 249 | C620B5BE142E329100C3250B /* Default@2x.png in Resources */, 250 | C620B5BF142E329100C3250B /* Icon-72.png in Resources */, 251 | C620B5C0142E329100C3250B /* Icon.png in Resources */, 252 | C620B5C1142E329100C3250B /* Icon@2x.png in Resources */, 253 | C620B5C2142E329100C3250B /* IconSmall-50.png in Resources */, 254 | C620B5C3142E329100C3250B /* IconSmall.png in Resources */, 255 | C620B5C4142E329100C3250B /* IconSmall@2x.png in Resources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | /* End PBXResourcesBuildPhase section */ 260 | 261 | /* Begin PBXSourcesBuildPhase section */ 262 | C6900107142CC7F400095285 /* Sources */ = { 263 | isa = PBXSourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | C690011C142CC7F400095285 /* main.m in Sources */, 267 | C6900120142CC7F400095285 /* ColorPickerAppDelegate.m in Sources */, 268 | C6900124142CC7F400095285 /* ColorPickerAppDelegate_iPhone.m in Sources */, 269 | C690012B142CC7F400095285 /* ColorPickerAppDelegate_iPad.m in Sources */, 270 | C6900136142CC8C800095285 /* ColorPickerController.mm in Sources */, 271 | C6900153142CD89700095285 /* GradientView.mm in Sources */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | /* End PBXSourcesBuildPhase section */ 276 | 277 | /* Begin PBXVariantGroup section */ 278 | C6900125142CC7F400095285 /* MainWindow_iPhone.xib */ = { 279 | isa = PBXVariantGroup; 280 | children = ( 281 | C6900126142CC7F400095285 /* en */, 282 | ); 283 | name = MainWindow_iPhone.xib; 284 | sourceTree = ""; 285 | }; 286 | C690012C142CC7F400095285 /* MainWindow_iPad.xib */ = { 287 | isa = PBXVariantGroup; 288 | children = ( 289 | C690012D142CC7F400095285 /* en */, 290 | ); 291 | name = MainWindow_iPad.xib; 292 | sourceTree = ""; 293 | }; 294 | C6900169142E235300095285 /* Localizable.strings */ = { 295 | isa = PBXVariantGroup; 296 | children = ( 297 | C690016A142E235300095285 /* en */, 298 | ); 299 | name = Localizable.strings; 300 | sourceTree = ""; 301 | }; 302 | /* End PBXVariantGroup section */ 303 | 304 | /* Begin XCBuildConfiguration section */ 305 | C690012F142CC7F400095285 /* Debug */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ALWAYS_SEARCH_USER_PATHS = NO; 309 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 310 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 311 | COPY_PHASE_STRIP = NO; 312 | GCC_C_LANGUAGE_STANDARD = gnu99; 313 | GCC_DYNAMIC_NO_PIC = NO; 314 | GCC_OPTIMIZATION_LEVEL = 0; 315 | GCC_PREPROCESSOR_DEFINITIONS = ( 316 | "DEBUG=1", 317 | "$(inherited)", 318 | ); 319 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 320 | GCC_VERSION = com.apple.compilers.llvmgcc42; 321 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 322 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 323 | GCC_WARN_UNUSED_VARIABLE = YES; 324 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 325 | SDKROOT = iphoneos; 326 | TARGETED_DEVICE_FAMILY = "1,2"; 327 | }; 328 | name = Debug; 329 | }; 330 | C6900130142CC7F400095285 /* Release */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 335 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 336 | COPY_PHASE_STRIP = YES; 337 | GCC_C_LANGUAGE_STANDARD = gnu99; 338 | GCC_VERSION = com.apple.compilers.llvmgcc42; 339 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 340 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 341 | GCC_WARN_UNUSED_VARIABLE = YES; 342 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 343 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 344 | SDKROOT = iphoneos; 345 | TARGETED_DEVICE_FAMILY = "1,2"; 346 | VALIDATE_PRODUCT = YES; 347 | }; 348 | name = Release; 349 | }; 350 | C6900132142CC7F400095285 /* Debug */ = { 351 | isa = XCBuildConfiguration; 352 | buildSettings = { 353 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 354 | GCC_PREFIX_HEADER = "ColorPicker/ColorPicker-Prefix.pch"; 355 | INFOPLIST_FILE = "ColorPicker/ColorPicker-Info.plist"; 356 | PRODUCT_NAME = "$(TARGET_NAME)"; 357 | WRAPPER_EXTENSION = app; 358 | }; 359 | name = Debug; 360 | }; 361 | C6900133142CC7F400095285 /* Release */ = { 362 | isa = XCBuildConfiguration; 363 | buildSettings = { 364 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 365 | GCC_PREFIX_HEADER = "ColorPicker/ColorPicker-Prefix.pch"; 366 | INFOPLIST_FILE = "ColorPicker/ColorPicker-Info.plist"; 367 | PRODUCT_NAME = "$(TARGET_NAME)"; 368 | WRAPPER_EXTENSION = app; 369 | }; 370 | name = Release; 371 | }; 372 | /* End XCBuildConfiguration section */ 373 | 374 | /* Begin XCConfigurationList section */ 375 | C6900105142CC7F400095285 /* Build configuration list for PBXProject "ColorPicker" */ = { 376 | isa = XCConfigurationList; 377 | buildConfigurations = ( 378 | C690012F142CC7F400095285 /* Debug */, 379 | C6900130142CC7F400095285 /* Release */, 380 | ); 381 | defaultConfigurationIsVisible = 0; 382 | defaultConfigurationName = Release; 383 | }; 384 | C6900131142CC7F400095285 /* Build configuration list for PBXNativeTarget "ColorPicker" */ = { 385 | isa = XCConfigurationList; 386 | buildConfigurations = ( 387 | C6900132142CC7F400095285 /* Debug */, 388 | C6900133142CC7F400095285 /* Release */, 389 | ); 390 | defaultConfigurationIsVisible = 0; 391 | defaultConfigurationName = Release; 392 | }; 393 | /* End XCConfigurationList section */ 394 | }; 395 | rootObject = C6900102142CC7F400095285 /* Project object */; 396 | } 397 | -------------------------------------------------------------------------------- /ColorPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ColorPicker/ColorPicker-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIconFiles 14 | 15 | Icon.png 16 | Icon@2x.png 17 | Icon-72.png 18 | 19 | CFBundleIdentifier 20 | com.thinkflood.${PRODUCT_NAME:rfc1034identifier} 21 | CFBundleInfoDictionaryVersion 22 | 6.0 23 | CFBundleName 24 | ${PRODUCT_NAME} 25 | CFBundlePackageType 26 | APPL 27 | CFBundleShortVersionString 28 | 1.0 29 | CFBundleSignature 30 | ???? 31 | CFBundleVersion 32 | 1.0 33 | LSRequiresIPhoneOS 34 | 35 | NSMainNibFile 36 | MainWindow_iPhone 37 | NSMainNibFile~ipad 38 | MainWindow_iPad 39 | UISupportedInterfaceOrientations 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationLandscapeLeft 43 | UIInterfaceOrientationLandscapeRight 44 | 45 | UISupportedInterfaceOrientations~ipad 46 | 47 | UIInterfaceOrientationPortrait 48 | UIInterfaceOrientationPortraitUpsideDown 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /ColorPicker/ColorPicker-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPicker-Prefix.pch 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import 27 | 28 | #ifndef __IPHONE_3_0 29 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 30 | #endif 31 | 32 | #ifdef __OBJC__ 33 | #import 34 | #import 35 | #endif 36 | -------------------------------------------------------------------------------- /ColorPicker/ColorPickerAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerAppDelegate.h 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import 27 | 28 | @interface ColorPickerAppDelegate : NSObject 29 | 30 | @property (nonatomic, retain) IBOutlet UIWindow *window; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ColorPicker/ColorPickerAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerAppDelegate.m 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import "ColorPickerAppDelegate.h" 27 | #import "ColorPickerController.h" 28 | 29 | @implementation ColorPickerAppDelegate 30 | 31 | @synthesize window = _window; 32 | 33 | - (BOOL)application:(UIApplication *)application 34 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 35 | ColorPickerController *colorPicker = 36 | [[ColorPickerController alloc] initWithColor:[UIColor redColor] andTitle:@"Color Picker"]; 37 | UINavigationController *navigationController = 38 | [[UINavigationController alloc] initWithRootViewController:colorPicker]; 39 | [colorPicker release]; 40 | [self.window addSubview:navigationController.view]; 41 | [self.window makeKeyAndVisible]; 42 | 43 | return YES; 44 | } 45 | 46 | - (void)dealloc { 47 | [_window release]; 48 | [super dealloc]; 49 | } 50 | 51 | - (void)applicationWillResignActive:(UIApplication *)application { 52 | 53 | } 54 | 55 | - (void)applicationDidEnterBackground:(UIApplication *)application { 56 | 57 | } 58 | 59 | - (void)applicationWillEnterForeground:(UIApplication *)application { 60 | 61 | } 62 | 63 | - (void)applicationDidBecomeActive:(UIApplication *)application { 64 | 65 | } 66 | 67 | - (void)applicationWillTerminate:(UIApplication *)application { 68 | 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /ColorPicker/ColorPickerController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerController.h 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import 27 | #import "GradientView.h" 28 | 29 | @class ColorPickerController; 30 | 31 | @protocol ColorPickerDelegate 32 | 33 | - (void)colorPickerSaved:(ColorPickerController *)controller; 34 | - (void)colorPickerCancelled:(ColorPickerController *)controller; 35 | 36 | @end 37 | 38 | typedef struct { 39 | int hueValue; 40 | int saturationValue; 41 | int brightnessValue; 42 | CGFloat hue; 43 | CGFloat saturation; 44 | CGFloat brightness; 45 | } HsvColor; 46 | 47 | typedef struct { 48 | int redValue; 49 | int greenValue; 50 | int blueValue; 51 | CGFloat red; 52 | CGFloat green; 53 | CGFloat blue; 54 | } RgbColor; 55 | 56 | @interface ColorPickerController : UIViewController 57 | 58 | { 59 | 60 | @private 61 | UIColor *_selectedColor; 62 | UIView *_colorView; 63 | UIImageView *_hueSaturationView; 64 | GradientView *_brightnessView; 65 | UIImageView *_horizontalSelector; 66 | UIImageView *_crosshairSelector; 67 | UITextField *_hueField; 68 | UITextField *_saturationField; 69 | UITextField *_brightnessField; 70 | UITextField *_redField; 71 | UITextField *_greenField; 72 | UITextField *_blueField; 73 | UITextField *_hexField; 74 | HsvColor _hsvColor; 75 | id _delegate; 76 | UITextField *_entryField; 77 | UIImageView *_movingView; 78 | NSCharacterSet *_hexadecimalCharacters; 79 | NSCharacterSet *_decimalCharacters; 80 | 81 | } 82 | 83 | + (HsvColor)hsvColorFromColor:(UIColor *)color; 84 | + (RgbColor)rgbColorFromColor:(UIColor *)color; 85 | + (NSString *)hexValueFromColor:(UIColor *)color; 86 | + (UIColor *)colorFromHexValue:(NSString *)hexValue; 87 | + (BOOL)isValidHexValue:(NSString *)hexValue; 88 | 89 | @property (nonatomic, readwrite, retain) UIColor *selectedColor; 90 | @property (nonatomic, readwrite, assign) id delegate; 91 | 92 | - (id)initWithColor:(UIColor *)color andTitle:(NSString *)title; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /ColorPicker/ColorPickerController.mm: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerController.mm 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import "ColorPickerController.h" 27 | #import 28 | 29 | #pragma mark Constants 30 | 31 | #define BACKGROUND_WHITE_COMPONENT 0.9f 32 | #define BACKGROUND_ALPHA_COMPONENT 1.0f 33 | 34 | #define DEFAULT_MARGIN 10.0f 35 | #define LABEL_MARGIN 5.0f 36 | 37 | #define LABEL_HEIGHT 21.0f 38 | #define LABEL_WIDTH 35.0f 39 | 40 | #define TEXT_FIELD_HEIGHT 31.0f 41 | 42 | #define COLOR_VIEW_CORNER_RADIUS 5.0f 43 | #define COLOR_VIEW_HEIGHT 103.0f 44 | 45 | #define HEXADECIMAL_TEXT_FIELD_WDITH LABEL_WIDTH * 2.0f + LABEL_MARGIN 46 | 47 | #define GRADIENT_HEIGHT 37.0f 48 | 49 | #define HUE_SATURATION_IMAGE_FILE_NAME @"HueSaturationGradient.png" 50 | #define HORIZONTAL_SELECTOR_IMAGE_FILE_NAME @"HorizontalSelector.png" 51 | #define CROSSHAIR_SELECTOR_IMAGE_FILE_NAME @"CrosshairSelector.png" 52 | 53 | #define COLOR_COMPONENT_RED_INDEX 0 54 | #define COLOR_COMPONENT_GREEN_INDEX 1 55 | #define COLOR_COMPONENT_BLUE_INDEX 2 56 | #define COLOR_COMPONENT_SCALE_FACTOR 255.0f 57 | #define COMPONENT_DOMAIN_DEGREES 60.0f 58 | #define COMPONENT_MAXIMUM_DEGREES 360.0f 59 | #define COMPONENT_OFFSET_DEGREES_GREEN 120.0f 60 | #define COMPONENT_OFFSET_DEGREES_BLUE 240.0f 61 | #define COMPONENT_PERCENTAGE 100.0f 62 | 63 | #define INTEGER_FORMAT_STRING @"%i" 64 | #define HEXADECIMAL_FORMAT_STRING @"%02X%02X%02X" 65 | #define HEXADECIMAL_LENGTH 6 66 | #define INTEGER_LENGTH 3 67 | 68 | #define ANIMATION_DURATION 0.5f 69 | 70 | #define HEXADECIMAL_CHARACTERS @"0123456789ABCDEF" 71 | #define DECIMAL_CHARACTERS @"0123456789" 72 | 73 | #define HEXADECIMAL_RED_LOCATION 0 74 | #define HEXADECIMAL_GREEN_LOCATION 2 75 | #define HEXADECIMAL_BLUE_LOCATION 4 76 | #define HEXADECIMAL_COMPONENT_LENGTH 2 77 | 78 | #pragma mark - 79 | #pragma mark Private Method Declarations 80 | 81 | @interface ColorPickerController () 82 | 83 | + (NSString *)hexValueFromRgbColor:(RgbColor)color; 84 | + (HsvColor)hsvColorFromRgbColor:(RgbColor)color; 85 | + (BOOL)stringIsValid:(NSString *)string 86 | forCharacterSet:(NSCharacterSet *)characters; 87 | - (void)setColorValues; 88 | - (void)moveSelectors; 89 | - (void)cancelButtonPressed; 90 | - (void)saveButtonPressed; 91 | - (void)evaluateTouchForHueSaturation:(UITouch *)touch; 92 | - (void)evaluateTouchForBrightness:(UITouch *)touch; 93 | 94 | @end 95 | 96 | #pragma mark - 97 | #pragma mark Implementation 98 | 99 | @implementation ColorPickerController 100 | 101 | #pragma mark - 102 | #pragma mark Class Methods 103 | 104 | + (HsvColor)hsvColorFromColor:(UIColor *)color { 105 | RgbColor rgbColor = [ColorPickerController rgbColorFromColor:color]; 106 | return [ColorPickerController hsvColorFromRgbColor:rgbColor]; 107 | } 108 | 109 | + (RgbColor)rgbColorFromColor:(UIColor *)color { 110 | RgbColor rgbColor; 111 | 112 | CGColorRef cgColor = [color CGColor]; 113 | const CGFloat *colorComponents = CGColorGetComponents(cgColor); 114 | rgbColor.red = colorComponents[COLOR_COMPONENT_RED_INDEX]; 115 | rgbColor.green = colorComponents[COLOR_COMPONENT_GREEN_INDEX]; 116 | rgbColor.blue = colorComponents[COLOR_COMPONENT_BLUE_INDEX]; 117 | 118 | rgbColor.redValue = (int)(rgbColor.red * COLOR_COMPONENT_SCALE_FACTOR); 119 | rgbColor.greenValue = (int)(rgbColor.green * COLOR_COMPONENT_SCALE_FACTOR); 120 | rgbColor.blueValue = (int)(rgbColor.blue * COLOR_COMPONENT_SCALE_FACTOR); 121 | 122 | return rgbColor; 123 | } 124 | 125 | + (NSString *)hexValueFromColor:(UIColor *)color { 126 | RgbColor rgbColor = [ColorPickerController rgbColorFromColor:color]; 127 | return [ColorPickerController hexValueFromRgbColor:rgbColor]; 128 | } 129 | 130 | + (UIColor *)colorFromHexValue:(NSString *)hexValue { 131 | UIColor *color = [UIColor blackColor]; 132 | 133 | NSRange componentRange = NSMakeRange(HEXADECIMAL_RED_LOCATION, 134 | HEXADECIMAL_COMPONENT_LENGTH); 135 | NSString *redComponent = [hexValue substringWithRange:componentRange]; 136 | 137 | componentRange.location = HEXADECIMAL_GREEN_LOCATION; 138 | NSString *greenComponent = [hexValue substringWithRange:componentRange]; 139 | 140 | componentRange.location = HEXADECIMAL_BLUE_LOCATION; 141 | NSString *blueComponent = [hexValue substringWithRange:componentRange]; 142 | 143 | uint red = 0; 144 | uint green = 0; 145 | uint blue = 0; 146 | [[NSScanner scannerWithString:redComponent] scanHexInt:&red]; 147 | [[NSScanner scannerWithString:greenComponent] scanHexInt:&green]; 148 | [[NSScanner scannerWithString:blueComponent] scanHexInt:&blue]; 149 | 150 | color = [UIColor colorWithRed:red / COLOR_COMPONENT_SCALE_FACTOR 151 | green:green / COLOR_COMPONENT_SCALE_FACTOR 152 | blue:blue / COLOR_COMPONENT_SCALE_FACTOR 153 | alpha:1.0f]; 154 | 155 | return color; 156 | } 157 | 158 | + (BOOL)isValidHexValue:(NSString *)hexValue { 159 | BOOL isValid = NO; 160 | 161 | NSString *trimmedString = 162 | [hexValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 163 | if (trimmedString.length == HEXADECIMAL_LENGTH) { 164 | NSCharacterSet *hexadecimalCharacters = 165 | [NSCharacterSet characterSetWithCharactersInString:HEXADECIMAL_CHARACTERS]; 166 | if ([ColorPickerController stringIsValid:trimmedString 167 | forCharacterSet:hexadecimalCharacters]) { 168 | isValid = YES; 169 | } 170 | } 171 | 172 | return isValid; 173 | } 174 | 175 | + (NSString *)hexValueFromRgbColor:(RgbColor)color { 176 | return [NSString stringWithFormat:HEXADECIMAL_FORMAT_STRING, 177 | color.redValue, 178 | color.greenValue, 179 | color.blueValue]; 180 | } 181 | 182 | + (HsvColor)hsvColorFromRgbColor:(RgbColor)color { 183 | HsvColor hsvColor; 184 | 185 | CGFloat maximumValue = MAX(color.red, color.green); 186 | maximumValue = MAX(maximumValue, color.blue); 187 | CGFloat minimumValue = MIN(color.red, color.green); 188 | minimumValue = MIN(minimumValue, color.blue); 189 | CGFloat range = maximumValue - minimumValue; 190 | 191 | hsvColor.hueValue = 0; 192 | if (maximumValue == minimumValue) { 193 | // continue 194 | } 195 | else if (maximumValue == color.red) { 196 | hsvColor.hueValue = 197 | (int)roundf(COMPONENT_DOMAIN_DEGREES * (color.green - color.blue) / range); 198 | if (hsvColor.hueValue < 0) { 199 | hsvColor.hueValue += COMPONENT_MAXIMUM_DEGREES; 200 | } 201 | } 202 | else if (maximumValue == color.green) { 203 | hsvColor.hueValue = 204 | (int)roundf(((COMPONENT_DOMAIN_DEGREES * (color.blue - color.red) / range) + 205 | COMPONENT_OFFSET_DEGREES_GREEN)); 206 | } 207 | else if (maximumValue == color.blue) { 208 | hsvColor.hueValue = 209 | (int)roundf(((COMPONENT_DOMAIN_DEGREES * (color.red - color.green) / range) + 210 | COMPONENT_OFFSET_DEGREES_BLUE)); 211 | } 212 | 213 | hsvColor.saturationValue = 0; 214 | if (maximumValue == 0.0f) { 215 | // continue 216 | } 217 | else { 218 | hsvColor.saturationValue = 219 | (int)roundf(((1.0f - (minimumValue / maximumValue)) * COMPONENT_PERCENTAGE)); 220 | } 221 | 222 | hsvColor.brightnessValue = (int)roundf((maximumValue * COMPONENT_PERCENTAGE)); 223 | 224 | hsvColor.hue = (float)hsvColor.hueValue / COMPONENT_MAXIMUM_DEGREES; 225 | hsvColor.saturation = (float)hsvColor.saturationValue / COMPONENT_PERCENTAGE; 226 | hsvColor.brightness = (float)hsvColor.brightnessValue / COMPONENT_PERCENTAGE; 227 | 228 | return hsvColor; 229 | } 230 | 231 | + (BOOL)stringIsValid:(NSString *)string 232 | forCharacterSet:(NSCharacterSet *)characters { 233 | BOOL isValid = YES; 234 | 235 | for (int counter = 0; counter < string.length; counter++) { 236 | unichar currentCharacter = [string characterAtIndex:counter]; 237 | if ([characters characterIsMember:currentCharacter]) { 238 | // continue 239 | } 240 | else { 241 | isValid = NO; 242 | break; 243 | } 244 | } 245 | 246 | return isValid; 247 | } 248 | 249 | #pragma mark - 250 | #pragma mark Properties 251 | 252 | @dynamic selectedColor; 253 | @synthesize delegate = _delegate; 254 | 255 | - (UIColor *)selectedColor { 256 | return _selectedColor; 257 | } 258 | 259 | - (void)setSelectedColor:(UIColor *)selectedColor { 260 | [_selectedColor autorelease]; 261 | _selectedColor = [selectedColor retain]; 262 | [self setColorValues]; 263 | } 264 | 265 | #pragma mark - 266 | #pragma mark Initializers 267 | 268 | - (id)initWithColor:(UIColor *)color andTitle:(NSString *)title { 269 | self = [super initWithNibName:nil bundle:nil]; 270 | 271 | if (self) { 272 | _selectedColor = [color retain]; 273 | _delegate = nil; 274 | _entryField = nil; 275 | _movingView = nil; 276 | _hexadecimalCharacters = 277 | [[NSCharacterSet characterSetWithCharactersInString:HEXADECIMAL_CHARACTERS] retain]; 278 | _decimalCharacters = 279 | [[NSCharacterSet characterSetWithCharactersInString:DECIMAL_CHARACTERS] retain]; 280 | 281 | self.navigationItem.title = title; 282 | } 283 | 284 | return self; 285 | } 286 | 287 | #pragma mark - 288 | #pragma mark Overrides 289 | 290 | - (void)dealloc { 291 | [_selectedColor release]; 292 | [_hexadecimalCharacters release]; 293 | [_decimalCharacters release]; 294 | 295 | [super dealloc]; 296 | } 297 | 298 | - (void)didReceiveMemoryWarning { 299 | [super didReceiveMemoryWarning]; 300 | } 301 | 302 | - (void)loadView { 303 | CGRect viewBounds = self.parentViewController.view.bounds; 304 | UIView *backgroundView = [[UIView alloc] initWithFrame:viewBounds]; 305 | backgroundView.backgroundColor = [UIColor colorWithWhite:BACKGROUND_WHITE_COMPONENT 306 | alpha:BACKGROUND_ALPHA_COMPONENT]; 307 | backgroundView.autoresizesSubviews = YES; 308 | backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | 309 | UIViewAutoresizingFlexibleHeight; 310 | self.view = [backgroundView autorelease]; 311 | 312 | UIBarButtonItem *cancelButton = 313 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 314 | target:self 315 | action:@selector(cancelButtonPressed)]; 316 | self.navigationItem.leftBarButtonItem = cancelButton; 317 | [cancelButton release]; 318 | 319 | UIBarButtonItem *saveButton = 320 | [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave 321 | target:self 322 | action:@selector(saveButtonPressed)]; 323 | self.navigationItem.rightBarButtonItem = saveButton; 324 | [saveButton release]; 325 | 326 | UILabel *hueSaturationValueLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 327 | hueSaturationValueLabel.text = 328 | NSLocalizedString(@"HueSaturationValueLabelText", @""); 329 | hueSaturationValueLabel.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; 330 | hueSaturationValueLabel.frame = CGRectMake(DEFAULT_MARGIN, 331 | DEFAULT_MARGIN + LABEL_MARGIN, 332 | LABEL_WIDTH, 333 | LABEL_HEIGHT); 334 | hueSaturationValueLabel.autoresizingMask = UIViewAutoresizingNone; 335 | hueSaturationValueLabel.textAlignment = UITextAlignmentRight; 336 | hueSaturationValueLabel.backgroundColor = [UIColor clearColor]; 337 | [backgroundView addSubview:hueSaturationValueLabel]; 338 | [hueSaturationValueLabel release]; 339 | 340 | CGFloat labelRightEdge = DEFAULT_MARGIN + LABEL_WIDTH; 341 | 342 | _hueField = [[UITextField alloc] initWithFrame:CGRectZero]; 343 | _hueField.frame = CGRectMake(labelRightEdge + LABEL_MARGIN, 344 | DEFAULT_MARGIN, 345 | LABEL_WIDTH, 346 | TEXT_FIELD_HEIGHT); 347 | _hueField.autoresizingMask = UIViewAutoresizingNone; 348 | _hueField.textAlignment = UITextAlignmentCenter; 349 | _hueField.borderStyle = UITextBorderStyleLine; 350 | _hueField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 351 | _hueField.returnKeyType = UIReturnKeyDone; 352 | _hueField.autocorrectionType = UITextAutocorrectionTypeNo; 353 | _hueField.backgroundColor = [UIColor whiteColor]; 354 | _hueField.delegate = self; 355 | [backgroundView addSubview:_hueField]; 356 | [_hueField release]; 357 | 358 | labelRightEdge += LABEL_WIDTH + LABEL_MARGIN; 359 | 360 | _saturationField = [[UITextField alloc] initWithFrame:CGRectZero]; 361 | _saturationField.frame = CGRectMake(labelRightEdge + LABEL_MARGIN, 362 | DEFAULT_MARGIN, 363 | LABEL_WIDTH, 364 | TEXT_FIELD_HEIGHT); 365 | _saturationField.autoresizingMask = UIViewAutoresizingNone; 366 | _saturationField.textAlignment = UITextAlignmentCenter; 367 | _saturationField.borderStyle = UITextBorderStyleLine; 368 | _saturationField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 369 | _saturationField.returnKeyType = UIReturnKeyDone; 370 | _saturationField.autocorrectionType = UITextAutocorrectionTypeNo; 371 | _saturationField.backgroundColor = [UIColor whiteColor]; 372 | _saturationField.delegate = self; 373 | [backgroundView addSubview:_saturationField]; 374 | [_saturationField release]; 375 | 376 | labelRightEdge += LABEL_WIDTH + LABEL_MARGIN; 377 | 378 | _brightnessField = [[UITextField alloc] initWithFrame:CGRectZero]; 379 | _brightnessField.frame = CGRectMake(labelRightEdge + LABEL_MARGIN, 380 | DEFAULT_MARGIN, 381 | LABEL_WIDTH, 382 | TEXT_FIELD_HEIGHT); 383 | _brightnessField.autoresizingMask = UIViewAutoresizingNone; 384 | _brightnessField.textAlignment = UITextAlignmentCenter; 385 | _brightnessField.borderStyle = UITextBorderStyleLine; 386 | _brightnessField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 387 | _brightnessField.returnKeyType = UIReturnKeyDone; 388 | _brightnessField.autocorrectionType = UITextAutocorrectionTypeNo; 389 | _brightnessField.backgroundColor = [UIColor whiteColor]; 390 | _brightnessField.delegate = self; 391 | [backgroundView addSubview:_brightnessField]; 392 | [_brightnessField release]; 393 | 394 | labelRightEdge += LABEL_WIDTH + LABEL_MARGIN; 395 | 396 | _colorView = [[UIView alloc] initWithFrame:CGRectZero]; 397 | _colorView.layer.cornerRadius = COLOR_VIEW_CORNER_RADIUS; 398 | _colorView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 399 | CGFloat colorViewLeftEdge = labelRightEdge + DEFAULT_MARGIN; 400 | _colorView.frame = CGRectMake(colorViewLeftEdge, 401 | DEFAULT_MARGIN, 402 | viewBounds.size.width - DEFAULT_MARGIN - colorViewLeftEdge, 403 | COLOR_VIEW_HEIGHT); 404 | [backgroundView addSubview:_colorView]; 405 | [_colorView release]; 406 | 407 | CGFloat textFieldBottomEdge = DEFAULT_MARGIN + TEXT_FIELD_HEIGHT + LABEL_MARGIN; 408 | 409 | UILabel *redGreenBlueLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 410 | redGreenBlueLabel.text = 411 | NSLocalizedString(@"RedGreenBlueLabelText", @""); 412 | redGreenBlueLabel.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; 413 | redGreenBlueLabel.frame = CGRectMake(DEFAULT_MARGIN, 414 | textFieldBottomEdge + LABEL_MARGIN, 415 | LABEL_WIDTH, 416 | LABEL_HEIGHT); 417 | redGreenBlueLabel.autoresizingMask = UIViewAutoresizingNone; 418 | redGreenBlueLabel.textAlignment = UITextAlignmentRight; 419 | redGreenBlueLabel.backgroundColor = [UIColor clearColor]; 420 | [backgroundView addSubview:redGreenBlueLabel]; 421 | [redGreenBlueLabel release]; 422 | 423 | labelRightEdge = DEFAULT_MARGIN + LABEL_WIDTH; 424 | 425 | _redField = [[UITextField alloc] initWithFrame:CGRectZero]; 426 | _redField.frame = CGRectMake(labelRightEdge + LABEL_MARGIN, 427 | textFieldBottomEdge, 428 | LABEL_WIDTH, 429 | TEXT_FIELD_HEIGHT); 430 | _redField.autoresizingMask = UIViewAutoresizingNone; 431 | _redField.textAlignment = UITextAlignmentCenter; 432 | _redField.borderStyle = UITextBorderStyleLine; 433 | _redField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 434 | _redField.returnKeyType = UIReturnKeyDone; 435 | _redField.autocorrectionType = UITextAutocorrectionTypeNo; 436 | _redField.backgroundColor = [UIColor whiteColor]; 437 | _redField.delegate = self; 438 | [backgroundView addSubview:_redField]; 439 | [_redField release]; 440 | 441 | labelRightEdge += LABEL_WIDTH + LABEL_MARGIN; 442 | 443 | _greenField = [[UITextField alloc] initWithFrame:CGRectZero]; 444 | _greenField.frame = CGRectMake(labelRightEdge + LABEL_MARGIN, 445 | textFieldBottomEdge, 446 | LABEL_WIDTH, 447 | TEXT_FIELD_HEIGHT); 448 | _greenField.autoresizingMask = UIViewAutoresizingNone; 449 | _greenField.textAlignment = UITextAlignmentCenter; 450 | _greenField.borderStyle = UITextBorderStyleLine; 451 | _greenField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 452 | _greenField.returnKeyType = UIReturnKeyDone; 453 | _greenField.autocorrectionType = UITextAutocorrectionTypeNo; 454 | _greenField.backgroundColor = [UIColor whiteColor]; 455 | _greenField.delegate = self; 456 | [backgroundView addSubview:_greenField]; 457 | [_greenField release]; 458 | 459 | labelRightEdge += LABEL_WIDTH + LABEL_MARGIN; 460 | 461 | _blueField = [[UITextField alloc] initWithFrame:CGRectZero]; 462 | _blueField.frame = CGRectMake(labelRightEdge + LABEL_MARGIN, 463 | textFieldBottomEdge, 464 | LABEL_WIDTH, 465 | TEXT_FIELD_HEIGHT); 466 | _blueField.autoresizingMask = UIViewAutoresizingNone; 467 | _blueField.textAlignment = UITextAlignmentCenter; 468 | _blueField.borderStyle = UITextBorderStyleLine; 469 | _blueField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; 470 | _blueField.returnKeyType = UIReturnKeyDone; 471 | _blueField.autocorrectionType = UITextAutocorrectionTypeNo; 472 | _blueField.backgroundColor = [UIColor whiteColor]; 473 | _blueField.delegate = self; 474 | [backgroundView addSubview:_blueField]; 475 | [_blueField release]; 476 | 477 | textFieldBottomEdge += TEXT_FIELD_HEIGHT + LABEL_MARGIN; 478 | 479 | UILabel *hexadecimalLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 480 | hexadecimalLabel.text = 481 | NSLocalizedString(@"HexadecimalLabelText", @""); 482 | hexadecimalLabel.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; 483 | hexadecimalLabel.frame = CGRectMake(DEFAULT_MARGIN, 484 | textFieldBottomEdge + LABEL_MARGIN, 485 | LABEL_WIDTH, 486 | LABEL_HEIGHT); 487 | hexadecimalLabel.autoresizingMask = UIViewAutoresizingNone; 488 | hexadecimalLabel.textAlignment = UITextAlignmentRight; 489 | hexadecimalLabel.backgroundColor = [UIColor clearColor]; 490 | [backgroundView addSubview:hexadecimalLabel]; 491 | [hexadecimalLabel release]; 492 | 493 | labelRightEdge = DEFAULT_MARGIN + LABEL_WIDTH; 494 | 495 | _hexField = [[UITextField alloc] initWithFrame:CGRectZero]; 496 | _hexField.frame = CGRectMake(labelRightEdge + LABEL_MARGIN, 497 | textFieldBottomEdge, 498 | HEXADECIMAL_TEXT_FIELD_WDITH, 499 | TEXT_FIELD_HEIGHT); 500 | _hexField.autoresizingMask = UIViewAutoresizingNone; 501 | _hexField.textAlignment = UITextAlignmentCenter; 502 | _hexField.borderStyle = UITextBorderStyleLine; 503 | _hexField.keyboardType = UIKeyboardTypeASCIICapable; 504 | _hexField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters; 505 | _hexField.autocorrectionType = UITextAutocorrectionTypeNo; 506 | _hexField.returnKeyType = UIReturnKeyDone; 507 | _hexField.backgroundColor = [UIColor whiteColor]; 508 | _hexField.delegate = self; 509 | [backgroundView addSubview:_hexField]; 510 | [_hexField release]; 511 | 512 | textFieldBottomEdge += TEXT_FIELD_HEIGHT + DEFAULT_MARGIN; 513 | 514 | CGRect gradientFrame = CGRectMake(DEFAULT_MARGIN, 515 | viewBounds.size.height - DEFAULT_MARGIN - GRADIENT_HEIGHT, 516 | viewBounds.size.width - 2.0f * DEFAULT_MARGIN, 517 | GRADIENT_HEIGHT); 518 | _brightnessView = [[GradientView alloc] initWithFrame:gradientFrame]; 519 | _brightnessView.colors = [NSArray arrayWithObjects:_selectedColor, 520 | [UIColor colorWithRed:0.0f 521 | green:0.0f 522 | blue:0.0f 523 | alpha:1.0f], 524 | nil]; 525 | _brightnessView.autoresizingMask = UIViewAutoresizingFlexibleWidth | 526 | UIViewAutoresizingFlexibleTopMargin; 527 | [backgroundView addSubview:_brightnessView]; 528 | [_brightnessView release]; 529 | 530 | UIImage *horizontalSelectorImage = 531 | [UIImage imageNamed:HORIZONTAL_SELECTOR_IMAGE_FILE_NAME]; 532 | _horizontalSelector = [[UIImageView alloc] initWithImage:horizontalSelectorImage]; 533 | _horizontalSelector.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; 534 | CGRect selectorFrame = _horizontalSelector.frame; 535 | selectorFrame.origin.x = gradientFrame.origin.x; 536 | selectorFrame.origin.y = gradientFrame.origin.y; 537 | _horizontalSelector.frame = selectorFrame; 538 | [backgroundView addSubview:_horizontalSelector]; 539 | [_horizontalSelector release]; 540 | 541 | 542 | CGFloat hueSaturationHeight = viewBounds.size.height - 543 | 2.0f * DEFAULT_MARGIN - 544 | GRADIENT_HEIGHT - 545 | textFieldBottomEdge; 546 | CGRect hueSaturationFrame = CGRectMake(DEFAULT_MARGIN, 547 | textFieldBottomEdge, 548 | viewBounds.size.width - 2.0f * DEFAULT_MARGIN, 549 | hueSaturationHeight); 550 | UIView *hueSaturationBackgroundView = 551 | [[UIView alloc] initWithFrame:hueSaturationFrame]; 552 | hueSaturationBackgroundView.backgroundColor = [UIColor blackColor]; 553 | hueSaturationBackgroundView.autoresizingMask = 554 | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 555 | hueSaturationBackgroundView.autoresizesSubviews = YES; 556 | hueSaturationBackgroundView.clipsToBounds = YES; 557 | [backgroundView addSubview:hueSaturationBackgroundView]; 558 | [hueSaturationBackgroundView release]; 559 | 560 | UIImage *hueSaturationImage = [UIImage imageNamed:HUE_SATURATION_IMAGE_FILE_NAME]; 561 | _hueSaturationView = [[UIImageView alloc] initWithImage:hueSaturationImage]; 562 | _hueSaturationView.contentMode = UIViewContentModeScaleToFill; 563 | _hueSaturationView.autoresizingMask = UIViewAutoresizingFlexibleHeight | 564 | UIViewAutoresizingFlexibleWidth; 565 | _hueSaturationView.frame = hueSaturationBackgroundView.bounds; 566 | _hueSaturationView.opaque = NO; 567 | [hueSaturationBackgroundView addSubview:_hueSaturationView]; 568 | [_hueSaturationView release]; 569 | 570 | UIImage *crosshairSelectorImage = 571 | [UIImage imageNamed:CROSSHAIR_SELECTOR_IMAGE_FILE_NAME]; 572 | _crosshairSelector = [[UIImageView alloc] initWithImage:crosshairSelectorImage]; 573 | [hueSaturationBackgroundView addSubview:_crosshairSelector]; 574 | [_crosshairSelector release]; 575 | 576 | [self setColorValues]; 577 | } 578 | 579 | - (void)viewDidAppear:(BOOL)animated { 580 | [self moveSelectors]; 581 | } 582 | 583 | - (void)viewDidUnload { 584 | [super viewDidUnload]; 585 | } 586 | 587 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 588 | return YES; 589 | } 590 | 591 | - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 592 | duration:(NSTimeInterval)duration { 593 | [self moveSelectors]; 594 | } 595 | 596 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 597 | UITouch *touch = [touches anyObject]; 598 | CGPoint touchPoint = [touch locationInView:self.view]; 599 | if (_entryField) { 600 | if (CGRectContainsPoint(_entryField.frame, touchPoint)) { 601 | // continue 602 | } 603 | else { 604 | [_entryField resignFirstResponder]; 605 | } 606 | } 607 | else if (CGRectContainsPoint([_hueSaturationView superview].frame, touchPoint)) { 608 | _movingView = _crosshairSelector; 609 | [self evaluateTouchForHueSaturation:touch]; 610 | [self moveSelectors]; 611 | } 612 | else if (CGRectContainsPoint(_brightnessView.frame, touchPoint)) { 613 | _movingView = _horizontalSelector; 614 | [self evaluateTouchForBrightness:touch]; 615 | [self moveSelectors]; 616 | } 617 | } 618 | 619 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 620 | UITouch *touch = [touches anyObject]; 621 | if (_movingView == _crosshairSelector) { 622 | [self evaluateTouchForHueSaturation:touch]; 623 | [self moveSelectors]; 624 | } 625 | else if (_movingView == _horizontalSelector) { 626 | [self evaluateTouchForBrightness:touch]; 627 | [self moveSelectors]; 628 | } 629 | } 630 | 631 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 632 | UITouch *touch = [touches anyObject]; 633 | if (_movingView == _crosshairSelector) { 634 | [self evaluateTouchForHueSaturation:touch]; 635 | [self moveSelectors]; 636 | } 637 | else if (_movingView == _horizontalSelector) { 638 | [self evaluateTouchForBrightness:touch]; 639 | [self moveSelectors]; 640 | } 641 | 642 | _movingView = nil; 643 | } 644 | 645 | #pragma mark - 646 | #pragma mark Private Methods 647 | 648 | - (void)setColorValues { 649 | if (_colorView) { 650 | _colorView.backgroundColor = _selectedColor; 651 | 652 | RgbColor rgbColor = 653 | [ColorPickerController rgbColorFromColor:_selectedColor]; 654 | _redField.text = [NSString stringWithFormat:INTEGER_FORMAT_STRING, 655 | rgbColor.redValue]; 656 | _greenField.text = [NSString stringWithFormat:INTEGER_FORMAT_STRING, 657 | rgbColor.greenValue]; 658 | _blueField.text = [NSString stringWithFormat:INTEGER_FORMAT_STRING, 659 | rgbColor.blueValue]; 660 | 661 | _hexField.text = [ColorPickerController hexValueFromRgbColor:rgbColor]; 662 | 663 | _hsvColor = [ColorPickerController hsvColorFromRgbColor:rgbColor]; 664 | _hueField.text = [NSString stringWithFormat:INTEGER_FORMAT_STRING, 665 | _hsvColor.hueValue]; 666 | _saturationField.text = [NSString stringWithFormat:INTEGER_FORMAT_STRING, 667 | _hsvColor.saturationValue]; 668 | _brightnessField.text = [NSString stringWithFormat:INTEGER_FORMAT_STRING, 669 | _hsvColor.brightnessValue]; 670 | 671 | _brightnessView.colors = 672 | [NSArray arrayWithObjects:[UIColor colorWithHue:_hsvColor.hue 673 | saturation:_hsvColor.saturation 674 | brightness:1.0f 675 | alpha:1.0f], 676 | [UIColor colorWithRed:0.0f 677 | green:0.0f 678 | blue:0.0f 679 | alpha:1.0f], 680 | nil]; 681 | 682 | _hueSaturationView.alpha = _hsvColor.brightness; 683 | } 684 | } 685 | 686 | - (void)moveSelectors { 687 | CGRect hueSaturationBounds = _hueSaturationView.bounds; 688 | CGPoint crosshairCenter = 689 | CGPointMake(_hsvColor.hue * hueSaturationBounds.size.width, 690 | (1.0f - _hsvColor.saturation) * hueSaturationBounds.size.height); 691 | 692 | CGRect brightnessFrame = _brightnessView.frame; 693 | CGPoint horizontalCenter = 694 | CGPointMake(brightnessFrame.origin.x + (1.0f - _hsvColor.brightness) * brightnessFrame.size.width, 695 | brightnessFrame.origin.y + (brightnessFrame.size.height / 2.0f)); 696 | 697 | _crosshairSelector.center = crosshairCenter; 698 | _horizontalSelector.center = horizontalCenter; 699 | } 700 | 701 | - (void)cancelButtonPressed { 702 | if (_delegate) { 703 | [_delegate colorPickerCancelled:self]; 704 | } 705 | } 706 | 707 | - (void)saveButtonPressed { 708 | if (_delegate) { 709 | [_delegate colorPickerSaved:self]; 710 | } 711 | } 712 | 713 | - (void)evaluateTouchForHueSaturation:(UITouch *)touch { 714 | CGPoint touchPoint = [touch locationInView:_hueSaturationView]; 715 | CGRect viewBounds = _hueSaturationView.bounds; 716 | 717 | CGFloat hue = touchPoint.x / viewBounds.size.width; 718 | if (hue < 0.0f) { 719 | hue = 0.0f; 720 | } 721 | else if (hue > 1.0f) { 722 | hue = 1.0f; 723 | } 724 | 725 | CGFloat saturation = 726 | (viewBounds.size.height - touchPoint.y) / viewBounds.size.height; 727 | if (saturation < 0.0f) { 728 | saturation = 0.0f; 729 | } 730 | else if (saturation > 1.0f) { 731 | saturation = 1.0f; 732 | } 733 | 734 | self.selectedColor = [UIColor colorWithHue:hue 735 | saturation:saturation 736 | brightness:_hsvColor.brightness 737 | alpha:1.0f]; 738 | } 739 | 740 | - (void)evaluateTouchForBrightness:(UITouch *)touch { 741 | CGPoint touchPoint = [touch locationInView:_brightnessView]; 742 | CGRect viewBounds = _brightnessView.bounds; 743 | 744 | CGFloat brightness = 745 | (viewBounds.size.width - touchPoint.x) / viewBounds.size.width; 746 | if (brightness < 0.0f) { 747 | brightness = 0.0f; 748 | } 749 | else if (brightness > 1.0f) { 750 | brightness = 1.0f; 751 | } 752 | 753 | self.selectedColor = [UIColor colorWithHue:_hsvColor.hue 754 | saturation:_hsvColor.saturation 755 | brightness:brightness 756 | alpha:1.0f]; 757 | } 758 | 759 | #pragma mark - 760 | #pragma mark UITextField Delegate Methods 761 | 762 | - (void)textFieldDidBeginEditing:(UITextField *)textField { 763 | _entryField = textField; 764 | } 765 | 766 | - (void)textFieldDidEndEditing:(UITextField *)textField { 767 | if (textField.text.length == 0) { 768 | self.selectedColor = _selectedColor; 769 | } 770 | else if (textField == _hexField) { 771 | NSString *hexadecimalColor = textField.text; 772 | if ([ColorPickerController isValidHexValue:hexadecimalColor]) { 773 | self.selectedColor = 774 | [ColorPickerController colorFromHexValue:hexadecimalColor]; 775 | [self moveSelectors]; 776 | } 777 | else { 778 | self.selectedColor = _selectedColor; 779 | } 780 | } 781 | else if (textField == _redField || 782 | textField == _greenField || 783 | textField == _blueField) { 784 | CGFloat redValue = [_redField.text floatValue]; 785 | CGFloat greenValue = [_greenField.text floatValue]; 786 | CGFloat blueValue = [_blueField.text floatValue]; 787 | self.selectedColor = [UIColor colorWithRed:redValue / COLOR_COMPONENT_SCALE_FACTOR 788 | green:greenValue / COLOR_COMPONENT_SCALE_FACTOR 789 | blue:blueValue / COLOR_COMPONENT_SCALE_FACTOR 790 | alpha:1.0f]; 791 | [self moveSelectors]; 792 | } 793 | else { 794 | CGFloat hueValue = [_hueField.text floatValue]; 795 | CGFloat saturationValue = [_saturationField.text floatValue]; 796 | CGFloat brightnessValue = [_brightnessField.text floatValue]; 797 | self.selectedColor = [UIColor colorWithHue:hueValue / COMPONENT_MAXIMUM_DEGREES 798 | saturation:saturationValue / COMPONENT_PERCENTAGE 799 | brightness:brightnessValue / COMPONENT_PERCENTAGE 800 | alpha:1.0f]; 801 | [self moveSelectors]; 802 | } 803 | 804 | _entryField = nil; 805 | } 806 | 807 | - (BOOL)textField:(UITextField *)textField 808 | shouldChangeCharactersInRange:(NSRange)range 809 | replacementString:(NSString *)string { 810 | BOOL replace = YES; 811 | NSString *newText = [textField.text stringByReplacingCharactersInRange:range 812 | withString:string]; 813 | 814 | if (textField == _hexField) { 815 | if (newText.length > HEXADECIMAL_LENGTH) { 816 | replace = NO; 817 | } 818 | else { 819 | replace = [ColorPickerController stringIsValid:newText 820 | forCharacterSet:_hexadecimalCharacters]; 821 | } 822 | } 823 | else { 824 | if (newText.length > INTEGER_LENGTH) { 825 | replace = NO; 826 | } 827 | else { 828 | int integerValue = [newText intValue]; 829 | if (textField == _hueField && integerValue > COMPONENT_MAXIMUM_DEGREES) { 830 | replace = NO; 831 | } 832 | else if ((textField == _saturationField || textField == _brightnessField) && 833 | integerValue > COMPONENT_PERCENTAGE) { 834 | replace = NO; 835 | } 836 | else if ((textField == _redField || 837 | textField == _greenField || 838 | textField == _blueField) && 839 | integerValue > COLOR_COMPONENT_SCALE_FACTOR) { 840 | replace = NO; 841 | } 842 | 843 | if (replace) { 844 | replace = [ColorPickerController stringIsValid:newText 845 | forCharacterSet:_decimalCharacters]; 846 | } 847 | } 848 | } 849 | 850 | return replace; 851 | } 852 | 853 | - (BOOL)textFieldShouldReturn:(UITextField *)textField { 854 | [textField resignFirstResponder]; 855 | return NO; 856 | } 857 | 858 | @end 859 | -------------------------------------------------------------------------------- /ColorPicker/CrosshairSelector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/CrosshairSelector.png -------------------------------------------------------------------------------- /ColorPicker/CrosshairSelector@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/CrosshairSelector@2x.png -------------------------------------------------------------------------------- /ColorPicker/Default-Landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/Default-Landscape.png -------------------------------------------------------------------------------- /ColorPicker/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/Default-Portrait.png -------------------------------------------------------------------------------- /ColorPicker/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/Default.png -------------------------------------------------------------------------------- /ColorPicker/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/Default@2x.png -------------------------------------------------------------------------------- /ColorPicker/GradientView.h: -------------------------------------------------------------------------------- 1 | // 2 | // GradientView.h 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import 27 | 28 | @interface GradientView : UIView { 29 | 30 | @private 31 | CGGradientRef _gradient; 32 | NSArray *_colors; 33 | 34 | } 35 | 36 | @property (nonatomic, readwrite, copy) NSArray *colors; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /ColorPicker/GradientView.mm: -------------------------------------------------------------------------------- 1 | // 2 | // GradientView.mm 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import "GradientView.h" 27 | 28 | #pragma mark Constants 29 | 30 | #define COLOR_COMPONENT_RED_INDEX 0 31 | #define COLOR_COMPONENT_GREEN_INDEX 1 32 | #define COLOR_COMPONENT_BLUE_INDEX 2 33 | 34 | #define COLOR_COMPONENT_ALPHA_VALUE 1.0f 35 | 36 | #define COLOR_COMPONENT_COUNT 4 37 | 38 | #define GRADIENT_DRAWING_OPTIONS_NONE 0 39 | 40 | #pragma mark - 41 | #pragma mark Implementation 42 | 43 | @implementation GradientView 44 | 45 | #pragma mark - 46 | #pragma mark Properties 47 | 48 | @dynamic colors; 49 | 50 | - (NSArray *)colors { 51 | return _colors; 52 | } 53 | 54 | - (void)setColors:(NSArray *)colors { 55 | if (colors == _colors) { 56 | // continue 57 | } 58 | else if (colors.count > 1) { 59 | if (_colors) { 60 | [_colors release]; 61 | CGGradientRelease(_gradient); 62 | } 63 | 64 | _colors = [colors copy]; 65 | 66 | int componentCount = colors.count * COLOR_COMPONENT_COUNT; 67 | CGFloat gradientColors[componentCount]; 68 | int counter = 0; 69 | for (UIColor *color in colors) { 70 | CGColorRef currentColor = [color CGColor]; 71 | const CGFloat *colorComponents = CGColorGetComponents(currentColor); 72 | gradientColors[counter] = colorComponents[COLOR_COMPONENT_RED_INDEX]; 73 | counter++; 74 | gradientColors[counter] = colorComponents[COLOR_COMPONENT_GREEN_INDEX]; 75 | counter++; 76 | gradientColors[counter] = colorComponents[COLOR_COMPONENT_BLUE_INDEX]; 77 | counter++; 78 | gradientColors[counter] = COLOR_COMPONENT_ALPHA_VALUE; 79 | counter++; 80 | } 81 | 82 | CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB(); 83 | 84 | size_t colorArraySize = 85 | sizeof(gradientColors) / (sizeof(gradientColors[0]) * COLOR_COMPONENT_COUNT); 86 | _gradient = CGGradientCreateWithColorComponents(rgbColorSpace, 87 | gradientColors, 88 | NULL, 89 | colorArraySize); 90 | 91 | CGColorSpaceRelease(rgbColorSpace); 92 | 93 | [self setNeedsDisplay]; 94 | } 95 | } 96 | 97 | #pragma mark - 98 | #pragma mark Initializers 99 | 100 | - (id)initWithFrame:(CGRect)frame { 101 | self = [super initWithFrame:frame]; 102 | 103 | if (self) { 104 | _colors = nil; 105 | _gradient = nil; 106 | } 107 | 108 | return self; 109 | } 110 | 111 | #pragma mark - 112 | #pragma mark Overrides 113 | 114 | - (void)dealloc { 115 | if (_colors) { 116 | [_colors release]; 117 | CGGradientRelease(_gradient); 118 | } 119 | 120 | [super dealloc]; 121 | } 122 | 123 | - (void)drawRect:(CGRect)rect { 124 | CGContextRef context = UIGraphicsGetCurrentContext(); 125 | CGContextSaveGState(context); 126 | 127 | CGRect viewBounds = self.bounds; 128 | CGContextClipToRect(context, viewBounds); 129 | 130 | CGPoint startPoint = CGPointMake(0.0f, 0.0f); 131 | CGPoint endPoint = CGPointMake(viewBounds.size.width, 0.0f); 132 | CGContextDrawLinearGradient(context, 133 | _gradient, 134 | startPoint, 135 | endPoint, 136 | GRADIENT_DRAWING_OPTIONS_NONE); 137 | CGContextRestoreGState(context); 138 | CGContextSaveGState(context); 139 | 140 | [super drawRect:rect]; 141 | } 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /ColorPicker/HorizontalSelector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/HorizontalSelector.png -------------------------------------------------------------------------------- /ColorPicker/HorizontalSelector@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/HorizontalSelector@2x.png -------------------------------------------------------------------------------- /ColorPicker/HueSaturationGradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/HueSaturationGradient.png -------------------------------------------------------------------------------- /ColorPicker/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/Icon-72.png -------------------------------------------------------------------------------- /ColorPicker/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/Icon.png -------------------------------------------------------------------------------- /ColorPicker/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/Icon@2x.png -------------------------------------------------------------------------------- /ColorPicker/IconSmall-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/IconSmall-50.png -------------------------------------------------------------------------------- /ColorPicker/IconSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/IconSmall.png -------------------------------------------------------------------------------- /ColorPicker/IconSmall@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/ColorPicker/IconSmall@2x.png -------------------------------------------------------------------------------- /ColorPicker/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | // 2 | // Localizable.strings 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | "HueSaturationValueLabelText" = "HSV"; 27 | "RedGreenBlueLabelText" = "RGB"; 28 | "HexadecimalLabelText" = "Hex"; 29 | -------------------------------------------------------------------------------- /ColorPicker/iPad/ColorPickerAppDelegate_iPad.h: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerAppDelegate_iPad.h 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import "ColorPickerAppDelegate.h" 27 | 28 | @interface ColorPickerAppDelegate_iPad : ColorPickerAppDelegate 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /ColorPicker/iPad/ColorPickerAppDelegate_iPad.m: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerAppDelegate_iPad.m 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import "ColorPickerAppDelegate_iPad.h" 27 | 28 | @implementation ColorPickerAppDelegate_iPad 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /ColorPicker/iPad/en.lproj/MainWindow_iPad.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1024 5 | 10D573 6 | 786 7 | 1038.29 8 | 460.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 112 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBIPadFramework 35 | 36 | 37 | IBFirstResponder 38 | IBIPadFramework 39 | 40 | 41 | 42 | 292 43 | 44 | YES 45 | 46 | 47 | 301 48 | {{284, 501}, {200, 22}} 49 | 50 | NO 51 | YES 52 | 7 53 | NO 54 | IBIPadFramework 55 | My Universal App on iPad 56 | 57 | 1 58 | MCAwIDAAA 59 | 60 | 61 | 1 62 | 10 63 | 64 | 65 | {768, 1024} 66 | 67 | 68 | 1 69 | MSAxIDEAA 70 | 71 | NO 72 | NO 73 | 74 | 2 75 | 76 | IBIPadFramework 77 | YES 78 | 79 | 80 | IBIPadFramework 81 | 82 | 83 | 84 | 85 | YES 86 | 87 | 88 | window 89 | 90 | 91 | 92 | 7 93 | 94 | 95 | 96 | delegate 97 | 98 | 99 | 100 | 8 101 | 102 | 103 | 104 | 105 | YES 106 | 107 | 0 108 | 109 | 110 | 111 | 112 | 113 | -1 114 | 115 | 116 | File's Owner 117 | 118 | 119 | -2 120 | 121 | 122 | 123 | 124 | 2 125 | 126 | 127 | YES 128 | 129 | 130 | 131 | 132 | 133 | 6 134 | 135 | 136 | 137 | 138 | 11 139 | 140 | 141 | 142 | 143 | 144 | 145 | YES 146 | 147 | YES 148 | -1.CustomClassName 149 | -2.CustomClassName 150 | 11.IBPluginDependency 151 | 2.IBEditorWindowLastContentRect 152 | 2.IBPluginDependency 153 | 6.CustomClassName 154 | 6.IBPluginDependency 155 | 156 | 157 | YES 158 | UIApplication 159 | UIResponder 160 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 161 | {{202, 84}, {783, 772}} 162 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 163 | ColorPickerAppDelegate_iPad 164 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 165 | 166 | 167 | 168 | YES 169 | 170 | 171 | YES 172 | 173 | 174 | 175 | 176 | YES 177 | 178 | 179 | YES 180 | 181 | 182 | 183 | 11 184 | 185 | 186 | 187 | YES 188 | 189 | ColorPickerAppDelegate 190 | NSObject 191 | 192 | window 193 | UIWindow 194 | 195 | 196 | window 197 | 198 | window 199 | UIWindow 200 | 201 | 202 | 203 | IBProjectSource 204 | Shared/ColorPickerAppDelegate.h 205 | 206 | 207 | 208 | ColorPickerAppDelegate_iPad 209 | ColorPickerAppDelegate 210 | 211 | IBProjectSource 212 | iPad/ColorPickerAppDelegate_iPad.h 213 | 214 | 215 | 216 | 217 | YES 218 | 219 | NSObject 220 | 221 | IBFrameworkSource 222 | Foundation.framework/Headers/NSError.h 223 | 224 | 225 | 226 | NSObject 227 | 228 | IBFrameworkSource 229 | Foundation.framework/Headers/NSFileManager.h 230 | 231 | 232 | 233 | NSObject 234 | 235 | IBFrameworkSource 236 | Foundation.framework/Headers/NSKeyValueCoding.h 237 | 238 | 239 | 240 | NSObject 241 | 242 | IBFrameworkSource 243 | Foundation.framework/Headers/NSKeyValueObserving.h 244 | 245 | 246 | 247 | NSObject 248 | 249 | IBFrameworkSource 250 | Foundation.framework/Headers/NSKeyedArchiver.h 251 | 252 | 253 | 254 | NSObject 255 | 256 | IBFrameworkSource 257 | Foundation.framework/Headers/NSObject.h 258 | 259 | 260 | 261 | NSObject 262 | 263 | IBFrameworkSource 264 | Foundation.framework/Headers/NSRunLoop.h 265 | 266 | 267 | 268 | NSObject 269 | 270 | IBFrameworkSource 271 | Foundation.framework/Headers/NSThread.h 272 | 273 | 274 | 275 | NSObject 276 | 277 | IBFrameworkSource 278 | Foundation.framework/Headers/NSURL.h 279 | 280 | 281 | 282 | NSObject 283 | 284 | IBFrameworkSource 285 | Foundation.framework/Headers/NSURLConnection.h 286 | 287 | 288 | 289 | NSObject 290 | 291 | IBFrameworkSource 292 | UIKit.framework/Headers/UIAccessibility.h 293 | 294 | 295 | 296 | NSObject 297 | 298 | IBFrameworkSource 299 | UIKit.framework/Headers/UINibLoading.h 300 | 301 | 302 | 303 | NSObject 304 | 305 | IBFrameworkSource 306 | UIKit.framework/Headers/UIResponder.h 307 | 308 | 309 | 310 | UIApplication 311 | UIResponder 312 | 313 | IBFrameworkSource 314 | UIKit.framework/Headers/UIApplication.h 315 | 316 | 317 | 318 | UIResponder 319 | NSObject 320 | 321 | 322 | 323 | UIView 324 | 325 | IBFrameworkSource 326 | UIKit.framework/Headers/UITextField.h 327 | 328 | 329 | 330 | UIView 331 | UIResponder 332 | 333 | IBFrameworkSource 334 | UIKit.framework/Headers/UIView.h 335 | 336 | 337 | 338 | UIWindow 339 | UIView 340 | 341 | IBFrameworkSource 342 | UIKit.framework/Headers/UIWindow.h 343 | 344 | 345 | 346 | 347 | 0 348 | IBIPadFramework 349 | 350 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 351 | 352 | 353 | 354 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 355 | 356 | 357 | YES 358 | ../ColorPicker.xcodeproj 359 | 3 360 | 112 361 | 362 | 363 | -------------------------------------------------------------------------------- /ColorPicker/iPhone/ColorPickerAppDelegate_iPhone.h: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerAppDelegate_iPhone.h 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import "ColorPickerAppDelegate.h" 27 | 28 | @interface ColorPickerAppDelegate_iPhone : ColorPickerAppDelegate 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /ColorPicker/iPhone/ColorPickerAppDelegate_iPhone.m: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerAppDelegate_iPhone.m 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import "ColorPickerAppDelegate_iPhone.h" 27 | 28 | @implementation ColorPickerAppDelegate_iPhone 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /ColorPicker/iPhone/en.lproj/MainWindow_iPhone.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1024 5 | 10D573 6 | 786 7 | 1038.29 8 | 460.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 112 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | IBCocoaTouchFramework 42 | 43 | 44 | 45 | 1316 46 | 47 | YES 48 | 49 | 50 | 1325 51 | {{51, 229}, {218, 22}} 52 | 53 | NO 54 | YES 55 | 7 56 | NO 57 | IBCocoaTouchFramework 58 | My Universal App on iPhone 59 | 60 | 1 61 | MCAwIDAAA 62 | 63 | 64 | 1 65 | 10 66 | 67 | 68 | 69 | {320, 480} 70 | 71 | 72 | 1 73 | MSAxIDEAA 74 | 75 | NO 76 | NO 77 | 78 | IBCocoaTouchFramework 79 | YES 80 | 81 | 82 | 83 | 84 | YES 85 | 86 | 87 | delegate 88 | 89 | 90 | 91 | 5 92 | 93 | 94 | 95 | window 96 | 97 | 98 | 99 | 6 100 | 101 | 102 | 103 | 104 | YES 105 | 106 | 0 107 | 108 | 109 | 110 | 111 | 112 | 2 113 | 114 | 115 | YES 116 | 117 | 118 | 119 | 120 | 121 | -1 122 | 123 | 124 | File's Owner 125 | 126 | 127 | 4 128 | 129 | 130 | App Delegate 131 | 132 | 133 | -2 134 | 135 | 136 | 137 | 138 | 8 139 | 140 | 141 | 142 | 143 | 144 | 145 | YES 146 | 147 | YES 148 | -1.CustomClassName 149 | -2.CustomClassName 150 | 2.IBAttributePlaceholdersKey 151 | 2.IBEditorWindowLastContentRect 152 | 2.IBPluginDependency 153 | 2.UIWindow.visibleAtLaunch 154 | 4.CustomClassName 155 | 4.IBPluginDependency 156 | 8.IBPluginDependency 157 | 158 | 159 | YES 160 | UIApplication 161 | UIResponder 162 | 163 | YES 164 | 165 | 166 | YES 167 | 168 | 169 | {{520, 376}, {320, 480}} 170 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 171 | 172 | ColorPickerAppDelegate_iPhone 173 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 174 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 175 | 176 | 177 | 178 | YES 179 | 180 | 181 | YES 182 | 183 | 184 | 185 | 186 | YES 187 | 188 | 189 | YES 190 | 191 | 192 | 193 | 8 194 | 195 | 196 | 197 | YES 198 | 199 | ColorPickerAppDelegate 200 | NSObject 201 | 202 | window 203 | UIWindow 204 | 205 | 206 | window 207 | 208 | window 209 | UIWindow 210 | 211 | 212 | 213 | IBProjectSource 214 | Shared/ColorPickerAppDelegate.h 215 | 216 | 217 | 218 | ColorPickerAppDelegate_iPhone 219 | ColorPickerAppDelegate 220 | 221 | IBProjectSource 222 | iPhone/ColorPickerAppDelegate_iPhone.h 223 | 224 | 225 | 226 | 227 | YES 228 | 229 | NSObject 230 | 231 | IBFrameworkSource 232 | Foundation.framework/Headers/NSError.h 233 | 234 | 235 | 236 | NSObject 237 | 238 | IBFrameworkSource 239 | Foundation.framework/Headers/NSFileManager.h 240 | 241 | 242 | 243 | NSObject 244 | 245 | IBFrameworkSource 246 | Foundation.framework/Headers/NSKeyValueCoding.h 247 | 248 | 249 | 250 | NSObject 251 | 252 | IBFrameworkSource 253 | Foundation.framework/Headers/NSKeyValueObserving.h 254 | 255 | 256 | 257 | NSObject 258 | 259 | IBFrameworkSource 260 | Foundation.framework/Headers/NSKeyedArchiver.h 261 | 262 | 263 | 264 | NSObject 265 | 266 | IBFrameworkSource 267 | Foundation.framework/Headers/NSObject.h 268 | 269 | 270 | 271 | NSObject 272 | 273 | IBFrameworkSource 274 | Foundation.framework/Headers/NSRunLoop.h 275 | 276 | 277 | 278 | NSObject 279 | 280 | IBFrameworkSource 281 | Foundation.framework/Headers/NSThread.h 282 | 283 | 284 | 285 | NSObject 286 | 287 | IBFrameworkSource 288 | Foundation.framework/Headers/NSURL.h 289 | 290 | 291 | 292 | NSObject 293 | 294 | IBFrameworkSource 295 | Foundation.framework/Headers/NSURLConnection.h 296 | 297 | 298 | 299 | NSObject 300 | 301 | IBFrameworkSource 302 | UIKit.framework/Headers/UIAccessibility.h 303 | 304 | 305 | 306 | NSObject 307 | 308 | IBFrameworkSource 309 | UIKit.framework/Headers/UINibLoading.h 310 | 311 | 312 | 313 | NSObject 314 | 315 | IBFrameworkSource 316 | UIKit.framework/Headers/UIResponder.h 317 | 318 | 319 | 320 | UIApplication 321 | UIResponder 322 | 323 | IBFrameworkSource 324 | UIKit.framework/Headers/UIApplication.h 325 | 326 | 327 | 328 | UIResponder 329 | NSObject 330 | 331 | 332 | 333 | UIView 334 | 335 | IBFrameworkSource 336 | UIKit.framework/Headers/UITextField.h 337 | 338 | 339 | 340 | UIView 341 | UIResponder 342 | 343 | IBFrameworkSource 344 | UIKit.framework/Headers/UIView.h 345 | 346 | 347 | 348 | UIWindow 349 | UIView 350 | 351 | IBFrameworkSource 352 | UIKit.framework/Headers/UIWindow.h 353 | 354 | 355 | 356 | 357 | 0 358 | IBCocoaTouchFramework 359 | 360 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 361 | 362 | 363 | 364 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 365 | 366 | 367 | YES 368 | ../ColorPicker.xcodeproj 369 | 3 370 | 112 371 | 372 | 373 | -------------------------------------------------------------------------------- /ColorPicker/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ColorPicker 4 | // 5 | // Created by Matthew Eagar on 9/23/11. 6 | // Copyright 2011 ThinkFlood Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is furnished 13 | // to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | #import 27 | 28 | int main(int argc, char *argv[]) { 29 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 30 | int retVal = UIApplicationMain(argc, argv, nil, nil); 31 | [pool release]; 32 | return retVal; 33 | } 34 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mateagar/Color-Picker-for-iOS/b9ad38f84bb6fa49c89b75fd212ee314427384d3/README --------------------------------------------------------------------------------