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

Preface

Cinder is one of the most powerful open source creative coding frameworks that is available right now on the Internet. It is based on one of the most popular and powerful intermediate-level programming language C++ and relies on minimum third-party libraries. It is a combination of low-level and high-level language features, and that makes it relatively easy to grasp for those who have a higher-level programming language background.

Cinder can be considered the next-level creative coding framework for those who are familiar with Processing, ActionScript, or other similar high-level programming languages or frameworks. Cinder may seem similar to openFrameworks, it is, in terms since it is based on C++, but the philosophy behind the framework is a bit different.

openFrameworks is based on a lot of third-party libraries that do the job and sometimes may make a simple application to be big in size. Cinder is different in terms, that is, it tries to make use of the features of the operating system that it runs on. It does not mean that it is better than openFrameworks, but for some scenarios it may be more efficient than the other one.

Programming is something that rapidly becomes a skill that everyone should know. Estonia just introduced computer programming learning for all children attending school, meaning that everyone from Grades 1 to 12 are learning how to code. It is not hard to believe that there will be a lot of other countries that will follow. This means that in the future computer technology will be everywhere more than it is today and the situation will demand a vast amount of people who will need to take care of it. Another fact is that we most probably will see programming in more and more fields that previously had weak or absolutely no connection to it.

And that is where creative coding comes in. Creative coding is becoming more and more popular these days as even more people start to appreciate the logical and interactive dimension that programming can give to their work. It is possible to create a painting that paints itself, a live sculpture, or an interactive chair that does not let anyone to sit on it—the possibilities are endless. It is only the matter of ones creativity and programming knowledge.

One thing that is important in todays creative coding frameworks is performance and flexibility. Usually the more powerful and flexible a framework is, the harder it is to learn it. As Cinder is both, flexible, and powerful, it is not an easy task to understand how to use it.

This book is a trial to make the Cinder learning curve less steep. Through a collection of simple guided examples, we will try to cover the basic functionality that is usually provided by other creative coding tools.

What this book covers

Chapter 1, Learn Cinder Basics – Now!, provides a brief introduction about creative coding and Cinder. It will help you to set up and test Cinder on Mac OS X and Windows machines.

Chapter 2, Know What is Possible – The Cinder Toolset, introduces you to various basic tasks that can be performed with Cinder through compiling, running, and discussing some of the Cinder sample applications.

Chapter 3, Initial Setup – Creating the BaseApp, explains how to create a base project by using Cinder's integrated tool TinderBox, and from scratch.

Chapter 4, Prepare Your Brushes – Drawing Basic Shapes, provides insight into Cinder's built-in basic shape drawing functions that are usually there in other creative coding frameworks.

Chapter 5, Making Use of Images – Loading and Displaying, explains loading and displaying of images, which is an important part of every creative coding language. In this chapter we will learn how to load and display images from local and networked storage with Cinder.

Chapter 6, Accelerate – Creating Generative Animation, teaches the basics of generative or procedural animation with Cinder. Throughout the chapter we will create an infinite looped animation application.

Chapter 7, Working with Images – Real-time Postprocessing and Effects, explains the several features that Cinder provides to let you manipulate images, and moving image frames down to the pixel level without loosing speed. In this chapter we will learn how to use Cinder for applying and creating basic effects for still images and real-time use.

Chapter 8, Adding Depth – Cinder 3D Basics, introduces you to the basic 3D aspects and practical methods, as well as the 3D primitives that can be drawn with Cinder.

Chapter 9, Enter Sound – Adding Sound and Audio, explains how to load, modify, play back, and use sound files, as well as live audio input to draw and animate.

Chapter 10, Talk to the User – Adding Interactivity and UI Events, explains how to handle mouse, keyboard, and other events in Cinder.

Appendix A, Basic Cinder Functionality Reference, helps you find some basic Cinder functionality used in this book for later reference.

Bonus Chapter, Escaping Singleness – Communicating with Other Applications, is not present in the book but is available for download at the following link: http://www.packtpub.com/sites/default/files/downloads/Escaping_Singleness.pdf

What you need for this book

All you need is a Mac OS X or Windows computer. The code samples in this book are tested on Mac OS X 10.6+ and Windows 7 machines. There is a list of development software for each operating system and further details about it will be discussed in the following chapters. In this book we will make use of the following software:

Mac OS X

  • Xcode 3+ or Xcode 4+

  • MadMapper

Windows

  • Microsoft Visual C++ 10+

  • Windows platform SDK

  • DirectX SDK

  • QuickTime SDK

Both

  • Pure Data

Who this book is for

This book is for those who want to make a change either from a lower-level creative coding framework or from other kinds of coding to creative coding with Cinder. You will not find an introductory chapter about programming in general in this book, you should know something about it already.

This book is for you if you have previous experience with text-based programming languages such as Processing, ActionScript, JavaScript, or visual ones, such as Pure Data, Max MSP, VVVV, or Quartz Composer.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

void TextBoxApp::render()
{
  string txt = "Here is some text that is larger than can fit 
  naturally inside of 100 pixels.\nAnd here is another line after 
  a hard break."; [default]

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

void TextBoxApp::render()
{
  string txt = "Here is some text that is larger than can fit 
  naturally inside of 100 pixels.\nAnd here is another line after 
  a hard break."; [default]

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output.

You can download this file from:

http://www.packtpub.com/sites/default/files/downloads/9564OS_ColoredImages.pdf

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.