Wir haben uns an der Hochschule mit Aleatorik (Zufallsgestaltung) beschäftigt. Von Hand bekommt man Zufall nicht so richtig hin, deshalb habe ich mir ein wenig Processing um die Ohren geschlagen und das hier ist dabei herausgekommen. Nicht besonders spektakulär, aber sieht hübsch aus :)
Den Code dazu gibt es hier:
// 2D Array of objects
Cell[][] grid;
// Number of columns and rows in the grid
int cell_width = 40;
int width;
int height;
int cols;
int rows;
void setup() {
colorMode(RGB);
width = displayWidth;
height = displayHeight;
size(width,height);
cols = width / cell_width;
rows = height / cell_width;
grid = new Cell[cols][rows];
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
// Initialize each object
grid[i][j] = new Cell(i*cell_width,j*cell_width,cell_width,cell_width);
}
}
}
void draw() {
background(255);
// The counter variables i and j are also the column and row numbers and
// are used as arguments to the constructor for each object in the grid.
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
// Oscillate and display each object
grid[i][j].oscillate();
grid[i][j].display();
}
}
}
// A Cell object
class Cell {
// A cell object knows about its location in the grid as well as its size with the variables x,y,w,h.
float x,y; // x,y location
float w,h; // width and height
float red;
float green;
float blue;
float transparent;
// Cell Constructor
Cell(float tempX, float tempY, float tempW, float tempH) {
x = tempX;
y = tempY;
w = tempW;
h = tempH;
red = random(255);
transparent = random(255);
makeGray();
}
// Oscillation means increase angle
void oscillate() {
if(mousePressed == true) {
if(mouseX > x && mouseX < (x + h * 2) && mouseY > y && mouseY < (y + w * 2)) {
red = 200;
green = 50;
blue = 0;
}
}
transparent += 0.7;
if(transparent > 255) {
transparent = 0;
red = random(255);
makeGray();
}
}
void display() {
stroke(255);
fill(red, green, blue, transparent);
rect(x,y,w,h);
}
void makeGray() {
green = red;
blue = red;
}
}