Animating text – scrolling text lines
In this recipe we will learn how we can create text scrolling line-by-line.
How to do it…
We will now create an animation with scrolling text. Perform the following steps to do so:
Include the necessary header files.
#include "cinder/gl/Texture.h" #include "cinder/Text.h" #include "cinder/Font.h" #include "cinder/Utilities.h"
Add the member values.
vector<gl::Texture> mTextTextures; Vec2f mTextSize;
Inside the
setup
method we need to generate textures for each line of text.setWindowSize(854, 480); string font( "Times New Roman" ); mTextSize = Vec2f::zero(); į for(int i = 0; i<5; i++) { TextLayout layout; layout.clear( ColorA(0.f,0.f,0.f, 0.f) ); layout.setFont( Font( font, 48 ) ); layout.setColor( Color( 1, 1, 1 ) ); layout.addLine( "Animating text " + toString(i) ); Surface8u rendered = layout.render( true ); gl::TexturetextTexture = gl::Texture( rendered ); textTexture.setMagFilter(GL_NICEST); textTexture.setMinFilter...