Last active
October 22, 2024 23:34
-
-
Save Lofionic/546554d84dcad121e77734ad821dc52c 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
ShaderFun.mov