private void MoveXY(SelectedBorder element, double toX, double toY, double width, double height) { PennerDoubleAnimation daX = new PennerDoubleAnimation() { To = toX, Equation = Equations.QuartEaseOut, Duration = TimeSpan.FromSeconds(0.5) }; PennerDoubleAnimation daY = new PennerDoubleAnimation() { To = toY, Equation = Equations.QuartEaseOut, Duration = TimeSpan.FromSeconds(0.5) }; PennerDoubleAnimation daW = new PennerDoubleAnimation() { To = width, Equation = Equations.QuintEaseOut, Duration = TimeSpan.FromSeconds(0.3) }; PennerDoubleAnimation daH = new PennerDoubleAnimation() { To = height, Equation = Equations.QuintEaseOut, Duration = TimeSpan.FromSeconds(0.3) }; element.BeginAnimation(Canvas.LeftProperty, daX); element.BeginAnimation(Canvas.TopProperty, daY); element.BeginAnimation(WidthProperty, daW); element.BeginAnimation(HeightProperty, daH); }
private void MoveTo() { double x = ListX[SelectedIndex]; double tox = x - showR.Width / 2.0 + 7; Utility.PlaySound("clickMove"); PennerDoubleAnimation daX = new PennerDoubleAnimation() { To = tox, Equation = Equations.QuartEaseOut, Duration = TimeSpan.FromSeconds(0.5) }; showR.BeginAnimation(Canvas.LeftProperty, daX); //Canvas.SetLeft(showR, x - showR.Width / 2.0+15); text.Text = ListResolution[SelectedIndex].width.ToString() + "*" + ListResolution[SelectedIndex].height.ToString(); DoubleAnimation daO = new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(0.5) }; text.BeginAnimation(OpacityProperty, daO); }
public void WinAppear() { MainWindow.ShowMessageWin.Children.Add(this); MainWindow.ShowMessageWin.Visibility = Visibility.Visible; PennerDoubleAnimation da = new PennerDoubleAnimation() { From = 0.8, To = 1, Equation = Equations.BackEaseOut, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; da.Completed += delegate { _scale.ScaleX = 1; _scale.ScaleY = 1; }; DoubleAnimation daO = new DoubleAnimation() { From = 0, To = 1, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.7) }; daO.Completed += delegate { Opacity = 1; }; _scale.BeginAnimation(ScaleTransform.ScaleXProperty, da); _scale.BeginAnimation(ScaleTransform.ScaleYProperty, da); BeginAnimation(OpacityProperty, daO); }
public static void CreateRadialGlow(out Texture targetTexture, uint size, Color col, float opacity = 0.2f, PennerDoubleAnimation.EquationType type = PennerDoubleAnimation.EquationType.Linear) { Image targetImage = new Image(size, size); Vector2u centerPosition = new Vector2u(size / 2, size / 2); float distanceToCenterMax = (float)Math.Sqrt(centerPosition.X * centerPosition.X + centerPosition.Y * centerPosition.Y) / 1.5f; for (uint i = 0; i != size; i++) { for (uint j = 0; j != size; j++) { Color pixelCol = col; Vector2u distanceToCenter = new Vector2u(centerPosition.X - i, centerPosition.Y - j); float distance = (float)Math.Sqrt(distanceToCenter.X * distanceToCenter.X + distanceToCenter.Y * distanceToCenter.Y); float newAlpha = 255.0f * opacity * (1.0f - (float)PennerDoubleAnimation.GetValue(type, distance, 0, 1, distanceToCenterMax)); if (newAlpha < 0.0f) { newAlpha = 0.0f; } //Console.WriteLine(newAlpha); pixelCol.A = (byte)newAlpha; targetImage.SetPixel(i, j, pixelCol); } } targetTexture = new Texture(targetImage); }
private void ReadAllLaw() { this.BeginAnimation(OpacityProperty, new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromSeconds(1) }); PennerDoubleAnimation daScale = new PennerDoubleAnimation() { From = 0, To = 1, Equation = Equations.BackEaseOut, Duration = TimeSpan.FromSeconds(1) }; _scale.BeginAnimation(ScaleTransform.ScaleYProperty, daScale); var lawpath = System.IO.Path.Combine(Directory.GetCurrentDirectory() + "lawText.txt"); if (File.Exists(lawpath)) { String st = File.ReadAllText(Directory.GetCurrentDirectory() + "\\lawText.txt", UnicodeEncoding.GetEncoding("GB2312")); _text.Text = st; } else { Console.WriteLine(lawpath + " 不存在..."); } }
public void DoAlphaTween() { if (!alive) { return; } float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime); _spr.Alpha = (byte)val; }
public void DoScaleTween() { if (!alive) { return; } float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime); _spr.Scale(val, val); }
private void DoParticleAlpha() { float time = TotalLifeTime - RemainingLifeTime; float value = 1.0f - (float)PennerDoubleAnimation.GetValue(AlphaChangeType, time, 0, 1, TotalLifeTime); if (value * (float)InitialAlpha <= 2) { IsAlive = false; } SetAlpha((byte)(value * (float)InitialAlpha)); }
public static void CreateLinearAssymetricGlowInOut(out Texture targetTexture, uint sizeX, uint sizeY, Color col, float opacity = 0.2f, PennerDoubleAnimation.EquationType type1 = PennerDoubleAnimation.EquationType.Linear, PennerDoubleAnimation.EquationType type2 = PennerDoubleAnimation.EquationType.Linear, ShakeDirection direction = ShakeDirection.UpDown) { Image targetImage = new Image(sizeX, sizeY); float centerPosition = 0.0f; if (direction == ShakeDirection.UpDown) { centerPosition = sizeY / 2.0f; } else if (direction == ShakeDirection.LeftRight) { centerPosition = sizeX / 2.0f; } for (uint i = 0; i != sizeX; i++) { for (uint j = 0; j != sizeY; j++) { Color pixelCol = col; float distanceToCenter = 0.0f; if (direction == ShakeDirection.UpDown) { distanceToCenter = (float)(centerPosition - j); } else if (direction == ShakeDirection.LeftRight) { distanceToCenter = (float)(centerPosition - i); } float newAlpha; if (distanceToCenter > 0.0f) { newAlpha = 255.0f * opacity * (1.0f - (float)PennerDoubleAnimation.GetValue(type1, distanceToCenter, 0, 1, centerPosition)); } else { newAlpha = 255.0f * opacity * (1.0f - (float)PennerDoubleAnimation.GetValue(type2, distanceToCenter, 0, 1, centerPosition)); } if (newAlpha < 0.0f) { newAlpha = 0.0f; } //Console.WriteLine(newAlpha); pixelCol.A = (byte)newAlpha; targetImage.SetPixel(i, j, pixelCol); } } targetTexture = new Texture(targetImage); }
public void DoAlphaTween() { if (!alive) { return; } float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime); //Console.WriteLine("do alpha tween" + val.ToString()); Color newCol = new Color(_shp.FillColor); newCol.A = (byte)(val); _shp.FillColor = newCol; }
private void MoveToX(PopCell Cell, double toX, Equations equation) { isAnimating = true; PennerDoubleAnimation daX = new PennerDoubleAnimation() { To = toX, Equation = equation, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.7) }; if (equation == Equations.QuadEaseOut) { daX.Duration = TimeSpan.FromSeconds(1); } daX.Completed += delegate { Cell.X = toX; isAnimating = false; }; Cell.BeginAnimation(Canvas.LeftProperty, daX); }
private void InitializeRotations() { _storyBoard.RepeatBehavior = RepeatBehavior.Forever; var duration = TimeSpan.FromSeconds(10); var animationRotation = new DoubleAnimationUsingKeyFrames { Duration = new Duration(duration), RepeatBehavior = RepeatBehavior.Forever }; var animationTranslate = new PennerDoubleAnimation { Equation = PennerDoubleAnimation.Equations.QuadEaseInOut, Duration = TimeSpan.FromSeconds(5), RepeatBehavior = RepeatBehavior.Forever, From = 0, To = 610, AutoReverse = true }; animationRotation.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0))); animationRotation.KeyFrames.Add(new LinearDoubleKeyFrame(360, KeyTime.FromPercent(1))); var rotateTransform = new RotateTransform(); PullPoint.RenderTransform = rotateTransform; PullPoint.RenderTransformOrigin = new Point(0.5, 0.5); var translateTransform = new TranslateTransform(); Yoke.RenderTransform = translateTransform; Yoke.RenderTransformOrigin = new Point(0.5,0.5); Storyboard.SetTarget(animationRotation, rotateTransform); Storyboard.SetTargetProperty(animationRotation, new PropertyPath(RotateTransform.AngleProperty)); Storyboard.SetTarget(animationTranslate, translateTransform); Storyboard.SetTargetProperty(animationTranslate, new PropertyPath(TranslateTransform.XProperty)); animationTranslate.Freeze(); animationRotation.Freeze(); _storyBoard.Children.Add(animationTranslate); _storyBoard.Children.Add(animationRotation); }
private void BarCome() { PennerDoubleAnimation daScaleY = new PennerDoubleAnimation() { From = 0, To = 1, FillBehavior = FillBehavior.Stop, Equation = Equations.BackEaseOut, Duration = TimeSpan.FromSeconds(0.5) }; daScaleY.Completed += delegate { scaleGrid.ScaleY = 1; if (BarReadyEvent != null) { BarReadyEvent(this, new EventArgs()); } }; scaleGrid.BeginAnimation(ScaleTransform.ScaleYProperty, daScaleY); }
public void WinDisAppear() { PennerDoubleAnimation da = new PennerDoubleAnimation() { From = 1, To = 0.9, Equation = Equations.BackEaseIn, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; da.Completed += delegate { _scale.ScaleX = 1; _scale.ScaleY = 1; }; DoubleAnimation daO = new DoubleAnimation() { From = 1, To = 0, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; daO.Completed += delegate { Opacity = 0; //Close(); MainWindow.ShowMessageWin.Children.Clear(); MainWindow.ShowMessageWin.Visibility = Visibility.Collapsed; }; _scale.BeginAnimation(ScaleTransform.ScaleXProperty, da); _scale.BeginAnimation(ScaleTransform.ScaleYProperty, da); BeginAnimation(OpacityProperty, daO); }
public void BarGo() { SettingStage.CurrentStage = StageEnum.MainFace; PennerDoubleAnimation daScaleY = new PennerDoubleAnimation() { To = 0, Equation = Equations.BackEaseIn, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; daScaleY.Completed += delegate { scaleGrid.ScaleY = 0; SettingStage.PopGrid.Visibility = Visibility.Collapsed; //SettingStage.CurrentStage = StageEnum.MainFace; Utility.RemoveUIElement(this); //DispatcherTimer dtX = new DispatcherTimer(); //dtX.Interval = TimeSpan.FromSeconds(0.1); //dtX.Tick += delegate //{ // dtX.Stop(); // Utility.RemoveUIElement(this); // if (!isFailed) // { // if (LoadFinished != null) // { // LoadFinished(this, new EventArgs()); // } // } //}; //dtX.Start(); }; daScaleY.BeginTime = TimeSpan.FromSeconds(0.5); scaleGrid.BeginAnimation(ScaleTransform.ScaleYProperty, daScaleY); }
/// <summary> /// 显示文字提示 /// </summary> private void PlateShow() { dt0.Stop(); dt0.Interval = TimeSpan.FromSeconds(2); gradien1.Offset = 1; this.Visibility = Visibility.Visible; PennerDoubleAnimation daY = new PennerDoubleAnimation() { From = -20, To = 0, Equation = Equations.BackEaseOut, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; DoubleAnimation daO = new DoubleAnimation() { From = 0, To = 1, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; daY.Completed += delegate { translate.Y = 0; Opacity = 1; gradient.Offset = 1; dt0.Tick += delegate { dt0.Stop(); #region 后续隐藏提示文字 daY = new PennerDoubleAnimation() { From = 0, To = -20, Equation = Equations.BackEaseIn, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; daO = new DoubleAnimation() { From = 1, To = 0, FillBehavior = FillBehavior.Stop, Duration = TimeSpan.FromSeconds(0.5) }; daO.Completed += delegate { translate.Y = -20; Opacity = 0; //gradien1.Offset = 0; this.Visibility = Visibility.Collapsed; }; translate.BeginAnimation(TranslateTransform.YProperty, daY); BeginAnimation(OpacityProperty, daO); #endregion }; dt0.Start(); }; translate.BeginAnimation(TranslateTransform.YProperty, daY); BeginAnimation(OpacityProperty, daO); gradient.BeginAnimation(GradientStop.OffsetProperty, daO); }
private void DoScaleTween() { float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime); _shp.Scale = new SFML.Window.Vector2f(val, val); }