Created
February 11, 2025 04:35
-
-
Save Koshimizu-Takehito/5ce2a862edd0553bc991354b01561e1f to your computer and use it in GitHub Desktop.
MSLでパーティクル
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 ShaderView: View { | |
let name: String | |
private let start = Date() | |
var body: some View { | |
let shader = ShaderFunction(library: .default, name: name) | |
TimelineView(.animation) { context in | |
let seconds = context.date.timeIntervalSince(start) | |
Rectangle() | |
.colorEffect(shader(.boundingRect, .float(seconds))) | |
} | |
.ignoresSafeArea() | |
} | |
} | |
#Preview("Sample") { | |
ShaderView(name: "Sample::main") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment