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.

Permutation Variationen

2. Dezember 2010

Nun kann man bei der Permutation (Siehe hier) mittels Tastatur-Ziffern "1" + "2" noch zwischen zwei Zeichenpermutation wählen:
/*
* PERMUTATION VARIATIONS
*
* Create a sign permutation with processing. Animate it with mouse input. Variated by number keys.
*
* @name Permutation Veriations
* @author Sebastian Pape <sebastian.pape@zhdk.ch>
* @version 1.0
*/

/*
* VARIABLES
*/
int     numberPerRow = 7;
int     padding = 50;
float   xStep;
float   yStep;

int[]   permutationsList = {
                            0, 1, 2, 3, 4, 5, 6,
                            1, 2, 3, 4, 5, 6, 5,
                            2, 3, 4, 5, 6, 5, 4,
                            3, 4, 5, 6, 5, 4, 3,
                            4, 5, 6, 5, 4, 3, 2,
                            5, 6, 5, 4, 3, 2, 1,
                            6, 5, 4, 3, 2, 1, 0
                           };
                           
int   currentVariation = 2;
                           

/*
* VARIABLES
*/
void setup()
{
  size(600, 600);
  smooth();

  xStep = (width - 2 * padding) / (float)(numberPerRow-1);
  yStep = (height - 2 * padding) / (float)(numberPerRow-1);
}

void draw()
{
  background(255);

  int     permutationsIndex = 0;

  pushMatrix();
    translate(padding,padding);
    for(int y=0; y<numberPerRow;y++) {
      pushMatrix();
        for(int x=0; x<numberPerRow;x++) {
          
          drawPermutationObj(permutationsList[permutationsIndex], radians(getMouseDegree(xStep*x + 35, yStep*y + 35)));

          ++permutationsIndex;

          translate(xStep,0.0f);
        }
      popMatrix();
      translate(0.0f,yStep);
    }
  popMatrix();
}

void drawPermutationObj(int type, float transformation)
{
  pushMatrix();
  rotate(transformation);
  pushStyle();
  switch(type)
  {
  case 0:
    if (currentVariation == 1) {
      /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
  
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,0,58,58);
  
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(-10,6,48,48);
  
      /* CIRCLE 4 */
      stroke(0);
      fill(0);
      ellipse(8,0,58,58);
    } else if (currentVariation == 2) {
       /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
      
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,-3,69,69);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-6,63,63);
      
       /* CIRCLE 4 */
      stroke(0);
      fill(255);
      ellipse(0,-18 ,40,40);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-22,30,30);
    }
  break;

  case 1:
    if (currentVariation == 1) {
      /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
  
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,0,62,62);
  
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(-13,1,49,49);
  
      /* CIRCLE 4 */
      stroke(0);
      fill(0);
      ellipse(4,5,62,62);
    } else if(currentVariation == 2) {
       /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
      
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,-3,69,69);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-6,56,56 );
      
       /* CIRCLE 4 */
      stroke(0);
      fill(255);
      ellipse(0,-16 ,40,40);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-17,30,30);
    }
  break;

  case 2:
    if(currentVariation == 1) {
      /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
  
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,0,64,64);
  
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(-11,-12,41,41);
  
      /* CIRCLE 4 */
      stroke(0);
      fill(0);
      ellipse(-5,4,55,55);
    } else if(currentVariation == 2) {
      /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
      
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,-3,70,70);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-4,51,51);
      
       /* CIRCLE 4 */
      stroke(0);
      fill(255);
      ellipse(0,-11 ,40,40);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-10,25,25);
    }
  break;

  case 3:
    if(currentVariation == 1) {
      /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
  
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,0,65,65);
  
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(-3,-17,40,40);
  
      /* CIRCLE 4 */
      stroke(0);
      fill(0);
      ellipse(-4,-1,53,53);
    } else if(currentVariation == 2) {
      /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
      
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,-3,70,70);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-2,45,45);
      
       /* CIRCLE 4 */
      stroke(0);
      fill(255);
      ellipse(0,-8 ,40,40);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-8,22,22);
    }
  break;  

  case 4:
     if(currentVariation == 1) {
        /* CIRCLE 1 */
        stroke(0);
        fill(0);
        ellipse(0,0,75,75);
    
        /* CIRCLE 2 */
        stroke(0);
        fill(255);
        ellipse(0,0,66,66);
    
         /* CIRCLE 3 */
        stroke(0);
        fill(0);
        ellipse(4,-17,38,38);
    
        /* CIRCLE 4 */
        stroke(0);
        fill(0);
        ellipse(-2,-4,45,45);
     } else if(currentVariation ==2) {
       /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
      
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,-2,71,71);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,0,42,42);
      
       /* CIRCLE 4 */
      stroke(0);
      fill(255);
      ellipse(0,-6 ,40,40);
      
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(0,-6,18,18);
     }
  break;

  case 5:
     if(currentVariation == 1) {
        /* CIRCLE 1 */
        stroke(0);
        fill(0);
        ellipse(0,0,75,75);
    
        /* CIRCLE 2 */
        stroke(0);
        fill(255);
        ellipse(0,0,67,67);
    
         /* CIRCLE 3 */
        stroke(0);
        fill(0);
        ellipse(15,-11,30,30);
    
        /* CIRCLE 4 */
        stroke(0);
        fill(0);
        ellipse(4,-4,39,39);
     } else if(currentVariation ==2){
         /* CIRCLE 1 */
        stroke(0);
        fill(0);
        ellipse(0,0,75,75);
        
        /* CIRCLE 2 */
        stroke(0);
        fill(255);
        ellipse(0,-1,72,72);
        
         /* CIRCLE 3 */
        stroke(0);
        fill(0);
        ellipse(0,3,38,38);
        
         /* CIRCLE 4 */
        stroke(0);
        fill(255);
        ellipse(0,-3 ,40,40);
        
         /* CIRCLE 3 */
        stroke(0);
        fill(0);
        ellipse(0,-3,15,15);
     }
  break;

  case 6:
     if(currentVariation == 1) {
       /* CIRCLE 1 */
      stroke(0);
      fill(0);
      ellipse(0,0,75,75);
  
      /* CIRCLE 2 */
      stroke(0);
      fill(255);
      ellipse(0,0,68,68);
  
       /* CIRCLE 3 */
      stroke(0);
      fill(0);
      ellipse(23,0,29,29);
  
      /* CIRCLE 4 */
      stroke(0);
      fill(0);
      ellipse(8,0,38,38);
     } else if (currentVariation == 2) {
         /* CIRCLE 1 */
        stroke(0);
        fill(0);
        ellipse(0,0,75,75);
        
        /* CIRCLE 2 */
        stroke(0);
        fill(255);
        ellipse(0,0,73,73);
        
         /* CIRCLE 3 */
        stroke(0);
        fill(0);
        ellipse(0,0,38,38);
        
         /* CIRCLE 4 */
        stroke(0);
        fill(255);
        ellipse(0,0,40,40);
        
         /* CIRCLE 3 */
        stroke(0);
        fill(0);
        ellipse(0,0,12,12);
     }
  break;

  default:
  break;
  }
  popStyle();
  popMatrix();
}

void keyPressed()
{
  switch(key)
  {
  case ' ':
    save("permutation.jpg");
  break;
  case '1':
    currentVariation = 1;
  break;  
  case '2':
    currentVariation = 2;
  break;
  }
}

/*
* GET MOUSE DEGREE
 */
float getMouseDegree(float _x, float _y) {
  float mouseDegree = degrees(atan2(mouseY - _y, mouseX - _x));

  if (mouseDegree < 0) {
    // negative
    if(mouseDegree >= -90) {
      mouseDegree = (mouseDegree+90);
    } 
    else {
      mouseDegree = (mouseDegree+450);
    }
  } 
  else {
    mouseDegree = (mouseDegree+90);
  }

  return mouseDegree;
}