2. Dezember 2010
Ausgehend von meiner Permutation hab ich zusätzlich noch einen Rotationsparmatere eingefügt, um die einzelnen Zeichen zu drehen. Diese Drehung soll, wenn sie richtig funktioniert die Zeichen auf einen Mittelpunkt (oder beliebigen Punkt) richten.int anzahl = 7; int rand = 50; float xStep; float yStep; float rot,rotx,roty; int[] permutationsIndexList = {0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 5, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 2, 5, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 0}; void setup() { size(600, 600); smooth(); xStep = (width - 2 * rand) / (float)(anzahl-1); yStep = (height - 2 * rand) / (float)(anzahl-1); 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++) { rotx = (((1.0/anzahl)*(x))*180.0)-90; roty = (((1.0/anzahl)*(y))*180.0)-90; rot = rotx + roty; println(rot); //rot = 0.0; drawPermutationObj(permutationsIndexList[permutationsIndex],rot); print(str(permutationsIndexList[permutationsIndex]) + "\t"); ++permutationsIndex; translate(xStep,0.0f); } println(); popMatrix(); translate(0.0f,yStep); } popMatrix(); } void drawPermutationObj(int type, float rot) { pushStyle(); pushMatrix(); rotate(radians(rot)); switch(type) { case 0: stroke(0); fill(0); ellipse(14,0,46,46); noStroke(); fill(255); ellipse(-14,0,50,50); stroke(0); fill(0); ellipse(-14,0,42,42); break; case 1: stroke(0); fill(0); ellipse(12,0,40,40); noStroke(); fill(255); ellipse(-12,0,49,49); stroke(0); fill(0); ellipse(-12,0,36,36); break; case 2: stroke(0); fill(0); ellipse(10,0,38,38); noStroke(); fill(255); ellipse(-10,0,48,48); stroke(0); fill(0); ellipse(-10,0,32,32); break; case 3: stroke(0); fill(0); ellipse(8,0,36,36); noStroke(); fill(255); ellipse(-8,0,47,47); stroke(0); fill(0); ellipse(-8,0,28,28); break; case 4: stroke(0); fill(0); ellipse(6,0,34,34); noStroke(); fill(255); ellipse(-6,0,47,47); stroke(0); fill(0); ellipse(-6,0,24,24); break; case 5: stroke(0); fill(0); ellipse(4,0,34,34); noStroke(); fill(255); ellipse(-4,0,46,46); stroke(0); fill(0); ellipse(-4,0,20,20); break; case 6: stroke(0); fill(0); ellipse(0,0,16,16); noStroke(); fill(255); ellipse(0,0,46,46); stroke(0); fill(0); ellipse(0,0,16,16); break; default: break; } popMatrix(); popStyle(); } void keyPressed() { switch(key) { case ' ': save("permutation.jpg"); break; } }