@@ -9,27 +9,46 @@ import SwiftUI
99
1010struct MeshView : View {
1111 @Binding var color : Color
12+
1213 var body : some View {
14+ #if compiler(>=6.0)
1315 if #available( iOS 18 . 0 , macOS 15 . 0 , visionOS 2 . 0 , tvOS 18 . 0 , * ) {
14- // Diagonal flow: clear at top-left → most opaque at bottom-right.
15- MeshGradient ( width: 3 , height: 3 , points: [
16- . init( 0 , 0 ) , . init( 0.5 , 0 ) , . init( 1 , 0 ) ,
17- . init( 0 , 0.5 ) , . init( 0.5 , 0.5 ) , . init( 1 , 0.5 ) ,
18- . init( 0 , 1 ) , . init( 0.5 , 1 ) , . init( 1 , 1 )
19- ] , colors: [
20- Color ( . clear) , Color ( . clear) , Color ( . clear) ,
21- color. opacity ( 0.1 ) , color. opacity ( 0.1 ) , color. opacity ( 0.2 ) ,
22- color. opacity ( 0.5 ) , color. opacity ( 0.6 ) , color. opacity ( 0.7 )
23- ] )
24- . ignoresSafeArea ( . all)
25- . overlay (
26- NoiseView ( size: 5000 )
27- . drawingGroup ( )
28- )
16+ meshGradient
2917 } else {
30- // Fallback on earlier versions
31- LinearGradient ( colors: [ Color ( . clear) , color. opacity ( 0.6 ) ] , startPoint: . topLeading, endPoint: . bottomTrailing)
32- . ignoresSafeArea ( . all)
18+ fallbackGradient
3319 }
20+ #else
21+ fallbackGradient
22+ #endif
23+ }
24+
25+ #if compiler(>=6.0)
26+ @available ( iOS 18 . 0 , macOS 15 . 0 , visionOS 2 . 0 , tvOS 18 . 0 , * )
27+ private var meshGradient : some View {
28+ // Diagonal flow: clear at top-left to most opaque at bottom-right.
29+ MeshGradient ( width: 3 , height: 3 , points: [
30+ . init( 0 , 0 ) , . init( 0.5 , 0 ) , . init( 1 , 0 ) ,
31+ . init( 0 , 0.5 ) , . init( 0.5 , 0.5 ) , . init( 1 , 0.5 ) ,
32+ . init( 0 , 1 ) , . init( 0.5 , 1 ) , . init( 1 , 1 )
33+ ] , colors: [
34+ Color ( . clear) , Color ( . clear) , Color ( . clear) ,
35+ color. opacity ( 0.1 ) , color. opacity ( 0.1 ) , color. opacity ( 0.2 ) ,
36+ color. opacity ( 0.5 ) , color. opacity ( 0.6 ) , color. opacity ( 0.7 )
37+ ] )
38+ . ignoresSafeArea ( . all)
39+ . overlay (
40+ NoiseView ( size: 5000 )
41+ . drawingGroup ( )
42+ )
43+ }
44+ #endif
45+
46+ private var fallbackGradient : some View {
47+ LinearGradient (
48+ colors: [ Color ( . clear) , color. opacity ( 0.6 ) ] ,
49+ startPoint: . topLeading,
50+ endPoint: . bottomTrailing
51+ )
52+ . ignoresSafeArea ( . all)
3453 }
3554}
0 commit comments