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
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.
Java and Processing – introduction
What Processing is and what the first sketch looks like.
Open lesson →Processing basics
Drawing shapes, colours and a simple animation.
Open lesson →Processing and the micro:bit
Controlling graphics with a micro:bit device.
Open lesson →Mouse and keyboard interaction (SR)
Mouse position and clicks, keys and arrows, the game "Hit the target".
Open lesson →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.
Animation of projectile motion
The motion of a body thrown at an angle.
Open lesson →Projectile motion – a football game
A game based on projectile motion.
Open lesson →Sliding down an inclined plane
A simulation of a body on an inclined plane.
Open lesson →Analysis of a sliding body
Forces and acceleration on an inclined plane.
Open lesson →Rotational motion
An animation of motion along a circle.
Open lesson →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;
}
}
