Now, say we want to make use of the easing algorithms that we saw in the EaseGallery
sample. To do that, we have to change the code by following certain steps.
To use the easing functions, we have to include the Easing.h
header file:
#include "cinder/Easing.h"
First we are going to add two more variables, startPostition
and circleTimeBase
:
Vec2f startPosition[CIRCLE_COUNT]; Vec2f currentPosition[CIRCLE_COUNT]; Vec2f targetPosition[CIRCLE_COUNT]; float circleRadius[CIRCLE_COUNT]; float circleTimeBase[CIRCLE_COUNT];
Then, in the setup()
method implementation, we have to change the currentPosition
parts to startPosition
and add an initial value to the circleTimeBase
array members:
startPosition[i].x = Rand::randFloat(0, getWindowWidth()); startPosition[i].y = Rand::randFloat(0, getWindowHeight()); circleTimeBase[i] = 0;
Next, we have to change the update()
method so that it can be used along with the easing functions. They are based on time and they return a floating point value...