// Konstanten int SIZE = 250; int COLOR_RANGE = 255; // Variablen int homageCounter = 0; color[] homageColors = { color(161, 182, 223), color(153, 153, 102), color(255, 255, 255), color(204, 255, 51) }; // Array welches die Permutationen enthält int countPermutations = factorial(homageColors.length); /** * berechnet die Fakultät */ int factorial(int n) { return n == 0 ? 1 : n * factorial (n-1); } /** * Vertauscht zwei Elemente des Arrays */ void swap(int index1, int index2) { color temp = homageColors[index1]; homageColors[index1] = homageColors[index2]; homageColors[index2] = temp; } /** * Führt eine Permutation durch * fix: Funktioniert noch nicht richtig! */ void permute(int index) { int i = (index == 0) ? 0 : index % homageColors.length; int j = (i == homageColors.length-1) ? 0 : i+1; swap(i, j); } /** * setup setzt die Bühneneigenschaften * und zeichent die erste Homage */ void setup() { size(SIZE, SIZE); colorMode(RGB, COLOR_RANGE); background(COLOR_RANGE); rectMode(CENTER); noStroke(); drawNewHomage(); } /** * homage erwartet als Eingabeparameter den * Farbvektor mit vier Farben und zeichnet * eine Homage auf die Bühne */ void homage(color[] c) { for(int i=0; i