21. September 2012
Der Einstieg in das IAD-Studium erfolgte mit Basics zur Programmiersprache Processing. Angeschaut wurden zu Beginn die grundsätzliche Syntax mit Semikolon, Klammern, Funktionen und Parametern. Auswirkungen beim Verändern des Codes wurden bei der ersten Aufgabe einfach ersichtlich. Es galt Smileys in neun Stimmungslagen zu zeichnen. Resultat siehe unten. Was auffällt im Vergleich zum Informatikunterricht an der Uni: Anstelle von Variabeln erstellen, Werte zuschreiben und diese dann zusammenrechnen, programmiert man hier an der ZHdK von Beginn weg mit dem Ziel eines visuellen Outputs. Sehr cool.int SMILEY_DEFAULT = 1; int SMILEY_SAD = 2; int SMILEY_DRUNK = 3; int SMILEY_ANGRY = 4; int SMILEY_OLD = 5; int SMILEY_ASTOUND = 6; int SMILEY_SLEEPY = 7; int SMILEY_HORNY = 8; int SMILEY_PANIC = 9; int smileyType = SMILEY_DEFAULT; void setup() { size(400, 400); // def. fenstergroesse smooth(); // aktiviere antialiasing strokeWeight(15); // linienbreite } void draw() { background(255); // def. hintergrundfarbe pushMatrix(); translate(width * .5, width * .5); smiley(smileyType); // funtions aufruf popMatrix(); } void keyPressed() { switch(key) { case '1': smileyType = SMILEY_DEFAULT; break; case '2': smileyType = SMILEY_SAD; break; case '3': smileyType = SMILEY_DRUNK; break; case '4': smileyType = SMILEY_ANGRY; break; case '5': smileyType = SMILEY_OLD; break; case '6': smileyType = SMILEY_ASTOUND; break; case '7': smileyType = SMILEY_SLEEPY; break; case '8': smileyType = SMILEY_HORNY; break; case '9': smileyType = SMILEY_PANIC; break; } } // funktion void smiley(int smileyType) { // kopf noFill(); ellipse(0, 0, 180, 180); // kopf // augen fill(0); if (smileyType == SMILEY_SAD) { ellipse(0 - 30, 0 - 30, 20, 5); // linkes augen ellipse(0 + 30, 0 - 30, 20, 5); // rechtes augen } else if (smileyType == SMILEY_DRUNK) { line(-50, -40, -10, -10); line(-50, -10, -10, -40); line(50, -40, 10, -10); line(50, -10, 10, -40); } if (smileyType == SMILEY_ANGRY) { line(-40, -55, -20, -50); line(40, -55, 20, -50); ellipse(0 - 30, 0 - 30, 20, 5); // linkes augen ellipse(0 + 30, 0 - 30, 20, 5); // rechtes augen } if (smileyType == SMILEY_OLD) { ellipse(0 - 30, 0 - 30, 20, 20); // linkes augen ellipse(0 + 30, 0 - 30, 20, 20); // rechtes augen noFill(); pushStyle(); strokeWeight(5); line(-5, -30, 5, -30); line(-80, -40, -55, -35); line(80, -40, 55, -35); ellipse(0 + 30, 0 - 30, 50, 50); // rechtes augen ellipse(0 - 30, 0 - 30, 50, 50); // linkes augen popStyle(); } else if (smileyType == SMILEY_PANIC) { pushStyle(); fill(255); strokeWeight(10); ellipse(0 + 30, 0 - 30, 40, 40); // rechtes augen ellipse(0 - 30, 0 - 30, 40, 40); // linkes augen popStyle(); pushStyle(); fill(0); strokeWeight(0); ellipse(-30, -22, 30, 20); // linkes augen ellipse(30, -22, 30, 20); // linkes auge popStyle(); } else if (smileyType == SMILEY_SLEEPY) { pushStyle(); fill(0); strokeWeight(5); ellipse(- 30, -30, 5, 10); // linkes augen ellipse(+ 30, -30, 5, 10); // rechtes augen line(20, -20, 40, -15); // schlafringe line(-40, -15, -20, -20); // schlafringe popStyle(); } else if (smileyType == SMILEY_HORNY) { ellipse(0 - 30, 0 - 30, 20, 10); // linkes augen ellipse(0 + 30, 0 - 30, 20, 10); // rechtes augen } else if (smileyType == SMILEY_ASTOUND) { ellipse(0 - 30, 0 - 30, 20, 30); // linkes augen ellipse(0 + 30, 0 - 30, 20, 30); // rechtes augen } else { ellipse(0 - 30, 0 - 30, 20, 20); // linkes augen ellipse(0 + 30, 0 - 30, 20, 20); // rechtes augen } // mund noFill(); if (smileyType == SMILEY_SAD) arc(0, 60, 100, 100, radians(180+20), radians(360-20)); // mund else if (smileyType == SMILEY_DRUNK) { line(-50, 20, 50, 20); arc(-10, 15, 50, 70, radians(20), radians(180-20)); // mund } else if (smileyType == SMILEY_ANGRY) { //line(-50, 20, 50, 40); arc(0, 60, 100, 100, radians(180+40), radians(360-40)); // mund } else if (smileyType == SMILEY_OLD) { arc(0, 0, 70, 100, radians(50), radians(180-50)); // mund pushStyle(); strokeWeight(5); arc(30, -45, 70, 100, radians(70), radians(180-70)); // Runzeln arc(-30, -45, 70, 100, radians(70), radians(180-70)); // Runzeln popStyle(); } else if (smileyType == SMILEY_PANIC) { pushStyle(); strokeWeight(10); ellipse(0, 40, 40, 50); popStyle(); } else if (smileyType == SMILEY_SLEEPY) { line(-20, 40, 20, 40); } else if (smileyType == SMILEY_HORNY) { arc(0, 0, 150, 50, radians(20), radians(180-20)); // mund pushMatrix(); rotate(-0.2); pushStyle(); fill(0); arc(0, 20, 20, 70, radians(20), radians(180-20)); // mund popStyle(); popMatrix(); } else if (smileyType == SMILEY_ASTOUND) { pushStyle(); strokeWeight(10); ellipse(0, 40, 50, 30); popStyle(); } else arc(0, 0, 100, 100, radians(20), radians(180-20)); // mund }