Last active
October 22, 2024 23:34
-
-
Save Lofionic/546554d84dcad121e77734ad821dc52c to your computer and use it in GitHub Desktop.
Revisions
-
Lofionic revised this gist
Oct 22, 2024 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,9 +9,7 @@ struct ContentView: View { let time = start.distance(to: timeline.date) Rectangle() .frame(width: 300, height: 500) .visualEffect { content, proxy in content .colorEffect( ShaderLibrary.colorEffect( -
Lofionic revised this gist
Oct 22, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,5 +28,4 @@ struct ContentView: View { .frame(maxWidth: .infinity, maxHeight: .infinity) .background(.gray) } } -
Lofionic created this gist
Oct 22, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ 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) } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ #include <metal_stdlib> using namespace metal; [[ stitchable ]] half4 colorEffect(float2 position, half4 color, float2 size, float time) { float2 uv = (position / size) * 2 - 1; half3 luma = half3(0.0); for (int i = 0; i < 3; i++) { float wave = cos(uv.x * 3.0 + time * 2.0) * sin(time * 3 + i * 2.0) * 5; luma[i] = abs(1 / (50 * uv.y + 10 + wave)) + abs(1 / (50 * uv.y - 10 - wave)); } return half4(luma * smoothstep(0, 1, (1 - abs(uv.x))) * smoothstep(0, 1, (1 - abs(uv.y))), 1.0); }