2 using System.Collections.Generic;
6 namespace ElmSharp.Test
8 class EcoreTimelineAnimatorTest1 : TestCaseBase
11 public override string TestName => "Timeline Animator Test1";
13 public override string TestDescription => "Ecore Timeline Animator Test1";
15 EcoreTimelineAnimator timelineAnimator;
19 Tuple<string, IAnimatorMotionMapper>[] mappers =
21 new Tuple<string, IAnimatorMotionMapper>("Linear", new LinearMotionMapper()),
22 new Tuple<string, IAnimatorMotionMapper>("Accelerate", new AccelerateMotionMapper()),
23 new Tuple<string, IAnimatorMotionMapper>("Decelerate", new DecelerateMotionMapper()),
24 new Tuple<string, IAnimatorMotionMapper>("Sinusoida", new SinusoidalMotionMapper()),
25 new Tuple<string, IAnimatorMotionMapper>("Bounce", new BounceMotionMapper{ Bounces = 3, DecayFactor = 1.8 }),
26 new Tuple<string, IAnimatorMotionMapper>("Spring", new SpringMotionMapper{ Wobbles = 3, DecayFactor = 1.8 }),
27 new Tuple<string, IAnimatorMotionMapper>("AccelerateFactor", new AccelerateFactorMotionMapper{ PowerFactor = 1.5 }),
28 new Tuple<string, IAnimatorMotionMapper>("DecelerateFactor", new DecelerateFactorMotionMapper{ PowerFactor = 1.5 }),
29 new Tuple<string, IAnimatorMotionMapper>("SinusoidaFactor", new SinusoidalFactorMotionMapper{ PowerFactor = 1.5 }),
30 new Tuple<string, IAnimatorMotionMapper>("DivisorInterpolate", new DivisorInterpolatedMotionMapper{ Divisor = 1.0, Power = 2.0 }),
31 new Tuple<string, IAnimatorMotionMapper>("CubicBezier", new CubicBezierMotionMapper{ X1 = 0, X2 = 1, Y1 = 0, Y2 = 1})
38 public override void Run(Window window)
40 Rect rect = new Rect(0, 0, window.ScreenSize.Width, window.ScreenSize.Height);
44 X2 = rect.X + rect.Width - rect.Width / 10;
47 square = new Rectangle(window)
49 Geometry = new Rect(X1, Y1, rect.Width / 10, rect.Height / 6),
54 Button btn = new Button(window)
56 Geometry = new Rect(rect.X, rect.Y + rect.Height - rect.Height / 4, rect.Width, rect.Height / 4),
57 Text = mappers[map_index].Item1
61 timelineAnimator = new EcoreTimelineAnimator(1.0, OnTimeline);
63 btn.Clicked += Btn_Clicked;
64 timelineAnimator.Finished += (s, e) =>
66 map_index = (map_index + 1) % mappers.Length;
71 private void Btn_Clicked(object sender, EventArgs e)
73 timelineAnimator.Start();
74 ((Button)sender).IsEnabled = false;
75 Log.Debug(mappers[map_index].Item1);
80 double o = mappers[map_index].Item2.Calculate(timelineAnimator.Position);
81 int x = (int)((X2 * o) + (X1 * (1.0 - o)));
82 int y = (int)((Y2 * o) + (Y1 * (1.0 - o)));