File tree 2 files changed +62
-1
lines changed 2 files changed +62
-1
lines changed Original file line number Diff line number Diff line change
1
+ using Uno ;
2
+ using Uno . UX ;
3
+ using Uno . Graphics ;
4
+ using Uno . Diagnostics ;
5
+ using Uno . Math ;
6
+ using Uno . Vector ;
7
+
8
+ using Fuse ;
9
+ using Fuse . Controls . Graphics ;
10
+ using Fuse . Drawing . Planar ;
11
+
12
+ public class BackgroundEffect : Fuse . Controls . Graphics . Visual
13
+ {
14
+ static readonly float3 Color1 = Uno . Color . Parse ( "#1d3042" ) . XYZ ;
15
+ static readonly float3 Color2 = Uno . Color . Parse ( "#5e8e8e" ) . XYZ * .75f ;
16
+
17
+ float2 _drawSize ;
18
+
19
+ protected override void OnRooted ( )
20
+ {
21
+ base . OnRooted ( ) ;
22
+ UpdateManager . AddAction ( InvalidateVisual ) ;
23
+ }
24
+
25
+ protected override void OnUnrooted ( )
26
+ {
27
+ UpdateManager . RemoveAction ( InvalidateVisual ) ;
28
+ base . OnUnrooted ( ) ;
29
+ }
30
+
31
+ protected sealed override float2 OnArrangeMarginBox ( float2 position , LayoutParams lp )
32
+ {
33
+ return _drawSize = base . OnArrangeMarginBox ( position , lp ) ;
34
+ }
35
+
36
+ public sealed override void Draw ( DrawContext dc )
37
+ {
38
+ var t = Clock . GetSeconds ( ) * .3 ;
39
+ var a1 = ( float ) Mod ( t , PI * 2 ) ;
40
+ var a2 = ( float ) Mod ( t * .3 , PI * 2 ) ;
41
+
42
+ draw Rectangle
43
+ {
44
+ DrawContext :
45
+ dc ;
46
+ Visual :
47
+ this ;
48
+ Size :
49
+ _drawSize ;
50
+ float Gradient :
51
+ Sin( pixel Rotate ( VertexData, a2 ) . Y * PIf - a1) * .5f + .5f ;
52
+ PixelColor :
53
+ float4 ( Lerp ( Color1 , Color2 , Gradient ) , 1 ) ;
54
+ } ;
55
+ }
56
+ }
Original file line number Diff line number Diff line change 3
3
<!-- Pressed buttons -->
4
4
<StackPanel Orientation =" Horizontal" Alignment =" TopCenter" Margin =" 10" ItemSpacing =" 5" >
5
5
<Each Items =" {pressed}" >
6
- <Rectangle CornerRadius =" 6" Color =" #8888 " Padding =" 12, 0" Height =" 24" >
6
+ <Rectangle CornerRadius =" 6" Color =" #444 " Padding =" 12, 0" Height =" 24" >
7
7
<Text Value =" {data()}" FontSize =" 14" Color =" #EEEE" Alignment =" Center" />
8
8
</Rectangle >
9
9
</Each >
15
15
<Thumbstick Grid.Column=" 1" Index =" Right" />
16
16
</Grid >
17
17
18
+ <!-- Background effect -->
19
+ <Rectangle >
20
+ <BackgroundEffect />
21
+ </Rectangle >
22
+
18
23
</App >
You can’t perform that action at this time.
0 commit comments