Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- namespace EasingTest
- {
- class MainClass
- {
- static int width = 75;
- static int frameDelay;
- public static float QuadEaseInOut(float time)
- {
- return time < 0.5f ? 2.0f * time * time : -1.0f + (4.0f - 2.0f * time) * time;
- //return t<.5 ? 2*t*t : -1+(4-2*t)*t
- }
- public static void displayEase(float time)
- {
- float ease = QuadEaseInOut(time);
- int nextWidth = (int)(ease * width);
- Console.Write("{0}{2}{1}\r", new string(' ', nextWidth), new String(' ', width - nextWidth), 'o');
- }
- public static void Main(string[] args)
- {
- Console.Write("Enter the frame delay: ");
- frameDelay = int.Parse(Console.ReadLine());
- int count = 0;
- float step = 0.01f;
- bool dir = false; // false = right->left, true = left->right
- while(count < 10)
- {
- if(!dir)
- {
- for(float t = step; t < 1; t += step)
- {
- displayEase(t);
- Thread.Sleep(frameDelay);
- }
- dir = true;
- }
- else
- {
- for(float t = 1; t > 0; t -= step)
- {
- displayEase(t);
- Thread.Sleep(frameDelay);
- }
- dir = false;
- }
- count++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement