-
-
Save Codelaby/7befb2aadbe6b6855bdf8960d52ebf4f to your computer and use it in GitHub Desktop.
Shader fun
This file contains 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 ContentView: View { | |
@State private var start = Date.now | |
var body: some View { | |
VStack { | |
TimelineView(.animation) { timeline in | |
let time = start.distance(to: timeline.date) | |
Rectangle() | |
.frame(width: 300, height: 500) | |
.visualEffect { content, proxy in | |
content | |
.colorEffect( | |
ShaderLibrary.colorEffect( | |
.float2(proxy.size), | |
.float(time) | |
) | |
) | |
} | |
.colorEffect(ShaderLibrary.colorEffect()) | |
.clipShape(RoundedRectangle(cornerRadius: 20)) | |
} | |
} | |
.padding() | |
.frame(maxWidth: .infinity, maxHeight: .infinity) | |
.background(.gray) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment