### Install ConfettiSwiftUI via Swift Package Manager Source: https://github.com/simibac/confettiswiftui/blob/master/README.md Instructions for adding the library as a dependency in Xcode using the Swift Package Manager. Use the provided repository URL to link the package to your project. ```ogdl https://github.com/simibac/ConfettiSwiftUI.git, :branch="master" ``` -------------------------------- ### SwiftUI Confetti Cannon with Image Confetti Source: https://github.com/simibac/confettiswiftui/blob/master/README.md This example demonstrates creating a confetti cannon effect with image-based confetti using ConfettiSwiftUI. It uses images of cryptocurrency logos as confetti and allows customization of confetti size. The effect is triggered by a binding variable. This is useful for creating themed animations. ```swift .confettiCannon(trigger: $trigger8, confettis: [.image("arb"), .image("eth"), .image("btc"), .image("op"), .image("link"), .image("doge")], confettiSize: 20) ``` -------------------------------- ### SwiftUI Confetti Cannon with Full Customization Source: https://context7.com/simibac/confettiswiftui/llms.txt This example demonstrates the usage of the .confettiCannon() modifier in SwiftUI, illustrating how to customize various parameters such as particle count, types, colors, size, animation angles, and repetition. ```swift import ConfettiSwiftUI import SwiftUI struct FullParameterView: View { @State private var trigger: Int = 0 var body: some View { Button("Full Custom") { trigger += 1 } .confettiCannon( trigger: $trigger, num: 20, confettis: ConfettiType.allCases, colors: [.blue, .red, .green, .yellow, .pink, .purple, .orange], confettiSize: 10.0, rainHeight: 600.0, fadesOut: true, opacity: 1.0, openingAngle: .degrees(60), closingAngle: .degrees(120), radius: 300, repetitions: 1, repetitionInterval: 1.0, hapticFeedback: true ) } } ``` -------------------------------- ### Implement Custom Image Confetti Source: https://context7.com/simibac/confettiswiftui/llms.txt Shows how to use custom images from the asset catalog as confetti particles using the .image() type. ```swift import ConfettiSwiftUI import SwiftUI struct ImageConfettiView: View { @State private var trigger: Int = 0 var body: some View { Button("Crypto Coins") { trigger += 1 } .confettiCannon( trigger: $trigger, confettis: [ .image("btc"), .image("eth"), .image("doge") ], confettiSize: 20 ) } } ``` -------------------------------- ### Configure Confetti Colors and Size Source: https://github.com/simibac/confettiswiftui/blob/master/README.md Customizes the appearance of the confetti by specifying a list of colors and adjusting the scale size of the confetti elements. ```swift .confettiCannon(trigger: $trigger, colors: [.red, .black], confettiSize: 20) ``` -------------------------------- ### Repeating Confetti Explosions Source: https://context7.com/simibac/confettiswiftui/llms.txt Illustrates how to create multiple sequential confetti bursts using the `repetitions` and `repetitionInterval` parameters. This is useful for sustained celebration effects. ```swift import ConfettiSwiftUI import SwiftUI struct RepeatingConfettiView: View { @State private var trigger: Int = 0 var body: some View { Button("Triple Burst") { trigger += 1 } .confettiCannon( trigger: $trigger, repetitions: 3, repetitionInterval: 0.7 ) } } ``` -------------------------------- ### Make-it-Rain with Image Confetti Source: https://github.com/simibac/confettiswiftui/blob/master/README.md This snippet shows how to create a confetti animation using image-based confetti, such as cryptocurrency logos. It uses the `confettiCannon` modifier with parameters for trigger, confettis (images), and confetti size. ```APIDOC ## Make-it-Rain with Image Confetti ### Description Creates a confetti animation using image assets, such as cryptocurrency logos, with customizable confetti size. ### Method SwiftUI Modifier ### Endpoint N/A (SwiftUI Modifier) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```swift .confettiCannon(trigger: $trigger8, confettis: [.image("arb"), .image("eth"), .image("btc"), .image("op"), .image("link"), .image("doge")], confettiSize: 20) ``` ### Response #### Success Response (200) N/A (SwiftUI Modifier) #### Response Example N/A ``` -------------------------------- ### Customizing Confetti Colors and Size Source: https://context7.com/simibac/confettiswiftui/llms.txt Shows how to customize the confetti particles' colors and size using the `colors` and `confettiSize` parameters of the `confettiCannon` modifier. This allows for theme matching. ```swift import ConfettiSwiftUI import SwiftUI struct ThemedConfettiView: View { @State private var trigger: Int = 0 var body: some View { Button("Team Colors") { trigger += 1 } .confettiCannon( trigger: $trigger, colors: [.red, .black], confettiSize: 20 ) } } ``` -------------------------------- ### Implement SF Symbol Confetti Source: https://context7.com/simibac/confettiswiftui/llms.txt Demonstrates how to use SF Symbols as confetti particles by passing the symbol name to the .sfSymbol() type within the confettiCannon modifier. ```swift import ConfettiSwiftUI import SwiftUI struct SFSymbolConfettiView: View { @State private var trigger: Int = 0 var body: some View { Button("Stars!") { trigger += 1 } .confettiCannon( trigger: $trigger, confettis: [ .sfSymbol(symbolName: "star.fill"), .sfSymbol(symbolName: "heart.fill"), .sfSymbol(symbolName: "moon.fill") ], colors: [.yellow, .pink, .purple], confettiSize: 15 ) } } ``` -------------------------------- ### Configure Endless Confetti Animation Source: https://github.com/simibac/confettiswiftui/blob/master/README.md Creates a continuous, repeating stream of confetti by setting a high number of repetitions with a short interval between them. ```swift .confettiCannon(trigger: $trigger, num:1, confettis: [.text("๐Ÿ’ฉ")], confettiSize: 20, repetitions: 100, repetitionInterval: 0.1) ``` -------------------------------- ### Make-it-Rain with Text Confetti Source: https://github.com/simibac/confettiswiftui/blob/master/README.md This snippet demonstrates how to create a confetti animation using text-based confetti like currency symbols. It utilizes the `confettiCannon` modifier with specified parameters for trigger, number of confettis, types of confettis, size, repetitions, and repetition interval. ```APIDOC ## Make-it-Rain with Text Confetti ### Description Creates a confetti animation using text symbols, such as currency, with customizable repetition settings. ### Method SwiftUI Modifier ### Endpoint N/A (SwiftUI Modifier) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```swift .confettiCannon(trigger: $trigger, num:1, confettis: [.text("๐Ÿ’ต"), .text("๐Ÿ’ถ"), .text("๐Ÿ’ท"), .text("๐Ÿ’ด")], confettiSize: 30, repetitions: 50, repetitionInterval: 0.1) ``` ### Response #### Success Response (200) N/A (SwiftUI Modifier) #### Response Example N/A ``` -------------------------------- ### Configure ConfettiType Enum Source: https://context7.com/simibac/confettiswiftui/llms.txt Explains the ConfettiType enum, which supports shapes, text, SF Symbols, and images, and demonstrates how to mix different types in a single animation. ```swift import ConfettiSwiftUI import SwiftUI struct MixedConfettiView: View { @State private var trigger: Int = 0 var body: some View { Button("Mixed Confetti") { trigger += 1 } .confettiCannon( trigger: $trigger, confettis: [ .shape(.circle), .shape(.triangle), .text("โญ"), .sfSymbol(symbolName: "heart.fill") ] ) } } ``` -------------------------------- ### Firework Effect with 360ยฐ Explosion Source: https://context7.com/simibac/confettiswiftui/llms.txt Demonstrates creating a firework-style effect by setting `openingAngle` to 0ยฐ and `closingAngle` to 360ยฐ. This results in a full circular confetti explosion. ```swift import ConfettiSwiftUI import SwiftUI struct FireworkView: View { @State private var trigger: Int = 0 var body: some View { Button("๐Ÿ’ฅ Firework") { trigger += 1 } .confettiCannon( trigger: $trigger, num: 50, openingAngle: Angle(degrees: 0), closingAngle: Angle(degrees: 360), radius: 200 ) } } ``` -------------------------------- ### Basic Confetti Animation with confettiCannon Source: https://context7.com/simibac/confettiswiftui/llms.txt Demonstrates the basic usage of the `.confettiCannon()` view modifier to trigger confetti animations. The animation is triggered by a state variable that increments when a button is tapped. ```swift import ConfettiSwiftUI import SwiftUI struct ContentView: View { @State private var trigger: Int = 0 var body: some View { VStack { Text("Tap the button for confetti!") .padding() Button("๐ŸŽ‰ Celebrate!") { trigger += 1 } .font(.largeTitle) .confettiCannon(trigger: $trigger) } } } ``` -------------------------------- ### Configure Confetti Repetition Source: https://github.com/simibac/confettiswiftui/blob/master/README.md Sets the number of times the confetti animation repeats and the time interval between each repetition cycle. ```swift .confettiCannon(trigger: $trigger, repetitions: 3, repetitionInterval: 0.7) ``` -------------------------------- ### Trigger Confetti Animation in SwiftUI Source: https://github.com/simibac/confettiswiftui/blob/master/README.md Demonstrates how to import the library and use the confettiCannon modifier. The animation is triggered by incrementing a state variable bound to the modifier. ```swift import ConfettiSwiftUI import SwiftUI struct ContentView: View { @State private var trigger: Int = 0 var body: some View { Button("๐ŸŽ‰") { trigger += 1 } .confettiCannon(trigger: $trigger) } } ``` -------------------------------- ### Configure Emoji Confetti Source: https://github.com/simibac/confettiswiftui/blob/master/README.md Uses custom text-based confetti elements, such as emojis, instead of the default geometric shapes. ```swift .confettiCannon(trigger: $trigger, confettis: [.text("โค๏ธ"), .text("๐Ÿ’™"), .text("๐Ÿ’š"), .text("๐Ÿงก")]) ``` -------------------------------- ### Disable Haptic Feedback Source: https://context7.com/simibac/confettiswiftui/llms.txt Demonstrates how to disable the default haptic feedback triggered during the confetti animation. ```swift import ConfettiSwiftUI import SwiftUI struct SilentConfettiView: View { @State private var trigger: Int = 0 var body: some View { Button("Silent Celebration") { trigger += 1 } .confettiCannon( trigger: $trigger, hapticFeedback: false ) } } ``` -------------------------------- ### Emoji Confetti Animation Source: https://context7.com/simibac/confettiswiftui/llms.txt Shows how to use custom emojis as confetti particles by utilizing the `confettis` parameter with `.text()` confetti type. This adds expressive elements to animations. ```swift import ConfettiSwiftUI import SwiftUI struct EmojiConfettiView: View { @State private var trigger: Int = 0 var body: some View { Button("Love Explosion") { trigger += 1 } .confettiCannon( trigger: $trigger, confettis: [ .text("โค๏ธ"), .text("๐Ÿ’™"), .text("๐Ÿ’š"), .text("๐Ÿงก") ] ) } } ``` -------------------------------- ### SwiftUI Confetti Cannon with Text Confetti Source: https://github.com/simibac/confettiswiftui/blob/master/README.md This code snippet shows how to create a confetti cannon effect in SwiftUI using ConfettiSwiftUI. It utilizes text-based confetti, specifically currency symbols, and allows customization of the number of confettis, their size, repetitions, and repetition interval. The effect is triggered by a binding variable. ```swift .confettiCannon(trigger: $trigger, num:1, confettis: [.text("๐Ÿ’ต"), .text("๐Ÿ’ถ"), .text("๐Ÿ’ท"), .text("๐Ÿ’ด")], confettiSize: 30, repetitions: 50, repetitionInterval: 0.1) ``` -------------------------------- ### Configure Firework Explosion Effect Source: https://github.com/simibac/confettiswiftui/blob/master/README.md Creates a circular explosion effect by adjusting the number of particles, opening and closing angles, and the explosion radius. ```swift .confettiCannon(trigger: $trigger, num: 50, openingAngle: Angle(degrees: 0), closingAngle: Angle(degrees: 360), radius: 200) ``` -------------------------------- ### Make It Rain Effect with Custom Emojis Source: https://context7.com/simibac/confettiswiftui/llms.txt Creates a continuous 'rain' effect using rapid repetitions and custom emojis. This is suitable for effects like money showers. ```swift import ConfettiSwiftUI import SwiftUI struct MoneyRainView: View { @State private var trigger: Int = 0 var body: some View { Button("๐Ÿ’ฐ Make It Rain") { trigger += 1 } .confettiCannon( trigger: $trigger, num: 1, confettis: [ .text("๐Ÿ’ต"), .text("๐Ÿ’ถ"), .text("๐Ÿ’ท"), .text("๐Ÿ’ด") ], confettiSize: 30, repetitions: 50, repetitionInterval: 0.1 ) } } ``` -------------------------------- ### Control Animation Direction Source: https://context7.com/simibac/confettiswiftui/llms.txt Utilizes openingAngle and closingAngle parameters to define the trajectory and spread of the confetti explosion. ```swift import ConfettiSwiftUI import SwiftUI struct DirectionalConfettiView: View { @State private var upwardTrigger: Int = 0 @State private var rightwardTrigger: Int = 0 var body: some View { VStack(spacing: 40) { Button("Upward Burst") { upwardTrigger += 1 } .confettiCannon( trigger: $upwardTrigger, openingAngle: Angle(degrees: 70), closingAngle: Angle(degrees: 110), radius: 250 ) Button("Rightward Burst") { rightwardTrigger += 1 } .confettiCannon( trigger: $rightwardTrigger, openingAngle: Angle(degrees: -20), closingAngle: Angle(degrees: 20), radius: 200 ) } } } ``` -------------------------------- ### Modifier: .confettiCannon() Source: https://context7.com/simibac/confettiswiftui/llms.txt The primary view modifier used to attach a confetti explosion to any SwiftUI view, triggered by a state binding. ```APIDOC ## .confettiCannon() ### Description Attaches a confetti animation to a view, triggered whenever the provided binding variable changes. ### Method View Modifier ### Parameters #### Binding Parameters - **trigger** (Binding) - Required - A state variable that triggers the animation on any value change. #### Configuration Parameters - **num** (Int) - Optional - Number of confetti particles (default: 20). - **confettis** ([ConfettiType]) - Optional - Array of particle types to display. - **colors** ([Color]) - Optional - Array of colors for the particles. - **confettiSize** (CGFloat) - Optional - Size of each particle. - **rainHeight** (CGFloat) - Optional - Vertical distance the particles fall. - **fadesOut** (Bool) - Optional - Whether particles fade out at the end. - **opacity** (Double) - Optional - Maximum opacity of particles. - **openingAngle** (Angle) - Optional - Left boundary of the explosion. - **closingAngle** (Angle) - Optional - Right boundary of the explosion. - **radius** (CGFloat) - Optional - The explosion radius. - **repetitions** (Int) - Optional - Number of times the animation repeats. - **repetitionInterval** (Double) - Optional - Seconds between repetitions. - **hapticFeedback** (Bool) - Optional - Whether to trigger haptic feedback on explosion. ### Request Example .confettiCannon(trigger: $trigger, num: 20, colors: [.blue, .red]) ### Response N/A - This is a UI View Modifier. ``` -------------------------------- ### Modifier: .confettiCannon Source: https://github.com/simibac/confettiswiftui/blob/master/README.md The primary modifier used to trigger confetti animations within a SwiftUI view hierarchy. ```APIDOC ## .confettiCannon ### Description Triggers a confetti animation when the bound trigger variable changes. Highly customizable via various parameters including count, shape, color, and physics properties. ### Method SwiftUI View Modifier ### Parameters #### Configuration Parameters - **trigger** (Binding) - Required - On any change of this variable, the animation triggers. - **num** (Int) - Optional - Amount of confettis (Default: 20). - **confettis** ([ConfettiType]) - Optional - List of shapes and text (Default: [.shape(.circle), .shape(.triangle), .shape(.square), .shape(.slimRectangle), .shape(.roundedCross)]). - **colors** ([Color]) - Optional - List of colors applied to the default shapes. - **confettiSize** (CGFloat) - Optional - Size that confettis and emojis are scaled to (Default: 10.0). - **rainHeight** (CGFloat) - Optional - Vertical distance that confettis pass (Default: 600.0). - **fadesOut** (Bool) - Optional - Whether confettis fade out during animation (Default: true). - **opacity** (Double) - Optional - Maximum opacity during the animation (Default: 1.0). - **openingAngle** (Angle) - Optional - Boundary that defines the opening angle in degrees (Default: 60). - **closingAngle** (Angle) - Optional - Boundary that defines the closing angle in degrees (Default: 120). - **radius** (CGFloat) - Optional - Explosion radius (Default: 300.0). - **repetitions** (Int) - Optional - Number of repetitions for the explosion (Default: 1). - **repetitionInterval** (Double) - Optional - Duration between the repetitions (Default: 1.0). - **hapticFeedback** (Bool) - Optional - Haptic feedback on each confetti explosion (Default: true). ### Request Example .confettiCannon(trigger: $trigger, num: 50, openingAngle: Angle(degrees: 0), closingAngle: Angle(degrees: 360), radius: 200) ``` -------------------------------- ### Modifier: confettiCannon Source: https://github.com/simibac/confettiswiftui/blob/master/README.md The primary modifier used to attach a confetti animation to a SwiftUI view, triggered by a state variable change. ```APIDOC ## .confettiCannon(trigger: $trigger) ### Description Attaches a confetti animation to a view. The animation is triggered whenever the value of the provided state variable changes. ### Method SwiftUI View Modifier ### Parameters #### Path Parameters - **trigger** (Binding) - Required - A state variable that, when incremented or decremented, triggers the confetti explosion. ### Request Example ```swift @State private var trigger: Int = 0 Button("๐ŸŽ‰") { trigger += 1 } .confettiCannon(trigger: $trigger) ``` ### Response #### Success Response (View Update) - **Effect** - The view displays a confetti animation overlay with haptic feedback. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.