AnimationsPage.xaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <UserControl
  2. xmlns="https://github.com/avaloniaui"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:viewModels="using:RenderDemo.ViewModels"
  5. x:Class="RenderDemo.Pages.AnimationsPage"
  6. x:DataType="viewModels:AnimationsPageViewModel"
  7. MaxWidth="600">
  8. <UserControl.Styles>
  9. <Styles>
  10. <Styles.Resources>
  11. <Template x:Key="Acorn">
  12. <Path Fill="White" Stretch="Uniform"
  13. Data="F1 M 16.6309,18.6563C 17.1309,
  14. 8.15625 29.8809,14.1563 29.8809,
  15. 14.1563C 30.8809,11.1563 34.1308,
  16. 11.4063 34.1308,11.4063C 33.5,12
  17. 34.6309,13.1563 34.6309,13.1563C
  18. 32.1309,13.1562 31.1309,14.9062
  19. 31.1309,14.9062C 41.1309,23.9062
  20. 32.6309,27.9063 32.6309,27.9062C
  21. 24.6309,24.9063 21.1309,22.1562
  22. 16.6309,18.6563 Z M 16.6309,19.9063C
  23. 21.6309,24.1563 25.1309,26.1562
  24. 31.6309,28.6562C 31.6309,28.6562
  25. 26.3809,39.1562 18.3809,36.1563C
  26. 18.3809,36.1563 18,38 16.3809,36.9063C
  27. 15,36 16.3809,34.9063 16.3809,34.9063C
  28. 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"/>
  29. </Template>
  30. <Template x:Key="Heart">
  31. <Path Fill="Red" Stretch="Uniform" Data="
  32. M 272.70141,238.71731
  33. C 206.46141,238.71731 152.70146,292.4773 152.70146,358.71731
  34. C 152.70146,493.47282 288.63461,528.80461 381.26391,662.02535
  35. C 468.83815,529.62199 609.82641,489.17075 609.82641,358.71731
  36. C 609.82641,292.47731 556.06651,238.7173 489.82641,238.71731
  37. C 441.77851,238.71731 400.42481,267.08774 381.26391,307.90481
  38. C 362.10311,267.08773 320.74941,238.7173 272.70141,238.71731 z "/>
  39. </Template>
  40. </Styles.Resources>
  41. <Style Selector="Border.Test">
  42. <Setter Property="Margin" Value="15"/>
  43. <Setter Property="Width" Value="100"/>
  44. <Setter Property="Height" Value="100"/>
  45. <Setter Property="Child" Value="{StaticResource Acorn}"/>
  46. </Style>
  47. <Style Selector="Border.Rect1:pointerover">
  48. <Style.Animations>
  49. <Animation Duration="0:0:2.5"
  50. IterationCount="4"
  51. FillMode="None"
  52. PlaybackDirection="AlternateReverse"
  53. Easing="SineEaseInOut">
  54. <KeyFrame Cue="20%">
  55. <Setter Property="RotateTransform.Angle" Value="45"/>
  56. </KeyFrame>
  57. <KeyFrame Cue="50%">
  58. <Setter Property="ScaleTransform.ScaleX" Value="1.5"/>
  59. </KeyFrame>
  60. <KeyFrame Cue="80%">
  61. <Setter Property="RotateTransform.Angle" Value="120"/>
  62. </KeyFrame>
  63. </Animation>
  64. </Style.Animations>
  65. </Style>
  66. <Style Selector="Border.Rect2:pointerover">
  67. <Style.Animations>
  68. <Animation Duration="0:0:0.5" Easing="SineEaseInOut">
  69. <KeyFrame Cue="50%">
  70. <Setter Property="ScaleTransform.ScaleX" Value="0.8"/>
  71. <Setter Property="ScaleTransform.ScaleY" Value="0.8"/>
  72. </KeyFrame>
  73. </Animation>
  74. </Style.Animations>
  75. </Style>
  76. <Style Selector="Border.Rect3">
  77. <Style.Animations>
  78. <Animation Duration="0:0:0.5"
  79. Easing="QuadraticEaseInOut"
  80. IterationCount="Infinite">
  81. <KeyFrame Cue="50%">
  82. <Setter Property="ScaleTransform.ScaleX" Value="0.8"/>
  83. <Setter Property="ScaleTransform.ScaleY" Value="0.8"/>
  84. </KeyFrame>
  85. </Animation>
  86. </Style.Animations>
  87. <Setter Property="Child" Value="{StaticResource Heart}"/>
  88. </Style>
  89. <Style Selector="Border.Rect4:pointerover">
  90. <Style.Animations>
  91. <Animation Duration="0:0:3" Easing="BounceEaseInOut">
  92. <KeyFrame Cue="48%">
  93. <Setter Property="TranslateTransform.Y" Value="-100"/>
  94. <Setter Property="Background" Value="Magenta"/>
  95. </KeyFrame>
  96. </Animation>
  97. </Style.Animations>
  98. </Style>
  99. <Style Selector="Border.Rect5:pointerover">
  100. <Style.Animations>
  101. <Animation Duration="0:0:3" Easing="CircularEaseInOut">
  102. <KeyFrame Cue="25%">
  103. <Setter Property="SkewTransform.AngleX" Value="-20"/>
  104. </KeyFrame>
  105. <KeyFrame Cue="75%">
  106. <Setter Property="SkewTransform.AngleX" Value="20"/>
  107. </KeyFrame>
  108. </Animation>
  109. </Style.Animations>
  110. </Style>
  111. <Style Selector="Border.Rect6">
  112. <Style.Animations>
  113. <Animation Duration="0:0:3"
  114. IterationCount="Infinite"
  115. PlaybackDirection="Alternate">
  116. <KeyFrame Cue="0%">
  117. <Setter Property="Background" Value="Red"/>
  118. </KeyFrame>
  119. <KeyFrame Cue="15%">
  120. <Setter Property="Background" Value="Yellow"/>
  121. </KeyFrame>
  122. <KeyFrame Cue="30%">
  123. <Setter Property="Background" Value="Green"/>
  124. </KeyFrame>
  125. <KeyFrame Cue="45%">
  126. <Setter Property="Background" Value="Cyan"/>
  127. </KeyFrame>
  128. <KeyFrame Cue="60%">
  129. <Setter Property="Background" Value="Blue"/>
  130. </KeyFrame>
  131. <KeyFrame Cue="75%">
  132. <Setter Property="Background" Value="Indigo"/>
  133. </KeyFrame>
  134. <KeyFrame Cue="90%">
  135. <Setter Property="Background" Value="Violet"/>
  136. </KeyFrame>
  137. </Animation>
  138. </Style.Animations>
  139. </Style>
  140. <Style Selector="Border.Shadow">
  141. <Setter Property="BorderBrush" Value="Black"/>
  142. <Setter Property="BorderThickness" Value="1"/>
  143. <Style.Animations>
  144. <Animation Duration="0:0:3"
  145. IterationCount="Infinite"
  146. PlaybackDirection="Alternate">
  147. <KeyFrame Cue="0%">
  148. <Setter Property="BoxShadow" Value="inset 0 0 0 2 Red, -15 -15 Green"/>
  149. </KeyFrame>
  150. <KeyFrame Cue="35%">
  151. <Setter Property="BoxShadow" Value="inset 0 0 20 2 Blue, -15 20 0 0 Blue"/>
  152. </KeyFrame>
  153. <KeyFrame Cue="70%">
  154. <Setter Property="BoxShadow" Value="inset 0 0 20 30 Green, 20 20 20 0 Red"/>
  155. </KeyFrame>
  156. <KeyFrame Cue="85%">
  157. <Setter Property="BoxShadow" Value="inset 30 0 20 30 Green, 20 20 20 10 Red"/>
  158. </KeyFrame>
  159. <KeyFrame Cue="100%">
  160. <Setter Property="BoxShadow" Value="inset 30 30 20 30 Green, 20 40 20 10 Red"/>
  161. </KeyFrame>
  162. </Animation>
  163. </Style.Animations>
  164. </Style>
  165. <Style Selector="Border.Rect7">
  166. <Style.Animations>
  167. <Animation Duration="0:0:3"
  168. IterationCount="Infinite"
  169. PlaybackDirection="Alternate">
  170. <KeyFrame Cue="0%">
  171. <Setter Property="Background" Value="Red" />
  172. </KeyFrame>
  173. <KeyFrame Cue="30%">
  174. <Setter Property="Background">
  175. <LinearGradientBrush StartPoint="0%,0%" EndPoint="0%,100%">
  176. <GradientStop Offset="0" Color="Red"/>
  177. <GradientStop Offset="1" Color="Blue"/>
  178. </LinearGradientBrush>
  179. </Setter>
  180. </KeyFrame>
  181. <KeyFrame Cue="60%">
  182. <Setter Property="Background" Value="Blue" />
  183. </KeyFrame>
  184. <KeyFrame Cue="100%">
  185. <Setter Property="Background">
  186. <LinearGradientBrush StartPoint="0%,0%" EndPoint="0%,100%">
  187. <GradientStop Offset="0" Color="Green"/>
  188. <GradientStop Offset="1" Color="Yellow"/>
  189. </LinearGradientBrush>
  190. </Setter>
  191. </KeyFrame>
  192. </Animation>
  193. </Style.Animations>
  194. </Style>
  195. <Style Selector="Border.Rect8">
  196. <Style.Animations>
  197. <Animation Duration="0:0:3"
  198. IterationCount="Infinite"
  199. PlaybackDirection="Alternate">
  200. <KeyFrame Cue="0%">
  201. <Setter Property="Background">
  202. <LinearGradientBrush StartPoint="0%,0%" EndPoint="0%,100%">
  203. <GradientStop Offset="0" Color="Red"/>
  204. <GradientStop Offset="1" Color="Blue"/>
  205. </LinearGradientBrush>
  206. </Setter>
  207. </KeyFrame>
  208. <KeyFrame Cue="50%">
  209. <Setter Property="Background">
  210. <LinearGradientBrush StartPoint="100%,0%" EndPoint="0%,100%">
  211. <GradientStop Offset="0" Color="Red"/>
  212. <GradientStop Offset="0.25" Color="Blue"/>
  213. <GradientStop Offset="0.5" Color="Blue"/>
  214. <GradientStop Offset="0.75" Color="Green"/>
  215. <GradientStop Offset="1" Color="Yellow"/>
  216. </LinearGradientBrush>
  217. </Setter>
  218. </KeyFrame>
  219. <KeyFrame Cue="100%">
  220. <Setter Property="Background">
  221. <LinearGradientBrush StartPoint="0%,0%" EndPoint="0%,100%">
  222. <GradientStop Offset="0" Color="Red"/>
  223. <GradientStop Offset="1" Color="Blue"/>
  224. </LinearGradientBrush>
  225. </Setter>
  226. </KeyFrame>
  227. </Animation>
  228. </Style.Animations>
  229. </Style>
  230. <Style Selector="Border.Rect9">
  231. <Style.Animations>
  232. <Animation Duration="0:0:3"
  233. IterationCount="Infinite"
  234. PlaybackDirection="Alternate">
  235. <KeyFrame Cue="0%">
  236. <Setter Property="Background">
  237. <ConicGradientBrush Center="50%,50%" Angle="0">
  238. <GradientStop Offset="0" Color="Blue"/>
  239. <GradientStop Offset="0.5" Color="Red"/>
  240. <GradientStop Offset="1" Color="Blue"/>
  241. </ConicGradientBrush>
  242. </Setter>
  243. </KeyFrame>
  244. <KeyFrame Cue="100%">
  245. <Setter Property="Background">
  246. <ConicGradientBrush Center="50%,70%" Angle="90">
  247. <GradientStop Offset="0" Color="Green"/>
  248. <GradientStop Offset="0.25" Color="Yellow"/>
  249. <GradientStop Offset="0.5" Color="Red"/>
  250. <GradientStop Offset="0.75" Color="Blue"/>
  251. <GradientStop Offset="1" Color="Green"/>
  252. </ConicGradientBrush>
  253. </Setter>
  254. </KeyFrame>
  255. </Animation>
  256. </Style.Animations>
  257. </Style>
  258. <Style Selector="Border.Rect10">
  259. <Style.Animations>
  260. <Animation Duration="0:0:3"
  261. IterationCount="Infinite"
  262. PlaybackDirection="Normal">
  263. <KeyFrame Cue="0%">
  264. <Setter Property="Background">
  265. <RadialGradientBrush Center="0%,100%" RadiusX="80%" RadiusY="80%">
  266. <GradientStop Offset="0" Color="Red"/>
  267. <GradientStop Offset="1" Color="Blue"/>
  268. </RadialGradientBrush>
  269. </Setter>
  270. </KeyFrame>
  271. <KeyFrame Cue="25%">
  272. <Setter Property="Background">
  273. <RadialGradientBrush Center="0%,0%" RadiusX="100%" RadiusY="100%">
  274. <GradientStop Offset="0" Color="Red"/>
  275. <GradientStop Offset="1" Color="Blue"/>
  276. </RadialGradientBrush>
  277. </Setter>
  278. </KeyFrame>
  279. <KeyFrame Cue="50%">
  280. <Setter Property="Background">
  281. <RadialGradientBrush Center="100%,0%" RadiusX="80%" RadiusY="80%">
  282. <GradientStop Offset="0" Color="Red"/>
  283. <GradientStop Offset="1" Color="Blue"/>
  284. </RadialGradientBrush>
  285. </Setter>
  286. </KeyFrame>
  287. <KeyFrame Cue="75%">
  288. <Setter Property="Background">
  289. <RadialGradientBrush Center="100%,100%" RadiusX="100%" RadiusY="100%">
  290. <GradientStop Offset="0" Color="Red"/>
  291. <GradientStop Offset="1" Color="Blue"/>
  292. </RadialGradientBrush>
  293. </Setter>
  294. </KeyFrame>
  295. <KeyFrame Cue="100%">
  296. <Setter Property="Background">
  297. <RadialGradientBrush Center="0%,100%" RadiusX="80%" RadiusY="80%">
  298. <GradientStop Offset="0" Color="Red"/>
  299. <GradientStop Offset="1" Color="Blue"/>
  300. </RadialGradientBrush>
  301. </Setter>
  302. </KeyFrame>
  303. </Animation>
  304. </Style.Animations>
  305. </Style>
  306. <Style Selector="Border.Blur">
  307. <Style.Animations>
  308. <Animation Duration="0:0:3"
  309. IterationCount="Infinite"
  310. PlaybackDirection="Alternate">
  311. <KeyFrame Cue="0%">
  312. <Setter Property="Effect" Value="blur(0)"/>
  313. </KeyFrame>
  314. <KeyFrame Cue="100%">
  315. <Setter Property="Effect" Value="blur(10)"/>
  316. </KeyFrame>
  317. </Animation>
  318. </Style.Animations>
  319. <Setter Property="Child" Value="{StaticResource Acorn}"/>
  320. </Style>
  321. <Style Selector="Border.DropShadow">
  322. <Style.Animations>
  323. <Animation Duration="0:0:3"
  324. IterationCount="Infinite"
  325. PlaybackDirection="Alternate">
  326. <KeyFrame Cue="0%">
  327. <Setter Property="Effect" Value="drop-shadow(0 0 0)"/>
  328. </KeyFrame>
  329. <KeyFrame Cue="35%">
  330. <Setter Property="Effect" Value="drop-shadow(5 5 0 Green)"/>
  331. </KeyFrame>
  332. <KeyFrame Cue="70%">
  333. <Setter Property="Effect" Value="drop-shadow(5 5 5 Red)"/>
  334. </KeyFrame>
  335. <KeyFrame Cue="100%">
  336. <Setter Property="Effect" Value="drop-shadow(20 -5 5 Blue)"/>
  337. </KeyFrame>
  338. </Animation>
  339. </Style.Animations>
  340. </Style>
  341. </Styles>
  342. </UserControl.Styles>
  343. <Grid>
  344. <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="False">
  345. <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="20">
  346. <TextBlock VerticalAlignment="Center">Hover to activate Keyframe Animations.</TextBlock>
  347. </StackPanel>
  348. <WrapPanel ClipToBounds="False">
  349. <Border Classes="Test Rect1" Background="DarkRed"/>
  350. <Border Classes="Test Rect2" Background="Magenta"/>
  351. <Border Classes="Test Rect3"/>
  352. <Border Classes="Test Rect4" Background="Navy"/>
  353. <Border Classes="Test Rect5" Background="SeaGreen"/>
  354. <Border Classes="Test Rect6" Background="Red"/>
  355. <Border Classes="Test Shadow" CornerRadius="10" Child="{x:Null}" />
  356. <Border Classes="Test Shadow" CornerRadius="0 30 60 0" Child="{x:Null}" />
  357. <Border Classes="Test Rect7" Child="{x:Null}" />
  358. <Border Classes="Test Rect8" Child="{x:Null}" />
  359. <Border Classes="Test Rect9" Child="{x:Null}" />
  360. <Border Classes="Test Rect10" Child="{x:Null}" />
  361. <Border Classes="Test Blur" Background="#ffa0a0a0" BorderThickness="4" BorderBrush="Yellow" Padding="10"/>
  362. <Border Classes="Test DropShadow" Background="Transparent" BorderThickness="4" BorderBrush="Yellow">
  363. <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Drop
  364. Shadow</TextBlock>
  365. </Border>
  366. </WrapPanel>
  367. </StackPanel>
  368. </Grid>
  369. </UserControl>