On-screen text
Import SwiftUI
struct ContentView: View {
@StateObject private var bubbleSystem = BubbleSystem()
var body: some View {
ZStack {
TimelineView(.animation) {
let time = timeline.date.timeline
Canvas { _ in
bubbleSystem.update(date: time)
}
}
ForEach(bubbleSystem.particles.indices, id: \.self) {
index in
BubbleView(bubble: bubbleSystem.particles[index])
}
}
}
}
struct BubbleView: View {
let bubble: Bubble
let cdgFloat: CGFloat = 5
var body: some View {
ZStack {
if bubble.color == .blue {
Capsule()
.frame(width: bubble.size, height: bubble.size)
.offset(x: bubble.x, y: bubble.y)
.opacity(bubble.opacity)
} else {
Circle()
.frame(width: bubble.size, height: bubble.size)
.offset(x: bubble.x, y: bubble.y)
.opacity(bubble.opacity)
}
}
}
}
// Instagram: @inncoder
// TikTok: @inncoder
// Twitter: @inncoder
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Preview crashed
@inncoder
@inncoder