BVB Source Codes

Gource Show caption.cpp Source code

Return Download Gource: download caption.cpp Source code - Download Gource Source code - Type:.cpp
  1. /*
  2.     Copyright (C) 2010 Andrew Caudwell (acaudwell@gmail.com)
  3.  
  4.     This program is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU General Public License
  6.     as published by the Free Software Foundation; either version
  7.     3 of the License, or (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. */
  17.  
  18. #include "caption.h"
  19.  
  20. RCaption::RCaption(const std::string& caption, time_t timestamp, const FXFont& font) {
  21.  
  22.     this->caption   = caption;
  23.     this->timestamp = timestamp;
  24.     this->font      = font;
  25.    
  26.     alpha   = 0.0;
  27.     elapsed = 0.0;
  28.     colour  = gGourceSettings.caption_colour;
  29. }
  30.  
  31. void RCaption::setPos(const vec2& pos) {
  32.     this->pos = pos;
  33. }
  34.  
  35. const vec2& RCaption::getPos() const {
  36.     return pos;
  37. }
  38.  
  39. const std::string& RCaption::getCaption() const {
  40.     return caption;
  41. }
  42.  
  43. bool RCaption::isFinished() const {
  44.     return elapsed >= gGourceSettings.caption_duration;
  45. }
  46.  
  47. void RCaption::logic(float dt) {
  48.     float fade_in = glm::min(2.0f, gGourceSettings.caption_duration / 3.0f);
  49.     elapsed += dt;
  50.     alpha = glm::min(1.0f, glm::min(elapsed,glm::max(0.0f,gGourceSettings.caption_duration-elapsed)) / fade_in);
  51. }
  52.  
  53. void RCaption::draw() {
  54.     font.setColour(vec4(colour.x, colour.y, colour.z, alpha));
  55.     font.draw(pos.x, pos.y, caption);
  56. }
  57.  
downloadcaption.cpp Source code - Download Gource Source code
Related Source Codes/Software:
FDFullscreenPopGesture - A UINavigationController's category to enable full... 2017-01-10
node-style-guide - A guide for styling your node.js / JavaScript code... 2017-01-09
ImageOptim - GUI image optimizer for Mac htt... 2017-01-09
falcon - Falcon is a low-level, high-performance Python fra... 2017-01-09
prerender - Node server that uses phantomjs to render a javasc... 2017-01-09
che - Eclipse Che: Next-generation Eclipse IDE. Open sou... 2017-01-10
notepad-plus-plus - Notepad++ official repository h... 2017-01-10
waterline - An adapter-based ORM for Node.js with support for ... 2017-01-10
Workerman - An asynchronous event driven PHP framework for eas... 2017-01-10
structor - An advanced visual editor for React components ... 2017-01-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top