Back to index

nux  3.0.0
TimelineEasings.cpp
Go to the documentation of this file.
00001 #include "Nux.h"
00002 #include "Timeline.h"
00003 #include "TimelineEasings.h"
00004 
00005 namespace nux
00006 {
00007   TimelineEaseInOutQuad::TimelineEaseInOutQuad(unsigned int msecs, const char *Caption, NUX_FILE_LINE_DECL)
00008     :   Timeline(msecs, Caption, NUX_FILE_LINE_PARAM)
00009   {
00010   }
00011 
00012   double TimelineEaseInOutQuad::GetEasing()
00013   {
00014     double prog = GetProgress();
00015     prog *= 2.0;
00016     if (prog < 1)
00017     {
00018       return (prog * prog) * 0.5;
00019     }
00020 
00021     prog -= 1.0;
00022 
00023     return -0.5 * (prog * (prog - 2) - 1);
00024   }
00025 
00026 
00027   TimelineEaseInQuad::TimelineEaseInQuad(unsigned int msecs, const char *Caption, NUX_FILE_LINE_DECL)
00028     :   Timeline(msecs, Caption, NUX_FILE_LINE_PARAM)
00029   {
00030   }
00031 
00032   double TimelineEaseInQuad::GetEasing()
00033   {
00034     double prog = GetProgress();
00035     return prog * prog;
00036   }
00037 
00038 
00039   TimelineEaseOutQuad::TimelineEaseOutQuad(unsigned int msecs, const char *Caption, NUX_FILE_LINE_DECL)
00040     :   Timeline(msecs, Caption, NUX_FILE_LINE_PARAM)
00041   {
00042   }
00043 
00044   double TimelineEaseOutQuad::GetEasing()
00045   {
00046     double prog = GetProgress();
00047     return -1.0 * prog * (prog - 2);
00048   }
00049 
00050   TimelineEaseInOutCubic::TimelineEaseInOutCubic(unsigned int msecs, const char *Caption, NUX_FILE_LINE_DECL)
00051     :   Timeline(msecs, Caption, NUX_FILE_LINE_PARAM)
00052   {
00053   }
00054 
00055 
00056   double TimelineEaseInOutCubic::GetEasing()
00057   {
00058     double prog = GetProgress();
00059     prog *= 2.0;
00060 
00061     if (prog < 1)
00062       {
00063         return (prog * prog * prog) * 0.5;
00064       }
00065 
00066     prog -= 2.0;
00067     return 0.5 * (prog * prog * prog + 2.0);
00068   }
00069 
00070   TimelineEaseInCubic::TimelineEaseInCubic(unsigned int msecs, const char *Caption, NUX_FILE_LINE_DECL)
00071     :   Timeline(msecs, Caption, NUX_FILE_LINE_PARAM)
00072   {
00073   }
00074 
00075 
00076   double TimelineEaseInCubic::GetEasing()
00077   {
00078     double prog = GetProgress();
00079     return prog * prog * prog;
00080   }
00081 
00082   TimelineEaseOutCubic::TimelineEaseOutCubic(unsigned int msecs, const char *Caption, NUX_FILE_LINE_DECL)
00083     :   Timeline(msecs, Caption, NUX_FILE_LINE_PARAM)
00084   {
00085   }
00086 
00087 
00088   double TimelineEaseOutCubic::GetEasing()
00089   {
00090     double prog = GetProgress();
00091     prog -= 1.0;
00092     return prog * prog * prog + 1.0;
00093   }
00094 }