Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
  • Programming in Processing (java)
    • Starting with Processing (en)
    • Variables (en)
    • Classes and Objects (en)
    • Events und Functions (en)
    • Writing our own Functions (en)
    • Random Numbers (en)
    • Conditionals (en)
    • Loops (en)
    • Nested Loops (en)
      • Verschachtelten Schleife (de)
    • Coordinates (en)
    • Arrays and Lists (en)
    • SVG + Images (en)
    • Motion and Temporality
    • Gesture Interactions
    • Using bitmaps as modifiers
    • Vectors
    • Animation
    • Animation 2
    • Simple Collision Detection
    • Sound
    • Typography

/
Verschachtelten Schleife (de)

Verschachtelten Schleife (de)

Sep 22, 2017

Beispiel mit Screenshot-Funktion

void setup()
{
  size(600,600);      // def. fenstergroesse
  
  smooth();           // aktiviere antialiasing
  strokeWeight(1);    // linienbreite
}
  
void draw()
{
  background(255);    // def. hintergrundfarbe
  
  for(int x = 0; x <= width; x+=30)
  {
    for(int y = 0; y <= height; y+=30)
    {
        smiley(x,y);          // funtions anruf
    }
  }
  
}
  
void keyPressed()
{
  switch(key)
  {
  case 's':
    save("screenShot.jpg");
    println("save the screen to screenShot.jpg");
    break;
  }
}
  
// funktion
void smiley(int x, int y)
{
  println("smiley");
  noFill();
  ellipse(x,y,18,18);  // kopf
  
  fill(0);
  ellipse(x - 3,y - 3,2,5);  // linkes augen
  ellipse(x + 3,y - 3,2,5);  // rechtes augen
  
  noFill();
  arc(x,y,10,10,radians(20),radians(180-20));  // mund
}

Dieses Beispiel gibt die Zeichnung nicht auf den Bildschirm aus, es schreibt die Ausgabe in ein PDF-File.

import processing.pdf.*;
  
void setup()
{
  size(600,600,PDF,"ornament.pdf");      // def. fenstergroesse
  
  smooth();           // aktiviere antialiasing
  strokeWeight(1);    // linienbreite
}
  
void draw()
{
  background(255);    // def. hintergrundfarbe
  
  for(int x = 0; x <= width; x+=30)
  {
    for(int y = 0; y <= height; y+=30)
    {
        smiley(x,y);          // funtions aufruf
    }
  }
  
  exit();
}
  
// funktion
void smiley(int x, int y)
{
  println("smiley");
  noFill();
  ellipse(x,y,18,18);  // kopf
  
  fill(0);
  ellipse(x - 3,y - 3,2,5);  // linkes augen
  ellipse(x + 3,y - 3,2,5);  // rechtes augen
  
  noFill();
  arc(x,y,10,10,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.
, multiple selections available,
{"serverDuration": 72, "requestCorrelationId": "36c9fd8967164cf6abf480da57b2af78"}