Category: Exercises

  • Using External Data

    There are many ways of getting data into a Processing sketch from importing a simple image, 3D geometry or importing spread sheet data and the list goes on. But amongst the simplest and most versatile methods of getting external data into Processing is by means of a text file. A text file imported into a…

  • Button Class: Part 2 Object Instantiation

    This is the second part of the Button Class Exercise (see part one) Object instantiation is not a new concept to you as you have already instantiated objects from the PImage class. The process of instantiating an object from our Button class will follow a very similar pattern. Since we want this object to be…

  • Button Class: Part 1

    This is the first part of the Button Class Exercise (see part two) If we wanted to create a class for a button, that we will call Button. This class will  have fields that will contain certain information about the object instantiated from the class such as the color of the button, it’s size and position. The class…

  • Intro to Objects

    As mentioned a class typically consists of method definitions and various fields (which we also refer to as member variables) that store information about the current state of the object instantiated from the class. The term fields refers to variables that are members of a particular class, and as a result are encapsulated data that…

  • Growing & Shrinking Circle

    int diam = 10; float centX, centY; boolean growth; void setup() { size(600, 600); frameRate(24); smooth(); background(180); centX = width/2; centY = height/2; stroke(0); strokeWeight(5); fill(255,50); } void draw() { if (growth) { bigger(); } else { smaller(); }; } void bigger() { background(180); ellipse(centX, centY, diam, diam); diam += 10; if (diam >=width) {…

  • Data Visualization Basic Example

    Here’s our first example of a Data Visualization: Your first task is to download the assets needed to make this visualization work: A map: map.png Some Data: locations.tsv /* Geographic Data Visualization take some data and plot it out onto a map */ PImage mapImage; Table locationTable; int rowCount; void setup() { size(640, 400); mapImage…

  • Randomizing a Line

    size(500, 100); int step = 10; float lastX = -999; float lastY = -999; float y= 50; int borderY = 20; for (int x=20; x-999) { line(x, y, lastX, lastY); } lastX = x; lastY = y; } size(500, 100); int step = 10; float lastX = -999; float lastY = -999; float y= 50;…

  • Growing Circle

    Open a new script and enter the code in the following code. Don’t worry about if you don’t understand all the instructions in the function blocks – a few more new concepts are being introduced here we’ll step through: int diam = 10; float centX, centY; void setup() { size(500, 300); frameRate(24); smooth(); background(180); centX…

  • Drawing Circles (the hard way)

    First we took a basic line and reconstructed it the hard way in order to alter that line in interesting random ways. Now we’re going to do the same with the circle. You know the drill, first we draw a circle the hard way: // a simple circle drawn by rotating dots around a constant…

  • Exporting

    Web page exporting Standalone Application   High Resolution PDF   Export Images Movies