Digital Bauhaus Vorkurs/Projekte/Raster: Difference between revisions

From Medien Wiki
No edit summary
No edit summary
Line 4: Line 4:




Durch drücken der Tasten 1,2,3,4 sowie a,b,c enstehen verschiedenste Muster.


<source lang="java>
<source lang="java>
int[] farbeR;
int[] farbeG;
int[] farbeB;
void setup()
{
background(150);
  size(500,500);
  smooth();
  strokeWeight(0.9);
  frameRate(30);
}
float winkel4;
int a;
int b;
void draw()
{
 
  stroke(0);
 
}
float winkel=0;
float winkel2=0;


void keyPressed()
{
  if(key=='1')
  {
   
  pushMatrix();
  stroke(255,0,0);
  translate(250,250);
  rotate(winkel4);
  winkel4+=0.2;
  noFill();
  rect(100,100,50,50);
  popMatrix();
  }
  if(key=='2')
  {
  pushMatrix();
  stroke(255,0,0);
  translate(250,250);
  rotate(winkel);
  winkel+=0.2;
  noFill();
  triangle(200,200,150,150,250,250);
  popMatrix();
  }
  if(key=='3')
  {
  pushMatrix();
  stroke(255,0,0);
  translate(250,250);
  rotate(winkel);
  winkel+=0.2;
  noFill();
  ellipse(50,50,150,150);
  popMatrix();
  }
  if(key=='4')
  {
  stroke(0);
  pushMatrix();
  stroke(255,0,0);
  translate(250,250);
  rotate(winkel);
  winkel+=0.2;
  noFill();
  beginShape();
    curveVertex(0,100);
    curveVertex(50,50);
    curveVertex(150,50);
    curveVertex(200,150);
    curveVertex(350,250);
  endShape();
  popMatrix();
  pushMatrix();
  stroke(255,255,0);
  noFill();
  translate(250,250);
  rotate(winkel2);
  winkel2-=0.2;
  beginShape();
  curveVertex(100,0);
  curveVertex(50,50);
  curveVertex(50,150);
  curveVertex(200,150);
  curveVertex(250,350);
endShape();
popMatrix();
  }
}
void keyReleased()
{
  if(key=='d')
  {
  stroke(0);
  pushMatrix();
  stroke(255,0,0);
  translate(250,250);
  rotate(winkel);
  winkel+=0.1;
  fill(255,255,0);
  beginShape();
    curveVertex(0,100);
    curveVertex(50,50);
    curveVertex(150,50);
    curveVertex(200,150);
    curveVertex(350,250);
    curveVertex(0,100);
  endShape();
  popMatrix();
  pushMatrix();
  stroke(255,255,0);
  fill(255,0,0);
  translate(250,250);
  rotate(winkel2);
  winkel2+=0.1;
  beginShape();
  curveVertex(100,0);
  curveVertex(50,50);
  curveVertex(50,150);
  curveVertex(200,150);
  curveVertex(250,350);
endShape();
popMatrix();
  }
if(key=='a')
{
  pushMatrix();
  stroke(255,0,0);
  translate(250,250);
  rotate(winkel4);
  winkel4+=0.2;
  fill(252,110,0);
  rect(100,100,50,50);
  popMatrix();
}
if(key=='b')
{
  pushMatrix();
  stroke(255,0,0);
  translate(250,250);
  rotate(winkel);
  winkel+=0.2;
  fill(255,111,103);
  ellipse(50,50,150,150);
  popMatrix();
}
}