├── KColorPicker.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── LICENSE.txt ├── README.md └── UndoDrawing ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj ├── LaunchScreen.xib └── Main.storyboard ├── DKVerticalColorPicker.h ├── DKVerticalColorPicker.m ├── ImageVC.h ├── ImageVC.m ├── Images.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m ├── background.png └── main.m /KColorPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 32216B541E3098DC009B47E5 /* DKVerticalColorPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 32216B531E3098DC009B47E5 /* DKVerticalColorPicker.m */; }; 11 | 32216B571E30C8FE009B47E5 /* ImageVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 32216B561E30C8FE009B47E5 /* ImageVC.m */; }; 12 | 39679DA11A1B21EA0007964E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 39679DA01A1B21EA0007964E /* main.m */; }; 13 | 39679DA41A1B21EB0007964E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 39679DA31A1B21EB0007964E /* AppDelegate.m */; }; 14 | 39679DA71A1B21EB0007964E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 39679DA61A1B21EB0007964E /* ViewController.m */; }; 15 | 39679DAA1A1B21EB0007964E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 39679DA81A1B21EB0007964E /* Main.storyboard */; }; 16 | 39679DAC1A1B21EB0007964E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 39679DAB1A1B21EB0007964E /* Images.xcassets */; }; 17 | 39679DAF1A1B21EB0007964E /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 39679DAD1A1B21EB0007964E /* LaunchScreen.xib */; }; 18 | 39679DC71A1B24EC0007964E /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = 39679DC61A1B24EC0007964E /* background.png */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 32216B521E3098DC009B47E5 /* DKVerticalColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DKVerticalColorPicker.h; sourceTree = ""; }; 23 | 32216B531E3098DC009B47E5 /* DKVerticalColorPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DKVerticalColorPicker.m; sourceTree = ""; }; 24 | 32216B551E30C8FE009B47E5 /* ImageVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageVC.h; sourceTree = ""; }; 25 | 32216B561E30C8FE009B47E5 /* ImageVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageVC.m; sourceTree = ""; }; 26 | 39679D9B1A1B21EA0007964E /* KColorPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KColorPicker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 39679D9F1A1B21EA0007964E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | 39679DA01A1B21EA0007964E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29 | 39679DA21A1B21EA0007964E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 30 | 39679DA31A1B21EB0007964E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 31 | 39679DA51A1B21EB0007964E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 32 | 39679DA61A1B21EB0007964E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 33 | 39679DA91A1B21EB0007964E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 34 | 39679DAB1A1B21EB0007964E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 35 | 39679DAE1A1B21EB0007964E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 36 | 39679DB91A1B21EB0007964E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | 39679DBA1A1B21EB0007964E /* UndoDrawingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UndoDrawingTests.m; sourceTree = ""; }; 38 | 39679DC61A1B24EC0007964E /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | 39679D981A1B21EA0007964E /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | 39679D921A1B21EA0007964E = { 53 | isa = PBXGroup; 54 | children = ( 55 | 39679D9D1A1B21EA0007964E /* UndoDrawing */, 56 | 39679DB71A1B21EB0007964E /* UndoDrawingTests */, 57 | 39679D9C1A1B21EA0007964E /* Products */, 58 | ); 59 | sourceTree = ""; 60 | }; 61 | 39679D9C1A1B21EA0007964E /* Products */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 39679D9B1A1B21EA0007964E /* KColorPicker.app */, 65 | ); 66 | name = Products; 67 | sourceTree = ""; 68 | }; 69 | 39679D9D1A1B21EA0007964E /* UndoDrawing */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 32216B521E3098DC009B47E5 /* DKVerticalColorPicker.h */, 73 | 32216B531E3098DC009B47E5 /* DKVerticalColorPicker.m */, 74 | 39679DA21A1B21EA0007964E /* AppDelegate.h */, 75 | 39679DA31A1B21EB0007964E /* AppDelegate.m */, 76 | 39679DA51A1B21EB0007964E /* ViewController.h */, 77 | 39679DA61A1B21EB0007964E /* ViewController.m */, 78 | 32216B551E30C8FE009B47E5 /* ImageVC.h */, 79 | 32216B561E30C8FE009B47E5 /* ImageVC.m */, 80 | 39679DA81A1B21EB0007964E /* Main.storyboard */, 81 | 39679DC61A1B24EC0007964E /* background.png */, 82 | 39679DAB1A1B21EB0007964E /* Images.xcassets */, 83 | 39679DAD1A1B21EB0007964E /* LaunchScreen.xib */, 84 | 39679D9E1A1B21EA0007964E /* Supporting Files */, 85 | ); 86 | path = UndoDrawing; 87 | sourceTree = ""; 88 | }; 89 | 39679D9E1A1B21EA0007964E /* Supporting Files */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 39679D9F1A1B21EA0007964E /* Info.plist */, 93 | 39679DA01A1B21EA0007964E /* main.m */, 94 | ); 95 | name = "Supporting Files"; 96 | sourceTree = ""; 97 | }; 98 | 39679DB71A1B21EB0007964E /* UndoDrawingTests */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 39679DBA1A1B21EB0007964E /* UndoDrawingTests.m */, 102 | 39679DB81A1B21EB0007964E /* Supporting Files */, 103 | ); 104 | path = UndoDrawingTests; 105 | sourceTree = ""; 106 | }; 107 | 39679DB81A1B21EB0007964E /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 39679DB91A1B21EB0007964E /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXNativeTarget section */ 118 | 39679D9A1A1B21EA0007964E /* KColorPicker */ = { 119 | isa = PBXNativeTarget; 120 | buildConfigurationList = 39679DBE1A1B21EB0007964E /* Build configuration list for PBXNativeTarget "KColorPicker" */; 121 | buildPhases = ( 122 | 39679D971A1B21EA0007964E /* Sources */, 123 | 39679D981A1B21EA0007964E /* Frameworks */, 124 | 39679D991A1B21EA0007964E /* Resources */, 125 | ); 126 | buildRules = ( 127 | ); 128 | dependencies = ( 129 | ); 130 | name = KColorPicker; 131 | productName = UndoDrawing; 132 | productReference = 39679D9B1A1B21EA0007964E /* KColorPicker.app */; 133 | productType = "com.apple.product-type.application"; 134 | }; 135 | /* End PBXNativeTarget section */ 136 | 137 | /* Begin PBXProject section */ 138 | 39679D931A1B21EA0007964E /* Project object */ = { 139 | isa = PBXProject; 140 | attributes = { 141 | LastUpgradeCheck = 0810; 142 | ORGANIZATIONNAME = codeall; 143 | TargetAttributes = { 144 | 39679D9A1A1B21EA0007964E = { 145 | CreatedOnToolsVersion = 6.1; 146 | ProvisioningStyle = Manual; 147 | }; 148 | }; 149 | }; 150 | buildConfigurationList = 39679D961A1B21EA0007964E /* Build configuration list for PBXProject "KColorPicker" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | Base, 157 | ); 158 | mainGroup = 39679D921A1B21EA0007964E; 159 | productRefGroup = 39679D9C1A1B21EA0007964E /* Products */; 160 | projectDirPath = ""; 161 | projectRoot = ""; 162 | targets = ( 163 | 39679D9A1A1B21EA0007964E /* KColorPicker */, 164 | ); 165 | }; 166 | /* End PBXProject section */ 167 | 168 | /* Begin PBXResourcesBuildPhase section */ 169 | 39679D991A1B21EA0007964E /* Resources */ = { 170 | isa = PBXResourcesBuildPhase; 171 | buildActionMask = 2147483647; 172 | files = ( 173 | 39679DC71A1B24EC0007964E /* background.png in Resources */, 174 | 39679DAA1A1B21EB0007964E /* Main.storyboard in Resources */, 175 | 39679DAF1A1B21EB0007964E /* LaunchScreen.xib in Resources */, 176 | 39679DAC1A1B21EB0007964E /* Images.xcassets in Resources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXResourcesBuildPhase section */ 181 | 182 | /* Begin PBXSourcesBuildPhase section */ 183 | 39679D971A1B21EA0007964E /* Sources */ = { 184 | isa = PBXSourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | 32216B571E30C8FE009B47E5 /* ImageVC.m in Sources */, 188 | 32216B541E3098DC009B47E5 /* DKVerticalColorPicker.m in Sources */, 189 | 39679DA71A1B21EB0007964E /* ViewController.m in Sources */, 190 | 39679DA41A1B21EB0007964E /* AppDelegate.m in Sources */, 191 | 39679DA11A1B21EA0007964E /* main.m in Sources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXSourcesBuildPhase section */ 196 | 197 | /* Begin PBXVariantGroup section */ 198 | 39679DA81A1B21EB0007964E /* Main.storyboard */ = { 199 | isa = PBXVariantGroup; 200 | children = ( 201 | 39679DA91A1B21EB0007964E /* Base */, 202 | ); 203 | name = Main.storyboard; 204 | sourceTree = ""; 205 | }; 206 | 39679DAD1A1B21EB0007964E /* LaunchScreen.xib */ = { 207 | isa = PBXVariantGroup; 208 | children = ( 209 | 39679DAE1A1B21EB0007964E /* Base */, 210 | ); 211 | name = LaunchScreen.xib; 212 | sourceTree = ""; 213 | }; 214 | /* End PBXVariantGroup section */ 215 | 216 | /* Begin XCBuildConfiguration section */ 217 | 39679DBC1A1B21EB0007964E /* Debug */ = { 218 | isa = XCBuildConfiguration; 219 | buildSettings = { 220 | ALWAYS_SEARCH_USER_PATHS = NO; 221 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 222 | CLANG_CXX_LIBRARY = "libc++"; 223 | CLANG_ENABLE_MODULES = YES; 224 | CLANG_ENABLE_OBJC_ARC = YES; 225 | CLANG_WARN_BOOL_CONVERSION = YES; 226 | CLANG_WARN_CONSTANT_CONVERSION = YES; 227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 228 | CLANG_WARN_EMPTY_BODY = YES; 229 | CLANG_WARN_ENUM_CONVERSION = YES; 230 | CLANG_WARN_INFINITE_RECURSION = YES; 231 | CLANG_WARN_INT_CONVERSION = YES; 232 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 233 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 234 | CLANG_WARN_UNREACHABLE_CODE = YES; 235 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 236 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 237 | COPY_PHASE_STRIP = NO; 238 | ENABLE_STRICT_OBJC_MSGSEND = YES; 239 | ENABLE_TESTABILITY = YES; 240 | GCC_C_LANGUAGE_STANDARD = gnu99; 241 | GCC_DYNAMIC_NO_PIC = NO; 242 | GCC_NO_COMMON_BLOCKS = YES; 243 | GCC_OPTIMIZATION_LEVEL = 0; 244 | GCC_PREPROCESSOR_DEFINITIONS = ( 245 | "DEBUG=1", 246 | "$(inherited)", 247 | ); 248 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 249 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 250 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 251 | GCC_WARN_UNDECLARED_SELECTOR = YES; 252 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 253 | GCC_WARN_UNUSED_FUNCTION = YES; 254 | GCC_WARN_UNUSED_VARIABLE = YES; 255 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 256 | MTL_ENABLE_DEBUG_INFO = YES; 257 | ONLY_ACTIVE_ARCH = YES; 258 | SDKROOT = iphoneos; 259 | TARGETED_DEVICE_FAMILY = "1,2"; 260 | }; 261 | name = Debug; 262 | }; 263 | 39679DBD1A1B21EB0007964E /* Release */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ALWAYS_SEARCH_USER_PATHS = NO; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_MODULES = YES; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_CONSTANT_CONVERSION = YES; 273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 274 | CLANG_WARN_EMPTY_BODY = YES; 275 | CLANG_WARN_ENUM_CONVERSION = YES; 276 | CLANG_WARN_INFINITE_RECURSION = YES; 277 | CLANG_WARN_INT_CONVERSION = YES; 278 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 279 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 280 | CLANG_WARN_UNREACHABLE_CODE = YES; 281 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 282 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 283 | COPY_PHASE_STRIP = YES; 284 | ENABLE_NS_ASSERTIONS = NO; 285 | ENABLE_STRICT_OBJC_MSGSEND = YES; 286 | GCC_C_LANGUAGE_STANDARD = gnu99; 287 | GCC_NO_COMMON_BLOCKS = YES; 288 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 289 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 290 | GCC_WARN_UNDECLARED_SELECTOR = YES; 291 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 292 | GCC_WARN_UNUSED_FUNCTION = YES; 293 | GCC_WARN_UNUSED_VARIABLE = YES; 294 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 295 | MTL_ENABLE_DEBUG_INFO = NO; 296 | SDKROOT = iphoneos; 297 | TARGETED_DEVICE_FAMILY = "1,2"; 298 | VALIDATE_PRODUCT = YES; 299 | }; 300 | name = Release; 301 | }; 302 | 39679DBF1A1B21EB0007964E /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 306 | DEVELOPMENT_TEAM = ""; 307 | INFOPLIST_FILE = UndoDrawing/Info.plist; 308 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 309 | PRODUCT_BUNDLE_IDENTIFIER = "codeall.$(PRODUCT_NAME:rfc1034identifier)"; 310 | PRODUCT_NAME = "$(TARGET_NAME)"; 311 | PROVISIONING_PROFILE_SPECIFIER = ""; 312 | }; 313 | name = Debug; 314 | }; 315 | 39679DC01A1B21EB0007964E /* Release */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 319 | DEVELOPMENT_TEAM = ""; 320 | INFOPLIST_FILE = UndoDrawing/Info.plist; 321 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 322 | PRODUCT_BUNDLE_IDENTIFIER = "codeall.$(PRODUCT_NAME:rfc1034identifier)"; 323 | PRODUCT_NAME = "$(TARGET_NAME)"; 324 | PROVISIONING_PROFILE_SPECIFIER = ""; 325 | }; 326 | name = Release; 327 | }; 328 | /* End XCBuildConfiguration section */ 329 | 330 | /* Begin XCConfigurationList section */ 331 | 39679D961A1B21EA0007964E /* Build configuration list for PBXProject "KColorPicker" */ = { 332 | isa = XCConfigurationList; 333 | buildConfigurations = ( 334 | 39679DBC1A1B21EB0007964E /* Debug */, 335 | 39679DBD1A1B21EB0007964E /* Release */, 336 | ); 337 | defaultConfigurationIsVisible = 0; 338 | defaultConfigurationName = Release; 339 | }; 340 | 39679DBE1A1B21EB0007964E /* Build configuration list for PBXNativeTarget "KColorPicker" */ = { 341 | isa = XCConfigurationList; 342 | buildConfigurations = ( 343 | 39679DBF1A1B21EB0007964E /* Debug */, 344 | 39679DC01A1B21EB0007964E /* Release */, 345 | ); 346 | defaultConfigurationIsVisible = 0; 347 | defaultConfigurationName = Release; 348 | }; 349 | /* End XCConfigurationList section */ 350 | }; 351 | rootObject = 39679D931A1B21EA0007964E /* Project object */; 352 | } 353 | -------------------------------------------------------------------------------- /KColorPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KColorPicker 2 | A beautiful Color Picker and Text Drawing like Facebook App on Image with UNDO, REDO and RESET options and generate Edited Image as output. 3 | 4 | 5 | NOTE: This Control uses following controls - 6 | https://github.com/davecom/DKVerticalColorPicker 7 | 8 | 9 | ![simulator screen shot may 11 2017 12 16 00 pm](https://cloud.githubusercontent.com/assets/16478904/25936479/8aeab37c-3645-11e7-8dfd-acd2faacc114.png) 10 | ![simulator screen shot may 11 2017 12 15 34 pm](https://cloud.githubusercontent.com/assets/16478904/25936493/952933fe-3645-11e7-879d-716da17e86ae.png) 11 | ![simulator screen shot may 11 2017 12 16 06 pm](https://cloud.githubusercontent.com/assets/16478904/25936498/9a0098f4-3645-11e7-8d9d-05edc29c37eb.png) 12 | -------------------------------------------------------------------------------- /UndoDrawing/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // UndoDrawing 4 | // 5 | // Created by min on 11/18/14. 6 | // Copyright (c) 2014 codeall. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /UndoDrawing/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // UndoDrawing 4 | // 5 | // Created by min on 11/18/14. 6 | // Copyright (c) 2014 codeall. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /UndoDrawing/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /UndoDrawing/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 63 | 74 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /UndoDrawing/DKVerticalColorPicker.h: -------------------------------------------------------------------------------- 1 | // DKVerticalColorPicker.h 2 | 3 | /* 4 | DKVerticalColorPicker 5 | Copyright (c) 2015 David Kopec 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | */ 25 | 26 | #import 27 | 28 | /*! 29 | A delegate that gets notifications when the color picked changes. 30 | */ 31 | @protocol DKVerticalColorPickerDelegate 32 | @optional 33 | -(void)colorPicked:(UIColor *)color withXAxis:(float)x andYAxis:(float)y; 34 | -(void)startedDraging; 35 | -(void)endDraging; 36 | 37 | @end 38 | 39 | IB_DESIGNABLE 40 | 41 | @interface DKVerticalColorPicker : UIView 42 | 43 | @property (nonatomic, weak) IBOutlet id delegate; //set after inited 44 | @property (nonatomic) IBInspectable UIColor *selectedColor; //setting this will update the UI & notify the delegate 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /UndoDrawing/DKVerticalColorPicker.m: -------------------------------------------------------------------------------- 1 | // DKVerticalColorPicker.m 2 | 3 | /* 4 | DKVerticalColorPicker 5 | Copyright (c) 2015 David Kopec 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | */ 25 | 26 | #import "DKVerticalColorPicker.h" 27 | 28 | @interface DKVerticalColorPicker () 29 | 30 | @property (nonatomic) CGFloat currentSelectionY; 31 | @property (nonatomic) CGFloat currentSelectionX; 32 | 33 | @end 34 | 35 | @implementation DKVerticalColorPicker 36 | 37 | - (instancetype)initWithFrame:(CGRect)frame 38 | { 39 | self = [super initWithFrame:frame]; 40 | if (self) { 41 | self.currentSelectionY = 0.0; 42 | self.backgroundColor = [UIColor clearColor]; 43 | } 44 | return self; 45 | } 46 | 47 | // for when coming out of a nib 48 | - (instancetype)initWithCoder:(NSCoder *)coder 49 | { 50 | self = [super initWithCoder:coder]; 51 | if (self) { 52 | self.currentSelectionY = 0.0; 53 | self.backgroundColor = [UIColor clearColor]; 54 | } 55 | return self; 56 | } 57 | 58 | - (void)drawRect:(CGRect)rect { 59 | // Drawing code 60 | [super drawRect:rect]; 61 | 62 | //draw wings 63 | [[UIColor blackColor] set]; 64 | CGFloat tempYPlace = self.currentSelectionY; 65 | if (tempYPlace < 0.0) { 66 | tempYPlace = 0.0; 67 | } else if (tempYPlace >= self.frame.size.height) { 68 | tempYPlace = self.frame.size.height - 1.0; 69 | } 70 | CGRect temp = CGRectMake(0.0, tempYPlace, self.frame.size.width, 1.0); 71 | UIRectFill(temp); 72 | 73 | //draw central bar over it 74 | CGFloat cbxbegin = self.frame.size.width * 0.2; 75 | CGFloat cbwidth = self.frame.size.width * 0.6; 76 | for (int y = 0; y < self.frame.size.height; y++) { 77 | [[UIColor colorWithHue:(y/self.frame.size.height) saturation:1.0 brightness:1.0 alpha:1.0] set]; 78 | CGRect temp = CGRectMake(cbxbegin, y, cbwidth, 1.0); 79 | UIRectFill(temp); 80 | } 81 | } 82 | 83 | /*! 84 | Changes the selected color, updates the UI, and notifies the delegate. 85 | */ 86 | - (void)setSelectedColor:(UIColor *)selectedColor 87 | { 88 | if (selectedColor != _selectedColor) 89 | { 90 | CGFloat hue = 0.0, temp = 0.0; 91 | if ([selectedColor getHue:&hue saturation:&temp brightness:&temp alpha:&temp]) 92 | { 93 | self.currentSelectionY = floorf(hue * self.frame.size.height); 94 | [self setNeedsDisplay]; 95 | } 96 | _selectedColor = selectedColor; 97 | if([self.delegate respondsToSelector:@selector(colorPicked:withXAxis:andYAxis:)]) 98 | { 99 | [self.delegate colorPicked:self.selectedColor withXAxis:self.currentSelectionX andYAxis:self.currentSelectionY]; 100 | } 101 | } 102 | } 103 | 104 | #pragma mark - Touch Events 105 | 106 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 107 | { 108 | //update color 109 | self.currentSelectionY = [((UITouch *)[touches anyObject]) locationInView:self].y; 110 | self.currentSelectionX = [((UITouch *)[touches anyObject]) locationInView:self].x; 111 | // NSLog(@"x axis on touch began-> %f", self.currentSelectionX); 112 | _selectedColor = [UIColor colorWithHue:(self.currentSelectionY / self.frame.size.height) saturation:1.0 brightness:1.0 alpha:1.0]; 113 | //notify delegate 114 | if([self.delegate respondsToSelector:@selector(colorPicked:withXAxis:andYAxis:)]) 115 | { 116 | [self.delegate colorPicked:self.selectedColor withXAxis:self.currentSelectionX andYAxis:self.currentSelectionY]; 117 | } 118 | 119 | [self setNeedsDisplay]; 120 | if([self.delegate respondsToSelector:@selector(startedDraging)]) 121 | { 122 | [self.delegate startedDraging]; 123 | } 124 | } 125 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 126 | { 127 | //update color 128 | self.currentSelectionY = [((UITouch *)[touches anyObject]) locationInView:self].y; 129 | self.currentSelectionX = [((UITouch *)[touches anyObject]) locationInView:self].x; 130 | // NSLog(@"x axis on touch began-> %f", self.currentSelectionX); 131 | 132 | _selectedColor = [UIColor colorWithHue:(self.currentSelectionY / self.frame.size.height) saturation:1.0 brightness:1.0 alpha:1.0]; 133 | //notify delegate 134 | if([self.delegate respondsToSelector:@selector(colorPicked:withXAxis:andYAxis:)]) 135 | { 136 | [self.delegate colorPicked:self.selectedColor withXAxis:self.currentSelectionX andYAxis:self.currentSelectionY]; 137 | } 138 | 139 | [self setNeedsDisplay]; 140 | } 141 | 142 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 143 | { 144 | //update color 145 | self.currentSelectionY = [((UITouch *)[touches anyObject]) locationInView:self].y; 146 | self.currentSelectionX = [((UITouch *)[touches anyObject]) locationInView:self].x; 147 | //NSLog(@"x axis on touch began-> %f", self.currentSelectionX); 148 | _selectedColor = [UIColor colorWithHue:(self.currentSelectionY / self.frame.size.height) saturation:1.0 brightness:1.0 alpha:1.0]; 149 | //notify delegate 150 | if([self.delegate respondsToSelector:@selector(colorPicked:withXAxis:andYAxis:)]) 151 | { 152 | [self.delegate colorPicked:self.selectedColor withXAxis:self.currentSelectionX andYAxis:self.currentSelectionY]; 153 | } 154 | if([self.delegate respondsToSelector:@selector(endDraging)]) 155 | { 156 | [self.delegate endDraging]; 157 | } 158 | [self setNeedsDisplay]; 159 | } 160 | 161 | - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 162 | { 163 | 164 | } 165 | @end 166 | -------------------------------------------------------------------------------- /UndoDrawing/ImageVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // ImageVC.h 3 | // UndoDrawing 4 | // 5 | // Created by Krishana on 1/19/17. 6 | // Copyright © 2017 codeall. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ImageVC : UIViewController 12 | 13 | @property (weak, nonatomic) UIImage *image; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /UndoDrawing/ImageVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // ImageVC.m 3 | // UndoDrawing 4 | // 5 | // Created by Krishana on 1/19/17. 6 | // Copyright © 2017 codeall. All rights reserved. 7 | // 8 | 9 | #import "ImageVC.h" 10 | 11 | @interface ImageVC () 12 | 13 | @property (weak, nonatomic) IBOutlet UIImageView *imageView; 14 | 15 | @end 16 | 17 | @implementation ImageVC 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view. 22 | 23 | self.imageView.image = self.image; 24 | } 25 | 26 | - (void)viewWillAppear:(BOOL)animated { 27 | [self.navigationController setNavigationBarHidden:NO]; 28 | } 29 | 30 | - (void)didReceiveMemoryWarning { 31 | [super didReceiveMemoryWarning]; 32 | // Dispose of any resources that can be recreated. 33 | } 34 | 35 | /* 36 | #pragma mark - Navigation 37 | 38 | // In a storyboard-based application, you will often want to do a little preparation before navigation 39 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 40 | // Get the new view controller using [segue destinationViewController]. 41 | // Pass the selected object to the new view controller. 42 | } 43 | */ 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /UndoDrawing/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /UndoDrawing/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /UndoDrawing/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // UndoDrawing 4 | // 5 | // Created by min on 11/18/14. 6 | // Copyright (c) 2014 codeall. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /UndoDrawing/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // UndoDrawing 4 | // 5 | // Created by min on 11/18/14. 6 | // Copyright (c) 2014 codeall. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DKVerticalColorPicker.h" 11 | #import "ImageVC.h" 12 | 13 | 14 | @interface ViewController () 15 | { 16 | CGPoint lastPoint; 17 | CGFloat opacity; 18 | CGFloat brush; 19 | CGFloat red, green, blue; 20 | UIImage *previousImage; 21 | UIImage *rawImage; 22 | } 23 | 24 | @property (weak, nonatomic) IBOutlet UIImageView *tempImage; 25 | @property (weak, nonatomic) IBOutlet UIImageView *mainImage; 26 | @property (nonatomic, strong) NSMutableArray *stack; 27 | @property (nonatomic, strong) NSMutableArray *contextArray; 28 | 29 | @property (nonatomic, strong) NSMutableArray *pointsArray; 30 | @property (strong, nonatomic) IBOutlet UIView *movingView; 31 | @property (strong, nonatomic) IBOutlet UIView *movingWidthView; 32 | @property (nonatomic, strong) UIColor *selectedColor; 33 | 34 | @end 35 | 36 | @implementation ViewController 37 | 38 | - (void)viewDidLoad { 39 | [super viewDidLoad]; 40 | brush = 4; opacity = 1.0; red = 0.5; green = blue = 0.4; 41 | // previousImage = self.tempImage.image; 42 | _stack = [NSMutableArray array]; 43 | _contextArray = [NSMutableArray array]; 44 | 45 | rawImage = [UIImage imageNamed:@"0.png"]; 46 | previousImage = [UIImage imageNamed:@"0.png"]; 47 | 48 | self.movingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; 49 | self.movingWidthView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; 50 | self.movingWidthView.center = self.movingView.center; 51 | self.movingWidthView.backgroundColor = self.selectedColor; 52 | [self.movingView addSubview:self.movingWidthView]; 53 | self.movingView.layer.cornerRadius = 25; 54 | self.movingView.layer.borderWidth = 0; 55 | self.movingView.layer.borderColor = [UIColor whiteColor].CGColor; 56 | self.movingView.layer.masksToBounds = YES; 57 | 58 | self.movingWidthView.layer.cornerRadius = 20; 59 | self.movingWidthView.layer.borderWidth = 4; 60 | self.movingWidthView.layer.borderColor = [UIColor whiteColor].CGColor; 61 | self.movingWidthView.layer.masksToBounds = YES; 62 | 63 | self.movingView.backgroundColor = self.selectedColor; 64 | [self.movingView setHidden:YES]; 65 | [self.view addSubview:self.movingView]; 66 | self.selectedColor = [UIColor redColor]; 67 | 68 | } 69 | 70 | - (void)viewWillAppear:(BOOL)animated { 71 | self.title = @"Image Edit"; 72 | //[self.navigationController setNavigationBarHidden:YES]; 73 | } 74 | 75 | - (void)didReceiveMemoryWarning { 76 | [super didReceiveMemoryWarning]; 77 | } 78 | 79 | - (IBAction)btnClicked:(id)sender { 80 | if ([self.undoManager canUndo]) { 81 | [self.undoManager undo]; 82 | } 83 | } 84 | 85 | - (IBAction)redoBtnClicked:(id)sender { 86 | if ([self.undoManager canRedo]) { 87 | [self.undoManager redo]; 88 | } 89 | } 90 | 91 | - (IBAction)resetAction:(id)sender { 92 | [self setImage:previousImage fromImage:self.tempImage.image]; 93 | } 94 | 95 | - (IBAction)saveAction:(id)sender { 96 | [self performSegueWithIdentifier:@"NAVIGATE_TO_IMAGE" sender:nil]; 97 | } 98 | 99 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 100 | 101 | UITouch *touch = [touches anyObject]; 102 | lastPoint = [touch locationInView:self.view]; 103 | _pointsArray = [NSMutableArray array]; 104 | [_pointsArray addObject:NSStringFromCGPoint(lastPoint)]; 105 | 106 | UIGraphicsBeginImageContext(self.view.frame.size); 107 | CGContextRef context = UIGraphicsGetCurrentContext(); 108 | [self.tempImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 109 | CGContextSetLineCap(context, kCGLineCapRound); 110 | CGContextSetLineWidth(context, brush); 111 | CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), self.selectedColor.CGColor); 112 | CGContextMoveToPoint(context, lastPoint.x, lastPoint.y); 113 | CGContextAddLineToPoint(context, lastPoint.x, lastPoint.y); 114 | CGContextStrokePath(context); 115 | self.tempImage.image = UIGraphicsGetImageFromCurrentImageContext(); 116 | UIGraphicsEndImageContext(); 117 | 118 | } 119 | 120 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 121 | 122 | UITouch *touch = [touches anyObject]; 123 | CGPoint currentPoint = [touch locationInView:self.view]; 124 | 125 | UIGraphicsBeginImageContext(self.view.frame.size); 126 | [self.tempImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 127 | 128 | CGContextRef context = UIGraphicsGetCurrentContext(); 129 | CGContextMoveToPoint(context, lastPoint.x, lastPoint.y); 130 | CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y); 131 | 132 | //Now set our brush size and opacity and brush stroke color: 133 | CGContextSetLineCap(context, kCGLineCapRound); 134 | CGContextSetLineWidth(context, brush ); 135 | CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), self.selectedColor.CGColor); 136 | CGContextSetBlendMode(context,kCGBlendModeNormal); 137 | CGContextStrokePath(context); 138 | 139 | self.tempImage.image = UIGraphicsGetImageFromCurrentImageContext(); 140 | [self.tempImage setAlpha:opacity]; 141 | UIGraphicsEndImageContext(); 142 | 143 | lastPoint = currentPoint; 144 | [self.pointsArray addObject:NSStringFromCGPoint(lastPoint)]; 145 | 146 | } 147 | 148 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 149 | //handle single tap, make _pointsArray has two identical points, draw a line between them 150 | if (_pointsArray.count == 1) { 151 | [_pointsArray addObject:NSStringFromCGPoint(lastPoint)]; 152 | } 153 | 154 | [self.stack addObject:_pointsArray]; 155 | NSLog(@"color -> %@ \nwidth->%f", self.selectedColor.description, brush); 156 | 157 | NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; 158 | [dic setObject:self.selectedColor forKey:@"color"]; 159 | [dic setObject:[NSNumber numberWithFloat:brush] forKey:@"width"]; 160 | [self.contextArray addObject:dic]; 161 | 162 | [self.undoManager registerUndoWithTarget: self 163 | selector: @selector(popDrawing) 164 | object: nil]; 165 | 166 | } 167 | 168 | - (void)pushDrawing:(NSDictionary *)allDic 169 | { 170 | 171 | [self.stack addObject: (NSArray *)[allDic objectForKey:@"points"]]; 172 | [self.contextArray addObject:(NSDictionary *)[allDic objectForKey:@"context"]]; 173 | 174 | [self redrawLastLine:(NSArray *)[allDic objectForKey:@"points"]]; 175 | 176 | [self.undoManager registerUndoWithTarget: self 177 | selector: @selector(popDrawing) 178 | object: nil]; 179 | } 180 | 181 | - (void)popDrawing 182 | { 183 | NSArray *array = [self.stack lastObject]; 184 | [self.stack removeLastObject]; 185 | NSDictionary *contextDic = [_contextArray lastObject]; 186 | 187 | NSDictionary *allDic = @{ 188 | @"points" : array, 189 | @"context" : contextDic 190 | }; 191 | [self.contextArray removeLastObject]; 192 | [self redrawLinePathsInStack]; 193 | [self.undoManager registerUndoWithTarget: self 194 | selector: @selector(pushDrawing:) 195 | object: allDic]; 196 | } 197 | 198 | - (void)redrawLastLine:(NSArray*)array 199 | { 200 | UIGraphicsBeginImageContext(self.view.frame.size); 201 | CGContextRef context = UIGraphicsGetCurrentContext(); 202 | [self.tempImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 203 | CGContextSetLineCap(context, kCGLineCapRound); 204 | CGContextSetBlendMode(context,kCGBlendModeNormal); 205 | 206 | for(int i = 0; i < array.count - 1; i++) 207 | { 208 | NSDictionary *contextDic = [self.contextArray lastObject]; 209 | float lineWidth = [[contextDic objectForKey:@"width"] floatValue]; 210 | UIColor *lineColor = (UIColor *)[contextDic objectForKey:@"color"] ; 211 | CGContextSetLineWidth(context, lineWidth); 212 | CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), lineColor.CGColor); 213 | 214 | NSString *pointStr = [array objectAtIndex:i]; 215 | NSString *pointStr1 = [array objectAtIndex:i+1]; 216 | 217 | CGPoint point = CGPointFromString(pointStr); 218 | CGPoint point1 = CGPointFromString(pointStr1); 219 | 220 | CGContextMoveToPoint(context, point.x, point.y); 221 | CGContextAddLineToPoint(context, point1.x, point1.y); 222 | CGContextStrokePath(UIGraphicsGetCurrentContext()); 223 | } 224 | 225 | 226 | self.tempImage.image = UIGraphicsGetImageFromCurrentImageContext(); 227 | [self.tempImage setAlpha:opacity]; 228 | UIGraphicsEndImageContext(); 229 | } 230 | 231 | - (void)redrawLinePathsInStack 232 | { 233 | 234 | UIGraphicsBeginImageContext(self.view.frame.size); 235 | CGContextRef context = UIGraphicsGetCurrentContext(); 236 | [rawImage drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 237 | CGContextSetLineCap(context, kCGLineCapRound); 238 | 239 | CGContextSetBlendMode(context,kCGBlendModeNormal); 240 | 241 | int count = 0; 242 | for (NSArray *array in self.stack) 243 | { 244 | NSDictionary *contextDic = [self.contextArray objectAtIndex:count]; 245 | float lineWidth = [[contextDic objectForKey:@"width"] floatValue]; 246 | UIColor *lineColor = (UIColor *)[contextDic objectForKey:@"color"] ; 247 | CGContextSetLineWidth(context, lineWidth); 248 | CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), lineColor.CGColor); 249 | 250 | for(int i = 0; i < array.count - 1; i++) 251 | { 252 | NSString *pointStr = [array objectAtIndex:i]; 253 | NSString *pointStr1 = [array objectAtIndex:i+1]; 254 | 255 | CGPoint point = CGPointFromString(pointStr); 256 | CGPoint point1 = CGPointFromString(pointStr1); 257 | 258 | CGContextMoveToPoint(context, point.x, point.y); 259 | CGContextAddLineToPoint(context, point1.x, point1.y); 260 | CGContextStrokePath(UIGraphicsGetCurrentContext()); 261 | } 262 | count ++; 263 | } 264 | 265 | self.tempImage.image = UIGraphicsGetImageFromCurrentImageContext(); 266 | [self.tempImage setAlpha:opacity]; 267 | UIGraphicsEndImageContext(); 268 | } 269 | 270 | - (void)setImage:(UIImage*)currentImage fromImage:(UIImage*)preImage 271 | { 272 | // Prepare undo-redo 273 | [[self.undoManager prepareWithInvocationTarget:self] setImage:preImage fromImage:currentImage]; 274 | //self.mainImage.image = currentImage; 275 | self.tempImage.image = currentImage; 276 | //prev = currentImage; 277 | } 278 | 279 | 280 | #pragma mark color picker delegate 281 | 282 | - (void)colorPicked:(UIColor *)color withXAxis:(float)x andYAxis:(float)y { 283 | if (self.movingView.isHidden) { 284 | [self.movingView setHidden:NO]; 285 | } 286 | 287 | self.selectedColor = color; 288 | //[self.drawerView setSelectedColor:color]; 289 | self.movingView.backgroundColor = color; 290 | 291 | //NSLog(@"touch distance ->%f", y); 292 | if (x <= 0) { 293 | float distanceFromPicker = (-1) * x; 294 | //[self.drawerView setFontWidth:distanceFromPicker / 10]; 295 | float brushWidth = distanceFromPicker / 10; 296 | if (brushWidth > 1) { 297 | brush = distanceFromPicker / 10; 298 | } 299 | else { 300 | brushWidth = 1; 301 | } 302 | self.movingView.center = CGPointMake(300 - distanceFromPicker, y); 303 | self.movingWidthView.layer.borderWidth = 15 - (distanceFromPicker / 20); 304 | } 305 | } 306 | 307 | - (void)endDraging { 308 | [self.movingView setHidden:YES]; 309 | } 310 | 311 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 312 | ImageVC *imgVC = [segue destinationViewController]; 313 | imgVC.image = self.tempImage.image; 314 | } 315 | 316 | @end 317 | -------------------------------------------------------------------------------- /UndoDrawing/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishnads/KColorPicker/43e2de41142705fb20be59ce036232232e042b4e/UndoDrawing/background.png -------------------------------------------------------------------------------- /UndoDrawing/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UndoDrawing 4 | // 5 | // Created by min on 11/18/14. 6 | // Copyright (c) 2014 codeall. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------