├── CoreImageReactionDiffusion.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── simongladman.xcuserdatad │ └── xcschemes │ ├── CoreImageReactionDiffusion.xcscheme │ └── xcschememanagement.plist ├── CoreImageReactionDiffusion ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.swift └── screenshot.jpg └── README.md /CoreImageReactionDiffusion.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3E4B11081C3AC9080082CB1C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4B11071C3AC9080082CB1C /* AppDelegate.swift */; }; 11 | 3E4B110A1C3AC9080082CB1C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4B11091C3AC9080082CB1C /* ViewController.swift */; }; 12 | 3E4B110D1C3AC9080082CB1C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3E4B110B1C3AC9080082CB1C /* Main.storyboard */; }; 13 | 3E4B110F1C3AC9080082CB1C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3E4B110E1C3AC9080082CB1C /* Assets.xcassets */; }; 14 | 3E4B11121C3AC9080082CB1C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3E4B11101C3AC9080082CB1C /* LaunchScreen.storyboard */; }; 15 | 3E4B111E1C3BD0A40082CB1C /* screenshot.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 3E4B111D1C3BD0A40082CB1C /* screenshot.jpg */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 3E4B11041C3AC9080082CB1C /* CoreImageReactionDiffusion.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoreImageReactionDiffusion.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 3E4B11071C3AC9080082CB1C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 3E4B11091C3AC9080082CB1C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 3E4B110C1C3AC9080082CB1C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 3E4B110E1C3AC9080082CB1C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 3E4B11111C3AC9080082CB1C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 3E4B11131C3AC9080082CB1C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 3E4B111D1C3BD0A40082CB1C /* screenshot.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = screenshot.jpg; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 3E4B11011C3AC9080082CB1C /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 3E4B10FB1C3AC9080082CB1C = { 41 | isa = PBXGroup; 42 | children = ( 43 | 3E4B11061C3AC9080082CB1C /* CoreImageReactionDiffusion */, 44 | 3E4B11051C3AC9080082CB1C /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 3E4B11051C3AC9080082CB1C /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 3E4B11041C3AC9080082CB1C /* CoreImageReactionDiffusion.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 3E4B11061C3AC9080082CB1C /* CoreImageReactionDiffusion */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 3E4B111D1C3BD0A40082CB1C /* screenshot.jpg */, 60 | 3E4B11071C3AC9080082CB1C /* AppDelegate.swift */, 61 | 3E4B11091C3AC9080082CB1C /* ViewController.swift */, 62 | 3E4B110B1C3AC9080082CB1C /* Main.storyboard */, 63 | 3E4B110E1C3AC9080082CB1C /* Assets.xcassets */, 64 | 3E4B11101C3AC9080082CB1C /* LaunchScreen.storyboard */, 65 | 3E4B11131C3AC9080082CB1C /* Info.plist */, 66 | ); 67 | path = CoreImageReactionDiffusion; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | 3E4B11031C3AC9080082CB1C /* CoreImageReactionDiffusion */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = 3E4B11161C3AC9080082CB1C /* Build configuration list for PBXNativeTarget "CoreImageReactionDiffusion" */; 76 | buildPhases = ( 77 | 3E4B11001C3AC9080082CB1C /* Sources */, 78 | 3E4B11011C3AC9080082CB1C /* Frameworks */, 79 | 3E4B11021C3AC9080082CB1C /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = CoreImageReactionDiffusion; 86 | productName = CoreImageReactionDiffusion; 87 | productReference = 3E4B11041C3AC9080082CB1C /* CoreImageReactionDiffusion.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 3E4B10FC1C3AC9080082CB1C /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0720; 97 | LastUpgradeCheck = 0720; 98 | ORGANIZATIONNAME = "Simon Gladman"; 99 | TargetAttributes = { 100 | 3E4B11031C3AC9080082CB1C = { 101 | CreatedOnToolsVersion = 7.2; 102 | }; 103 | }; 104 | }; 105 | buildConfigurationList = 3E4B10FF1C3AC9080082CB1C /* Build configuration list for PBXProject "CoreImageReactionDiffusion" */; 106 | compatibilityVersion = "Xcode 3.2"; 107 | developmentRegion = English; 108 | hasScannedForEncodings = 0; 109 | knownRegions = ( 110 | en, 111 | Base, 112 | ); 113 | mainGroup = 3E4B10FB1C3AC9080082CB1C; 114 | productRefGroup = 3E4B11051C3AC9080082CB1C /* Products */; 115 | projectDirPath = ""; 116 | projectRoot = ""; 117 | targets = ( 118 | 3E4B11031C3AC9080082CB1C /* CoreImageReactionDiffusion */, 119 | ); 120 | }; 121 | /* End PBXProject section */ 122 | 123 | /* Begin PBXResourcesBuildPhase section */ 124 | 3E4B11021C3AC9080082CB1C /* Resources */ = { 125 | isa = PBXResourcesBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | 3E4B11121C3AC9080082CB1C /* LaunchScreen.storyboard in Resources */, 129 | 3E4B110F1C3AC9080082CB1C /* Assets.xcassets in Resources */, 130 | 3E4B110D1C3AC9080082CB1C /* Main.storyboard in Resources */, 131 | 3E4B111E1C3BD0A40082CB1C /* screenshot.jpg in Resources */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXResourcesBuildPhase section */ 136 | 137 | /* Begin PBXSourcesBuildPhase section */ 138 | 3E4B11001C3AC9080082CB1C /* Sources */ = { 139 | isa = PBXSourcesBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | 3E4B110A1C3AC9080082CB1C /* ViewController.swift in Sources */, 143 | 3E4B11081C3AC9080082CB1C /* AppDelegate.swift in Sources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXSourcesBuildPhase section */ 148 | 149 | /* Begin PBXVariantGroup section */ 150 | 3E4B110B1C3AC9080082CB1C /* Main.storyboard */ = { 151 | isa = PBXVariantGroup; 152 | children = ( 153 | 3E4B110C1C3AC9080082CB1C /* Base */, 154 | ); 155 | name = Main.storyboard; 156 | sourceTree = ""; 157 | }; 158 | 3E4B11101C3AC9080082CB1C /* LaunchScreen.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | 3E4B11111C3AC9080082CB1C /* Base */, 162 | ); 163 | name = LaunchScreen.storyboard; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXVariantGroup section */ 167 | 168 | /* Begin XCBuildConfiguration section */ 169 | 3E4B11141C3AC9080082CB1C /* Debug */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 174 | CLANG_CXX_LIBRARY = "libc++"; 175 | CLANG_ENABLE_MODULES = YES; 176 | CLANG_ENABLE_OBJC_ARC = YES; 177 | CLANG_WARN_BOOL_CONVERSION = YES; 178 | CLANG_WARN_CONSTANT_CONVERSION = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_EMPTY_BODY = YES; 181 | CLANG_WARN_ENUM_CONVERSION = YES; 182 | CLANG_WARN_INT_CONVERSION = YES; 183 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 187 | COPY_PHASE_STRIP = NO; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu99; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 210 | TARGETED_DEVICE_FAMILY = 2; 211 | }; 212 | name = Debug; 213 | }; 214 | 3E4B11151C3AC9080082CB1C /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 219 | CLANG_CXX_LIBRARY = "libc++"; 220 | CLANG_ENABLE_MODULES = YES; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_BOOL_CONVERSION = YES; 223 | CLANG_WARN_CONSTANT_CONVERSION = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_EMPTY_BODY = YES; 226 | CLANG_WARN_ENUM_CONVERSION = YES; 227 | CLANG_WARN_INT_CONVERSION = YES; 228 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 229 | CLANG_WARN_UNREACHABLE_CODE = YES; 230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 231 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 232 | COPY_PHASE_STRIP = NO; 233 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 234 | ENABLE_NS_ASSERTIONS = NO; 235 | ENABLE_STRICT_OBJC_MSGSEND = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_NO_COMMON_BLOCKS = YES; 238 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 239 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 240 | GCC_WARN_UNDECLARED_SELECTOR = YES; 241 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 242 | GCC_WARN_UNUSED_FUNCTION = YES; 243 | GCC_WARN_UNUSED_VARIABLE = YES; 244 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 245 | MTL_ENABLE_DEBUG_INFO = NO; 246 | SDKROOT = iphoneos; 247 | TARGETED_DEVICE_FAMILY = 2; 248 | VALIDATE_PRODUCT = YES; 249 | }; 250 | name = Release; 251 | }; 252 | 3E4B11171C3AC9080082CB1C /* Debug */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 256 | INFOPLIST_FILE = CoreImageReactionDiffusion/Info.plist; 257 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 258 | PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.CoreImageReactionDiffusion; 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | TARGETED_DEVICE_FAMILY = 2; 261 | }; 262 | name = Debug; 263 | }; 264 | 3E4B11181C3AC9080082CB1C /* Release */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 268 | INFOPLIST_FILE = CoreImageReactionDiffusion/Info.plist; 269 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 270 | PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.CoreImageReactionDiffusion; 271 | PRODUCT_NAME = "$(TARGET_NAME)"; 272 | TARGETED_DEVICE_FAMILY = 2; 273 | }; 274 | name = Release; 275 | }; 276 | /* End XCBuildConfiguration section */ 277 | 278 | /* Begin XCConfigurationList section */ 279 | 3E4B10FF1C3AC9080082CB1C /* Build configuration list for PBXProject "CoreImageReactionDiffusion" */ = { 280 | isa = XCConfigurationList; 281 | buildConfigurations = ( 282 | 3E4B11141C3AC9080082CB1C /* Debug */, 283 | 3E4B11151C3AC9080082CB1C /* Release */, 284 | ); 285 | defaultConfigurationIsVisible = 0; 286 | defaultConfigurationName = Release; 287 | }; 288 | 3E4B11161C3AC9080082CB1C /* Build configuration list for PBXNativeTarget "CoreImageReactionDiffusion" */ = { 289 | isa = XCConfigurationList; 290 | buildConfigurations = ( 291 | 3E4B11171C3AC9080082CB1C /* Debug */, 292 | 3E4B11181C3AC9080082CB1C /* Release */, 293 | ); 294 | defaultConfigurationIsVisible = 0; 295 | defaultConfigurationName = Release; 296 | }; 297 | /* End XCConfigurationList section */ 298 | }; 299 | rootObject = 3E4B10FC1C3AC9080082CB1C /* Project object */; 300 | } 301 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion.xcodeproj/xcuserdata/simongladman.xcuserdatad/xcschemes/CoreImageReactionDiffusion.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion.xcodeproj/xcuserdata/simongladman.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CoreImageReactionDiffusion.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 3E4B11031C3AC9080082CB1C 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CoreImageReactionDiffusion 4 | // 5 | // Created by Simon Gladman on 04/01/2016. 6 | // Copyright © 2016 Simon Gladman. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "ipad", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "ipad", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "ipad", 15 | "size" : "40x40", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "40x40", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "76x76", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "76x76", 31 | "scale" : "2x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /CoreImageReactionDiffusion/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 | 27 | 28 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion/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 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion/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~ipad 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CoreImageReactionDiffusion/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CoreImageReactionDiffusion 4 | // 5 | // Created by Simon Gladman on 04/01/2016. 6 | // Copyright © 2016 Simon Gladman. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import GLKit 11 | 12 | class ViewController: UIViewController { 13 | 14 | let grayScottFilter = GrayScottFilter() 15 | 16 | let rect640x640 = CGRect(x: 0, y: 0, width: 640, height: 640) 17 | 18 | let accumulator = CIImageAccumulator(extent: CGRect(x: 0, y: 0, width: 640, height: 640), format: kCIFormatARGB8) 19 | 20 | let edgesFilter = CIFilter(name: "CIEdges", 21 | withInputParameters: [kCIInputIntensityKey: 50])! 22 | 23 | let imageView = MetalImageView() 24 | 25 | override func viewDidLoad() 26 | { 27 | super.viewDidLoad() 28 | 29 | view.addSubview(imageView) 30 | 31 | setInitialImage() 32 | 33 | let displayLink = CADisplayLink(target: self, selector: #selector(ViewController.step)) 34 | displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSDefaultRunLoopMode) 35 | } 36 | 37 | func setInitialImage() 38 | { 39 | let yellow = CIImage(color: CIColor(color: UIColor.yellowColor())) 40 | let noise = CIFilter(name: "CIRandomGenerator")! 41 | 42 | let crop = CIFilter(name: "CICrop", 43 | withInputParameters: [kCIInputImageKey: noise.outputImage!, 44 | "inputRectangle": CIVector(CGRect: rect640x640.insetBy(dx: 250, dy: 250))])! 45 | 46 | let composite = CIFilter(name: "CISourceAtopCompositing", 47 | withInputParameters: [kCIInputBackgroundImageKey: yellow, 48 | kCIInputImageKey:crop.outputImage!])! 49 | 50 | accumulator.setImage(composite.outputImage!) 51 | } 52 | 53 | func step() 54 | { 55 | for _ in 0 ..< 5 56 | { 57 | grayScottFilter.setValue(accumulator.image(), 58 | forKey: kCIInputImageKey) 59 | accumulator.setImage(grayScottFilter.outputImage) 60 | } 61 | 62 | edgesFilter.setValue(accumulator.image(), 63 | forKey: kCIInputImageKey) 64 | 65 | imageView.image = edgesFilter.outputImage! 66 | } 67 | 68 | override func viewDidLayoutSubviews() 69 | { 70 | imageView.frame = CGRect( 71 | origin: CGPoint( 72 | x: view.frame.width / 2 - rect640x640.width / 2, 73 | y: view.frame.height / 2 - rect640x640.height / 2), 74 | size: CGSize( 75 | width: rect640x640.width, 76 | height: rect640x640.height)) 77 | } 78 | 79 | } 80 | 81 | 82 | // MARK: GrayScottFilter_v2 - Uses Core Image convolution filter with Laplacian kernel 83 | class GrayScottFilter_v2: CIFilter 84 | { 85 | var inputImage : CIImage? 86 | 87 | var D_a: CGFloat = 0.189 88 | var D_b: CGFloat = 0.080 89 | var k: CGFloat = 0.062 90 | var f: CGFloat = 0.0425 91 | 92 | let grayScottKernel = CIColorKernel(string: 93 | "kernel vec4 coreImageKernel(__sample pixel, __sample laplacian, float D_a, float D_b, float k, float f) " + 94 | "{" + 95 | "float reactionRate = pixel.x * pixel.z * pixel.z;" + 96 | 97 | "float u = pixel.x + (D_a * laplacian.x) - reactionRate + f * (1.0 - pixel.x);" + 98 | "float v = pixel.z + (D_b * laplacian.z) + reactionRate - (f + k) * pixel.z;" + 99 | 100 | "return vec4(u, u, v, 1.0);" + 101 | "}" 102 | ) 103 | 104 | let laplacianFilter: CIFilter = 105 | { 106 | let laplacianWeights = CIVector(values: [ 107 | CGFloat(0.0), CGFloat(1.0), CGFloat(0.0), 108 | CGFloat(1.0), CGFloat(-4.0), CGFloat(1.0), 109 | CGFloat(0.0), CGFloat(1.0), CGFloat(0.0) ], count: 9) 110 | 111 | return CIFilter(name: "CIConvolution3X3", 112 | withInputParameters: [ 113 | kCIInputWeightsKey: laplacianWeights])! 114 | }() 115 | 116 | override var outputImage : CIImage! 117 | { 118 | if let inputImage = inputImage, 119 | grayScottKernel = grayScottKernel 120 | { 121 | laplacianFilter.setValue(inputImage, 122 | forKey: kCIInputImageKey) 123 | 124 | let arguments = [inputImage, 125 | laplacianFilter.outputImage!, 126 | D_a, D_b, k, f] 127 | let extent = inputImage.extent 128 | 129 | return grayScottKernel.applyWithExtent(extent, 130 | arguments: arguments) 131 | } 132 | return nil 133 | } 134 | } 135 | 136 | // MARK: GrayScottFilter_v3 - Hand coded convolution filter 137 | class GrayScottFilter_v3: CIFilter 138 | { 139 | var inputImage : CIImage? 140 | 141 | var D_a: CGFloat = 0.189 142 | var D_b: CGFloat = 0.080 143 | var k: CGFloat = 0.062 144 | var f: CGFloat = 0.0425 145 | 146 | let grayScottKernel = CIColorKernel(string: 147 | "kernel vec4 coreImageKernel(__sample pixel, __sample laplacian, float D_a, float D_b, float k, float f) " + 148 | "{" + 149 | "float reactionRate = pixel.x * pixel.z * pixel.z;" + 150 | 151 | "float u = pixel.x + (D_a * laplacian.x) - reactionRate + f * (1.0 - pixel.x);" + 152 | "float v = pixel.z + (D_b * laplacian.z) + reactionRate - (f + k) * pixel.z;" + 153 | 154 | "return vec4(u, u, v, 1.0);" + 155 | "}" 156 | ) 157 | 158 | let laplacianKernel = CIKernel(string: 159 | "kernel vec4 laplacianConvolution(sampler image) " + 160 | "{" + 161 | "vec2 d = destCoord();" + 162 | 163 | "vec2 northSample = sample(image, samplerTransform(image, d + vec2(0.0,-1.0))).rb;" + 164 | "vec2 southSample = sample(image, samplerTransform(image, d + vec2(0.0,1.0))).rb;" + 165 | "vec2 eastSample = sample(image, samplerTransform(image, d + vec2(1.0,0.0))).rb;" + 166 | "vec2 westSample = sample(image, samplerTransform(image, d + vec2(-1.0,0.0))).rb;" + 167 | 168 | "vec2 thisSample = sample(image, samplerCoord(image)).xz;" + 169 | 170 | "vec2 laplacian = (northSample + southSample + eastSample + westSample) - (4.0 * thisSample);" + 171 | 172 | "return vec4(laplacian.x, laplacian.x, laplacian.y, 1.0);" + 173 | "}" 174 | ) 175 | 176 | override var outputImage : CIImage! 177 | { 178 | if let inputImage = inputImage, 179 | laplacianKernel = laplacianKernel, 180 | grayScottKernel = grayScottKernel 181 | { 182 | let laplacian = laplacianKernel.applyWithExtent(inputImage.extent, 183 | roiCallback: 184 | { 185 | (index, rect) in 186 | return rect 187 | }, 188 | arguments: [inputImage]) 189 | 190 | let arguments = [inputImage, 191 | laplacian!, 192 | D_a, D_b, k, f] 193 | let extent = inputImage.extent 194 | 195 | return grayScottKernel.applyWithExtent(extent, 196 | arguments: arguments) 197 | } 198 | return nil 199 | } 200 | } 201 | 202 | // MARK: GrayScottFilter 203 | 204 | class GrayScottFilter: CIFilter 205 | { 206 | var inputImage : CIImage? 207 | 208 | 209 | var D_a: CGFloat = 0.189 210 | var D_b: CGFloat = 0.080 211 | var k: CGFloat = 0.062 212 | var f: CGFloat = 0.0425 213 | 214 | let grayScottKernel = CIKernel(string: 215 | "kernel vec4 coreImageKernel(sampler image, float D_a, float D_b, float k, float f) " + 216 | "{" + 217 | 218 | "vec2 d = destCoord();" + 219 | 220 | "vec2 northSample = sample(image, samplerTransform(image, d + vec2(0.0,-1.0))).rb;" + 221 | "vec2 southSample = sample(image, samplerTransform(image, d + vec2(0.0,1.0))).rb;" + 222 | "vec2 eastSample = sample(image, samplerTransform(image, d + vec2(1.0,0.0))).rb;" + 223 | "vec2 westSample = sample(image, samplerTransform(image, d + vec2(-1.0,0.0))).rb;" + 224 | 225 | "vec2 thisSample = sample(image, samplerCoord(image)).xz;" + 226 | 227 | "vec2 laplacian = (northSample + southSample + eastSample + westSample) - (4.0 * thisSample);" + 228 | 229 | "float reactionRate = thisSample.x * thisSample.y * thisSample.y;" + 230 | 231 | "float u = thisSample.x + (D_a * laplacian.x) - reactionRate + f * (1.0 - thisSample.x);" + 232 | "float v = thisSample.y + (D_b * laplacian.y) + reactionRate - (f + k) * thisSample.y;" + 233 | 234 | "return vec4(u, u, v, 1.0);" + 235 | "}" 236 | ) 237 | 238 | override var outputImage : CIImage! 239 | { 240 | if let inputImage = inputImage, 241 | grayScottKernel = grayScottKernel 242 | { 243 | let arguments = [inputImage, D_a, D_b, k, f] 244 | let extent = inputImage.extent 245 | 246 | return grayScottKernel.applyWithExtent(extent, 247 | roiCallback: 248 | { 249 | (index, rect) in 250 | return rect 251 | }, 252 | arguments: arguments) 253 | } 254 | return nil 255 | } 256 | } 257 | 258 | // MARK Metal Image View 259 | 260 | import MetalKit 261 | 262 | /// `MetalImageView` extends an `MTKView` and exposes an `image` property of type `CIImage` to 263 | /// simplify Metal based rendering of Core Image filters. 264 | 265 | class MetalImageView: MTKView 266 | { 267 | let colorSpace = CGColorSpaceCreateDeviceRGB()! 268 | 269 | lazy var commandQueue: MTLCommandQueue = 270 | { 271 | [unowned self] in 272 | 273 | return self.device!.newCommandQueue() 274 | }() 275 | 276 | lazy var ciContext: CIContext = 277 | { 278 | [unowned self] in 279 | 280 | return CIContext(MTLDevice: self.device!) 281 | }() 282 | 283 | override init(frame frameRect: CGRect, device: MTLDevice?) 284 | { 285 | super.init(frame: frameRect, 286 | device: device ?? MTLCreateSystemDefaultDevice()) 287 | 288 | if super.device == nil 289 | { 290 | fatalError("Device doesn't support Metal") 291 | } 292 | 293 | framebufferOnly = false 294 | } 295 | 296 | required init(coder: NSCoder) 297 | { 298 | fatalError("init(coder:) has not been implemented") 299 | } 300 | 301 | /// The image to display 302 | var image: CIImage? 303 | { 304 | didSet 305 | { 306 | renderImage() 307 | } 308 | } 309 | 310 | func renderImage() 311 | { 312 | guard let 313 | image = image, 314 | targetTexture = currentDrawable?.texture else 315 | { 316 | return 317 | } 318 | 319 | let commandBuffer = commandQueue.commandBuffer() 320 | 321 | let bounds = CGRect(origin: CGPointZero, size: drawableSize) 322 | 323 | let originX = image.extent.origin.x 324 | let originY = image.extent.origin.y 325 | 326 | let scaleX = drawableSize.width / image.extent.width 327 | let scaleY = drawableSize.height / image.extent.height 328 | let scale = min(scaleX, scaleY) 329 | 330 | let scaledImage = image 331 | .imageByApplyingTransform(CGAffineTransformMakeTranslation(-originX, -originY)) 332 | .imageByApplyingTransform(CGAffineTransformMakeScale(scale, scale)) 333 | 334 | ciContext.render(scaledImage, 335 | toMTLTexture: targetTexture, 336 | commandBuffer: commandBuffer, 337 | bounds: bounds, 338 | colorSpace: colorSpace) 339 | 340 | commandBuffer.presentDrawable(currentDrawable!) 341 | 342 | commandBuffer.commit() 343 | } 344 | } -------------------------------------------------------------------------------- /CoreImageReactionDiffusion/screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlexMonkey/CoreImageReactionDiffusion/907d90c6d8ef619232f4b153e3450b7c0defa5dd/CoreImageReactionDiffusion/screenshot.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoreImageReactionDiffusion 2 | Gary-Scott reaction Diffusion Implemented as a CIKernel 3 | 4 | ![screenshot](CoreImageReactionDiffusion/screenshot.jpg) 5 | 6 | Another project for my upcoming book, _Core Image for Swift_ - an implementation of the Gray-Scott reaction diffusion model as a custom Core Image kernel. 7 | 8 | --------------------------------------------------------------------------------