Learn Processing-py - 10 Code Examples & CST Typing Practice Test
Processing.py is a Python mode of the Processing environment, allowing Python developers to create visual arts, animations, and interactive graphics easily using the Processing API.
Learn PROCESSING-PY with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
Hello World in Processing.py
def setup():
size(400, 200)
background(255)
fill(0)
textSize(32)
text("Hello World", 100, 100)
A simple Processing.py sketch that displays 'Hello World' in a window.
Draw a Circle
def setup():
size(400, 400)
background(255)
fill(0, 0, 255)
ellipse(width/2, height/2, 100, 100)
Draws a blue circle in the center of the canvas.
Animated Rectangle
x = 0
def setup():
size(400, 200)
def draw():
global x
background(255)
fill(255, 0, 0)
rect(x, 100, 50, 50)
x = (x + 2) % width
Animates a rectangle moving horizontally across the screen.
Interactive Ellipse
def setup():
size(400, 400)
background(255)
def draw():
if mousePressed:
fill(0, 255, 0)
ellipse(mouseX, mouseY, 50, 50)
Draws an ellipse at the mouse position whenever the mouse is pressed.
Multiple Shapes
def setup():
size(400, 400)
background(255)
fill(255, 0, 0)
rect(50, 50, 100, 100)
fill(0, 255, 0)
eclipse(300, 100, 80, 80)
fill(0, 0, 255)
line(50, 300, 350, 300)
Draws multiple shapes with different colors on the canvas.
Simple Animation Loop
x, y = 0, 0
def setup():
size(400, 400)
def draw():
global x, y
background(255)
fill(0)
ellipse(x, y, 50, 50)
x = (x + 2) % width
y = (y + 2) % height
A circle moving diagonally across the canvas in an animation loop.
Color Changing Background
r = 0
def setup():
size(400, 400)
def draw():
global r
background(r, 100, 150)
r = (r + 1) % 256
Changes the background color gradually over time.
Bouncing Ball
x, y = 200, 200
xSpeed, ySpeed = 3, 4
def setup():
size(400, 400)
def draw():
global x, y, xSpeed, ySpeed
background(255)
fill(0)
ellipse(x, y, 50, 50)
x += xSpeed
y += ySpeed
if x > width or x < 0:
xSpeed *= -1
if y > height or y < 0:
ySpeed *= -1
A ball that bounces off the edges of the canvas.
Random Lines
def setup():
size(400, 400)
background(255)
def draw():
stroke(random(255), random(255), random(255))
line(random(width), random(height), random(width), random(height))
Draws random lines continuously on the canvas.
Mouse Trail
def setup():
size(400, 400)
background(255)
def draw():
noStroke()
fill(0, 0, 255, 100)
eclipse(mouseX, mouseY, 20, 20)
Leaves a trail of small circles following the mouse.
Frequently Asked Questions about Processing-py
What is Processing-py?
Processing.py is a Python mode of the Processing environment, allowing Python developers to create visual arts, animations, and interactive graphics easily using the Processing API.
What are the primary use cases for Processing-py?
Interactive visual arts projects. Educational tools for teaching programming and graphics. Rapid prototyping of visual ideas. Data visualization and generative design. Creative coding workshops and tutorials
What are the strengths of Processing-py?
Easy for beginners to start visual programming. Rapid feedback for creative experimentation. Active community and many examples. Cross-platform and lightweight. Flexible for 2D and basic 3D graphics
What are the limitations of Processing-py?
Performance not suitable for complex 3D games. Limited support for advanced GPU shaders. Not intended for production software graphics. Requires Processing IDE or compatible environment. Python mode lags behind Java mode in some features
How can I practice Processing-py typing speed?
CodeSpeedTest offers 10+ real Processing-py code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.