Animating text around curves
In this recipe, we will learn how we can animate text around a user-defined curve.
We will create the
Letter
and Word
classes to manage the animation, a ci::Path2d
object to define the curve, and a ci::Timer
object to define the duration of the animation.
Getting ready
Create and add the following files to your project:
Word.h
Word.cpp
Letter.h
Letter.cpp
How to do it…
We will create a word and animate its letters along a ci::Path2d
object. Perform the following steps to do so:
In the
Letter.h
file, include the necessary to use thetext
,ci::Vec2f
, andci::gl::Texture
files.Also add the
#pragma once
macro#pragma once #include "cinder/vector.h" #include "cinder/text.h" #include "cinder/gl/Texture.h"
Declare the
Letter
class with the following members and methods:class Letter{ public: Letter( ci::Font font, conststd::string& letter ); void draw(); void setPos( const ci::Vec2f& newPos ); ci::Vec2f pos; float rotation; ci::gl::Texture texture...