void CNotificationDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add your message handler code here and/or call default if(nIDEvent==100){ CRect rect; GetWindowRect(rect); int y=EaseOut(_i, src_y, dst_y+1, 50); SetWindowPos(NULL, rect.left, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE); CDC scrdc; scrdc.Attach(::GetDC(0)); BLENDFUNCTION func; func.BlendOp=AC_SRC_OVER; func.AlphaFormat=AC_SRC_ALPHA; func.SourceConstantAlpha=EaseOut(_i, 0, 255, 50); func.BlendFlags=0; UpdateLayeredWindow(&scrdc, &CPoint(rect.left, y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA); ::ReleaseDC(0, scrdc); _i++; if(_i==50){ KillTimer(100); SetTimer(101, 3000, NULL); _i=0; } } if(nIDEvent==101){ KillTimer(101); if(!mouseInside){ SetTimer(102, 10, NULL); }else{ cls=true; } } if(nIDEvent==102){ CRect rect; GetWindowRect(rect); CDC scrdc; scrdc.Attach(::GetDC(0)); BLENDFUNCTION func; func.BlendOp=AC_SRC_OVER; func.AlphaFormat=AC_SRC_ALPHA; func.SourceConstantAlpha=EaseIn(_i, 255, -255, 50); func.BlendFlags=0; UpdateLayeredWindow(&scrdc, &CPoint(rect.left, src_y+dst_y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA); ::ReleaseDC(0, scrdc); _i++; if(_i==50){ KillTimer(102); PostMessage(WM_CLOSE); } } CDialog::OnTimer(nIDEvent); }
void renderTitle(double elapsedTime, const ResourceLoader& resources) { auto tMain = resources.getTextures().getMainTitleTexture(); auto tSub = resources.getTextures().getSubTitleTexture(); auto tSpace = resources.getTextures().getSpacePressTexture(); auto main_y = elapsedTime < 1000 ? (elapsedTime / 1000.0) * (Window::Height() / 4.0f * 2.0f) - Window::Height() / 4.0f : Window::Height() / 4.0f; auto sub_y = 0.0; auto sub_angle = 0.0; auto main_w = tMain.size.x; if (elapsedTime < 1500) sub_y = -Window::Height() / 4.0f; else if (elapsedTime < 2500) sub_y = EaseOut(Easing::Bounce, (elapsedTime - 1500) / 1000.0) * (Window::Height() / 4.0f * 2.0f) - Window::Height() / 4.0f + 24.0f; else sub_y = Window::Height() / 4.0f + 24.0f; if (elapsedTime < 3000) sub_angle = 0.0; else if (elapsedTime < 3200) sub_angle = ((elapsedTime - 3000) / 200) * 5.0f; else sub_angle = 5.0f; tMain.draw(Vec2((Window::Width() - main_w) / 2.0f, main_y)); tSub.rotateAt(Vec2(0.0f, tSub.size.y), Math::Radians(sub_angle)).draw(Vec2((Window::Width() + main_w) / 2.0f, sub_y)); if (elapsedTime >= 4000) { if (Math::Fmod(elapsedTime, 1000.0) < 500.0) { tSpace.draw(Vec2((Window::Width() - tSpace.size.x) / 2.0, Window::Height() / 4.0 * 3.0)); } } }
void CNotificationWnd::DoTransitionIn(){ RECT rect; GetWindowRect(&rect); int src_y=rect.top; int dst_y=-30; for(int i=0;i<50;i++){ int y=EaseOut(i, src_y, dst_y+1, 50); SetWindowPos(NULL, rect.left, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE); CDC scrdc; scrdc.Attach(::GetDC(0)); BLENDFUNCTION func; func.BlendOp=AC_SRC_OVER; func.AlphaFormat=AC_SRC_ALPHA; func.SourceConstantAlpha=EaseOut(i, 0, 255, 50); func.BlendFlags=0; UpdateLayeredWindow(&scrdc, &CPoint(rect.left, y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA); ::ReleaseDC(0, scrdc); _sleep(10); } for(int i=0;i<300;i++){ _sleep(10); if(needClose)break; } while(mouseInside && !needClose){ _sleep(10); } if(!this)return; for(int i=0;i<50;i++){ CDC scrdc; scrdc.Attach(::GetDC(0)); BLENDFUNCTION func; func.BlendOp=AC_SRC_OVER; func.AlphaFormat=AC_SRC_ALPHA; func.SourceConstantAlpha=EaseIn(i, 255, -255, 50); func.BlendFlags=0; UpdateLayeredWindow(&scrdc, &CPoint(rect.left, src_y+dst_y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA); ::ReleaseDC(0, scrdc); _sleep(10); } SendMessage(WM_CLOSE); }
double easeOut(double easingFunction(double) = Easing::Quart) const { return EaseOut(easingFunction, m_value); }
Type easeOut() const { return EaseOut(m_start, m_end, m_easingFunction, elapsed()); }
[[nodiscard]] inline constexpr Type EaseOut(double f(double), const Type& start, const Type& end, const double t) { return Math::Lerp(start, end, EaseOut(f, t)); }
[[nodiscard]] inline constexpr double EaseInOut(double f(double), const double t) { return (t < 0.5) ? f(2.0 * t) * 0.5 : 0.5 + EaseOut(f, 2.0 * t - 1.0) * 0.5; }
float CCinemaPath::EaseOutIn(float t) const { if (t < m_Switch) return EaseOut(1.0f/m_Switch * t) * m_Switch; return EaseIn(1.0f/m_Switch * (t-m_Switch)) * m_Switch + m_Switch; }
[[nodiscard]] constexpr double easeOut(double easingFunction(double) = Easing::Quart) const { return EaseOut(easingFunction, m_value); }
float Bounce::EaseInOut( float t, float b, float c, float d ) { if ( t < d / 2 ) return EaseIn( t * 2, 0, c, d ) * .5f + b; else return EaseOut( t * 2 - d, 0, c, d ) * .5f + c*.5f + b; }
float Bounce::EaseIn( float t, float b, float c, float d ) { return c - EaseOut( d - t, 0, c, d ) + b; }