3. Dezember 2010
Ich hab meine Code soweit erweitert, dass der Mauszeiger den "Punkt" darstellt, zu welchem sich die Zeichen durch Rotation orientieren.int anzahl = 7; int rand = 50; float xStep; float yStep; float rot,rotx,roty; int[] permutationsIndexList = { 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 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++) { rot = atan2(((mouseX-xStep/2) -(x*xStep)),((mouseY-yStep/2) - (y*yStep))); 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(-rot+HALF_PI); 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; } }