Created
July 30, 2024 19:18
-
-
Save ashishkakkad8/e222dfa1e118575c0ade2eea58a25aa3 to your computer and use it in GitHub Desktop.
Animate MeshGradient in SwiftUI
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
TimelineView(.animation) { timeline in | |
let x = (sin(timeline.date.timeIntervalSince1970) + 1) / 2 | |
MeshGradient( | |
width: 3, | |
height: 3, | |
points: [ | |
[0.0, 0.0], [0.5, 0.0], [1.0, 0.0], | |
[0.0, 0.5], [Float(x), 0.5], [1.0, 0.5], | |
[0.0, 1.0], [0.5, 1.0], [1.0, 1.0] | |
], colors: [ | |
.red, .red, .red, | |
.black, .red, .black, | |
.black, .red, .black | |
]) | |
.edgesIgnoringSafeArea(.all) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment