Last active
May 5, 2024 12:30
-
-
Save Koshimizu-Takehito/7bb4a983ae02c1db5f5750aa42550143 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct SmoothMin2dView: View { | |
@State private var value: Double = 0.8 | |
private let start = Date() | |
private let shader = ShaderFunction(library: .default, name: "SmoothMin2d::main") | |
var body: some View { | |
ZStack { | |
TimelineView(.animation) { context in | |
let seconds = context.date.timeIntervalSince(start) | |
Rectangle() | |
.colorEffect( | |
shader( | |
.boundingRect, // box | |
.float(seconds), // sec | |
.float(value) // k | |
) | |
) | |
} | |
.ignoresSafeArea() | |
VStack { | |
Spacer() | |
Slider(value: $value, in: 0...1) | |
.tint(.pink) | |
} | |
.padding(20) | |
} | |
} | |
} | |
#Preview { | |
SmoothMin2dView() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment