Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Ornament v2

8. November 2010

This ornament with a spiral-like motive is animated. It fades in and out continually to conserve the symmetry.
void setup()
{
  size(600,600);      // def. fenstergroesse
  noFill();
  smooth();           // aktiviere antialiasing
  strokeWeight(1);    // linienbreite
}

void draw()
{
  background(255);    // def. hintergrundfarbe
  boolean select=false;
  float rot = 0;
  for(int x = 0; x <= width; x+=134)
  {
    for(int y = 0; y <= height; y+=124)
    {
      pushMatrix();
      translate(x,y);
      scale(0.5);
      rotate(PI/(rot+=1)%4);
      figure(select, random(255.0));
      popMatrix();
    }
  }
}

void keyPressed()
{
  switch(key)
  {
  case 's':
    save("screenShot.jpg");
    println("save the screen to screenShot.jpg");
    break;
  }
}


//funktion
void figure(boolean select, float al) {
  
  float r = 0;  //radius

  boolean flag=true; //fade-in/fade-out
  
  for(float theta=0; theta<50.0; theta+=0.01){  //incement angle
    stroke(0, 0, 0, al);
    r=theta*5.0;  //increase radius
    
    // Polar to Cartesian conversion
    float x = r * cos(theta);
    float y = r * sin(theta);
    
    if(select)
      ellipse(x, y, 16, 16);  
    else
       point(x,y);
       
    if(al >= 255.0)  //alpha = 255
      flag = true;
    if(al <= 0.0)  //alpha = 0
      flag = false;
    
    if(flag)  //if alpha = 255, then reduce alpha
      al-=0.1;
    else      //if alpha = 0, then augment alpha
      al+=0.1;
     
  }
}