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

Beautiful functions


The first task for our current mission is to create a 2D shape that can be used as a cross section for a vase. We will use polar coordinates to create a circular shape and a function that alters the radius based on the rotational angle to make it look more interesting.

We will also add a GUI using the controlP5 library by Andreas Schlegel to enable the users of our sketch to modify the curve.

Engage Thrusters

Let's start drawing curves:

  1. Start a new Processing sketch and add the setup() and draw() methods.

    void setup() {
    }
    
    void draw() {
    }
  2. Now add two float arrays that will hold the vertex coordinates of our shape. Also add the initialization code to your setup() method. We will use a vertex every 5 degrees, so we need 72 vertices for our shape.

    float vertx[];
    float verty[];
    void setup() {
      size(400,400);
      vertx = new float[72];
      verty = new float[72];
    }
  3. To create the values for our coordinates, we add two methods; one that calculates the radius of our polar coordinates for...