├── .gitignore ├── Particles.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Particles ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist └── ViewController.swift ├── ParticlesTests ├── Info.plist └── ParticlesTests.swift ├── README.md └── img └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Swift ### 4 | # Xcode 5 | # 6 | build/ 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.xcuserstate 22 | -------------------------------------------------------------------------------- /Particles.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BEA9F0C61ADE490E00230156 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA9F0C51ADE490E00230156 /* AppDelegate.swift */; }; 11 | BEA9F0C81ADE490E00230156 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA9F0C71ADE490E00230156 /* ViewController.swift */; }; 12 | BEA9F0CB1ADE490E00230156 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BEA9F0C91ADE490E00230156 /* Main.storyboard */; }; 13 | BEA9F0CD1ADE490E00230156 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BEA9F0CC1ADE490E00230156 /* Images.xcassets */; }; 14 | BEA9F0D01ADE490E00230156 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = BEA9F0CE1ADE490E00230156 /* LaunchScreen.xib */; }; 15 | BEA9F0DC1ADE490E00230156 /* ParticlesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEA9F0DB1ADE490E00230156 /* ParticlesTests.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | BEA9F0D61ADE490E00230156 /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = BEA9F0B81ADE490E00230156 /* Project object */; 22 | proxyType = 1; 23 | remoteGlobalIDString = BEA9F0BF1ADE490E00230156; 24 | remoteInfo = Particles; 25 | }; 26 | /* End PBXContainerItemProxy section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | BEA9F0C01ADE490E00230156 /* Particles.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Particles.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | BEA9F0C41ADE490E00230156 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | BEA9F0C51ADE490E00230156 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | BEA9F0C71ADE490E00230156 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 33 | BEA9F0CA1ADE490E00230156 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 34 | BEA9F0CC1ADE490E00230156 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 35 | BEA9F0CF1ADE490E00230156 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 36 | BEA9F0D51ADE490E00230156 /* ParticlesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ParticlesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | BEA9F0DA1ADE490E00230156 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | BEA9F0DB1ADE490E00230156 /* ParticlesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParticlesTests.swift; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | BEA9F0BD1ADE490E00230156 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | BEA9F0D21ADE490E00230156 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | BEA9F0B71ADE490E00230156 = { 60 | isa = PBXGroup; 61 | children = ( 62 | BEA9F0C21ADE490E00230156 /* Particles */, 63 | BEA9F0D81ADE490E00230156 /* ParticlesTests */, 64 | BEA9F0C11ADE490E00230156 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | BEA9F0C11ADE490E00230156 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | BEA9F0C01ADE490E00230156 /* Particles.app */, 72 | BEA9F0D51ADE490E00230156 /* ParticlesTests.xctest */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | BEA9F0C21ADE490E00230156 /* Particles */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | BEA9F0C51ADE490E00230156 /* AppDelegate.swift */, 81 | BEA9F0C71ADE490E00230156 /* ViewController.swift */, 82 | BEA9F0C91ADE490E00230156 /* Main.storyboard */, 83 | BEA9F0CC1ADE490E00230156 /* Images.xcassets */, 84 | BEA9F0CE1ADE490E00230156 /* LaunchScreen.xib */, 85 | BEA9F0C31ADE490E00230156 /* Supporting Files */, 86 | ); 87 | path = Particles; 88 | sourceTree = ""; 89 | }; 90 | BEA9F0C31ADE490E00230156 /* Supporting Files */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | BEA9F0C41ADE490E00230156 /* Info.plist */, 94 | ); 95 | name = "Supporting Files"; 96 | sourceTree = ""; 97 | }; 98 | BEA9F0D81ADE490E00230156 /* ParticlesTests */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | BEA9F0DB1ADE490E00230156 /* ParticlesTests.swift */, 102 | BEA9F0D91ADE490E00230156 /* Supporting Files */, 103 | ); 104 | path = ParticlesTests; 105 | sourceTree = ""; 106 | }; 107 | BEA9F0D91ADE490E00230156 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | BEA9F0DA1ADE490E00230156 /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | /* End PBXGroup section */ 116 | 117 | /* Begin PBXNativeTarget section */ 118 | BEA9F0BF1ADE490E00230156 /* Particles */ = { 119 | isa = PBXNativeTarget; 120 | buildConfigurationList = BEA9F0DF1ADE490E00230156 /* Build configuration list for PBXNativeTarget "Particles" */; 121 | buildPhases = ( 122 | BEA9F0BC1ADE490E00230156 /* Sources */, 123 | BEA9F0BD1ADE490E00230156 /* Frameworks */, 124 | BEA9F0BE1ADE490E00230156 /* Resources */, 125 | ); 126 | buildRules = ( 127 | ); 128 | dependencies = ( 129 | ); 130 | name = Particles; 131 | productName = Particles; 132 | productReference = BEA9F0C01ADE490E00230156 /* Particles.app */; 133 | productType = "com.apple.product-type.application"; 134 | }; 135 | BEA9F0D41ADE490E00230156 /* ParticlesTests */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = BEA9F0E21ADE490E00230156 /* Build configuration list for PBXNativeTarget "ParticlesTests" */; 138 | buildPhases = ( 139 | BEA9F0D11ADE490E00230156 /* Sources */, 140 | BEA9F0D21ADE490E00230156 /* Frameworks */, 141 | BEA9F0D31ADE490E00230156 /* Resources */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | BEA9F0D71ADE490E00230156 /* PBXTargetDependency */, 147 | ); 148 | name = ParticlesTests; 149 | productName = ParticlesTests; 150 | productReference = BEA9F0D51ADE490E00230156 /* ParticlesTests.xctest */; 151 | productType = "com.apple.product-type.bundle.unit-test"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | BEA9F0B81ADE490E00230156 /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | LastUpgradeCheck = 0630; 160 | ORGANIZATIONNAME = "William Townsend"; 161 | TargetAttributes = { 162 | BEA9F0BF1ADE490E00230156 = { 163 | CreatedOnToolsVersion = 6.3; 164 | }; 165 | BEA9F0D41ADE490E00230156 = { 166 | CreatedOnToolsVersion = 6.3; 167 | TestTargetID = BEA9F0BF1ADE490E00230156; 168 | }; 169 | }; 170 | }; 171 | buildConfigurationList = BEA9F0BB1ADE490E00230156 /* Build configuration list for PBXProject "Particles" */; 172 | compatibilityVersion = "Xcode 3.2"; 173 | developmentRegion = English; 174 | hasScannedForEncodings = 0; 175 | knownRegions = ( 176 | en, 177 | Base, 178 | ); 179 | mainGroup = BEA9F0B71ADE490E00230156; 180 | productRefGroup = BEA9F0C11ADE490E00230156 /* Products */; 181 | projectDirPath = ""; 182 | projectRoot = ""; 183 | targets = ( 184 | BEA9F0BF1ADE490E00230156 /* Particles */, 185 | BEA9F0D41ADE490E00230156 /* ParticlesTests */, 186 | ); 187 | }; 188 | /* End PBXProject section */ 189 | 190 | /* Begin PBXResourcesBuildPhase section */ 191 | BEA9F0BE1ADE490E00230156 /* Resources */ = { 192 | isa = PBXResourcesBuildPhase; 193 | buildActionMask = 2147483647; 194 | files = ( 195 | BEA9F0CB1ADE490E00230156 /* Main.storyboard in Resources */, 196 | BEA9F0D01ADE490E00230156 /* LaunchScreen.xib in Resources */, 197 | BEA9F0CD1ADE490E00230156 /* Images.xcassets in Resources */, 198 | ); 199 | runOnlyForDeploymentPostprocessing = 0; 200 | }; 201 | BEA9F0D31ADE490E00230156 /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | ); 206 | runOnlyForDeploymentPostprocessing = 0; 207 | }; 208 | /* End PBXResourcesBuildPhase section */ 209 | 210 | /* Begin PBXSourcesBuildPhase section */ 211 | BEA9F0BC1ADE490E00230156 /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | BEA9F0C81ADE490E00230156 /* ViewController.swift in Sources */, 216 | BEA9F0C61ADE490E00230156 /* AppDelegate.swift in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | BEA9F0D11ADE490E00230156 /* Sources */ = { 221 | isa = PBXSourcesBuildPhase; 222 | buildActionMask = 2147483647; 223 | files = ( 224 | BEA9F0DC1ADE490E00230156 /* ParticlesTests.swift in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | /* End PBXSourcesBuildPhase section */ 229 | 230 | /* Begin PBXTargetDependency section */ 231 | BEA9F0D71ADE490E00230156 /* PBXTargetDependency */ = { 232 | isa = PBXTargetDependency; 233 | target = BEA9F0BF1ADE490E00230156 /* Particles */; 234 | targetProxy = BEA9F0D61ADE490E00230156 /* PBXContainerItemProxy */; 235 | }; 236 | /* End PBXTargetDependency section */ 237 | 238 | /* Begin PBXVariantGroup section */ 239 | BEA9F0C91ADE490E00230156 /* Main.storyboard */ = { 240 | isa = PBXVariantGroup; 241 | children = ( 242 | BEA9F0CA1ADE490E00230156 /* Base */, 243 | ); 244 | name = Main.storyboard; 245 | sourceTree = ""; 246 | }; 247 | BEA9F0CE1ADE490E00230156 /* LaunchScreen.xib */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | BEA9F0CF1ADE490E00230156 /* Base */, 251 | ); 252 | name = LaunchScreen.xib; 253 | sourceTree = ""; 254 | }; 255 | /* End PBXVariantGroup section */ 256 | 257 | /* Begin XCBuildConfiguration section */ 258 | BEA9F0DD1ADE490E00230156 /* Debug */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ALWAYS_SEARCH_USER_PATHS = NO; 262 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 263 | CLANG_CXX_LIBRARY = "libc++"; 264 | CLANG_ENABLE_MODULES = YES; 265 | CLANG_ENABLE_OBJC_ARC = YES; 266 | CLANG_WARN_BOOL_CONVERSION = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 269 | CLANG_WARN_EMPTY_BODY = YES; 270 | CLANG_WARN_ENUM_CONVERSION = YES; 271 | CLANG_WARN_INT_CONVERSION = YES; 272 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 273 | CLANG_WARN_UNREACHABLE_CODE = YES; 274 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 275 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 276 | COPY_PHASE_STRIP = NO; 277 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 278 | ENABLE_STRICT_OBJC_MSGSEND = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_DYNAMIC_NO_PIC = NO; 281 | GCC_NO_COMMON_BLOCKS = YES; 282 | GCC_OPTIMIZATION_LEVEL = 0; 283 | GCC_PREPROCESSOR_DEFINITIONS = ( 284 | "DEBUG=1", 285 | "$(inherited)", 286 | ); 287 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 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.0; 295 | MTL_ENABLE_DEBUG_INFO = YES; 296 | ONLY_ACTIVE_ARCH = YES; 297 | SDKROOT = iphoneos; 298 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 299 | TARGETED_DEVICE_FAMILY = "1,2"; 300 | }; 301 | name = Debug; 302 | }; 303 | BEA9F0DE1ADE490E00230156 /* Release */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | ALWAYS_SEARCH_USER_PATHS = NO; 307 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 308 | CLANG_CXX_LIBRARY = "libc++"; 309 | CLANG_ENABLE_MODULES = YES; 310 | CLANG_ENABLE_OBJC_ARC = YES; 311 | CLANG_WARN_BOOL_CONVERSION = YES; 312 | CLANG_WARN_CONSTANT_CONVERSION = YES; 313 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 314 | CLANG_WARN_EMPTY_BODY = YES; 315 | CLANG_WARN_ENUM_CONVERSION = YES; 316 | CLANG_WARN_INT_CONVERSION = YES; 317 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 318 | CLANG_WARN_UNREACHABLE_CODE = YES; 319 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 320 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 321 | COPY_PHASE_STRIP = NO; 322 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 323 | ENABLE_NS_ASSERTIONS = NO; 324 | ENABLE_STRICT_OBJC_MSGSEND = YES; 325 | GCC_C_LANGUAGE_STANDARD = gnu99; 326 | GCC_NO_COMMON_BLOCKS = YES; 327 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 328 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 329 | GCC_WARN_UNDECLARED_SELECTOR = YES; 330 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 331 | GCC_WARN_UNUSED_FUNCTION = YES; 332 | GCC_WARN_UNUSED_VARIABLE = YES; 333 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 334 | MTL_ENABLE_DEBUG_INFO = NO; 335 | SDKROOT = iphoneos; 336 | TARGETED_DEVICE_FAMILY = "1,2"; 337 | VALIDATE_PRODUCT = YES; 338 | }; 339 | name = Release; 340 | }; 341 | BEA9F0E01ADE490E00230156 /* Debug */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 345 | INFOPLIST_FILE = Particles/Info.plist; 346 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 347 | PRODUCT_NAME = "$(TARGET_NAME)"; 348 | }; 349 | name = Debug; 350 | }; 351 | BEA9F0E11ADE490E00230156 /* Release */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 355 | INFOPLIST_FILE = Particles/Info.plist; 356 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 357 | PRODUCT_NAME = "$(TARGET_NAME)"; 358 | }; 359 | name = Release; 360 | }; 361 | BEA9F0E31ADE490E00230156 /* Debug */ = { 362 | isa = XCBuildConfiguration; 363 | buildSettings = { 364 | BUNDLE_LOADER = "$(TEST_HOST)"; 365 | FRAMEWORK_SEARCH_PATHS = ( 366 | "$(SDKROOT)/Developer/Library/Frameworks", 367 | "$(inherited)", 368 | ); 369 | GCC_PREPROCESSOR_DEFINITIONS = ( 370 | "DEBUG=1", 371 | "$(inherited)", 372 | ); 373 | INFOPLIST_FILE = ParticlesTests/Info.plist; 374 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 375 | PRODUCT_NAME = "$(TARGET_NAME)"; 376 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Particles.app/Particles"; 377 | }; 378 | name = Debug; 379 | }; 380 | BEA9F0E41ADE490E00230156 /* Release */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | BUNDLE_LOADER = "$(TEST_HOST)"; 384 | FRAMEWORK_SEARCH_PATHS = ( 385 | "$(SDKROOT)/Developer/Library/Frameworks", 386 | "$(inherited)", 387 | ); 388 | INFOPLIST_FILE = ParticlesTests/Info.plist; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Particles.app/Particles"; 392 | }; 393 | name = Release; 394 | }; 395 | /* End XCBuildConfiguration section */ 396 | 397 | /* Begin XCConfigurationList section */ 398 | BEA9F0BB1ADE490E00230156 /* Build configuration list for PBXProject "Particles" */ = { 399 | isa = XCConfigurationList; 400 | buildConfigurations = ( 401 | BEA9F0DD1ADE490E00230156 /* Debug */, 402 | BEA9F0DE1ADE490E00230156 /* Release */, 403 | ); 404 | defaultConfigurationIsVisible = 0; 405 | defaultConfigurationName = Release; 406 | }; 407 | BEA9F0DF1ADE490E00230156 /* Build configuration list for PBXNativeTarget "Particles" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | BEA9F0E01ADE490E00230156 /* Debug */, 411 | BEA9F0E11ADE490E00230156 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | }; 415 | BEA9F0E21ADE490E00230156 /* Build configuration list for PBXNativeTarget "ParticlesTests" */ = { 416 | isa = XCConfigurationList; 417 | buildConfigurations = ( 418 | BEA9F0E31ADE490E00230156 /* Debug */, 419 | BEA9F0E41ADE490E00230156 /* Release */, 420 | ); 421 | defaultConfigurationIsVisible = 0; 422 | }; 423 | /* End XCConfigurationList section */ 424 | }; 425 | rootObject = BEA9F0B81ADE490E00230156 /* Project object */; 426 | } 427 | -------------------------------------------------------------------------------- /Particles.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Particles/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Particles 4 | // 5 | // Created by William Townsend on 15/04/15. 6 | // Copyright (c) 2015 William Townsend. 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 | // From https://github.com/yeahdongcn/UIColor-Hex-Swift 48 | extension UIColor { 49 | convenience init(rgba: String) { 50 | var red: CGFloat = 0.0 51 | var green: CGFloat = 0.0 52 | var blue: CGFloat = 0.0 53 | var alpha: CGFloat = 1.0 54 | 55 | if rgba.hasPrefix("#") { 56 | let index = advance(rgba.startIndex, 1) 57 | let hex = rgba.substringFromIndex(index) 58 | let scanner = NSScanner(string: hex) 59 | var hexValue: CUnsignedLongLong = 0 60 | if scanner.scanHexLongLong(&hexValue) { 61 | switch (count(hex)) { 62 | case 3: 63 | red = CGFloat((hexValue & 0xF00) >> 8) / 15.0 64 | green = CGFloat((hexValue & 0x0F0) >> 4) / 15.0 65 | blue = CGFloat(hexValue & 0x00F) / 15.0 66 | case 4: 67 | red = CGFloat((hexValue & 0xF000) >> 12) / 15.0 68 | green = CGFloat((hexValue & 0x0F00) >> 8) / 15.0 69 | blue = CGFloat((hexValue & 0x00F0) >> 4) / 15.0 70 | alpha = CGFloat(hexValue & 0x000F) / 15.0 71 | case 6: 72 | red = CGFloat((hexValue & 0xFF0000) >> 16) / 255.0 73 | green = CGFloat((hexValue & 0x00FF00) >> 8) / 255.0 74 | blue = CGFloat(hexValue & 0x0000FF) / 255.0 75 | case 8: 76 | red = CGFloat((hexValue & 0xFF000000) >> 24) / 255.0 77 | green = CGFloat((hexValue & 0x00FF0000) >> 16) / 255.0 78 | blue = CGFloat((hexValue & 0x0000FF00) >> 8) / 255.0 79 | alpha = CGFloat(hexValue & 0x000000FF) / 255.0 80 | default: 81 | print("Invalid RGB string, number of characters after '#' should be either 3, 4, 6 or 8") 82 | } 83 | } else { 84 | println("Scan hex error") 85 | } 86 | } else { 87 | print("Invalid RGB string, missing '#' as prefix") 88 | } 89 | self.init(red:red, green:green, blue:blue, alpha:alpha) 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Particles/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Particles/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 | -------------------------------------------------------------------------------- /Particles/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 | } -------------------------------------------------------------------------------- /Particles/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.wtsnz.$(PRODUCT_NAME:rfc1034identifier) 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 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Particles/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Particles 4 | // 5 | // Created by William Townsend on 15/04/15. 6 | // Copyright (c) 2015 William Townsend. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | let particleField = ParticleField(frame: self.view.bounds) 17 | self.view.addSubview(particleField) 18 | } 19 | 20 | } 21 | 22 | class ParticleField: UIView { 23 | 24 | // MARK: Properties 25 | 26 | var displayLink: CADisplayLink? 27 | 28 | var array:[Particle] = [Particle]() 29 | 30 | let colors = [UIColor(rgba: "#69D2E7"), UIColor(rgba: "#A7DBD8"), UIColor(rgba: "#E0E4CC"), UIColor(rgba: "#F38630"), UIColor(rgba: "#FA6900"), UIColor(rgba: "#FF4E50"), UIColor(rgba: "#F9D423")] 31 | 32 | // MARK: Initialisation 33 | 34 | override init(frame: CGRect) { 35 | super.init(frame: frame) 36 | 37 | self.multipleTouchEnabled = true 38 | 39 | 40 | self.displayLink = CADisplayLink(target: self, selector: Selector("onFrame")) 41 | self.displayLink?.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSDefaultRunLoopMode) 42 | 43 | self.create() 44 | } 45 | 46 | required init(coder aDecoder: NSCoder) { 47 | fatalError("init(coder:) has not been implemented") 48 | } 49 | 50 | // MARK: UIResponder 51 | 52 | override func touchesBegan(touches: Set, withEvent event: UIEvent) { 53 | super.touchesBegan(touches, withEvent: event) 54 | 55 | for touch in touches as! Set { 56 | self.spawnForTouch(touch) 57 | } 58 | } 59 | 60 | override func touchesMoved(touches: Set, withEvent event: UIEvent) { 61 | super.touchesMoved(touches, withEvent: event) 62 | 63 | for touch in touches as! Set { 64 | self.spawnForTouch(touch) 65 | } 66 | } 67 | 68 | // MARK: View 69 | 70 | override func drawRect(rect: CGRect) { 71 | super.drawRect(rect) 72 | 73 | var context = UIGraphicsGetCurrentContext(); 74 | 75 | CGContextClearRect(context, self.bounds); 76 | 77 | CGContextSetBlendMode(context, kCGBlendModeLighten); 78 | 79 | for (index, particle) in enumerate(self.array) { 80 | 81 | particle.draw(context) 82 | 83 | } 84 | } 85 | 86 | // MARK: Functions 87 | 88 | func create() { 89 | for i in 0...200 { 90 | let x = CGFloat(arc4random_uniform(UInt32(self.frame.width))) 91 | let y = CGFloat(arc4random_uniform(UInt32(self.frame.height))) 92 | self.spawn(x, y: y) 93 | } 94 | } 95 | 96 | func onFrame() { 97 | 98 | for var i = self.array.count - 1; i >= 0; i-- { 99 | var particle = self.array[i] 100 | if particle.alive { 101 | particle.move() 102 | } else { 103 | array.removeAtIndex(i) 104 | } 105 | } 106 | self.setNeedsDisplay() 107 | } 108 | 109 | func spawnForTouch(touch: UITouch) { 110 | self.spawn(touch.locationInView(self).x, y: touch.locationInView(self).y) 111 | self.spawn(touch.locationInView(self).x, y: touch.locationInView(self).y) 112 | self.spawn(touch.locationInView(self).x, y: touch.locationInView(self).y) 113 | self.spawn(touch.locationInView(self).x, y: touch.locationInView(self).y) 114 | } 115 | 116 | func spawn(x: CGFloat, y: CGFloat) { 117 | 118 | let force = random(-8.0, 8.0) 119 | var particle = Particle(x: x, y: y, radius: random(10, 20)) 120 | 121 | particle.wander = random(0, 5.3) 122 | particle.drag = random(0.9, 0.99) 123 | particle.theta = random(0.0, CGFloat(M_PI_2)) 124 | particle.vx = sin(particle.theta) * force 125 | particle.vy = cos(particle.theta) * force 126 | particle.fillColor = self.colors[Int(arc4random_uniform(UInt32(self.colors.count)))] 127 | 128 | self.array.append(particle) 129 | } 130 | } 131 | 132 | func random() -> CGFloat { 133 | return CGFloat(Float(arc4random()) / 0xFFFFFFFF) 134 | } 135 | 136 | func random(min: CGFloat, max:CGFloat) -> CGFloat { 137 | return random()*(max-min)+min 138 | } 139 | 140 | class Particle { 141 | 142 | var x: CGFloat 143 | var y: CGFloat 144 | 145 | var vx: CGFloat = 0 146 | var vy: CGFloat = 0 147 | 148 | var radius: CGFloat = 20 149 | var alive = true 150 | var wander = CGFloat(1.15) 151 | var theta = random(0, 2*3.14159265) 152 | var drag = CGFloat(0.92) 153 | 154 | 155 | var fillColor: UIColor = UIColor.redColor() 156 | 157 | init(x:CGFloat, y: CGFloat, radius: CGFloat) { 158 | self.x = x 159 | self.y = y 160 | self.radius = radius 161 | } 162 | 163 | func move() { 164 | 165 | self.x += self.vx 166 | self.y += self.vy 167 | 168 | self.vx *= self.drag 169 | self.vy *= self.drag 170 | 171 | self.theta += random(-0.5, 0.5) * self.wander 172 | 173 | self.vx += sin(self.theta) * 0.1 174 | self.vy += cos(self.theta) * 0.1 175 | 176 | self.radius *= 0.96 177 | 178 | self.alive = self.radius > 0.1 179 | } 180 | 181 | func draw(ctx: CGContextRef) { 182 | 183 | var frame = CGRectMake(self.x - self.radius, self.y - self.radius, radius*2, radius*2) 184 | 185 | CGContextSetFillColorWithColor(ctx, self.fillColor.CGColor) 186 | CGContextFillEllipseInRect(ctx, frame) 187 | 188 | } 189 | } 190 | 191 | -------------------------------------------------------------------------------- /ParticlesTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.wtsnz.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ParticlesTests/ParticlesTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParticlesTests.swift 3 | // ParticlesTests 4 | // 5 | // Created by William Townsend on 15/04/15. 6 | // Copyright (c) 2015 William Townsend. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class ParticlesTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift-Particles 2 | 3 | Browsing the net today I came accross [Sketch.js](http://soulwire.github.io/sketch.js/) and a [Particle demo](http://soulwire.github.io/sketch.js/examples/particles.html). I quite liked it so spent an hour or so to implement (port js really..) something similar in Swift. 4 | 5 | It brought back memories of writing games in action script, which was great. 6 | 7 | ![ScreenShot](https://raw.github.com/wtsnz/Swift-Particles/master/img/screenshot.png) 8 | -------------------------------------------------------------------------------- /img/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wtsnz/Swift-Particles/0dae4559efab3e27ad9fa76da7fa447ba3623c7a/img/screenshot.png --------------------------------------------------------------------------------