AnimationsPage.xaml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <UserControl
  2. xmlns="https://github.com/avaloniaui"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. x:Class="RenderDemo.Pages.AnimationsPage">
  5. <UserControl.Styles>
  6. <Styles>
  7. <Styles.Resources>
  8. <Template x:Key="Acorn">
  9. <Path Fill="White" Stretch="Uniform"
  10. Data="F1 M 16.6309,18.6563C 17.1309,
  11. 8.15625 29.8809,14.1563 29.8809,
  12. 14.1563C 30.8809,11.1563 34.1308,
  13. 11.4063 34.1308,11.4063C 33.5,12
  14. 34.6309,13.1563 34.6309,13.1563C
  15. 32.1309,13.1562 31.1309,14.9062
  16. 31.1309,14.9062C 41.1309,23.9062
  17. 32.6309,27.9063 32.6309,27.9062C
  18. 24.6309,24.9063 21.1309,22.1562
  19. 16.6309,18.6563 Z M 16.6309,19.9063C
  20. 21.6309,24.1563 25.1309,26.1562
  21. 31.6309,28.6562C 31.6309,28.6562
  22. 26.3809,39.1562 18.3809,36.1563C
  23. 18.3809,36.1563 18,38 16.3809,36.9063C
  24. 15,36 16.3809,34.9063 16.3809,34.9063C
  25. 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"/>
  26. </Template>
  27. <Template x:Key="Heart">
  28. <Path Fill="Red" Stretch="Uniform" Data="
  29. M 272.70141,238.71731
  30. C 206.46141,238.71731 152.70146,292.4773 152.70146,358.71731
  31. C 152.70146,493.47282 288.63461,528.80461 381.26391,662.02535
  32. C 468.83815,529.62199 609.82641,489.17075 609.82641,358.71731
  33. C 609.82641,292.47731 556.06651,238.7173 489.82641,238.71731
  34. C 441.77851,238.71731 400.42481,267.08774 381.26391,307.90481
  35. C 362.10311,267.08773 320.74941,238.7173 272.70141,238.71731 z "/>
  36. </Template>
  37. </Styles.Resources>
  38. <Style Selector="Border.Test">
  39. <Setter Property="Margin" Value="15"/>
  40. <Setter Property="Width" Value="100"/>
  41. <Setter Property="Height" Value="100"/>
  42. <Setter Property="Child" Value="{StaticResource Acorn}"/>
  43. </Style>
  44. <Style Selector="Border.Rect1:pointerover">
  45. <Style.Animations>
  46. <Animation Duration="0:0:2.5"
  47. IterationCount="4"
  48. FillMode="None"
  49. PlaybackDirection="AlternateReverse"
  50. Easing="SineEaseInOut">
  51. <KeyFrame Cue="20%">
  52. <Setter Property="RotateTransform.Angle" Value="45"/>
  53. </KeyFrame>
  54. <KeyFrame Cue="50%">
  55. <Setter Property="ScaleTransform.ScaleX" Value="1.5"/>
  56. </KeyFrame>
  57. <KeyFrame Cue="80%">
  58. <Setter Property="RotateTransform.Angle" Value="120"/>
  59. </KeyFrame>
  60. </Animation>
  61. </Style.Animations>
  62. </Style>
  63. <Style Selector="Border.Rect2:pointerover">
  64. <Style.Animations>
  65. <Animation Duration="0:0:0.5" Easing="SineEaseInOut">
  66. <KeyFrame Cue="50%">
  67. <Setter Property="ScaleTransform.ScaleX" Value="0.8"/>
  68. <Setter Property="ScaleTransform.ScaleY" Value="0.8"/>
  69. </KeyFrame>
  70. </Animation>
  71. </Style.Animations>
  72. </Style>
  73. <Style Selector="Border.Rect3">
  74. <Style.Animations>
  75. <Animation Duration="0:0:0.5"
  76. Easing="QuadraticEaseInOut"
  77. IterationCount="Infinite">
  78. <KeyFrame Cue="50%">
  79. <Setter Property="ScaleTransform.ScaleX" Value="0.8"/>
  80. <Setter Property="ScaleTransform.ScaleY" Value="0.8"/>
  81. </KeyFrame>
  82. </Animation>
  83. </Style.Animations>
  84. <Setter Property="Child" Value="{StaticResource Heart}"/>
  85. </Style>
  86. <Style Selector="Border.Rect4:pointerover">
  87. <Style.Animations>
  88. <Animation Duration="0:0:3" Easing="BounceEaseInOut">
  89. <KeyFrame Cue="48%">
  90. <Setter Property="TranslateTransform.Y" Value="-100"/>
  91. <Setter Property="Background" Value="Magenta"/>
  92. </KeyFrame>
  93. </Animation>
  94. </Style.Animations>
  95. </Style>
  96. <Style Selector="Border.Rect5:pointerover">
  97. <Style.Animations>
  98. <Animation Duration="0:0:3" Easing="CircularEaseInOut">
  99. <KeyFrame Cue="25%">
  100. <Setter Property="SkewTransform.AngleX" Value="-20"/>
  101. </KeyFrame>
  102. <KeyFrame Cue="75%">
  103. <Setter Property="SkewTransform.AngleX" Value="20"/>
  104. </KeyFrame>
  105. </Animation>
  106. </Style.Animations>
  107. </Style>
  108. <Style Selector="Border.Rect6">
  109. <Style.Animations>
  110. <Animation Duration="0:0:3"
  111. IterationCount="Infinite"
  112. PlaybackDirection="Alternate">
  113. <KeyFrame Cue="0%">
  114. <Setter Property="Background" Value="Red"/>
  115. </KeyFrame>
  116. <KeyFrame Cue="15%">
  117. <Setter Property="Background" Value="Yellow"/>
  118. </KeyFrame>
  119. <KeyFrame Cue="30%">
  120. <Setter Property="Background" Value="Green"/>
  121. </KeyFrame>
  122. <KeyFrame Cue="45%">
  123. <Setter Property="Background" Value="Cyan"/>
  124. </KeyFrame>
  125. <KeyFrame Cue="60%">
  126. <Setter Property="Background" Value="Blue"/>
  127. </KeyFrame>
  128. <KeyFrame Cue="75%">
  129. <Setter Property="Background" Value="Indigo"/>
  130. </KeyFrame>
  131. <KeyFrame Cue="90%">
  132. <Setter Property="Background" Value="Violet"/>
  133. </KeyFrame>
  134. </Animation>
  135. </Style.Animations>
  136. </Style>
  137. <Style Selector="Border.Shadow">
  138. <Setter Property="BorderBrush" Value="Black"/>
  139. <Setter Property="BorderThickness" Value="1"/>
  140. <Style.Animations>
  141. <Animation Duration="0:0:3"
  142. IterationCount="Infinite"
  143. PlaybackDirection="Alternate">
  144. <KeyFrame Cue="0%">
  145. <Setter Property="BoxShadow" Value="inset 0 0 0 2 Red, -15 -15 Green"/>
  146. </KeyFrame>
  147. <KeyFrame Cue="35%">
  148. <Setter Property="BoxShadow" Value="inset 0 0 20 2 Blue, -15 20 0 0 Blue"/>
  149. </KeyFrame>
  150. <KeyFrame Cue="70%">
  151. <Setter Property="BoxShadow" Value="inset 0 0 20 30 Green, 20 20 20 0 Red"/>
  152. </KeyFrame>
  153. <KeyFrame Cue="85%">
  154. <Setter Property="BoxShadow" Value="inset 30 0 20 30 Green, 20 20 20 10 Red"/>
  155. </KeyFrame>
  156. <KeyFrame Cue="100%">
  157. <Setter Property="BoxShadow" Value="inset 30 30 20 30 Green, 20 40 20 10 Red"/>
  158. </KeyFrame>
  159. </Animation>
  160. </Style.Animations>
  161. </Style>
  162. </Styles>
  163. </UserControl.Styles>
  164. <Grid>
  165. <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="False">
  166. <StackPanel.Clock>
  167. <Clock />
  168. </StackPanel.Clock>
  169. <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
  170. <TextBlock VerticalAlignment="Center">Hover to activate Transform Keyframe Animations.</TextBlock>
  171. <Button Content="{Binding PlayStateText}" Command="{Binding TogglePlayState}" Click="ToggleClock" />
  172. </StackPanel>
  173. <WrapPanel ClipToBounds="False">
  174. <Border Classes="Test Rect1" Background="DarkRed"/>
  175. <Border Classes="Test Rect2" Background="Magenta"/>
  176. <Border Classes="Test Rect3"/>
  177. <Border Classes="Test Rect4" Background="Navy"/>
  178. <Border Classes="Test Rect5" Background="SeaGreen"/>
  179. <Border Classes="Test Rect6" Background="Red"/>
  180. <Border Classes="Test Shadow" CornerRadius="10" Child="{x:Null}" />
  181. <Border Classes="Test Shadow" CornerRadius="0 30 60 0" Child="{x:Null}" />
  182. </WrapPanel>
  183. </StackPanel>
  184. </Grid>
  185. </UserControl>