19. September 2013
Die erste Aufgabe: Das Ergebnis gibt es hier: Drawing Editor v1.0 Der Code dazu sieht so aus:
char taste;
color farbe = color(43);</code>
void setup()
{
size(400, 400);
smooth();
stroke(255, 255, 255);
strokeWeight(10);
background(0);
}
void draw() {
if (keyPressed) {
taste = key;
println(taste);
switch(taste)
{
case '1':
farbe = color(105, 255, 105);
println("case1");
break;
case '2':
farbe = color(255, 215, 0);
break;
case '3':
farbe = color(32, 238, 238);
break;
case '4':
farbe = color(23, 11, 120);
break;
case '5':
farbe = color(40, 28, 40);
break;
case '6':
farbe = color(250, 3, 12);
break;
default:
println("no key");
break;
}
}
strokeWeight(0);
ellipse(40, 40, 25, 25);
fill(farbe);
smooth();
stroke(farbe);
if (mousePressed == true) {
if (mouseButton == LEFT) {
strokeWeight(random(2, 10));
line(mouseX, mouseY, pmouseX, pmouseY);
}
else if (mouseButton == RIGHT) {
stroke(0);
strokeWeight(40);
line(mouseX, mouseY, pmouseX, pmouseY);
strokeWeight(10);
}
}
}