top of page

A Sequence of Primitives

21 Aug 2020

Written by: Yasmin Dullabh

Visualising a Statistic Presentation Through Code

the ocean absorbs around 23 per cent of the annual emissions of anthropogenic carbon dioxide to the atmosphere ... resulting in a decreasing pH and acidification of the ocean (United Nations, 2020).
 

The first thing I wanted to do was make sure I fully understood the weight of the statistic, and I began to unpack the statistic via a brainstorm.

From here, I began to draw out some ideas for how I could visualise this statistic.


I chose idea four as I felt that it had more impact than idea one, as well as it is visually more attractive. I also chose idea four over idea two, as I felt that it was less literal in its visualisation of the statistic.

 

Actually putting this idea into code was the most challenging part for me. Getting the water to change in colour as specific circles hit the water was something I was finding quite hard to do. After discussing it with a friend, I decided that having them change from circles into arcs, and then increasing in size would be an easier way to do this. This also shows the pollution dissolving into the water, creating a cleaner and more visually appealing design.



Lastly, I had to choose between two designs, one where the grey circles disappeared as they hit the water, or where they sunk to the bottom but did not dissolve as the black circles did.




In the end, I chose the one where they sink, as I felt it showed that only 23% of anthropogenic carbon dioxide is absorbed better than having them disappear.


int circlePositionX[]; // an array to hold our X position
int circlePositionY[]; // an array to hold our Y position
int circleSize[]; // an array to hold our size
int circle2PositionX[]; // an array to hold our X position for circle 2
int circle2PositionY[]; // an array to hold our Y position for circle 2
int circle2Size[]; // an array to hold our size for circle 2
int showDots = 0; // circle 1
int show2Dots = 0; // circle 2
int moveDown = 0;
int inWater = 0; // number of black dots in water
float semiCircleX []; // semicircle xposition
float semiCircleS []; // semicircle size
float semiCircleC []; // semicircle colour
int dropColour = 201; // colour of first dot in water
void setup() {
size(1000, 1000); // sketch size
background (255); // background colour
int numberOfDots = 77; // maximum number of grey circles made is 77
int number2OfDots = 23; // maximum number of black circles made is 23
// i want 23% of them to be black while the rest are grey
circlePositionX = new int[numberOfDots];
circlePositionY = new int[numberOfDots];
circleSize = new int[numberOfDots];
circle2PositionX = new int[number2OfDots];
circle2PositionY = new int[number2OfDots];
circle2Size = new int[number2OfDots];
for ( int i=0; i <numberOfDots; i++) {
circlePositionX[i] = int(random(width)); //
circlePositionY[i] = int(random(0, 300)); // circles are placed inbetween 0 and 350
circleSize[i] = int(random(20, 50)); // size of circles is between 20 and 30
println("A dot is made at : "+circlePositionX[i]+","+circlePositionY[i]+" with this size : "+circleSize[i]); // tells me where the dots are located and what size they are
}
for ( int x=0; x <number2OfDots; x++) {
circle2PositionX[x] = int(random(width)); // black circles are placed inbetween x position 25 and 975
circle2PositionY[x] = int(random(0, 300)); // black circles are placed inbetween 0 and 350
circle2Size[x] = int(random(20, 50)); // size of circles is between 20 and 30
println("A dot is made at : "+circle2PositionX[x]+","+circle2PositionY[x]+" with this size : "+circle2Size[x]); // tells me where the black dots are located and what size they are
}
semiCircleX = new float[number2OfDots];
semiCircleS = new float[number2OfDots];
semiCircleC = new float[number2OfDots];
for (int y=0; y < number2OfDots; y++) {
semiCircleX[y] = -1;
semiCircleS[y] = -1;
semiCircleC[y] = -1; // making sure nothing is there before it hits the water
}
}
void draw() {
background(255); // background colour
// ocean
fill (250); // sea fill
stroke (250); // sea outline
rect (0000, 500, 1000, 500); // sea size
for ( int i=0; i <showDots; i++) {
fill(#C9C9C9); // circle fill
stroke(#C9C9C9); // circle stroke
circle(circlePositionX[i], circlePositionY[i]+moveDown, circleSize[i]); // circle position
}
for ( int x=0; x < showDots; x++) {
fill(0); // circle 2 fill
stroke(5); // circle 2 stroke
circle(circle2PositionX[x], circle2PositionY[x]+moveDown, circle2Size[x]); // circle 2 position
}
delay (80);
for (int z = 0; z< show2Dots; z++) {
if ((circle2PositionY[z]+moveDown) >= 500) {
semiCircleX[inWater]= circle2PositionX[z]; // when circle hits water it makes a semi circle at that same spot
semiCircleS[inWater]= 0; // 1st value as it hits the water
semiCircleC[inWater]= dropColour; // slightly darker than the water
circle2PositionY[z]= -999999999; // to get rid of error - shoots the circle off the canvas
inWater++ ; // how many are in the water
if (dropColour >=10) {
dropColour-=10; // so the darkest colour it is is black
}
}
}
for (int a = 0; a<inWater; a++) {
fill (semiCircleC[a]); //semi circle colour
stroke (semiCircleC[a]);// semi circle colour
arc(semiCircleX[a], 500, semiCircleS[a], semiCircleS[a], 0, PI); // making semi circle at location where circle hits the water
semiCircleS[a]+=10 ;
}
if (showDots < 23) {
showDots++; // when a key is pressed a grey circle appears
show2Dots++; // when a key is pressed a black circle appears
}
moveDown+=5;
//saveFrame("absorbs_23##.jpg");
}

bottom of page