Robotergesetze

Big Data & Me #002

The second part of my Big Data online program was about changing variables and using them several times. We are still working with Processing. The program should draw a picture from our environment. I opted for my desk: tabletop, keyboard, screen and a pot with a flower. Still, the program has to do without loops, which is why it is relatively long. The difficulty was to calculate the individual elements to fit the screen size. Hence the strange calculations, for which there are certainly more elegant solutions.

background(255);
size(400,400);
strokeWeight(3);

// Desk
float deskx = height * 0.1;
float desky = height / 2;
float deskw = width * 0.8;
float deskh = height * 0.15;

// Keyboard
float keyboardx = height / 2 – height / 5;
float keyboardy = height / 2 + 10;
float keyboardw = deskw / 5 ;
float keyboardh = height * 0.05;
float key = height * 0.01;
float keyx = keyboardx + keyboardx * 0.03;
float keyy = keyboardy + keyboardy * 0.03;

// Screen
float screenx = deskx + height * 0.17;
float screeny = deskx + height * 0.26;
float screenw = width * 0.22;
float screenh = height * 0.12;
float screenholdx = screenx + height * 0.06;
float screenholdy = screeny + height * 0.12;
float screenholdw = width * 0.1;
float screenholdh = height * 0.02;

// Flower
float flowerx = deskx + height * 0.6;
float flowery = deskx + height * 0.3;
float flowerw = width * 0.12;
float flowerh = height * 0.12;
float flowerpotx = flowerx – flowerx * 0.07;
float flowerpoty = flowery + height * 0.09;
float flowerpotw = width * 0.10;
float flowerpoth = height * 0.08;
float flowerbx1 = flowerpotx + flowerpotw * 0.5; // 280
float flowerby1 = flowerpoty + flowerpoth * 0.2; // 200
float flowerbx2 = flowerbx1;
float flowerby2 = flowerpoty – flowerpoth * 1.2; // 160
print(flowerby2);

// Desk Output
fill(173,124,69);
rect(deskx,desky,deskw,deskh);

// Keyboard Output
fill(0);
rect(keyboardx,keyboardy,keyboardw,keyboardh);
fill(255);
strokeWeight(1);
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyboardx + keyboardx * 0.03;
keyy = keyy + keyboardy * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);
keyx = keyx + keyboardx * 0.04;
rect(keyx,keyy,key,key);

// Screen Output
strokeWeight(2);
fill(242);
rect(screenx,screeny,screenw,screenh);
fill(0);
rect(screenholdx,screenholdy,screenholdw,screenholdh);

// Flower Output
strokeWeight(2);
fill(0,205,205);
ellipse(flowerx, flowery, flowerw, flowerh);
fill(92,79,81);
rect(flowerpotx,flowerpoty,flowerpotw,flowerpoth);
line(flowerbx1, flowerby1, flowerbx2, flowerby2);

And here is the output:

Share this post