diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.pbxproj b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.pbxproj new file mode 100644 index 0000000..fec794f --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.pbxproj @@ -0,0 +1,352 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + 4F4DA16E28C64BAC00BF748F /* Challenge_3_Matt_PfeifferApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4DA16D28C64BAC00BF748F /* Challenge_3_Matt_PfeifferApp.swift */; }; + 4F4DA17028C64BAC00BF748F /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4DA16F28C64BAC00BF748F /* ContentView.swift */; }; + 4F4DA17228C64BAC00BF748F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F4DA17128C64BAC00BF748F /* Assets.xcassets */; }; + 4F4DA17528C64BAD00BF748F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F4DA17428C64BAD00BF748F /* Preview Assets.xcassets */; }; + 4F4DA17C28C65DE900BF748F /* Flame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4DA17B28C65DE900BF748F /* Flame.swift */; }; + 4F4DA17E28C65E3800BF748F /* AnimationFlameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4DA17D28C65E3800BF748F /* AnimationFlameView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 4F4DA16A28C64BAC00BF748F /* Challenge-3-Matt-Pfeiffer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Challenge-3-Matt-Pfeiffer.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4F4DA16D28C64BAC00BF748F /* Challenge_3_Matt_PfeifferApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Challenge_3_Matt_PfeifferApp.swift; sourceTree = ""; }; + 4F4DA16F28C64BAC00BF748F /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 4F4DA17128C64BAC00BF748F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 4F4DA17428C64BAD00BF748F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 4F4DA17B28C65DE900BF748F /* Flame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Flame.swift; sourceTree = ""; }; + 4F4DA17D28C65E3800BF748F /* AnimationFlameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimationFlameView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4F4DA16728C64BAC00BF748F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4F4DA16128C64BAC00BF748F = { + isa = PBXGroup; + children = ( + 4F4DA16C28C64BAC00BF748F /* Challenge-3-Matt-Pfeiffer */, + 4F4DA16B28C64BAC00BF748F /* Products */, + ); + sourceTree = ""; + }; + 4F4DA16B28C64BAC00BF748F /* Products */ = { + isa = PBXGroup; + children = ( + 4F4DA16A28C64BAC00BF748F /* Challenge-3-Matt-Pfeiffer.app */, + ); + name = Products; + sourceTree = ""; + }; + 4F4DA16C28C64BAC00BF748F /* Challenge-3-Matt-Pfeiffer */ = { + isa = PBXGroup; + children = ( + 4F4DA16D28C64BAC00BF748F /* Challenge_3_Matt_PfeifferApp.swift */, + 4F4DA16F28C64BAC00BF748F /* ContentView.swift */, + 4F4DA17D28C65E3800BF748F /* AnimationFlameView.swift */, + 4F4DA17B28C65DE900BF748F /* Flame.swift */, + 4F4DA17128C64BAC00BF748F /* Assets.xcassets */, + 4F4DA17328C64BAD00BF748F /* Preview Content */, + ); + path = "Challenge-3-Matt-Pfeiffer"; + sourceTree = ""; + }; + 4F4DA17328C64BAD00BF748F /* Preview Content */ = { + isa = PBXGroup; + children = ( + 4F4DA17428C64BAD00BF748F /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4F4DA16928C64BAC00BF748F /* Challenge-3-Matt-Pfeiffer */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4F4DA17828C64BAD00BF748F /* Build configuration list for PBXNativeTarget "Challenge-3-Matt-Pfeiffer" */; + buildPhases = ( + 4F4DA16628C64BAC00BF748F /* Sources */, + 4F4DA16728C64BAC00BF748F /* Frameworks */, + 4F4DA16828C64BAC00BF748F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Challenge-3-Matt-Pfeiffer"; + productName = "Challenge-3-Matt-Pfeiffer"; + productReference = 4F4DA16A28C64BAC00BF748F /* Challenge-3-Matt-Pfeiffer.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4F4DA16228C64BAC00BF748F /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1340; + LastUpgradeCheck = 1340; + TargetAttributes = { + 4F4DA16928C64BAC00BF748F = { + CreatedOnToolsVersion = 13.4.1; + }; + }; + }; + buildConfigurationList = 4F4DA16528C64BAC00BF748F /* Build configuration list for PBXProject "Challenge-3-Matt-Pfeiffer" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 4F4DA16128C64BAC00BF748F; + productRefGroup = 4F4DA16B28C64BAC00BF748F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4F4DA16928C64BAC00BF748F /* Challenge-3-Matt-Pfeiffer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 4F4DA16828C64BAC00BF748F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4F4DA17528C64BAD00BF748F /* Preview Assets.xcassets in Resources */, + 4F4DA17228C64BAC00BF748F /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 4F4DA16628C64BAC00BF748F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4F4DA17C28C65DE900BF748F /* Flame.swift in Sources */, + 4F4DA17028C64BAC00BF748F /* ContentView.swift in Sources */, + 4F4DA16E28C64BAC00BF748F /* Challenge_3_Matt_PfeifferApp.swift in Sources */, + 4F4DA17E28C65E3800BF748F /* AnimationFlameView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4F4DA17628C64BAD00BF748F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 4F4DA17728C64BAD00BF748F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 4F4DA17928C64BAD00BF748F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Challenge-3-Matt-Pfeiffer/Preview Content\""; + DEVELOPMENT_TEAM = L2FL95P32D; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.MattPfeiffer.Challenge-3-Matt-Pfeiffer"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4F4DA17A28C64BAD00BF748F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Challenge-3-Matt-Pfeiffer/Preview Content\""; + DEVELOPMENT_TEAM = L2FL95P32D; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.MattPfeiffer.Challenge-3-Matt-Pfeiffer"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4F4DA16528C64BAC00BF748F /* Build configuration list for PBXProject "Challenge-3-Matt-Pfeiffer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4F4DA17628C64BAD00BF748F /* Debug */, + 4F4DA17728C64BAD00BF748F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4F4DA17828C64BAD00BF748F /* Build configuration list for PBXNativeTarget "Challenge-3-Matt-Pfeiffer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4F4DA17928C64BAD00BF748F /* Debug */, + 4F4DA17A28C64BAD00BF748F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4F4DA16228C64BAC00BF748F /* Project object */; +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/AnimationFlameView.swift b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/AnimationFlameView.swift new file mode 100644 index 0000000..9140d4c --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/AnimationFlameView.swift @@ -0,0 +1,66 @@ +// +// AnimationFlameView.swift +// Challenge-3-Matt-Pfeiffer +// +// Created by Matt Pfeiffer on 9/5/22. +// + +import SwiftUI + +struct AnimationFlameView: View { + @State private var wiggleFactor1 = CGSize(width: -1.0, height: -1.0) + @State private var wiggleFactor2 = CGSize(width: -1.0, height: -1.0) + + let lightBlue = Color(red: 170/255, green: 211/255, blue: 253/255) + let yellow = Color(red: 255/255, green: 196/255, blue: 47/255) + let orange = Color(red: 254/255, green: 136/255, blue: 36/255) + + var body: some View { + GeometryReader { geo in + ZStack { + Flame(wiggleFactorX: wiggleFactor1.width, wiggleFactorY: wiggleFactor1.height) + .fill(.orange) + Flame(wiggleFactorX: wiggleFactor2.width, wiggleFactorY: wiggleFactor2.height) + .fill(yellow) + .frame(width: geo.size.width * 0.4, height: geo.size.width * 0.4) + .offset(y: geo.size.height * 0.03) // magic number + } + .padding(.horizontal, 50) + .aspectRatio(1.0, contentMode: .fit) + .frame(width: geo.size.width, height: geo.size.height) + .background(lightBlue) + } + .onAppear { + stepInnerFlame() + stepOuterFlame() + } + } + + func stepOuterFlame() { + withAnimation { + wiggleFactor2 = CGSize(width: CGFloat.random(in: -1...1), height: CGFloat.random(in: -1...1)) + } + + let delayValue = CGFloat.random(in: 0.0...0.25) + DispatchQueue.main.asyncAfter(deadline: .now() + TimeInterval(delayValue)) { + self.stepOuterFlame() + } + } + + func stepInnerFlame() { + withAnimation { + wiggleFactor1 = CGSize(width: CGFloat.random(in: -1...1), height: CGFloat.random(in: -1...1)) + } + + let delayValue = CGFloat.random(in: 0.0...0.25) + DispatchQueue.main.asyncAfter(deadline: .now() + TimeInterval(delayValue)) { + self.stepInnerFlame() + } + } +} + +struct AnimationFlameView_Previews: PreviewProvider { + static var previews: some View { + AnimationFlameView() + } +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/AccentColor.colorset/Contents.json b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/AppIcon.appiconset/Contents.json b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..5a3257a --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,93 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/Contents.json b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Challenge_3_Matt_PfeifferApp.swift b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Challenge_3_Matt_PfeifferApp.swift new file mode 100644 index 0000000..956148f --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Challenge_3_Matt_PfeifferApp.swift @@ -0,0 +1,17 @@ +// +// Challenge_3_Matt_PfeifferApp.swift +// Challenge-3-Matt-Pfeiffer +// +// Created by Matt Pfeiffer on 9/5/22. +// + +import SwiftUI + +@main +struct Challenge_3_Matt_PfeifferApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/ContentView.swift b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/ContentView.swift new file mode 100644 index 0000000..5f12541 --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/ContentView.swift @@ -0,0 +1,20 @@ +// +// ContentView.swift +// Challenge-3-Matt-Pfeiffer +// +// Created by Matt Pfeiffer on 9/5/22. +// + +import SwiftUI + +struct ContentView: View { + var body: some View { + AnimationFlameView() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Flame.swift b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Flame.swift new file mode 100644 index 0000000..10a4d7e --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Flame.swift @@ -0,0 +1,55 @@ +// +// Flame.swift +// Challenge-3-Matt-Pfeiffer +// +// Created by Matt Pfeiffer on 9/5/22. +// + +import SwiftUI + +struct Flame: Shape { + var wiggleFactorX: Double + var wiggleFactorY: Double + + var animatableData: AnimatablePair { + get { + AnimatablePair(Double(wiggleFactorX), Double(wiggleFactorY)) + } + set { + wiggleFactorX = newValue.first + wiggleFactorY = newValue.second + } + } + + func path(in rect: CGRect) -> Path { + // special animating top point (wiggles around) + let wiggleAmountX = rect.maxX * wiggleFactorX * 0.1 + let wiggleAmountY = rect.maxX * wiggleFactorY * 0.1 + let topX = rect.midX + wiggleAmountX + let topY = rect.minY + wiggleAmountY + let top = CGPoint(x: topX, y: topY) + + // top control points + let radiusForTop = rect.maxX * 0.05 + let topControl1Left = CGPoint(x: topX - radiusForTop, y: topY + radiusForTop) + let topControl2Left = CGPoint(x: topX - radiusForTop, y: topY) + let topControl1Right = CGPoint(x: topX + radiusForTop, y: topY + radiusForTop) + let topControl2Right = CGPoint(x: topX + radiusForTop, y: topY) + + // other points + let bottom = CGPoint(x: rect.midX, y: rect.maxY) + let leftSemiCircle = CGPoint(x: rect.minX, y: rect.maxY * 0.6) + let leftControl = CGPoint(x: rect.minX, y: rect.maxY) + let rightSemiCircle = CGPoint(x: rect.maxX, y: rect.maxY * 0.6) + let rightControl = CGPoint(x: rect.maxX, y: rect.maxY) + + // draw and return the path + var path = Path() + path.move(to: bottom) + path.addQuadCurve(to: leftSemiCircle, control: leftControl) + path.addCurve(to: top, control1: topControl1Left, control2: topControl2Left) + path.addCurve(to: rightSemiCircle, control1: topControl2Right, control2: topControl1Right) + path.addQuadCurve(to: bottom, control: rightControl) + return path + } +} diff --git a/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Preview Content/Preview Assets.xcassets/Contents.json b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Challenge-3-Matt-Pfeiffer/Challenge-3-Matt-Pfeiffer/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +}