For this assignment I decided to experiment with simple complexity using processing. I had the idea to try out a 3D sketch, with features like camera control, color, randomness, and more. With some simple loops, I was able to create a random matrix of 3D shapes that form interesting patterns. The space can then be explored by holding a mouse click to rotate, scrolling to zoom in and out, and pan by holding ctrl or command and holding a mouse click. The formation can be reset and regenerated by pressing r, color can be toggled by pressing c, shapes can draw paths by pressing v, the screen can be cleared by pressing x, and a screenshot can be saved by pressing s. I found it interesting to play around and see what kinds of formations and drawings you can create with this sketch.
//
// 3D rotations
//
// Press 'x' to clear the screen
// Press 'c' to toggle color
// Press 'v' to toggle shape paths
// Press 'r' to regenerate the shapes
// Press 's' to save a screenshot
//
import peasy.*;
PeasyCam cam;
boolean toggleColor, rotation, drawPath;
float rotX, rotY, r, g, b;
void setup() {
size(800, 800, P3D);
frameRate(60);
smooth(8);
background(10);
cam = new PeasyCam(this, 100);
cam.setMinimumDistance(50);
cam.setMaximumDistance(5000);
rotX = random(0, 100);
rotY = random(0, 100);
}
void draw() {
if (!drawPath) {
background(0);
}
for (int y = -30; y <= height; y += 40) {
for (int x = -30; x <= width; x += 50) {
rotateX(rotX);
rotateY(rotY);
pushMatrix();
if (toggleColor) {
fill(r, g - x/3, b - y/3);
} else {
fill(255);
}
translate(x + 150, y + 150);
box(25);
rotateX(PI/4);
rotateY(3*PI/4);
box(25);
popMatrix();
}
}
}
void keyReleased() {
if (key == 'c' || key == 'C') {
if (toggleColor) {
toggleColor = false;
} else {
toggleColor = true;
r = random(0, 255);
g = random(0, 255);
b = random(0, 255);
}
}
if (key == 's' || key == 'S') {
saveFrame("screenshot-###.png");
}
if (key == 'x' || key == 'x') {
background(0);
}
if (key == 'r' || key == 'R') {
rotX = random(0, 100);
rotY = random(0, 100);
background(0);
}
if (key == 'v' || key == 'V') {
if (drawPath) {
drawPath = false;
} else {
drawPath = true;
}
}
}