Final outcome

After playing around with the code for a while, adjusting colours and speeds and the line between functions I settled on this as my final wall paper –

I went for a strong black and white contrast with the background and the inbetween lines as they make such beautiful geometric shapes when the interact with each other that I wanted this to be them main focus then with a nice bold hint of colour on the circles to brighten it up a bit.

It works great as a desktop background but also, in a futuristic sense, if projected on a wall I think it’d be well suited as a feature wall for a bar or restaurant as it’s really quite transfixing soothing.

Final code –

ballCollection = new ArrayList();
for (int i = 0; i<200; i++) {
 Vec3D origin = new Vec3D(random(width), random(200), 0);
 Ball myBall = new Ball(origin);
 ballCollection.add(myBall);
 }
}
void draw() {
background(0);
//Calls the function of the class. The '.' opens up the class.
for (int i = 0; i<ballCollection.size(); i++) {
 Ball mb = (Ball) ballCollection.get(i);
 mb.run();
 }
}
class Ball {
//global variables. location, speed...
Vec3D loc = new Vec3D (0, 0, 0);
 Vec3D speed = new Vec3D(random(-4, 4), random(-4, 4), 0);
Vec3D grav = new Vec3D(0, 0.01, 0);
 //constructor. how to build the class, calling variables, happens just once.
 Ball(Vec3D _loc) {
loc = _loc;
 }
 //functions.
 void run() {
 display();
 move();
 bounce();
 //gravity();
 lineBetween();
 }
 void lineBetween() {
for (int i = 0; i <ballCollection.size(); i++) {
Ball other = (Ball) ballCollection.get(i);
float distance = loc.distanceTo(other.loc);
if (distance > 0 && distance < 100) {
 stroke(244,221,173);
 strokeWeight(0.4);
 line(loc.x, loc.y, other.loc.x, other.loc.y);
 }
 }
 }
 
 void bounce() {
if (loc.x > width) {
 speed.x = speed.x * -1;
 }
 if (loc.x < 0) {
 speed.x = speed.x * -1;
 }
 if (loc.y > height) {
 speed.y = speed.y * -1;
 }
 if (loc.y < 0) {
 speed.y = speed.y * -1;
 }
 }
 void move() {

loc.addSelf(speed);
}void display() {
noStroke();
fill(243,5,114);
ellipse(loc.x, loc.y, 20, 20);
}
}

In this project I put a lot of my focus into full understanding the code I was writing, a lot of the time I found myself re writing the code over and over again so I could know how and why it was written. I think this has resulted in my final wallpaper not being that ambitious in design but the coding elements behind it being very complex under the surface. Its has allowed me to learn and understand how build basic shapes, how to use
variable to animate these shapes and get my head around the
types of variables like integers and floats then apply things like ‘if’
conditional statement and for loops to these variables. I then delved a little deeper watching hours of tutorials online to look at building classes and class instances with init and furthermore adding arraylists into this so I could build a collection of my class instances easily. From here I looked into changing my code so it used a vector library called toxiclibs which I had imported, I haven’t fully got my head around this part just yet but I plan on continuing to try and learn it. Finally I played around with lots of different functions. I found the structure of these really easy to understand and using the references on the processing website I was able to play around with such things as bounce, gravity and creating a line between my elements.

I’ve actually found myself really interested in this type of coding language and want to continue to build my knowledge of the subject to I can make my results a lot more unique and interesting pieces of interactive design. A lot of my research looked into mapping projections and this is something I would love to look into more in the future.

Steering behaviours and line between function

Finally, I learnt a behavioural function called ‘lineBetween’ which works with if statements and executes a visual behaviour if the class instance does a certain thing.

‘line between’ literally does what it says on the tin. It creates a line between the class instances. It goes with in the ‘void run’ function and then you create its own ‘void lineBetween’ where this section of code goes

for (int i = 0; i <ballCollection.size(); i++) {
Ball other = (Ball) ballCollection.get(i);
float distance = loc.distanceTo(other.loc);
if (distance > 0 && distance < 80) {
 stroke(255);
 strokeWeight(0.4);
 line(loc.x, loc.y, other.loc.x, other.loc.y);

This part of the code states that if the distance between the instances of the class are more than 0 and less than 80 connect them with a white line that has a weight of 0.4.

Which looks like this –

I played around with colours and speeds and changing the distance of when the lines will appear.