Book Image

Cinder - Begin Creative Coding

By : Krisjanis Rijnieks
Book Image

Cinder - Begin Creative Coding

By: Krisjanis Rijnieks

Overview of this book

<p>Cinder is one of the most powerful professional grade C++ creative coding frameworks out there. It is open-source and peer-reviewed, meaning that there are experienced professionals behind its developmentand that every development step is taken seriously. Its philosophy is based on the capabilities of the operating system it is used for - Cinder will take the best from every OS and hardware you choose to work on.</p> <p><em>Cinder - Begin Creative Coding</em> will let you take your previous creative coding experience to a higher and also more demanding level. It will show you the Cinder way of using the most used creative coding functions for drawing, animation, interaction and allow you to do much more in terms of performance and cross-application-compatibility.</p> <p>Starting by downloading Cinder and setting up the development environment, we will work through some of the most widely used topics in creative coding by creating and discussing simple sample applications.</p> <p>Throughout this book we will deal with relatively simple topics like basic drawing, basic animation, basic 3D, interaction, loading files, playing back video files, applying built in and custom effects. Then going through to more advanced topics like how to use Cinder for a generative projection mapping project by using Syphon technology and how to connect Open Sound Control enabled applications for receiving and sending data and commands.</p> <p><em>Cinder - Begin Creative Coding</em> will bring your craziest ideas closer to the core of your computer by using the pure power of C++.</p>
Table of Contents (19 chapters)
Cinder – Begin Creative Coding
Credits
About the Author
About the Reviewers
About the Reviewers
www.PacktPub.com
Preface
10
Talk to the User – Adding Interactivity and UI Events
Index

Using built-in eases


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...