12. Dezember 2011
Das einfache Grundelement wird um sein Zentrum rotiert. Es entsteht eine Vielfalt an interessanten Resultaten. leverkusen.svg/* ---------------------------------------------------------------------------- * Permutatiosstruktur * ---------------------------------------------------------------------------- * prog: daniel.mischler@zhdk.ch * ---------------------------------------------------------------------------- */ int anzahl = 7; int rand = 100; float xStep; float yStep; PShape leverkusenShape; int geradeEin = 1; int ungerdaeEin = 1; float rotWert = 0; float festGe = 0; float festUn = 0; int[] permutationsIndexList = {0, 1, 0, 1, 0, 1, 0, 3, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 0, 3, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 0, 3, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 0}; void setup() { size(800, 800); smooth(); xStep = (width - 2 * rand) / (float)(anzahl-1); yStep = (height - 2 * rand) / (float)(anzahl-1); leverkusenShape = loadShape ("leverkusen.svg"); shapeMode(CENTER); noLoop(); } void draw() { background(255); int permutationsIndex = 0; pushMatrix(); translate(rand,rand); for(int y=0; y<anzahl;y++) { pushMatrix(); for(int x=0; x<anzahl;x++) { drawPermutationObj(permutationsIndexList[permutationsIndex]); // zeichne erste X linie print(str(permutationsIndexList[permutationsIndex]) + "\t"); // Zeichennummern in Textausgabefensetr ++permutationsIndex; translate(xStep,0.0f); } println(); popMatrix(); translate(0.0f,yStep); } popMatrix(); } void drawPermutationObj(int type) { rotWert=mouseX + mouseY; pushStyle(); switch(type) { case 0: pushMatrix(); if (geradeEin == 1) { rotate(radians(rotWert + 0)); } if (geradeEin == 0) { rotate(radians(festGe + 0)); } shape(leverkusenShape,0,0,100,100); popMatrix(); break; case 1: pushMatrix(); if (ungerdaeEin == 1) { rotate(radians(rotWert + 90)); } if (ungerdaeEin == 0) { rotate(radians(festUn + 90)); } shape(leverkusenShape,0,0,100,100); popMatrix(); break; case 2: pushMatrix(); if (geradeEin == 1) { rotate(radians(rotWert +180)); } if (geradeEin == 0) { rotate(radians(festGe + 180)); } shape(leverkusenShape,0,0,100,100); popMatrix(); break; case 3: pushMatrix(); if (ungerdaeEin == 1) { rotate(radians(rotWert +270)); } if (ungerdaeEin == 0) { rotate(radians(festGe + 270)); } shape(leverkusenShape,0,0,100,100); popMatrix(); break; } popStyle(); } void keyPressed() { println("key"); switch(key) { case '1': geradeEin = 1; ungerdaeEin = 1; break; case '2': geradeEin = 1; ungerdaeEin = 0; festUn = rotWert; break; case '3': geradeEin = 0; ungerdaeEin = 1; festGe = rotWert; break; case ' ': save("permutation.jpg"); break; } } void mouseMoved() { redraw(); }