-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
Description
As a developer using Vortex, I would like to have access to the emissionCount and the number of currently active/live particles in a VortexSystem. This would allow for better control over the particle system lifecycle, such as:
- Removing a view after all particles have been emitted.
- Dynamically adjusting the system based on the number of emitted particles.
- Implementing effects such as a firework where the birthrate increases over time to simulate acceleration.
Current Behavior
- The emissionCount is tracked internally in
VortexSystem, but it is not accessible for external observation. - The particles array exists but is also private, preventing developers from monitoring active particles.
Code Example
Below is a code block of current basic example of having fireworks shoot off faster and faster each second. With the proposed changed, a timer would not have to be used, and the emissionCount could be referenced instead.
struct FireworksShowView: View {
@State private var rate = 2.0
let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
var body: some View {
VortexView(.fireworks(emissionsLimit: 100, rate: rate)) {
Circle()
.fill(.white)
.frame(width: 32)
.blur(radius: 5)
.blendMode(.plusLighter)
.tag("circle")
.ignoresSafeArea(edges: .top)
}
.navigationSubtitle("Demonstrates multi-stage effects")
.onReceive(timer) { input in
rate += 1
}
}
}
extension VortexSystem {
public static func fireworks(emissionsLimit: Int, rate: Double) -> VortexSystem {
let fireworks = VortexSystem.fireworks
fireworks.emissionLimit = emissionsLimit
fireworks.birthRate = rate
return fireworks
}
}Metadata
Metadata
Assignees
Labels
No labels