Last active
December 23, 2020 11:51
-
-
Save colinkiama/eb1cbf641fb61e5cfc729819873abe6f to your computer and use it in GitHub Desktop.
UWP endless rotation animation with Windows.UI.Composition
This file contains 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 characters
Vector3 centerPoint = new Vector3((float)(element.ActualWidth * 0.5), | |
(float)(element.ActualHeight * 0.5), 0); | |
Visual logoDropShadowVisual = ElementCompositionPreview.GetElementVisual(element); | |
Compositor compositor = logoDropShadowVisual.Compositor; | |
ScalarKeyFrameAnimation animation = compositor.CreateScalarKeyFrameAnimation(); | |
// Ensures that visual rotates at a consistent rate. | |
LinearEasingFunction easing = compositor.CreateLinearEasingFunction(); | |
animation.InsertKeyFrame(1f, 360f, easing); | |
animation.Duration = TimeSpan.FromSeconds(5); | |
animation.IterationBehavior = AnimationIterationBehavior.Forever; | |
logoDropShadowVisual.CenterPoint = centerPoint; | |
logoDropShadowVisual.StartAnimation("RotationAngleInDegrees", animation); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment