20. Oktober 2011
![Screenshot](../../../../files/2011/10/screenshot-04-233x300.png)
PShape loadOrnament; PFont font; int rotateOrn = mouseX-mouseY; /* Pattern wiederholt sich. Einzelne Ornamente sollen rotieren, wenn die Maus bewegt wird. 's' speichert einen Screenshot 'r' setzt die Rotation zurück Zweite Ebene > Farbig? */ void setup() { size(600,770); // def. fenstergroesse smooth(); // aktiviere antialiasing } void draw() { background(255,207,31); // hintergrundfarbe font = loadFont("Serif-48.vlw"); textFont(font, 120); fill(0); text("Patternin'", 80, 180); strokeWeight(3); line(0,263,600,263); for(int x = 0; x { for(int y = 0; y { pushMatrix(); translate(x,y); scale(0.5); ornament(); // Funktionsaufruf popMatrix(); instructions(); } } } // Keyboardeingaben void keyPressed() { switch(key) { case 's': saveFrame("screenshot-##.png"); println("save the screen to screenshot-##.png"); break; case 'r': //resets the rotation of the single ornaments to the initial state println("Reset Rotation of patterns"); break; case 'i': //hides or shows instructions panel println("Show/Hide instructions"); break; } } // Funktionen void ornament() { loadOrnament = loadShape("ornament.svg"); rotate(mouseX + mouseY); shape(loadOrnament, 10, 10, 80, 80); } void instructions() { fill(255); strokeWeight(10); strokeJoin(BEVEL); rect(125,600,350,100); fill(0); textFont(font, 14); text("Move the mouse to rotate patterns.", 150, 625); text("Press 's' to save a screenshot.", 150, 650); text("Press 'r' to reset ornaments.", 150, 665); text("Press 'i' to hide instructions.", 150, 680); }