...
| Code Block |
|---|
void setup()
{
size(600,600); // def. fenstergroesse
smooth(); // aktiviere antialiasing
strokeWeight(15); // linienbreite
}
void draw()
{
background(255); // def. hintergrundfarbe
for(int x = 0; x <= width; x+=30)
{
for(int y = 0; y <= height; y+=30)
{
pushMatrix();
translate(x,y);
scale(.1);
smiley(); // funtions aufruf
popMatrix();
}
}
}
void keyPressed()
{
switch(key)
{
case 's':
save("screenShot.jpg");
println("save the screen to screenShot.jpg");
break;
}
}
// funktion
void smiley()
{
noFill();
ellipse(0,0,180,180); // kopf
fill(0);
ellipse(0 - 30,0 - 30,20,5); // linkes augen
ellipse(0 + 30,0 - 30,20,5); // rechtes augen
noFill();
arc(0,0,100,100,radians(20),radians(180-20)); // mund
} |
Dieses Beispiel gibt die Zeichnung nicht auf den Bildschirm aus, es schreibt die Ausgabe in ein PDF-File.
| Code Block |
|---|
import processing.pdf.*;
void setup()
{
size(600,600,PDF,"ornament.pdf"); // def. fenstergroesse
smooth(); // aktiviere antialiasing
strokeWeight(15); // linienbreite
}
void draw()
{
background(255); // def. hintergrundfarbe
for(int x = 0; x <= width; x+=30)
{
for(int y = 0; y <= height; y+=30)
{
pushMatrix();
translate(x,y);
scale(.1);
smiley(); // funtions aufruf
popMatrix();
}
}
exit();
}
// funktion
void smiley()
{
noFill();
ellipse(0,0,180,180); // kopf
fill(0);
ellipse(0 - 30,0 - 30,20,5); // linkes augen
ellipse(0 + 30,0 - 30,20,5); // rechtes augen
noFill();
arc(0,0,100,100,radians(20),radians(180-20)); // mund
} |
Aufgabe
- Erstelle ein Ornament, welches sich auf allen 4 Seiten mit sich selbst erweitern lässt. Druck es aus und test es.
- Erstelle ein Ornament welches mit einem Ornament einer anderen Person erweitert werden kann.
...