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

Running your sketch in the browser


The next task of our current mission is to take the game we have created in the previous task and make it run in the browser using JavaScript. We will use the Processing.js mode to make our script run and we will create a customized HTML template for our game. The Processing.js mode allows us to run sketches that don't use any external libraries with little to no change in a modern browser.

Engage Thrusters

Let's convert the game to a browser application:

  1. Open our sketch and switch from the Processing mode to the JavaScript mode by clicking on the icon above the New Tab icon and selecting JavaScript , as shown in the following screenshot:

  2. Now run the sketch. Processing starts a small web server in the background and opens the default browser with an HTML page running our game. This following screenshot shows the game running in a Firefox browser:

  3. Processing.js is implementing a little workaround to make the image loading work. If we run our code as it is, it...