Book Image

Processing 2: Creative Coding Hotshot

By : Nikolaus Gradwohl
Book Image

Processing 2: Creative Coding Hotshot

By: Nikolaus Gradwohl

Overview of this book

Processing makes it convenient for developers, artists, and designers to create their own projects easily and efficiently. Processing offers you a platform for expressing your ideas and engaging audiences in new ways. This book teaches you everything you need to know to explore new frontiers in animation and interactivity with the help of Processing."Processing 2: Creative Coding Hotshot' will present you with nine exciting projects that will take you beyond the basics and show you how you can make your programs see, hear, and even feel! With these projects, you will also learn how to build your own hardware controllers and integrate devices such as a Kinect senor board in your Processing sketches.Processing is an exciting programming environment for programmers and visual artists alike that makes it easier to create interactive programs.Through nine complete projects, "Processing 2: Creative Coding Hotshot' will help you explore the exciting possibilities that this open source language provides. The topics we will cover range from creating robot - actors performing Shakespeare's "Romeo and Juliet", to generating objects for 3D printing, and you will learn how to run your processing sketches nearly anywhere from a desktop computer to a browser or a mobile device.
Table of Contents (16 chapters)
Processing 2: Creative Coding Hotshot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Processing is an open source programming language that was invented by Casey Reas and Benjamin Fry in 2001 for the Aesthetics and Computation group at the MIT Media Lab. The language is designed to serve as a sketchbook for visual design applications, media art, electronic arts, and teaching.

Processing 2: Creative Coding Hotshot will present you with nine exciting complete projects that will show you how to go beyond the basics and make your programs see, hear, and feel.

The projects show you how to make use of devices like a Kinect sensor board or an Arduino board in the Processing sketches.

What this book covers

Project 1, Romeo and Juliet, will help you learn how to make some cardboard robots that perform the famous balcony scene from Shakespeare's Romeo and Juliet. We will create some talking robots using a pair of cheap speakers and some cardboard boxes, and learn how to install and use a text-to-speech library in Processing.

Project 2, The Stick Figure Dance Company, will help you in creating a dance company that is controlled using Microsoft Kinect. The dancers will be controlled using the Kinect skeletal tracking. After we have managed to control one stick figure, we will make more and more stick figures show up until we have a whole dance company, dancing the same moves the player makes.

Project 3, The Disco Dance Floor, will teach us how to play music and create a sound-reactive dance floor, since there is no dancing without music. We will learn how to use the Processing-sound API to make an audio visualizer. Then we will turn the 2D visualizer into a 3D dancefloor and invite our stick figure dance company from the previous project to dance on it.

Project 4, Smilie-O-Mat, will help you in creating an application that allows the user to create a smiley that matches his or her current mood using a customized user interface. This smiley can then be posted to a social network to let your buddies know how you currently feel, because sometimes a picture tells more than 140 characters.

Project 5, The Smilie-O-Mat Controller, helps you generate a custom controller board using Arduino and use it to simplify the adjustment of the Smilie-O-Mat controller from our previous project. For the controller, we will use an Arduino board, learn how to set up a simple electronic circuit, and then how to interface it with a computer. Then we will use the input parameters generated by the controller to change the face of a smiley and post it to a social network.

Project 6, Fly to the Moon, explores the different modes Processing offers and teaches you how to export a sketch for the Web or run it as an Android app. We will create a small moon-lander-like game from scratch and learn how to adapt it to run on different hardware as well as use different input devices.

Project 7, The Neon Globe, wonders what world-domination plans would be without a spinning neon globe? Here, we will learn how to generate a rotating 3D sphere that we will turn into a spinning globe using image textures and some lighting. We will later highlight the continent borders and make them glow using a GLSL filter.

Project 8, Logfile Geo-visualizer, will help us learn how to visualize some data on the spinning globe we generated in the previous project. We will use a web server logfile as our input and learn how to parse it in Processing. Then, we will geocode the data and use the geocoordinates of the page requests to draw something on our globe.

Project 9, From Virtual to Real, will help us learn how to turn mathematics into physical objects. We will learn how to unleash the beauty of mathematical functions and use them to generate a printable object like a pen box or a flower vase. Then, we will learn how to export the object to a format that can be fed into a 3D printer.

What you need for this book

Project 2, The Stick Figure Dance Company, shows you how to use Kinect to create a stick figure that is controlled by the player's movements. To run this example, you will need a Kinect sensor board and a power adapter for it.

Project 5, The Smilie-O-Mat Controller, uses an Arduino board and some electronic components to create a customized hardware controller.

In Project 6, Fly to the Moon, we will create a game that runs on a PC, in a web browser, and on an Android device. If you want to see the game on a real device instead of an emulator, you need an Android mobile phone or tablet.

Project 9, From Virtual to Real, shows you how to create a 3D shape and turn it into a physical object using 3D printing or an online 3D printing service.

Who this book is for

If you are a programmer or a visual artist that already has some experience with the Processing environment or another language similar to Java and want to make programs that reach beyond a window on your screen, this book is for you.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Mission Briefing

This section explains what you will build, with a screenshot of the completed project.

Why Is It Awesome?

This section explains why the project is cool, unique, exciting, and interesting. It describes what advantage the project will give you.

Your Hotshot Objectives

This section explains the major tasks required to complete your project.

  • Task 1

  • Task 2

  • Task 3

  • Task 4, and so on

Mission Checklist

This section explains any pre-requisites for the project, such as resources or libraries that need to be downloaded, and so on.

Task 1

This section explains the task that you will perform.

Prepare for Lift Off

This section explains any preliminary work that you may need to do before beginning work on the task.

Engage Thrusters

This section lists the steps required in order to complete the task.

Objective Complete - Mini Debriefing

This section explains how the steps performed in the previous section allow us to complete the task. This section is mandatory.

Classified Intel

The extra information in this section is relevant to the task.

You will also 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: "Now we add a mousePressed() method to our sketch, which gets called if someone clicks on our sketch window."

A block of code is set as follows:

void mousePressed() {
  tts.speak("Hello, I am a Computer");
}

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 setup() {
  String[] rawLines = loadStrings( "romeo_and_juliet.txt" );

  ArrayList lines = new ArrayList();
  for ( int i=0; i<rawLines.length; i++) {
    if (!"".equals(rawLines[i])) {
      String[] tmp = rawLines[i].split("#");
      lines.add( new Line( tmp[0], tmp[1].trim() ));
    }
  }

}

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: "In the Library Manager dialog, enter ttslib in the search field to filter the list of libraries."

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/6726OS_Processing_2_Creative_Coding_Hotshot_Color_Graphics.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 copyrighted 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.