Guide · Processing (Java)

Processing – Learning Guide

Processing is an environment for drawing, animations and simulations. Programs are written in Java and the result is visible on the screen immediately, so it is excellent for learning programming through graphics and physics.

The guide starts with the basics of drawing, continues with vectors and 2D simulations and ends with 3D graphics.

  • Primary and secondary school
  • Graphics and physics
  • Examples in Java
Installation: Processing can be downloaded for free from processing.org. Programs (sketches) are run with the ▶ button in the environment itself.

Some lessons linked below are available only in Serbian for now. They are marked (SR).

1 Introduction to Processing

Installation, the coordinate system, the setup() and draw() functions.

2 Vectors

Vectors are the basis for motion and forces in simulations.

3 2D simulations

Animations of motion from physics, with an explanation of the code.

4 Processing in 3D

Three-dimensional graphics, the camera and transformations.

5 Processing in Python

The same tool can also be used with the Python language.

✎ A short example

A ball that falls and bounces off the floor (simple gravity).

float y = 50;     // position of the ball
float v = 0;      // velocity
float g = 0.4;    // gravitational acceleration

void setup() {
    size(400, 300);
}

void draw() {
    background(230);
    ellipse(200, y, 40, 40);

    v += g;   // velocity grows because of gravity
    y += v;   // position changes by the velocity

    // bouncing off the floor with a loss of energy
    if (y > height - 20) {
        y = height - 20;
        v = -v * 0.8;
    }
}