public CompositionAnimationGroup GetShadowFocusAnimations(Compositor compositor, Layer layer) { var newShadowBlurRadius = BlurRadius + _focusShadowBlurRadiusIncreaseAmount; var oldShadowOffset = Offset; var additionalShadowOffsetAmount = _focusShadowOffsetIncreaseAmount; var newShadowOffset = new Vector3(oldShadowOffset.X + additionalShadowOffsetAmount, oldShadowOffset.Y + additionalShadowOffsetAmount, oldShadowOffset.Z + additionalShadowOffsetAmount); // Create AnimationGroup CompositionAnimationGroup animationGroup = compositor.CreateAnimationGroup(); // Blur Radius ScalarKeyFrameAnimation shadowBlurAnimation = compositor.CreateScalarKeyFrameAnimation(); shadowBlurAnimation.InsertKeyFrame(0.0f, BlurRadius); shadowBlurAnimation.InsertKeyFrame(1.0f, newShadowBlurRadius); shadowBlurAnimation.Duration = ConfigurationConstants.FocusAnimationDuration; shadowBlurAnimation.Target = "BlurRadius"; animationGroup.Add(shadowBlurAnimation); // Offset Vector3KeyFrameAnimation shadowOffsetAnimation = compositor.CreateVector3KeyFrameAnimation(); shadowOffsetAnimation.InsertKeyFrame(0.0f, Offset); shadowOffsetAnimation.InsertKeyFrame(1.0f, newShadowOffset); shadowOffsetAnimation.Duration = ConfigurationConstants.FocusAnimationDuration; shadowOffsetAnimation.Target = "Offset"; animationGroup.Add(shadowOffsetAnimation); return(animationGroup); }
private void AnimateToLayerHelper(SpriteVisual target) { // Create AnimationGroup for target visual propery animation CompositionAnimationGroup animationGroup = _compositor.CreateAnimationGroup(); // Scale Vector3KeyFrameAnimation scaleAnimation = _compositor.CreateVector3KeyFrameAnimation(); scaleAnimation.InsertKeyFrame(0.0f, target.Scale); scaleAnimation.InsertKeyFrame(1.0f, this.DepthTreatment.ChildScale); scaleAnimation.Duration = ConfigurationConstants.FocusAnimationDuration; scaleAnimation.Target = "Scale"; animationGroup.Add(scaleAnimation); target.StartAnimationGroup(animationGroup); // Update item color to match items in new layer. Preserve content if any. var brushType = target.Brush.GetType(); if (brushType != typeof(CompositionSurfaceBrush) && brushType != typeof(CompositionEffectBrush)) { target.Brush = LayerColor; } }
private void ItemConainer_Loaded(object sender, RoutedEventArgs e) { var itemPanel = albumView.ItemsPanelRoot as ItemsWrapGrid; var itemContainer = sender as GridViewItem; var itemIndex = albumView.IndexFromContainer(itemContainer); if (itemIndex >= itemPanel.FirstVisibleIndex && itemIndex <= itemPanel.LastVisibleIndex) { //Loading animation var itemVisual = ElementCompositionPreview.GetElementVisual(itemContainer); float width = 200; float height = 200; itemVisual.Size = new Vector2(width, height); itemVisual.CenterPoint = new Vector3(width / 2, height / 2, 0f); itemVisual.Opacity = 0.0f; Vector3KeyFrameAnimation scalAnimation = _compositor.CreateVector3KeyFrameAnimation(); scalAnimation.InsertKeyFrame(0f, new Vector3(0.9f, 0.9f, .9f)); scalAnimation.InsertKeyFrame(1f, new Vector3(1f, 1f, 0f)); scalAnimation.Duration = TimeSpan.FromMilliseconds(600); var x = itemIndex - itemPanel.FirstVisibleIndex; scalAnimation.DelayTime = TimeSpan.FromMilliseconds((itemIndex - itemPanel.FirstVisibleIndex) * 20); KeyFrameAnimation fadeAnimation = _compositor.CreateScalarKeyFrameAnimation(); fadeAnimation.InsertExpressionKeyFrame(1f, "1"); fadeAnimation.Duration = TimeSpan.FromMilliseconds(600); fadeAnimation.DelayTime = TimeSpan.FromMilliseconds((itemIndex - itemPanel.FirstVisibleIndex) * 20); itemVisual.StartAnimation("Scale", scalAnimation); itemVisual.StartAnimation("Opacity", fadeAnimation); } itemContainer.Loaded -= ItemConainer_Loaded; }
private void animateShowNotification() { var itemVisual = ElementCompositionPreview.GetElementVisual(this.NotificationPanel); if (this.notificationsHidden) { this.notificationsHidden = false; Vector3KeyFrameAnimation offsetAnimation = _compositor.CreateVector3KeyFrameAnimation(); offsetAnimation.Duration = TimeSpan.FromMilliseconds(1000); offsetAnimation.InsertKeyFrame(0f, new Vector3(0f, 100f, 0f)); offsetAnimation.InsertKeyFrame(1f, new Vector3(0f, 0f, 0f)); ScalarKeyFrameAnimation fadeAnimation = _compositor.CreateScalarKeyFrameAnimation(); fadeAnimation.Duration = TimeSpan.FromMilliseconds(1000); fadeAnimation.InsertKeyFrame(0f, 0f); fadeAnimation.InsertKeyFrame(1f, 1f); itemVisual.StartAnimation("Offset", offsetAnimation); itemVisual.StartAnimation("Opacity", fadeAnimation); } else { itemVisual.Opacity = 1f; } }
private void PlayPausePanel_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { this.togglePlayPause(); var itemVisual = ElementCompositionPreview.GetElementVisual(this.PlayPauseGrid); float width = (float)this.PlayPauseGrid.RenderSize.Width; float height = (float)this.PlayPauseGrid.RenderSize.Height; itemVisual.CenterPoint = new Vector3(width / 2, height / 2, 0f); ScalarKeyFrameAnimation opacityAnimation = this._compositor.CreateScalarKeyFrameAnimation(); opacityAnimation.Duration = TimeSpan.FromMilliseconds(500); opacityAnimation.InsertKeyFrame(0f, 1f); if (!this.pointerEntered) { opacityAnimation.InsertKeyFrame(1f, 0f); } Vector3KeyFrameAnimation scaleAnimation = this._compositor.CreateVector3KeyFrameAnimation(); scaleAnimation.Duration = TimeSpan.FromMilliseconds(500); scaleAnimation.InsertKeyFrame(0f, new Vector3(1f, 1f, 1f)); scaleAnimation.InsertKeyFrame(0.2f, new Vector3(1.1f, 1.1f, 1.1f)); scaleAnimation.InsertKeyFrame(1f, new Vector3(1f, 1f, 1f)); itemVisual.StartAnimation("Opacity", opacityAnimation); itemVisual.StartAnimation("Scale", scaleAnimation); }
private void EnsureAnimation() { if (_animationGroup != null) { return; } var linear = Window.Current.Compositor.CreateLinearEasingFunction(); _opacityAnimation = Window.Current.Compositor.CreateScalarKeyFrameAnimation(); _opacityAnimation.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay; _opacityAnimation.DelayTime = TimeSpan.FromMilliseconds(200); _opacityAnimation.InsertKeyFrame(0, 0); _opacityAnimation.InsertKeyFrame(0.2f, 0, linear); _opacityAnimation.InsertKeyFrame(1, 1, linear); _opacityAnimation.Duration = TimeSpan.FromMilliseconds(600); _opacityAnimation.Target = nameof(Visual.Opacity); _flyInTranslationAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation(); _flyInTranslationAnimation.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay; _flyInTranslationAnimation.DelayTime = TimeSpan.FromMilliseconds(200); _flyInTranslationAnimation.InsertKeyFrame(0, new Vector3(0, 2000, 0)); _flyInTranslationAnimation.InsertKeyFrame(1, Vector3.Zero); _flyInTranslationAnimation.Duration = TimeSpan.FromMilliseconds(600); _flyInTranslationAnimation.Target = "Translation"; _animationGroup = Window.Current.Compositor.CreateAnimationGroup(); _animationGroup.Add(_opacityAnimation); _animationGroup.Add(_flyInTranslationAnimation); }
private void TryNavigateToScenario(int num) { foreach (Scenario scenario in _scenarios) { if (scenario.Identifier == num && _currentScenario != scenario) { var oldScenario = _currentScenario; _currentScenario = scenario; var newOffset = _scenarioContainersMapping[scenario].Offset; var currOffset = _tracker.Position; // Offset animation Vector3KeyFrameAnimation offsetAnimation = _compositor.CreateVector3KeyFrameAnimation(); offsetAnimation.InsertKeyFrame(0.0f, currOffset); offsetAnimation.InsertKeyFrame(1.0f, newOffset); offsetAnimation.Duration = ConfigurationConstants.FocusAnimationDuration; offsetAnimation.Target = "Position"; _tracker.TryUpdatePositionWithAnimation(offsetAnimation); UpdateActiveScenarioIndicator(oldScenario); break; } } }
// This animation has constant duration, speedy changes depending on the distance // between sourceElement and targetElement. public async Task StartAnimation2(FrameworkElement sourceElement, FrameworkElement targetElement) { Point point = sourceElement.TransformToVisual(_rootElement).TransformPoint(new Point(0, 0)); CompositionDrawingSurface surface = await CompositionDrawingSurfaceFacade1.GetCompositionDrawingSurface(sourceElement, _compositor); SpriteVisual spriteVisual = _compositor.CreateSpriteVisual(); spriteVisual.Brush = _compositor.CreateSurfaceBrush(surface); spriteVisual.Size = new Vector2((float)surface.Size.Width, (float)surface.Size.Height); spriteVisual.Offset = new Vector3((float)point.X, (float)point.Y, 0f); _containerVisual.Children.InsertAtBottom(spriteVisual); Vector3 targetOffset = GetTargetOffset(targetElement); Vector3KeyFrameAnimation offsetAnimation = _compositor.CreateVector3KeyFrameAnimation(); Vector2 targetSize = GetTargetSize(targetElement); Vector2KeyFrameAnimation sizeAnimation = _compositor.CreateVector2KeyFrameAnimation(); var newWidth = (float)(sourceElement.ActualWidth * 1.3); var newHeight = (float)(sourceElement.ActualHeight * 1.3); var newX = (float)(point.X - (newWidth - sourceElement.ActualWidth) / 2); var newY = (float)(point.Y - (newHeight - sourceElement.ActualHeight) / 2); double sizeDurationInMs = 250; double distance = Math.Sqrt(Math.Pow(targetOffset.X - newX, 2) + Math.Pow(targetOffset.Y - newY, 2)); double offsetDurationInMs = distance / 2; double animationDurationInMs = sizeDurationInMs + offsetDurationInMs; sizeAnimation.Duration = TimeSpan.FromMilliseconds(animationDurationInMs); offsetAnimation.Duration = TimeSpan.FromMilliseconds(animationDurationInMs); SetAnimationDefautls(offsetAnimation); SetAnimationDefautls(sizeAnimation); var normalizedProgressKey0 = (float)(sizeDurationInMs / animationDurationInMs); offsetAnimation.InsertKeyFrame(normalizedProgressKey0, new Vector3(newX, newY, 0f)); sizeAnimation.InsertKeyFrame(normalizedProgressKey0, new Vector2(newWidth, newHeight)); const float normalizedProgressKey1 = 1f; offsetAnimation.InsertKeyFrame(normalizedProgressKey1, targetOffset, _compositor.CreateLinearEasingFunction()); sizeAnimation.InsertKeyFrame(normalizedProgressKey1, targetSize, _compositor.CreateLinearEasingFunction()); CompositionScopedBatch myScopedBatch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation); var batchCompletitionAwaiter = new BatchCompletitionAwaiter(myScopedBatch); spriteVisual.StartAnimation("Offset", offsetAnimation); spriteVisual.StartAnimation("Size", sizeAnimation); myScopedBatch.End(); await batchCompletitionAwaiter.Completed(); myScopedBatch.Dispose(); spriteVisual.Dispose(); surface.Dispose(); offsetAnimation.Dispose(); sizeAnimation.Dispose(); }
private static Vector3KeyFrameAnimation Vector3KeyFrameAnimation(Compositor compositor) { Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); animation.IterationBehavior = AnimationIterationBehavior.Count; animation.IterationCount = 1; animation.Duration = TimeSpan.FromSeconds(1); animation.InsertKeyFrame(0, new Vector3(0, 0, 0)); animation.InsertKeyFrame(1, Vector3.One); return(animation); }
private void BuildVisualTree() { // use current position for laying out as we iterate Vector3 currentGridPosition = new Vector3(horizontalSpace, horizontalSpace, 1.0f); Vector2 imageSize = new Vector2(imageDimension, imageDimension); Vector3KeyFrameAnimation firstAnimation = _compositor.CreateVector3KeyFrameAnimation(); firstAnimation.InsertKeyFrame(0.0f, new Vector3(-50.0f, -50.0f, 0.0f)); firstAnimation.InsertKeyFrame(1.0f, currentGridPosition); firstAnimation.Duration = TimeSpan.FromMilliseconds(2000); var animation = _compositor.CreateVector3KeyFrameAnimation(); animation.InsertExpressionKeyFrame(0.0f, "previous.Offset"); animation.InsertExpressionKeyFrame(1.0f, "finalvalue"); animation.DelayTime = TimeSpan.FromMilliseconds(1000); animation.Duration = TimeSpan.FromMilliseconds(1500); Visual previousVisual = null; foreach (Uri profileImageUri in GetProfileUrisForTwitterFollowers("@wincomposition")) { var profileImageVisual = MakeImageVisualforFollower(profileImageUri, imageSize); if (previousVisual == null) { firstAnimation.SetVector3Parameter("finalvalue", currentGridPosition); profileImageVisual.ConnectAnimation("Offset", firstAnimation).Start(); } else { animation.SetReferenceParameter("previous", previousVisual); animation.SetVector3Parameter("finalvalue", currentGridPosition); animation.DelayTime += TimeSpan.FromMilliseconds(300); //50 profileImageVisual.ConnectAnimation("Offset", animation).Start(); } _rootVisual.Children.InsertAtBottom(profileImageVisual); previousVisual = profileImageVisual; #region CalcNextOffset // simple dumb layout currentGridPosition.X += horizontalSpace + imageDimension; if (currentGridPosition.X + imageDimension > this.ActualWidth) { currentGridPosition.X = horizontalSpace; currentGridPosition.Y += imageDimension + verticalSpace; } #endregion } }
private void ItemContainer_Loaded(object sender, RoutedEventArgs e) { var itemsPanel = (ItemsStackPanel)ActivityList.ItemsPanelRoot; var itemContainer = (ListViewItem)sender; var itemIndex = ActivityList.IndexFromContainer(itemContainer); var uc = itemContainer.ContentTemplateRoot as FrameworkElement; var childPanel = uc.FindName("ActivityListItemPanel") as RelativePanel; // Don't animate if we're not in the visible viewport if (itemIndex >= itemsPanel.FirstVisibleIndex && itemIndex <= itemsPanel.LastVisibleIndex) { var itemVisual = ElementCompositionPreview.GetElementVisual(uc); float width = (float)childPanel.RenderSize.Width; float height = (float)childPanel.RenderSize.Height; itemVisual.Size = new Vector2(width, height); itemVisual.CenterPoint = new Vector3(width / 2, height / 2, 0f); itemVisual.Scale = new Vector3(1, 1, 1); // new Vector3(0.25f, 0.25f, 0); itemVisual.Opacity = 0f; itemVisual.Offset = new Vector3(0, 100, 0); var relativeIndex = itemIndex - itemsPanel.FirstVisibleIndex; // Create KeyFrameAnimations KeyFrameAnimation offsetAnimation = Compositor.CreateScalarKeyFrameAnimation(); offsetAnimation.InsertExpressionKeyFrame(1f, "0"); offsetAnimation.Duration = TimeSpan.FromMilliseconds(1250); offsetAnimation.DelayTime = TimeSpan.FromMilliseconds(relativeIndex * 100); Vector3KeyFrameAnimation scaleAnimation = Compositor.CreateVector3KeyFrameAnimation(); scaleAnimation.InsertKeyFrame(0, new Vector3(1f, 1f, 0f)); scaleAnimation.InsertKeyFrame(0.1f, new Vector3(0.05f, 0.05f, 0.05f)); scaleAnimation.InsertKeyFrame(1f, new Vector3(1f, 1f, 0f)); scaleAnimation.Duration = TimeSpan.FromMilliseconds(1000); scaleAnimation.DelayTime = TimeSpan.FromMilliseconds(relativeIndex * 100); KeyFrameAnimation fadeAnimation = Compositor.CreateScalarKeyFrameAnimation(); fadeAnimation.InsertExpressionKeyFrame(1f, "1"); fadeAnimation.Duration = TimeSpan.FromMilliseconds(500); fadeAnimation.DelayTime = TimeSpan.FromMilliseconds(relativeIndex * 100); // Start animations itemVisual.StartAnimation("Offset.Y", offsetAnimation); itemVisual.StartAnimation("Scale", scaleAnimation); itemVisual.StartAnimation("Opacity", fadeAnimation); } itemContainer.Loaded -= ItemContainer_Loaded; }
private void Translate(Visual visual, float to, float?from = null, bool RestartContentAnimationAfter = false) { CompositionEasingFunction cubicBezier = compositor.CreateCubicBezierEasingFunction(new Vector2(.45f, 1.5f), new Vector2(.45f, 1f)); // Create the Vector3 KFA Vector3KeyFrameAnimation kfa = compositor.CreateVector3KeyFrameAnimation(); kfa.Duration = TimeSpan.FromSeconds(0.3); if (from.HasValue) { kfa.InsertKeyFrame(0.0f, new Vector3(from.Value, 0, 0)); } kfa.InsertKeyFrame(1.0f, new Vector3(to, 0, 0), cubicBezier); // Update InteractionTracker position using this animation visual.StartAnimation("Translation", kfa); }
/// <summary> /// Creates a <see cref="ScalarKeyFrameAnimation"/> instance with the given parameters to on a target element /// </summary> /// <param name="compositor">The current <see cref="Compositor"/> instance used to create the animation</param> /// <param name="from">The optional starting value for the animation</param> /// <param name="to">The final value for the animation</param> /// <param name="duration">The animation duration</param> /// <param name="delay">The optional initial delay for the animation</param> /// <param name="ease">The optional easing function for the animation</param> public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation( this Compositor compositor, Vector3? from, Vector3 to, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease = null) { // Set duration and delay time Vector3KeyFrameAnimation ani = compositor.CreateVector3KeyFrameAnimation(); ani.Duration = duration; if (delay.HasValue) ani.DelayTime = delay.Value; // Insert "to" and "from" keyframes ani.InsertKeyFrame(1, to, ease ?? compositor.CreateLinearEasingFunction()); if (from.HasValue) ani.InsertKeyFrame(0, from.Value); return ani; }
private void StartAnimation(double value) { float ratio = (float)this.Value / (float)value; Visual recVisual = ElementCompositionPreview.GetElementVisual(rec); Visual txtVisual = ElementCompositionPreview.GetElementVisual(txt); recVisual.CenterPoint = new Vector3(0, 0.5f, 0); recVisual.Scale = new Vector3(ratio, 1, 0); txtVisual.Opacity = 0; CompositionEasingFunction cubicBezierEasingFunction = _compositor.CreateCubicBezierEasingFunction(new Vector2(0.5f, 0f), new Vector2(0.3f, 0.9f)); Vector3KeyFrameAnimation scaleAnimation = _compositor.CreateVector3KeyFrameAnimation(); scaleAnimation.InsertKeyFrame(1f, new Vector3(1, 1, 0), cubicBezierEasingFunction); scaleAnimation.Duration = TimeSpan.FromMilliseconds(1250); scaleAnimation.DelayTime = TimeSpan.FromMilliseconds(100); ScalarKeyFrameAnimation offsetAnimation = _compositor.CreateScalarKeyFrameAnimation(); //offsetAnimation.InsertKeyFrame(0f, 10); offsetAnimation.InsertKeyFrame(1f, (float)(10 + value), cubicBezierEasingFunction); offsetAnimation.Duration = TimeSpan.FromMilliseconds(1250); offsetAnimation.DelayTime = TimeSpan.FromMilliseconds(100); ScalarKeyFrameAnimation opacityAnimation = _compositor.CreateScalarKeyFrameAnimation(); //opacityAnimation.InsertKeyFrame(0.2f, 0, cubicBezierEasingFunction); opacityAnimation.InsertKeyFrame(1f, 1, cubicBezierEasingFunction); opacityAnimation.Duration = TimeSpan.FromMilliseconds(1250); opacityAnimation.DelayTime = TimeSpan.FromMilliseconds(100); recVisual.StartAnimation(nameof(recVisual.Scale), scaleAnimation); txtVisual.StartAnimation("Offset.X", offsetAnimation); txtVisual.StartAnimation(nameof(txtVisual.Opacity), opacityAnimation); }
public void ToggleRight() { CompositionEasingFunction cubicBezier = compositor.CreateCubicBezierEasingFunction(new Vector2(.45f, 1.5f), new Vector2(.45f, 1f)); Vector3KeyFrameAnimation kfa = compositor.CreateVector3KeyFrameAnimation(); kfa.Duration = TimeSpan.FromSeconds(0.5); if (tracker.Position.X != 0) { kfa.InsertKeyFrame(1.0f, Vector3Zero, cubicBezier); } else { kfa.InsertKeyFrame(1.0f, tracker.MaxPosition, cubicBezier); } tracker.TryUpdatePositionWithAnimation(kfa); }
private void Animate(Windows.UI.Composition.AnimationDirection direction) { double height = Root.ActualHeight + Root.Margin.Top + Root.Margin.Bottom; ElementCompositionPreview.SetIsTranslationEnabled(Root, true); Visual visual = ElementCompositionPreview.GetElementVisual(Root); visual.Offset = new Vector3(0, VerticalAlignment == VerticalAlignment.Top ? (float)-height : (float)height, 0); visual.Opacity = 0; Compositor compositor = visual.Compositor; Vector3KeyFrameAnimation vfa = compositor.CreateVector3KeyFrameAnimation(); vfa.InsertKeyFrame(1f, new Vector3(0, 0, 0)); vfa.Duration = TimeSpan.FromMilliseconds(250); vfa.Direction = direction; vfa.IterationCount = 1; ScalarKeyFrameAnimation sfa = compositor.CreateScalarKeyFrameAnimation(); sfa.InsertKeyFrame(1, 1); sfa.Duration = TimeSpan.FromMilliseconds(250); sfa.Direction = direction; sfa.IterationCount = 1; visual.StartAnimation("Offset", vfa); visual.StartAnimation("Opacity", sfa); }
private void PerformZoomAnimation(Windows.UI.Composition.AnimationDirection direction, int duration) { if (direction == Windows.UI.Composition.AnimationDirection.Reverse) { duration = duration / 3 * 2; } Visual dvisual = ElementCompositionPreview.GetElementVisual(LayoutRoot); Compositor dcompositor = dvisual.Compositor; var size = Window.Current.Bounds; float cx = (float)size.Width / 2; float cy = (float)size.Height / 2; dvisual.Scale = new Vector3(1.13f, 1.13f, 1); dvisual.Opacity = 0; dvisual.CenterPoint = new Vector3(cx, cy, 1); Vector3KeyFrameAnimation vfa = dcompositor.CreateVector3KeyFrameAnimation(); vfa.InsertKeyFrame(1f, new Vector3(1, 1, 1)); vfa.Duration = TimeSpan.FromMilliseconds(duration); vfa.Direction = direction; vfa.IterationCount = 1; ScalarKeyFrameAnimation sdfa = dcompositor.CreateScalarKeyFrameAnimation(); sdfa.InsertKeyFrame(1, 1); sdfa.Duration = TimeSpan.FromMilliseconds(duration); sdfa.Direction = direction; sdfa.IterationCount = 1; dvisual.StartAnimation("Scale", vfa); dvisual.StartAnimation("Opacity", sdfa); }
private CompositionAnimation GetScrollKFA(Vector3 newPosition) { Vector3KeyFrameAnimation kfa = _compositor.CreateVector3KeyFrameAnimation(); kfa.Duration = TimeSpan.FromMilliseconds(400); kfa.InsertKeyFrame(1, newPosition); return(kfa); }
public void OpenLeft() { CompositionEasingFunction cubicBezier = compositor.CreateCubicBezierEasingFunction(new Vector2(.45f, 1.5f), new Vector2(.45f, 1f)); Vector3KeyFrameAnimation kfa = compositor.CreateVector3KeyFrameAnimation(); kfa.Duration = TimeSpan.FromSeconds(0.5); kfa.InsertKeyFrame(1.0f, tracker.MinPosition, cubicBezier); tracker.TryUpdatePositionWithAnimation(kfa); }
/// <summary> /// Closes the right rawer if open. /// </summary> public void CloseRight() { CompositionEasingFunction cubicBezier = _compositor.CreateCubicBezierEasingFunction(new Vector2(.45f, 1.5f), new Vector2(.45f, 1f)); Vector3KeyFrameAnimation kfa = _compositor.CreateVector3KeyFrameAnimation(); kfa.Duration = TimeSpan.FromSeconds(0.5); kfa.InsertKeyFrame(1.0f, _vector3Zero, cubicBezier); _tracker.TryUpdatePositionWithAnimation(kfa); }
private void StartVector3Animation(String propertyName, Vector3 endValue) { // Create and start a Vector3 KeyFrame animation on shadow with given begin and end values Vector3KeyFrameAnimation animation = _compositor.CreateVector3KeyFrameAnimation(); animation.InsertKeyFrame(1.0f, endValue); animation.Duration = new TimeSpan(0, 0, ANIMATION_DURATION); _shadow.StartAnimation(propertyName, animation); }
public void ToggleLeft() { CompositionEasingFunction cubicBezier = compositor.CreateCubicBezierEasingFunction(new Vector2(.45f, 1.5f), new Vector2(.45f, 1f)); Vector3KeyFrameAnimation kfa = compositor.CreateVector3KeyFrameAnimation(); kfa.Duration = TimeSpan.FromSeconds(0.5); if (tracker.Position.X < 0) { kfa.InsertKeyFrame(1.0f, Vector3Zero, cubicBezier); DrawsClosed?.Invoke(null, null); } else { kfa.InsertKeyFrame(1.0f, tracker.MinPosition, cubicBezier); DrawOpenedLeft?.Invoke(null, null); } tracker.TryUpdatePositionWithAnimation(kfa); }
/// <summary> /// Toggles the right drawer's open status. /// </summary> public void ToggleRight() { CompositionEasingFunction cubicBezier = _compositor.CreateCubicBezierEasingFunction(new Vector2(.45f, 1.5f), new Vector2(.45f, 1f)); Vector3KeyFrameAnimation kfa = _compositor.CreateVector3KeyFrameAnimation(); kfa.Duration = TimeSpan.FromSeconds(0.5); if (_tracker.Position.X > 0) { DrawsClosed?.Invoke(null, null); kfa.InsertKeyFrame(1.0f, _vector3Zero, cubicBezier); } else { DrawOpenedRight?.Invoke(null, null); kfa.InsertKeyFrame(1.0f, _tracker.MaxPosition, cubicBezier); } _tracker.TryUpdatePositionWithAnimation(kfa); }
public void AnimateAddedVisual(SpriteVisual target) { float currShadowBlurRadius = 0f; Vector3 currShadowOffset = new Vector3(); if (target.Shadow != null) { currShadowBlurRadius = ((DropShadow)(target.Shadow)).BlurRadius; currShadowOffset = ((DropShadow)(target.Shadow)).Offset; } else { DropShadow shadow = _compositor.CreateDropShadow(); shadow.Color = ConfigurationConstants.ShadowColor; shadow.Opacity = ConfigurationConstants.ShadowOpacity; target.Shadow = shadow; } // Create AnimationGroup for shadow change animation CompositionAnimationGroup animationGroup = _compositor.CreateAnimationGroup(); // Animate shadow blur radius change ScalarKeyFrameAnimation shadowBlurAnimation = _compositor.CreateScalarKeyFrameAnimation(); shadowBlurAnimation.InsertKeyFrame(0.0f, currShadowBlurRadius); shadowBlurAnimation.InsertKeyFrame(1.0f, DepthTreatment.ShadowTreatment.BlurRadius); shadowBlurAnimation.Duration = ConfigurationConstants.FocusAnimationDuration; shadowBlurAnimation.Target = "BlurRadius"; animationGroup.Add(shadowBlurAnimation); // Animate shadow offset change Vector3KeyFrameAnimation shadowOffsetAnimation = _compositor.CreateVector3KeyFrameAnimation(); shadowOffsetAnimation.InsertKeyFrame(0.0f, currShadowOffset); shadowOffsetAnimation.InsertKeyFrame(1.0f, DepthTreatment.ShadowTreatment.Offset); shadowOffsetAnimation.Duration = ConfigurationConstants.FocusAnimationDuration; shadowOffsetAnimation.Target = "Offset"; animationGroup.Add(shadowOffsetAnimation); target.Shadow.StartAnimationGroup(animationGroup); AnimateToLayerHelper(target); }
public CompositionAnimationGroup GetVisualFocusAnimations(Compositor compositor, Layer layer) { var oldscale = ChildScale; var newScale = new Vector3(oldscale.X * _focusScaleIncreaseFactor, oldscale.Y * _focusScaleIncreaseFactor, oldscale.Z); // Create AnimationGroup CompositionAnimationGroup animationGroup = compositor.CreateAnimationGroup(); // Scale Vector3KeyFrameAnimation scaleAnimation = compositor.CreateVector3KeyFrameAnimation(); scaleAnimation.InsertKeyFrame(0.0f, oldscale); scaleAnimation.InsertKeyFrame(1.0f, newScale); scaleAnimation.Duration = ConfigurationConstants.FocusAnimationDuration; scaleAnimation.Target = "Scale"; animationGroup.Add(scaleAnimation); return(animationGroup); }
/// <summary> /// Initializes a new instance of the <see cref="AdaptiveGridView"/> class. /// </summary> public AdaptiveGridView() { IsTabStop = false; SizeChanged += OnSizeChanged; ItemClick += OnItemClick; if (Items != null) { Items.VectorChanged += ItemsOnVectorChanged; } Loaded += OnLoaded; Unloaded += OnUnloaded; // Define ItemContainerStyle in code rather than using the DefaultStyle // to avoid having to define the entire style of a GridView. This can still // be set by the enduser to values of their chosing var style = new Style(typeof(GridViewItem)); style.Setters.Add(new Setter(HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch)); style.Setters.Add(new Setter(VerticalContentAlignmentProperty, VerticalAlignment.Stretch)); ItemContainerStyle = style; // Set up opacity and scale animations. var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; _scaleAnimation = compositor.CreateVector3KeyFrameAnimation(); _scaleAnimation.Duration = TimeSpan.FromMilliseconds(AnimationDuration); _scaleAnimation.InsertKeyFrame(0, new Vector3(0.8f, 0.8f, 0)); _scaleAnimation.InsertKeyFrame(1, Vector3.One, EaseOutCubic(compositor)); _opacityAnimation = compositor.CreateScalarKeyFrameAnimation(); _opacityAnimation.Duration = TimeSpan.FromMilliseconds(AnimationDuration); _opacityAnimation.InsertKeyFrame(1, 1.0f, EaseOutCubic(compositor)); // Remove the default entrance transition if existed. RegisterPropertyChangedCallback(ItemContainerTransitionsProperty, (s, e) => { var entranceThemeTransition = ItemContainerTransitions.OfType <EntranceThemeTransition>().SingleOrDefault(); if (entranceThemeTransition != null) { ItemContainerTransitions.Remove(entranceThemeTransition); } }); }
private void AnimateSquare(SpriteVisual visual, int delay) { float offsetX = (float)(visual.Offset.X); Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); float bottom = Height - visual.Size.Y; animation.InsertKeyFrame(1f, new Vector3(offsetX, bottom, 0f)); animation.Duration = TimeSpan.FromSeconds(2); animation.DelayTime = TimeSpan.FromSeconds(delay); visual.StartAnimation("Offset", animation); }
protected override void OnConnected(UIElement targetElement) { if (targetElement == null) { return; } Compositor compositor = Window.Current.Compositor; // Create SpotLight and set its properties SpotLight spotLight = compositor.CreateSpotLight(); spotLight.InnerConeColor = Colors.FloralWhite; spotLight.OuterConeColor = Colors.FloralWhite; spotLight.InnerConeAngleInDegrees = 0f; spotLight.InnerConeIntensity = 4; //spotLight.OuterConeAngleInDegrees = 3f; spotLight.ConstantAttenuation = 1f; spotLight.LinearAttenuation = 0.253f; spotLight.QuadraticAttenuation = 0.58f; spotLight.Offset = new Vector3(0, 0, 0); // Associate CompositionLight with XamlLight this.CompositionLight = spotLight; // Define resting position Animation Vector3 restingPosition = new Vector3(200, 200, 400); CubicBezierEasingFunction cbEasing = compositor.CreateCubicBezierEasingFunction(new Vector2(0.3f, 0.7f), new Vector2(0.9f, 0.5f)); _offsetAnimation = compositor.CreateVector3KeyFrameAnimation(); _offsetAnimation.InsertKeyFrame(1, restingPosition, cbEasing); _offsetAnimation.Duration = TimeSpan.FromSeconds(0.5f); //spotLight.Offset = restingPosition; // Define expression animation that relates light's offset to pointer position CompositionPropertySet hoverPosition = ElementCompositionPreview.GetPointerPositionPropertySet(targetElement); _lightPositionExpression = compositor.CreateExpressionAnimation("Vector3(hover.Position.X, hover.Position.Y, height)"); _lightPositionExpression.SetReferenceParameter("hover", hoverPosition); _lightPositionExpression.SetScalarParameter("height", 150f); // Configure pointer entered/ exited events targetElement.PointerMoved += TargetElement_PointerMoved; targetElement.PointerExited += TargetElement_PointerExited; // Add UIElement to the Light's Targets HoverLight.AddTargetElement(GetId(), targetElement); //MoveToRestingPosition(); }
/// <summary> /// Start animations and re-parent to destination UI Elmenent to finish the operations /// </summary> /// <param name="destinationElement">Destination UIElement where Visual should show up after page has loaded</param> /// <param name="containerVisual">ContainerVisual that contains Visual which needs to show in UIElement</param> /// <param name="newContainerVisual">ContainerVisual after visual is parented to UIElement</param> public static void InitiateContinuity(FrameworkElement destinationElement, ContainerVisual containerVisual, out ContainerVisual newContainerVisual) { if (null == containerVisual || null == destinationElement) { newContainerVisual = null; return; } //Get the frame of Window var rootFrame = AppShell.Current; Visual rootVisual = ElementCompositionPreview.GetElementVisual(AppShell.Current); Compositor compositor = rootVisual.Compositor; //Create Temporary Container. this will be added to final UIElement ContainerVisual tempContainer = compositor.CreateContainerVisual(); // Get Sprite Visual from incoming container var spriteHeroImage = containerVisual.Children.FirstOrDefault(); //Create animation scoped batch to track animation completion and to complete re-parenting CompositionScopedBatch scopeBatch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation); //Get coordinates of UIElement in reference to root so that it can be used for animations final value var coordinate = destinationElement.TransformToVisual(rootFrame); var position = coordinate.TransformPoint(new Point(0, 0)); //Create offset animation to make visual move on screen Vector3KeyFrameAnimation offsetAnimation = compositor.CreateVector3KeyFrameAnimation(); offsetAnimation.InsertKeyFrame(1f, new System.Numerics.Vector3((float)position.X, (float)position.Y, 0)); offsetAnimation.Duration = TimeSpan.FromMilliseconds(600); //Create size animation to change size of the visuals Vector2KeyFrameAnimation sizeAnimation = compositor.CreateVector2KeyFrameAnimation(); sizeAnimation.InsertKeyFrame(1f, new System.Numerics.Vector2((float)destinationElement.ActualWidth, (float)destinationElement.ActualHeight)); sizeAnimation.Duration = TimeSpan.FromMilliseconds(600); //Start Animations spriteHeroImage.StartAnimation("size", sizeAnimation); containerVisual.StartAnimation("offset", offsetAnimation); //Scoped batch completed event. scopeBatch.Completed += (o, e) => { //Re-parent SpriteVisual to temp container and add temp container to UIElement as animations are finished. spriteHeroImage.Offset = new System.Numerics.Vector3(0, 0, 2000); containerVisual.Children.Remove(spriteHeroImage); tempContainer.Children.InsertAtTop(spriteHeroImage); ElementCompositionPreview.SetElementChildVisual(destinationElement, tempContainer); containerVisual = null; }; newContainerVisual = tempContainer; scopeBatch.End(); }
void PrepareAnimation() { _contentGridVisual = ElementCompositionPreview.GetElementVisual(_contentGrid); _compositor = _contentGridVisual.Compositor; rotationAnimation = _compositor.CreateScalarKeyFrameAnimation(); scaleAnimation = _compositor.CreateVector3KeyFrameAnimation(); var easing = _compositor.CreateLinearEasingFunction(); _contentGrid.SizeChanged += (s, e) => { _contentGridVisual.CenterPoint = new Vector3((float)_contentGrid.ActualWidth / 2.0f, (float)_contentGrid.ActualHeight / 2.0f, 0); }; scaleAnimation.InsertKeyFrame(0.0f, new Vector3() { X = 0.0f, Y = 0.0f, Z = 0.0f }); scaleAnimation.InsertKeyFrame(1.0f, new Vector3() { X = 1.0f, Y = 1.0f, Z = 0.0f }, easing); rotationAnimation.InsertKeyFrame(0.0f, -90.0f); rotationAnimation.InsertKeyFrame(1.0f, 0.0f, easing); }
/// <summary> /// Initializes the Composition elements /// </summary> private void InitComposition() { // Compositor _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; // CompositionGenerator _generator = CompositionGeneratorFactory.GetCompositionGenerator(_compositor); // Fade Out Animation _fadeOutAnimation = _compositor.CreateScalarKeyFrameAnimation(); _fadeOutAnimation.InsertKeyFrame(1f, 0); _fadeOutAnimation.Duration = TransitionDuration; // Fade In Animation _fadeInAnimation = _compositor.CreateScalarKeyFrameAnimation(); _fadeInAnimation.InsertKeyFrame(1f, 1); _fadeInAnimation.Duration = TransitionDuration; // Color Animation _colorAnimation = _compositor.CreateColorKeyFrameAnimation(); _colorAnimation.Duration = TransitionDuration; // Offset Animation _offsetAnimation = _compositor.CreateVector3KeyFrameAnimation(); _offsetAnimation.Target = "Offset"; _offsetAnimation.Duration = TransitionDuration; _offsetAnimation.InsertKeyFrame(1f, Vector3.Zero); // Alignment animations _alignXAnimation = _compositor.CreateScalarKeyFrameAnimation(); _alignXAnimation.Duration = AlignmentTransitionDuration; _alignYAnimation = _compositor.CreateScalarKeyFrameAnimation(); _alignYAnimation.Duration = AlignmentTransitionDuration; // ZoomIn Animation Group _scaleAnimation = _compositor.CreateVector3KeyFrameAnimation(); _scaleAnimation.Target = "Scale"; _scaleAnimation.InsertKeyFrame(1f, Vector3.One); _scaleAnimation.Duration = TransitionDuration; _zoomInAnimationGroup = _compositor.CreateAnimationGroup(); _zoomInAnimationGroup.Add(_scaleAnimation); _zoomInAnimationGroup.Add(_offsetAnimation); // Visuals _rootContainer = _compositor.CreateContainerVisual(); _frameLayer = _compositor.CreateLayerVisual(); _frameBackgroundVisual = _compositor.CreateSpriteVisual(); _frameContentVisual = _compositor.CreateSpriteVisual(); _placeholderContentVisual = _compositor.CreateSpriteVisual(); _placeholderBackgroundVisual = _compositor.CreateSpriteVisual(); _nextVisualContent = _compositor.CreateSpriteVisual(); _frameLayer.Children.InsertAtTop(_frameBackgroundVisual); _frameLayer.Children.InsertAtTop(_frameContentVisual); _frameLayer.Children.InsertAtTop(_placeholderBackgroundVisual); _frameLayer.Children.InsertAtTop(_placeholderContentVisual); _frameLayer.Children.InsertAtTop(_nextVisualContent); // Placeholder content _placeholderContentMask = _generator.CreateGeometrySurface(PlaceholderSize, GetPlaceHolderGeometry(), PlaceholderColor, PlaceholderBackground); _placeholderContentBrush = _compositor.CreateSurfaceBrush(_placeholderContentMask.Surface); _placeholderContentVisual.Brush = _placeholderContentBrush; // Placeholder background _placeholderBackgroundVisual.Brush = _compositor.CreateColorBrush(PlaceholderBackground); // By default placeholder visual will not be visible HidePlaceholder(); // Shadow visual _shadowVisual = _compositor.CreateSpriteVisual(); _rootContainer.Children.InsertAtBottom(_shadowVisual); _rootContainer.Children.InsertAtTop(_frameLayer); _frameBackgroundVisual.Brush = _compositor.CreateColorBrush(FrameBackground); // Create the effect to create the opacity mask var layerEffect = new CompositeEffect { // CanvasComposite.DestinationIn - Intersection of source and mask. // Equation: O = MA * S // where O - Output pixel, MA - Mask Alpha, S - Source pixel. Mode = CanvasComposite.DestinationIn, Sources = { new CompositionEffectSourceParameter("source"), new CompositionEffectSourceParameter("mask") } }; var layerEffectFactory = _compositor.CreateEffectFactory(layerEffect); _layerEffectBrush = layerEffectFactory.CreateBrush(); // The mask for the imageFrame _frameLayerMask = _generator.CreateMaskSurface(new Size(0, 0), null); _layerEffectBrush.SetSourceParameter("mask", _compositor.CreateSurfaceBrush(_frameLayerMask.Surface)); // Apply the mask effect to the frameLayer _frameLayer.Effect = _layerEffectBrush; ElementCompositionPreview.SetElementChildVisual(this, _rootContainer); }
private void CreateAnimationTemplates(Compositor compositor) { // // Near-slide and far-slide animations. // _nearSlideOffsetAnimation = compositor.CreateVector3KeyFrameAnimation(); _nearSlideOffsetAnimation.InsertExpressionKeyFrame(0.0f, "this.StartingValue"); _nearSlideOffsetAnimation.InsertExpressionKeyFrame(1.0f, "vector3(0,0,0) - myViewportCenter"); _farSlideOffsetAnimation = compositor.CreateVector3KeyFrameAnimation(); _farSlideOffsetAnimation.InsertExpressionKeyFrame(0.0f, "this.StartingValue"); _farSlideOffsetAnimation.InsertExpressionKeyFrame(0.9f, "vector3(0,0,0) - myViewportCenter"); _farSlideOffsetAnimation.InsertExpressionKeyFrame(1.0f, "vector3(0,0,0) - myViewportCenter"); _slideCenterAnimation = compositor.CreateVector3KeyFrameAnimation(); _slideCenterAnimation.InsertExpressionKeyFrame(0.0f, "this.StartingValue"); _slideCenterAnimation.InsertExpressionKeyFrame(1.0f, "myTargetCenterPoint"); _nearSlideScaleAnimation = compositor.CreateVector3KeyFrameAnimation(); _nearSlideScaleAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue"); _nearSlideScaleAnimation.InsertExpressionKeyFrame(1.00f, "myScale"); _farSlideScaleAnimation = compositor.CreateVector3KeyFrameAnimation(); _farSlideScaleAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue"); _farSlideScaleAnimation.InsertKeyFrame(0.30f, new Vector3(1.0f, 1.0f, 1.0f)); _farSlideScaleAnimation.InsertKeyFrame(1.00f, new Vector3(1.0f, 1.0f, 1.0f)); TimeSpan time4sec = TimeSpan.FromSeconds(4); TimeSpan time8sec = TimeSpan.FromSeconds(8); _nearSlideOffsetAnimation.Duration = time4sec; _farSlideOffsetAnimation.Duration = time8sec; _slideCenterAnimation.Duration = time4sec; _nearSlideScaleAnimation.Duration = time4sec; _farSlideScaleAnimation.Duration = time4sec; // // Zoom animations. // _zoomScaleAnimation = compositor.CreateVector3KeyFrameAnimation(); _zoomScaleAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue"); _zoomScaleAnimation.InsertKeyFrame(0.40f, new Vector3(1.0f, 1.0f, 1.0f)); _zoomScaleAnimation.InsertKeyFrame(0.60f, new Vector3(1.0f, 1.0f, 1.0f)); _zoomScaleAnimation.InsertExpressionKeyFrame(1.00f, "myScale"); _zoomCenterAnimation = compositor.CreateVector3KeyFrameAnimation(); _zoomCenterAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue"); _zoomCenterAnimation.InsertExpressionKeyFrame(0.40f, "this.StartingValue"); _zoomCenterAnimation.InsertExpressionKeyFrame(0.60f, "myTargetCenterPoint"); _zoomCenterAnimation.InsertExpressionKeyFrame(1.00f, "myTargetCenterPoint"); _zoomOffsetAnimation = compositor.CreateVector3KeyFrameAnimation(); _zoomOffsetAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue"); _zoomOffsetAnimation.InsertExpressionKeyFrame(1.00f, "vector3(0,0,0) - myViewportCenter"); TimeSpan time12sec = TimeSpan.FromSeconds(12); _zoomScaleAnimation.Duration = time12sec; _zoomCenterAnimation.Duration = time12sec; _zoomOffsetAnimation.Duration = time12sec; // // Stack animations. // CubicBezierEasingFunction flyInEasing; CubicBezierEasingFunction flyOutEasing; flyInEasing = compositor.CreateCubicBezierEasingFunction(new Vector2(0.0f, 1.0f), new Vector2(0.8f, 1.0f)); _stackFlyInAnimation = compositor.CreateVector3KeyFrameAnimation(); _stackFlyInAnimation.InsertExpressionKeyFrame(0.00f, "stackVisual.Offset + startDelta"); _stackFlyInAnimation.InsertExpressionKeyFrame(1.00f, "stackVisual.Offset + endDelta", flyInEasing); _stackFlyInAnimation.Duration = TimeSpan.FromSeconds(2); flyOutEasing = compositor.CreateCubicBezierEasingFunction(new Vector2(0.0f, 0.4f), new Vector2(1.0f, 0.6f)); _stackFlyOutAnimation = compositor.CreateVector3KeyFrameAnimation(); _stackFlyOutAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue", flyOutEasing); _stackFlyOutAnimation.InsertExpressionKeyFrame(0.50f, "this.StartingValue + delta", flyOutEasing); _stackFlyOutAnimation.InsertExpressionKeyFrame(1.00f, "originalOffset", flyOutEasing); _stackFlyOutAnimation.Duration = TimeSpan.FromSeconds(2); _stackScaleAnimation = compositor.CreateVector3KeyFrameAnimation(); _stackScaleAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue"); _stackScaleAnimation.InsertExpressionKeyFrame(1.00f, "myScale"); _stackScaleAnimation.Duration = TimeSpan.FromSeconds(6); // // Color flashlight expression animation. // // This expression returns a computes between 0 and 1 as a function of on how close the // center of the frame is to the center of the window. // - If the frame is at the center of the window, the expression computes 0 (no // desaturation). // - If the frame is more than 300px away from the center of the window, the // expression computes 1 (full desaturation). // - If the frame is within 300px from the center of the window, the expression // computes a value between 0 and 1 relative to how far the frame is from the 300px // boundary (partial desaturation). _colorFlashlightAnimation = compositor.CreateExpressionAnimation( "1.0 - min(" + " 1.0," + " (" + " (" + " ( frame.Offset.x + (frame.Size.x * 0.5) + grid.Offset.x - (windowWidth * 0.5) )" + " * ( frame.Offset.x + (frame.Size.x * 0.5) + grid.Offset.x - (windowWidth * 0.5) )" + " ) + (" + " ( frame.Offset.y + (frame.Size.y * 0.5) + grid.Offset.y - (windowHeight * 0.5) )" + " * ( frame.Offset.y + (frame.Size.y * 0.5) + grid.Offset.y - (windowHeight * 0.5) )" + " )" + " ) / ( radius * radius )" + ")"); _colorFlashlightAnimation.SetReferenceParameter("grid", _layoutManager.GridVisual); _colorFlashlightAnimation.SetScalarParameter("radius", 300); _colorFlashlightAnimation.SetScalarParameter("windowWidth", _windowWidth); _colorFlashlightAnimation.SetScalarParameter("windowHeight", _windowHeight); }