├── .DS_Store ├── .gitattributes ├── .gitignore ├── Colour Wheel.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── Colour Wheel ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── Outline.colorset │ │ └── Contents.json │ ├── ShadowInner.colorset │ │ └── Contents.json │ └── ShadowOuter.colorset │ │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── Colour Wheel.entitlements ├── Helpers │ ├── ColourStructs.swift │ └── Helpers.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── SceneDelegate.swift └── Views │ ├── CIHueSaturationValueGradientView.swift │ ├── ColourShowView.swift │ ├── ColourWheel.swift │ ├── CustomSlider.swift │ ├── Experimental │ ├── AngularGradientHueView.swift │ └── NewColourWheel.swift │ └── FinalView.swift ├── README.md ├── preview.gif └── preview.jpg /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Priva28/SwiftUIColourWheel/e71c2c66ca0b91d28ddc57a59d3090d67ff71326/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /Colour Wheel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 305B7E1924934E4900D3F588 /* ColourShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 305B7E1824934E4900D3F588 /* ColourShowView.swift */; }; 11 | 30862008249209A4000AF70D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30862007249209A4000AF70D /* AppDelegate.swift */; }; 12 | 3086200A249209A4000AF70D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30862009249209A4000AF70D /* SceneDelegate.swift */; }; 13 | 3086200E249209A5000AF70D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3086200D249209A5000AF70D /* Assets.xcassets */; }; 14 | 30862011249209A5000AF70D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 30862010249209A5000AF70D /* Preview Assets.xcassets */; }; 15 | 30862014249209A5000AF70D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 30862012249209A5000AF70D /* LaunchScreen.storyboard */; }; 16 | 3086201E249209C9000AF70D /* FinalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3086201D249209C9000AF70D /* FinalView.swift */; }; 17 | 30862021249209D0000AF70D /* ColourWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3086201F249209CF000AF70D /* ColourWheel.swift */; }; 18 | 30862022249209D0000AF70D /* CIHueSaturationValueGradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30862020249209CF000AF70D /* CIHueSaturationValueGradientView.swift */; }; 19 | 30862025249209D9000AF70D /* AngularGradientHueView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30862023249209D9000AF70D /* AngularGradientHueView.swift */; }; 20 | 30862026249209D9000AF70D /* NewColourWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30862024249209D9000AF70D /* NewColourWheel.swift */; }; 21 | 3086202C24920A0C000AF70D /* ColourStructs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3086202A24920A0C000AF70D /* ColourStructs.swift */; }; 22 | 3086202D24920A0C000AF70D /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3086202B24920A0C000AF70D /* Helpers.swift */; }; 23 | 308620312492E531000AF70D /* CustomSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 308620302492E531000AF70D /* CustomSlider.swift */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 305B7E1824934E4900D3F588 /* ColourShowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColourShowView.swift; sourceTree = ""; }; 28 | 30862004249209A4000AF70D /* Colour Wheel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Colour Wheel.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 30862007249209A4000AF70D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 30 | 30862009249209A4000AF70D /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 31 | 3086200D249209A5000AF70D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 32 | 30862010249209A5000AF70D /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 33 | 30862013249209A5000AF70D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 34 | 30862015249209A5000AF70D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | 3086201D249209C9000AF70D /* FinalView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FinalView.swift; sourceTree = ""; }; 36 | 3086201F249209CF000AF70D /* ColourWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColourWheel.swift; sourceTree = ""; }; 37 | 30862020249209CF000AF70D /* CIHueSaturationValueGradientView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CIHueSaturationValueGradientView.swift; sourceTree = ""; }; 38 | 30862023249209D9000AF70D /* AngularGradientHueView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AngularGradientHueView.swift; sourceTree = ""; }; 39 | 30862024249209D9000AF70D /* NewColourWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewColourWheel.swift; sourceTree = ""; }; 40 | 3086202A24920A0C000AF70D /* ColourStructs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColourStructs.swift; sourceTree = ""; }; 41 | 3086202B24920A0C000AF70D /* Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = ""; }; 42 | 3086202F24920B00000AF70D /* Colour Wheel.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Colour Wheel.entitlements"; sourceTree = ""; }; 43 | 308620302492E531000AF70D /* CustomSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSlider.swift; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | 30862001249209A4000AF70D /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 30861FFB249209A4000AF70D = { 58 | isa = PBXGroup; 59 | children = ( 60 | 30862006249209A4000AF70D /* Colour Wheel */, 61 | 30862005249209A4000AF70D /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | 30862005249209A4000AF70D /* Products */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 30862004249209A4000AF70D /* Colour Wheel.app */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | 30862006249209A4000AF70D /* Colour Wheel */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 3086202F24920B00000AF70D /* Colour Wheel.entitlements */, 77 | 3086202E24920A10000AF70D /* Helpers */, 78 | 30862028249209EC000AF70D /* Views */, 79 | 30862007249209A4000AF70D /* AppDelegate.swift */, 80 | 30862009249209A4000AF70D /* SceneDelegate.swift */, 81 | 3086200D249209A5000AF70D /* Assets.xcassets */, 82 | 30862012249209A5000AF70D /* LaunchScreen.storyboard */, 83 | 30862015249209A5000AF70D /* Info.plist */, 84 | 3086200F249209A5000AF70D /* Preview Content */, 85 | ); 86 | path = "Colour Wheel"; 87 | sourceTree = ""; 88 | }; 89 | 3086200F249209A5000AF70D /* Preview Content */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 30862010249209A5000AF70D /* Preview Assets.xcassets */, 93 | ); 94 | path = "Preview Content"; 95 | sourceTree = ""; 96 | }; 97 | 30862028249209EC000AF70D /* Views */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 308620302492E531000AF70D /* CustomSlider.swift */, 101 | 30862020249209CF000AF70D /* CIHueSaturationValueGradientView.swift */, 102 | 3086201F249209CF000AF70D /* ColourWheel.swift */, 103 | 3086201D249209C9000AF70D /* FinalView.swift */, 104 | 305B7E1824934E4900D3F588 /* ColourShowView.swift */, 105 | 30862029249209F3000AF70D /* Experimental */, 106 | ); 107 | path = Views; 108 | sourceTree = ""; 109 | }; 110 | 30862029249209F3000AF70D /* Experimental */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 30862024249209D9000AF70D /* NewColourWheel.swift */, 114 | 30862023249209D9000AF70D /* AngularGradientHueView.swift */, 115 | ); 116 | path = Experimental; 117 | sourceTree = ""; 118 | }; 119 | 3086202E24920A10000AF70D /* Helpers */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 3086202A24920A0C000AF70D /* ColourStructs.swift */, 123 | 3086202B24920A0C000AF70D /* Helpers.swift */, 124 | ); 125 | path = Helpers; 126 | sourceTree = ""; 127 | }; 128 | /* End PBXGroup section */ 129 | 130 | /* Begin PBXNativeTarget section */ 131 | 30862003249209A4000AF70D /* Colour Wheel */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = 30862018249209A5000AF70D /* Build configuration list for PBXNativeTarget "Colour Wheel" */; 134 | buildPhases = ( 135 | 30862000249209A4000AF70D /* Sources */, 136 | 30862001249209A4000AF70D /* Frameworks */, 137 | 30862002249209A4000AF70D /* Resources */, 138 | ); 139 | buildRules = ( 140 | ); 141 | dependencies = ( 142 | ); 143 | name = "Colour Wheel"; 144 | productName = "Colour Wheel"; 145 | productReference = 30862004249209A4000AF70D /* Colour Wheel.app */; 146 | productType = "com.apple.product-type.application"; 147 | }; 148 | /* End PBXNativeTarget section */ 149 | 150 | /* Begin PBXProject section */ 151 | 30861FFC249209A4000AF70D /* Project object */ = { 152 | isa = PBXProject; 153 | attributes = { 154 | LastSwiftUpdateCheck = 1150; 155 | LastUpgradeCheck = 1150; 156 | ORGANIZATIONNAME = "Christian Privitelli"; 157 | TargetAttributes = { 158 | 30862003249209A4000AF70D = { 159 | CreatedOnToolsVersion = 11.5; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = 30861FFF249209A4000AF70D /* Build configuration list for PBXProject "Colour Wheel" */; 164 | compatibilityVersion = "Xcode 9.3"; 165 | developmentRegion = en; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | Base, 170 | ); 171 | mainGroup = 30861FFB249209A4000AF70D; 172 | productRefGroup = 30862005249209A4000AF70D /* Products */; 173 | projectDirPath = ""; 174 | projectRoot = ""; 175 | targets = ( 176 | 30862003249209A4000AF70D /* Colour Wheel */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | 30862002249209A4000AF70D /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | 30862014249209A5000AF70D /* LaunchScreen.storyboard in Resources */, 187 | 30862011249209A5000AF70D /* Preview Assets.xcassets in Resources */, 188 | 3086200E249209A5000AF70D /* Assets.xcassets in Resources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXResourcesBuildPhase section */ 193 | 194 | /* Begin PBXSourcesBuildPhase section */ 195 | 30862000249209A4000AF70D /* Sources */ = { 196 | isa = PBXSourcesBuildPhase; 197 | buildActionMask = 2147483647; 198 | files = ( 199 | 30862008249209A4000AF70D /* AppDelegate.swift in Sources */, 200 | 308620312492E531000AF70D /* CustomSlider.swift in Sources */, 201 | 3086202C24920A0C000AF70D /* ColourStructs.swift in Sources */, 202 | 30862025249209D9000AF70D /* AngularGradientHueView.swift in Sources */, 203 | 3086202D24920A0C000AF70D /* Helpers.swift in Sources */, 204 | 305B7E1924934E4900D3F588 /* ColourShowView.swift in Sources */, 205 | 30862026249209D9000AF70D /* NewColourWheel.swift in Sources */, 206 | 3086200A249209A4000AF70D /* SceneDelegate.swift in Sources */, 207 | 30862021249209D0000AF70D /* ColourWheel.swift in Sources */, 208 | 30862022249209D0000AF70D /* CIHueSaturationValueGradientView.swift in Sources */, 209 | 3086201E249209C9000AF70D /* FinalView.swift in Sources */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXSourcesBuildPhase section */ 214 | 215 | /* Begin PBXVariantGroup section */ 216 | 30862012249209A5000AF70D /* LaunchScreen.storyboard */ = { 217 | isa = PBXVariantGroup; 218 | children = ( 219 | 30862013249209A5000AF70D /* Base */, 220 | ); 221 | name = LaunchScreen.storyboard; 222 | sourceTree = ""; 223 | }; 224 | /* End PBXVariantGroup section */ 225 | 226 | /* Begin XCBuildConfiguration section */ 227 | 30862016249209A5000AF70D /* Debug */ = { 228 | isa = XCBuildConfiguration; 229 | buildSettings = { 230 | ALWAYS_SEARCH_USER_PATHS = NO; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_ENABLE_OBJC_WEAK = YES; 238 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 239 | CLANG_WARN_BOOL_CONVERSION = YES; 240 | CLANG_WARN_COMMA = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 243 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 244 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 245 | CLANG_WARN_EMPTY_BODY = YES; 246 | CLANG_WARN_ENUM_CONVERSION = YES; 247 | CLANG_WARN_INFINITE_RECURSION = YES; 248 | CLANG_WARN_INT_CONVERSION = YES; 249 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 250 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 251 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 252 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 253 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 254 | CLANG_WARN_STRICT_PROTOTYPES = YES; 255 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 256 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 257 | CLANG_WARN_UNREACHABLE_CODE = YES; 258 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 259 | COPY_PHASE_STRIP = NO; 260 | DEBUG_INFORMATION_FORMAT = dwarf; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | ENABLE_TESTABILITY = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu11; 264 | GCC_DYNAMIC_NO_PIC = NO; 265 | GCC_NO_COMMON_BLOCKS = YES; 266 | GCC_OPTIMIZATION_LEVEL = 0; 267 | GCC_PREPROCESSOR_DEFINITIONS = ( 268 | "DEBUG=1", 269 | "$(inherited)", 270 | ); 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 13.5; 278 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 279 | MTL_FAST_MATH = YES; 280 | ONLY_ACTIVE_ARCH = YES; 281 | SDKROOT = iphoneos; 282 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 283 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 284 | }; 285 | name = Debug; 286 | }; 287 | 30862017249209A5000AF70D /* Release */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ALWAYS_SEARCH_USER_PATHS = NO; 291 | CLANG_ANALYZER_NONNULL = YES; 292 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 293 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 294 | CLANG_CXX_LIBRARY = "libc++"; 295 | CLANG_ENABLE_MODULES = YES; 296 | CLANG_ENABLE_OBJC_ARC = YES; 297 | CLANG_ENABLE_OBJC_WEAK = YES; 298 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 299 | CLANG_WARN_BOOL_CONVERSION = YES; 300 | CLANG_WARN_COMMA = YES; 301 | CLANG_WARN_CONSTANT_CONVERSION = YES; 302 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 303 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 304 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 305 | CLANG_WARN_EMPTY_BODY = YES; 306 | CLANG_WARN_ENUM_CONVERSION = YES; 307 | CLANG_WARN_INFINITE_RECURSION = YES; 308 | CLANG_WARN_INT_CONVERSION = YES; 309 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 310 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 311 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 312 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 313 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 314 | CLANG_WARN_STRICT_PROTOTYPES = YES; 315 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 316 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 317 | CLANG_WARN_UNREACHABLE_CODE = YES; 318 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 319 | COPY_PHASE_STRIP = NO; 320 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 321 | ENABLE_NS_ASSERTIONS = NO; 322 | ENABLE_STRICT_OBJC_MSGSEND = YES; 323 | GCC_C_LANGUAGE_STANDARD = gnu11; 324 | GCC_NO_COMMON_BLOCKS = YES; 325 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 326 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 327 | GCC_WARN_UNDECLARED_SELECTOR = YES; 328 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 329 | GCC_WARN_UNUSED_FUNCTION = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | IPHONEOS_DEPLOYMENT_TARGET = 13.5; 332 | MTL_ENABLE_DEBUG_INFO = NO; 333 | MTL_FAST_MATH = YES; 334 | SDKROOT = iphoneos; 335 | SWIFT_COMPILATION_MODE = wholemodule; 336 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 337 | VALIDATE_PRODUCT = YES; 338 | }; 339 | name = Release; 340 | }; 341 | 30862019249209A5000AF70D /* Debug */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 345 | CODE_SIGN_ENTITLEMENTS = "Colour Wheel/Colour Wheel.entitlements"; 346 | CODE_SIGN_STYLE = Automatic; 347 | DEVELOPMENT_ASSET_PATHS = "\"Colour Wheel/Preview Content\""; 348 | DEVELOPMENT_TEAM = 939BQQZ3GG; 349 | ENABLE_PREVIEWS = YES; 350 | INFOPLIST_FILE = "Colour Wheel/Info.plist"; 351 | IPHONEOS_DEPLOYMENT_TARGET = 13.3; 352 | LD_RUNPATH_SEARCH_PATHS = ( 353 | "$(inherited)", 354 | "@executable_path/Frameworks", 355 | ); 356 | MARKETING_VERSION = 1.2; 357 | PRODUCT_BUNDLE_IDENTIFIER = priva28.ColourWheel; 358 | PRODUCT_NAME = "$(TARGET_NAME)"; 359 | SUPPORTS_MACCATALYST = YES; 360 | SWIFT_VERSION = 5.0; 361 | TARGETED_DEVICE_FAMILY = "1,2"; 362 | }; 363 | name = Debug; 364 | }; 365 | 3086201A249209A5000AF70D /* Release */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 369 | CODE_SIGN_ENTITLEMENTS = "Colour Wheel/Colour Wheel.entitlements"; 370 | CODE_SIGN_STYLE = Automatic; 371 | DEVELOPMENT_ASSET_PATHS = "\"Colour Wheel/Preview Content\""; 372 | DEVELOPMENT_TEAM = 939BQQZ3GG; 373 | ENABLE_PREVIEWS = YES; 374 | INFOPLIST_FILE = "Colour Wheel/Info.plist"; 375 | IPHONEOS_DEPLOYMENT_TARGET = 13.3; 376 | LD_RUNPATH_SEARCH_PATHS = ( 377 | "$(inherited)", 378 | "@executable_path/Frameworks", 379 | ); 380 | MARKETING_VERSION = 1.2; 381 | PRODUCT_BUNDLE_IDENTIFIER = priva28.ColourWheel; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | SUPPORTS_MACCATALYST = YES; 384 | SWIFT_VERSION = 5.0; 385 | TARGETED_DEVICE_FAMILY = "1,2"; 386 | }; 387 | name = Release; 388 | }; 389 | /* End XCBuildConfiguration section */ 390 | 391 | /* Begin XCConfigurationList section */ 392 | 30861FFF249209A4000AF70D /* Build configuration list for PBXProject "Colour Wheel" */ = { 393 | isa = XCConfigurationList; 394 | buildConfigurations = ( 395 | 30862016249209A5000AF70D /* Debug */, 396 | 30862017249209A5000AF70D /* Release */, 397 | ); 398 | defaultConfigurationIsVisible = 0; 399 | defaultConfigurationName = Release; 400 | }; 401 | 30862018249209A5000AF70D /* Build configuration list for PBXNativeTarget "Colour Wheel" */ = { 402 | isa = XCConfigurationList; 403 | buildConfigurations = ( 404 | 30862019249209A5000AF70D /* Debug */, 405 | 3086201A249209A5000AF70D /* Release */, 406 | ); 407 | defaultConfigurationIsVisible = 0; 408 | defaultConfigurationName = Release; 409 | }; 410 | /* End XCConfigurationList section */ 411 | }; 412 | rootObject = 30861FFC249209A4000AF70D /* Project object */; 413 | } 414 | -------------------------------------------------------------------------------- /Colour Wheel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Colour Wheel.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Colour Wheel/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 11/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Colour Wheel/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Colour Wheel/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Colour Wheel/Assets.xcassets/Outline.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.800", 9 | "green" : "0.800", 10 | "red" : "0.800" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "1.000", 26 | "blue" : "0.200", 27 | "green" : "0.200", 28 | "red" : "0.200" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Colour Wheel/Assets.xcassets/ShadowInner.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "0.500", 8 | "blue" : "0.000", 9 | "green" : "0.000", 10 | "red" : "0.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Colour Wheel/Assets.xcassets/ShadowOuter.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "0.200", 8 | "blue" : "0.000", 9 | "green" : "0.000", 10 | "red" : "0.000" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | }, 15 | { 16 | "appearances" : [ 17 | { 18 | "appearance" : "luminosity", 19 | "value" : "dark" 20 | } 21 | ], 22 | "color" : { 23 | "color-space" : "srgb", 24 | "components" : { 25 | "alpha" : "0.200", 26 | "blue" : "1.000", 27 | "green" : "1.000", 28 | "red" : "1.000" 29 | } 30 | }, 31 | "idiom" : "universal" 32 | } 33 | ], 34 | "info" : { 35 | "author" : "xcode", 36 | "version" : 1 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Colour Wheel/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /Colour Wheel/Colour Wheel.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Colour Wheel/Helpers/ColourStructs.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColourStructs.swift 3 | // color wheel 4 | // 5 | // Created by Christian P on 9/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | /// This was all taken from here and only slightly edited. -> https://gist.github.com/FredrikSjoberg/cdea97af68c6bdb0a89e3aba57a966ce 12 | 13 | /// Struct that holds red, green and blue values. Also has a `hsv` value that converts it's values to hsv. 14 | struct RGB { 15 | 16 | var r: CGFloat // Percent [0,1] 17 | var g: CGFloat // Percent [0,1] 18 | var b: CGFloat // Percent [0,1] 19 | 20 | static func toHSV(r: CGFloat, g: CGFloat, b: CGFloat) -> HSV { 21 | let min = r < g ? (r < b ? r : b) : (g < b ? g : b) 22 | let max = r > g ? (r > b ? r : b) : (g > b ? g : b) 23 | 24 | let v = max 25 | let delta = max - min 26 | 27 | guard delta > 0.00001 else { return HSV(h: 0, s: 0, v: max) } 28 | guard max > 0 else { return HSV(h: -1, s: 0, v: v) } // Undefined, achromatic grey 29 | let s = delta / max 30 | 31 | let hue: (CGFloat, CGFloat) -> CGFloat = { max, delta -> CGFloat in 32 | if r == max { return (g-b)/delta } // between yellow & magenta 33 | else if g == max { return 2 + (b-r)/delta } // between cyan & yellow 34 | else { return 4 + (r-g)/delta } // between magenta & cyan 35 | } 36 | 37 | let h = hue(max, delta) * 60 // In degrees 38 | 39 | return HSV(h: (h < 0 ? h+360 : h) , s: s, v: v) 40 | } 41 | 42 | var hsv: HSV { 43 | return RGB.toHSV(r: self.r, g: self.g, b: self.b) 44 | } 45 | } 46 | 47 | /// Struct that holds hue, saturation, value values. Also has a `rgb` value that converts it's values to hsv. 48 | struct HSV { 49 | var h: CGFloat // Angle in degrees [0,360] or -1 as Undefined 50 | var s: CGFloat // Percent [0,1] 51 | var v: CGFloat // Percent [0,1] 52 | 53 | static func toRGB(h: CGFloat, s: CGFloat, v: CGFloat) -> RGB { 54 | if s == 0 { return RGB(r: v, g: v, b: v) } // Achromatic grey 55 | 56 | let angle = (h >= 360 ? 0 : h) 57 | let sector = angle / 60 // Sector 58 | let i = floor(sector) 59 | let f = sector - i // Factorial part of h 60 | 61 | let p = v * (1 - s) 62 | let q = v * (1 - (s * f)) 63 | let t = v * (1 - (s * (1 - f))) 64 | 65 | switch(i) { 66 | case 0: 67 | return RGB(r: v, g: t, b: p) 68 | case 1: 69 | return RGB(r: q, g: v, b: p) 70 | case 2: 71 | return RGB(r: p, g: v, b: t) 72 | case 3: 73 | return RGB(r: p, g: q, b: v) 74 | case 4: 75 | return RGB(r: t, g: p, b: v) 76 | default: 77 | return RGB(r: v, g: p, b: q) 78 | } 79 | } 80 | 81 | var rgb: RGB { 82 | return HSV.toRGB(h: self.h, s: self.s, v: self.v) 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /Colour Wheel/Helpers/Helpers.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Helpers.swift 3 | // color wheel 4 | // 5 | // Created by Christian P on 9/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | func atan2To360(_ angle: CGFloat) -> CGFloat { 12 | var result = angle 13 | if result < 0 { 14 | result = (2 * CGFloat.pi) + angle 15 | } 16 | return result * 180 / CGFloat.pi 17 | } 18 | 19 | func distance(_ a: CGPoint, _ b: CGPoint) -> CGFloat { 20 | let xDist = a.x - b.x 21 | let yDist = a.y - b.y 22 | return CGFloat(sqrt(xDist * xDist + yDist * yDist)) 23 | } 24 | 25 | extension CGFloat { 26 | func map(from: ClosedRange, to: ClosedRange) -> CGFloat { 27 | let result = ((self - from.lowerBound) / (from.upperBound - from.lowerBound)) * (to.upperBound - to.lowerBound) + to.lowerBound 28 | return result 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Colour Wheel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Colour Wheel/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Colour Wheel/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 11/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 21 | 22 | // Create the SwiftUI view that provides the window contents. 23 | let contentView = FinalView() 24 | 25 | // Use a UIHostingController as window root view controller. 26 | if let windowScene = scene as? UIWindowScene { 27 | let window = UIWindow(windowScene: windowScene) 28 | window.rootViewController = UIHostingController(rootView: contentView) 29 | self.window = window 30 | window.makeKeyAndVisible() 31 | } 32 | } 33 | 34 | func sceneDidDisconnect(_ scene: UIScene) { 35 | // Called as the scene is being released by the system. 36 | // This occurs shortly after the scene enters the background, or when its session is discarded. 37 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 38 | // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 39 | } 40 | 41 | func sceneDidBecomeActive(_ scene: UIScene) { 42 | // Called when the scene has moved from an inactive state to an active state. 43 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 44 | } 45 | 46 | func sceneWillResignActive(_ scene: UIScene) { 47 | // Called when the scene will move from an active state to an inactive state. 48 | // This may occur due to temporary interruptions (ex. an incoming phone call). 49 | } 50 | 51 | func sceneWillEnterForeground(_ scene: UIScene) { 52 | // Called as the scene transitions from the background to the foreground. 53 | // Use this method to undo the changes made on entering the background. 54 | } 55 | 56 | func sceneDidEnterBackground(_ scene: UIScene) { 57 | // Called as the scene transitions from the foreground to the background. 58 | // Use this method to save data, release shared resources, and store enough scene-specific state information 59 | // to restore the scene back to its current state. 60 | } 61 | 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Colour Wheel/Views/CIHueSaturationValueGradientView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CIHueSaturationValueGradientView.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 9/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | /// This UIViewRepresentable uses `CIHueSaturationValueGradient` to draw a circular gradient with the RGB colour space as a CIFilter. 12 | struct CIHueSaturationValueGradientView: UIViewRepresentable { 13 | 14 | /// Radius to draw 15 | var radius: CGFloat 16 | 17 | /// The brightness/value of the wheel. 18 | @Binding var brightness: CGFloat 19 | 20 | /// Image view that will hold the rendered CIHueSaturationValueGradient. 21 | let imageView = UIImageView() 22 | 23 | func makeUIView(context: Context) -> UIImageView { 24 | /// Render CIHueSaturationValueGradient and set it to the ImageView that will be returned. 25 | imageView.image = renderFilter() 26 | return imageView 27 | } 28 | 29 | func updateUIView(_ uiView: UIImageView, context: Context) { 30 | /// When the view updates eg. brightness changes, a new CIHueSaturationValueGradient will be generated. 31 | uiView.image = renderFilter() 32 | } 33 | 34 | /// Generate the CIHueSaturationValueGradient and output it as a UIImage. 35 | func renderFilter() -> UIImage { 36 | let filter = CIFilter(name: "CIHueSaturationValueGradient", parameters: [ 37 | "inputColorSpace": CGColorSpaceCreateDeviceRGB(), 38 | "inputDither": 0, 39 | "inputRadius": radius * 0.4, 40 | "inputSoftness": 0, 41 | "inputValue": brightness 42 | ])! 43 | 44 | /// Output as UIImageView 45 | let image = UIImage(ciImage: filter.outputImage!) 46 | return image 47 | } 48 | } 49 | 50 | struct CIHueSaturationValueGradientView_Previews: PreviewProvider { 51 | static var previews: some View { 52 | CIHueSaturationValueGradientView(radius: 350, brightness: .constant(1)) 53 | .frame(width: 350, height: 350) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Colour Wheel/Views/ColourShowView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColourShowView.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 12/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ColourShowView: View { 12 | 13 | @Binding var rgbColour: RGB 14 | 15 | var body: some View { 16 | /// The view that shows the selected colour. 17 | RoundedRectangle(cornerRadius: 10) 18 | .foregroundColor(Color.init(red: Double(rgbColour.r), green: Double(rgbColour.g), blue: Double(rgbColour.b))) 19 | .frame(width: 300, height: 50) 20 | /// The outline. 21 | .overlay( 22 | RoundedRectangle(cornerRadius: 10) 23 | .stroke(Color("Outline"), lineWidth: 5) 24 | ) 25 | /// The outer shadow. 26 | .shadow(color: Color("ShadowOuter"), radius: 18) 27 | } 28 | } 29 | 30 | struct ColourShowView_Previews: PreviewProvider { 31 | static var previews: some View { 32 | ColourShowView(rgbColour: .constant(RGB(r: 1, g: 1, b: 1))) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Colour Wheel/Views/ColourWheel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorWheel.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 9/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | /// The actual colour wheel view. 12 | struct ColourWheel: View { 13 | 14 | /// Draws at a specified radius. 15 | var radius: CGFloat 16 | 17 | /// The RGB colour. Is a binding as it can change and the view will update when it does. 18 | @Binding var rgbColour: RGB 19 | 20 | /// The brightness/value of the colour wheel 21 | @Binding var brightness: CGFloat 22 | 23 | var body: some View { 24 | 25 | DispatchQueue.main.async { 26 | self.rgbColour = HSV(h: self.rgbColour.hsv.h, s: self.rgbColour.hsv.s, v: self.brightness).rgb 27 | } 28 | 29 | /// Geometry reader so we can know more about the geometry around and within the view. 30 | return GeometryReader { geometry in 31 | ZStack { 32 | 33 | /// The colour wheel. See the definition. 34 | CIHueSaturationValueGradientView(radius: self.radius, brightness: self.$brightness) 35 | /// Smoothing out of the colours. 36 | .blur(radius: 10) 37 | /// The outline. 38 | .overlay( 39 | Circle() 40 | .size(CGSize(width: self.radius, height: self.radius)) 41 | .stroke(Color("Outline"), lineWidth: 10) 42 | /// Inner shadow. 43 | .shadow(color: Color("ShadowInner"), radius: 8) 44 | ) 45 | /// Clip inner shadow. 46 | .clipShape( 47 | Circle() 48 | .size(CGSize(width: self.radius, height: self.radius)) 49 | ) 50 | /// Outer shadow. 51 | .shadow(color: Color("ShadowOuter"), radius: 15) 52 | 53 | /// This is not required and actually makes the gradient less "accurate" but looks nicer. It's basically just a white radial gradient that blends the colours together nicer. We also slowly dissolve it as the brightness/value goes down. 54 | RadialGradient(gradient: Gradient(colors: [Color.white.opacity(0.8*Double(self.brightness)), .clear]), center: .center, startRadius: 0, endRadius: self.radius/2 - 10) 55 | .blendMode(.screen) 56 | 57 | /// The little knob that shows selected colour. 58 | Circle() 59 | .frame(width: 10, height: 10) 60 | .offset(x: (self.radius/2 - 10) * self.rgbColour.hsv.s) 61 | .rotationEffect(.degrees(-Double(self.rgbColour.hsv.h))) 62 | 63 | } 64 | /// The gesture so we can detect touches on the wheel. 65 | .gesture( 66 | DragGesture(minimumDistance: 0, coordinateSpace: .global) 67 | .onChanged { value in 68 | 69 | /// Work out angle which will be the hue. 70 | let y = geometry.frame(in: .global).midY - value.location.y 71 | let x = value.location.x - geometry.frame(in: .global).midX 72 | 73 | /// Use `atan2` to get the angle from the center point then convert than into a 360 value with custom function(find it in helpers). 74 | let hue = atan2To360(atan2(y, x)) 75 | 76 | /// Work out distance from the center point which will be the saturation. 77 | let center = CGPoint(x: geometry.frame(in: .global).midX, y: geometry.frame(in: .global).midY) 78 | 79 | /// Maximum value of sat is 1 so we find the smallest of 1 and the distance. 80 | let saturation = min(distance(center, value.location)/(self.radius/2), 1) 81 | 82 | /// Convert HSV to RGB and set the colour which will notify the views. 83 | self.rgbColour = HSV(h: hue, s: saturation, v: self.brightness).rgb 84 | } 85 | ) 86 | } 87 | /// Set the size. 88 | .frame(width: self.radius, height: self.radius) 89 | } 90 | } 91 | 92 | struct ColourWheel_Previews: PreviewProvider { 93 | static var previews: some View { 94 | ColourWheel(radius: 350, rgbColour: .constant(RGB(r: 1, g: 1, b: 1)), brightness: .constant(0)) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Colour Wheel/Views/CustomSlider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomSlider.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 12/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct CustomSlider: View { 12 | 13 | /// The slider will also show the selected colour. 14 | @Binding var rgbColour: RGB 15 | 16 | /// The value that the slider is currently showing. 17 | @Binding var value: CGFloat 18 | 19 | /// The range of the slider. 20 | var range: ClosedRange 21 | 22 | /// What the last x offset of the slider knob was before it was moved. 23 | @State var lastOffset: CGFloat = 0 24 | 25 | /// If the knob is being touched or not. 26 | @State var isTouchingKnob = false 27 | 28 | /// Set the leading and trailing offset of the track for the knob. 29 | var leadingOffset: CGFloat = 8 30 | var trailingOffset: CGFloat = 8 31 | 32 | /// Set the knob size. 33 | var knobSize: CGSize = CGSize(width: 28, height: 28) 34 | 35 | var body: some View { 36 | GeometryReader { geometry in 37 | ZStack { 38 | 39 | /// The slider track. 40 | RoundedRectangle(cornerRadius: 30) 41 | /// Set the colour to be the selected colour. 42 | .foregroundColor(Color.init(red: Double(self.rgbColour.r), green: Double(self.rgbColour.g), blue: Double(self.rgbColour.b))) 43 | /// The outline. 44 | .overlay( 45 | RoundedRectangle(cornerRadius: 30) 46 | .stroke(Color("Outline"), lineWidth: 3) 47 | ) 48 | /// The outer shadow. 49 | .shadow(color: Color("ShadowOuter"), radius: 18) 50 | HStack { 51 | /// The knob. 52 | ZStack { 53 | /// The knob outline. 54 | RoundedRectangle(cornerRadius: 50) 55 | .stroke(Color("Outline"), lineWidth: self.isTouchingKnob ? 4 : 5) 56 | .frame(width: self.knobSize.width, height: self.knobSize.height) 57 | /// The knob center. 58 | RoundedRectangle(cornerRadius: 50) 59 | .foregroundColor(Color.init(red: Double(self.rgbColour.r-0.1), green: Double(self.rgbColour.g-0.1), blue: Double(self.rgbColour.b-0.1))) 60 | .frame(width: self.knobSize.width, height: self.knobSize.height) 61 | } 62 | /// Set the offset of the knob. 63 | .offset(x: self.$value.wrappedValue.map(from: self.range, to: self.leadingOffset...(geometry.size.width - self.knobSize.width - self.trailingOffset))) 64 | /// The knob shadow. 65 | .shadow(color: Color("ShadowOuter"), radius: 18) 66 | /// Gesture to detect drag. 67 | .gesture( 68 | DragGesture(minimumDistance: 0) 69 | .onChanged { value in 70 | 71 | /// Tell view we are now touching the knob and record the position before we move it. 72 | self.isTouchingKnob = true 73 | if abs(value.translation.width) < 0.1 { 74 | self.lastOffset = self.$value.wrappedValue.map(from: self.range, to: self.leadingOffset...(geometry.size.width - self.knobSize.width - self.trailingOffset)) 75 | } 76 | 77 | /// Calculate what the new x offset as well as the value should be. 78 | let sliderPos = max(0 + self.leadingOffset, min(self.lastOffset + value.translation.width, geometry.size.width - self.knobSize.width - self.trailingOffset)) 79 | let sliderVal = sliderPos.map(from: self.leadingOffset...(geometry.size.width - self.knobSize.width - self.trailingOffset), to: self.range) 80 | 81 | self.value = sliderVal 82 | } 83 | .onEnded { _ in 84 | 85 | /// Gesture is ended and we are no longer touching the knob. 86 | self.isTouchingKnob = false 87 | } 88 | ) 89 | /// Spacer in HStack aligns the knob to the left so that we don't have to deal with abs(). 90 | Spacer() 91 | } 92 | } 93 | } 94 | .frame(height: 40) 95 | } 96 | } 97 | 98 | struct CustomSlider_Previews: PreviewProvider { 99 | static var previews: some View { 100 | CustomSlider(rgbColour: .constant(RGB(r: 0.5, g: 0.1, b: 0.9)), value: .constant(10), range: 1...100) 101 | } 102 | } 103 | 104 | 105 | -------------------------------------------------------------------------------- /Colour Wheel/Views/Experimental/AngularGradientHueView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AngularGradientHueView.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 11/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct AngularGradientHueView: View { 12 | 13 | var colours: [Color] = { 14 | let hue = Array(0...359).reversed() 15 | return hue.map { 16 | Color(UIColor(hue: CGFloat($0) / 359, saturation: 1, brightness: 1, alpha: 1)) 17 | } 18 | }() 19 | var radius: CGFloat 20 | 21 | var body: some View { 22 | AngularGradient(gradient: Gradient(colors: colours), center: UnitPoint(x: 0.5, y: 0.5)) 23 | .frame(width: radius, height: radius) 24 | .clipShape(Circle()) 25 | } 26 | } 27 | 28 | struct AngularGradientHueView_Previews: PreviewProvider { 29 | static var previews: some View { 30 | AngularGradientHueView(radius: 350) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Colour Wheel/Views/Experimental/NewColourWheel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NewColourWheel.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 11/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | /// The actual colour wheel view. 12 | struct NewColourWheel: View { 13 | 14 | /// Draws at a specified radius. 15 | var radius: CGFloat 16 | 17 | /// The RGB colour. Is a binding as it can change and the view will update when it does. 18 | @Binding var rgbColour: RGB 19 | 20 | var body: some View { 21 | 22 | /// Geometry reader so we can know more about the geometry around and within the view. 23 | GeometryReader { geometry in 24 | ZStack { 25 | 26 | /// The colour wheel. See the definition. 27 | AngularGradientHueView(radius: self.radius) 28 | /// Smoothing out of the colours. 29 | .blur(radius: 10) 30 | /// The outline. 31 | .overlay( 32 | Circle() 33 | .size(CGSize(width: self.radius, height: self.radius)) 34 | .stroke(Color("Outline"), lineWidth: 10) 35 | /// Inner shadow. 36 | .shadow(color: Color("ShadowInner"), radius: 8) 37 | ) 38 | /// Clip inner shadow. 39 | .clipShape( 40 | Circle() 41 | .size(CGSize(width: self.radius, height: self.radius)) 42 | ) 43 | /// Outer shadow. 44 | .shadow(color: Color("ShadowOuter"), radius: 15) 45 | 46 | /// This *is* required for the saturation scale of the wheel. It actually makes the gradient less "accurate" but looks nicer. It's basically just a white radial gradient that blends the colours together nicer. 47 | RadialGradient(gradient: Gradient(colors: [.white, .black]), center: .center, startRadius: 0, endRadius: self.radius/2 - 10) 48 | .blendMode(.screen) 49 | 50 | /// The little knob that shows selected colour. 51 | Circle() 52 | .frame(width: 10, height: 10) 53 | .offset(x: (self.radius/2 - 10) * self.rgbColour.hsv.s) 54 | .rotationEffect(.degrees(-Double(self.rgbColour.hsv.h))) 55 | 56 | } 57 | /// The gesture so we can detect taps and drags on the wheel. 58 | .gesture( 59 | DragGesture(minimumDistance: 0, coordinateSpace: .global) 60 | .onChanged { value in 61 | 62 | /// Work out angle which will be the hue. 63 | let y = geometry.frame(in: .global).midY - value.location.y 64 | let x = value.location.x - geometry.frame(in: .global).midX 65 | 66 | /// Use `atan2` to get the angle from the center point then convert than into a 360 value with custom function(find it in helpers). 67 | let hue = atan2To360(atan2(y, x)) 68 | 69 | /// Work out distance from the center point which will be the saturation. 70 | let center = CGPoint(x: geometry.frame(in: .global).midX, y: geometry.frame(in: .global).midY) 71 | 72 | /// Maximum value of sat is 1 so we find the smallest of 1 and the distance. 73 | let saturation = min(distance(center, value.location)/(self.radius/2), 1) 74 | 75 | /// Convert HSV to RGB and set the colour which will notify the views. 76 | self.rgbColour = HSV(h: hue, s: saturation, v: 1).rgb 77 | } 78 | ) 79 | } 80 | /// Set the size. 81 | .frame(width: self.radius, height: self.radius) 82 | } 83 | } 84 | 85 | struct NewColourWheel_Previews: PreviewProvider { 86 | static var previews: some View { 87 | NewColourWheel(radius: 350, rgbColour: .constant(RGB(r: 1, g: 1, b: 1))) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Colour Wheel/Views/FinalView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FinalView.swift 3 | // Colour Wheel 4 | // 5 | // Created by Christian P on 9/6/20. 6 | // Copyright © 2020 Christian P. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | /// The final view that presents everything. 12 | struct FinalView: View { 13 | 14 | /// Source of truth of the colour that will be presented as well as controlled with the colour wheel. 15 | @State var rgbColour = RGB(r: 0, g: 1, b: 1) 16 | @State var brightness: CGFloat = 1 17 | 18 | var body: some View { 19 | VStack { 20 | 21 | /// The text at the top. 22 | HStack { 23 | Text("Pick a colour.") 24 | .font(.largeTitle) 25 | .fontWeight(.heavy) 26 | .padding() 27 | Spacer() 28 | } 29 | 30 | /// The actual colour wheel. 31 | ColourWheel(radius: 300, rgbColour: $rgbColour, brightness: $brightness) 32 | .padding() 33 | 34 | /// The slider shows the selected colour and allows control of the brightness/value. Cannot have value at 0 otherwise we lose the RGB value. 35 | CustomSlider(rgbColour: $rgbColour, value: $brightness, range: 0.001...1) 36 | .padding() 37 | 38 | /// If you don't want a brightness/value slider then remove it and use this instead to show the current colour. 39 | //ColourShowView(rgbColour: $rgbColour) 40 | } 41 | } 42 | } 43 | 44 | struct FinalView_Previews: PreviewProvider { 45 | static var previews: some View { 46 | FinalView() 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftUI Colour Wheel 2 | 3 | A colour wheel made all in SwiftUI. 4 | 5 | There are 2 different colour wheels to choose from. 6 | 7 | - The first main one uses `CIHueSaturationValueGradient` `CIFilter` to draw itself, then uses `RadialGradient` and `.blur` to smooth it out. Named `ColourWheel` in code. 8 | - The second one uses SwiftUI's `AngularGradient` with all 360 hues to draw the gradient, then a `RadialGradient` and `.blur` to smooth it out. Named `NewColourWheel` in code. 9 | 10 | If you would like to use the slider to change brightness/value, use `ColourWheel`, as `NewColourWheel` does not support setting value at this point in time. 11 | 12 | They both interact the same and output in [Red, Green, Blue] or [Hue, Saturation]. 13 | 14 | ![previewjpg](https://raw.githubusercontent.com/Priva28/SwiftUIColourWheel/master/preview.jpg) 15 | 16 | ![preview](https://raw.githubusercontent.com/Priva28/SwiftUIColourWheel/master/preview.gif) 17 | -------------------------------------------------------------------------------- /preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Priva28/SwiftUIColourWheel/e71c2c66ca0b91d28ddc57a59d3090d67ff71326/preview.gif -------------------------------------------------------------------------------- /preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Priva28/SwiftUIColourWheel/e71c2c66ca0b91d28ddc57a59d3090d67ff71326/preview.jpg --------------------------------------------------------------------------------