Learning Processing 7

Groups of my class were challenged to make an image’s pixels explode using what we have learnt in the past few weeks. This was an interesting and tough challenge and something a group of 4 of us got stuck in with. We revised previous codes we have used and researched how to do this on the internet too and managed to achieve it after about half an hour. The dispersion uses velocity then gravity brings it down. I really liked this challenge, it helped me realise what I do and don’t know; so what to research.. The challenge was enjoyable working in groups and there was a big sense of achievement when we accomplished this. It made for a lot of enjoyment in the lecture and something I would love to do again after a few weeks to recap the new methods we learnt and piece it together in a short project/challenge.

processing7-1 processing7-2 processing7-3

Code –

PImage img;

PVector grav;

ArrayList agents;

int p = 2;

float r,g,b;

void setup(){


img = loadImage(“apple.jpg”);


agents = imageToAgents();


void draw(){


for (int i = 0; i < agents.size(); i++) {

Agent tempA = (Agent)agents.get(i);

if (mousePressed){






ArrayList imageToAgents() {

ArrayList agents = new ArrayList();


for(int x = 0; x < img.width; x += p){

for (int y = 0; y < img.height; y += p){

int loc = x + (y * img.width);

color c = img.pixels[loc];

Agent pixel = new Agent(x,y,c);




return agents;


class Agent {

PVector pos,vel,grav,force;

float x,y;

color c;

Agent(int x, int y, color c){

this.x = x;

this.y = y;

this.c = c;

grav = new PVector (0,random(0.5,1));

pos = new PVector (x,y);

force = new PVector();

vel = new PVector(random(-9,9),random(-9,9));


void update(){






void draw() {







Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s