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.

Some Smiley Presets

8. November 2010

static int SMILEY_DEFAULT  = 1<<0;
static int SMILEY_SAD      = 1<<1;
static int SMILEY_DRUNK    = 1<<2;
static int SMILEY_ANGRY    = 1<<4;
static int SMILEY_OLD      = 1<<5;
static int SMILEY_ASTOUND  = 1<<6;
static int SMILEY_SLEEPY   = 1<<7;
static int SMILEY_HORNY    = 1<<8;
static int SMILEY_PANIC    = 1<<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;
  }
}

// funktion
void smiley(int smileyType)
{
  // kopf
  noFill();
  ellipse(0,0,180,180);  // kopf

  // augen
  fill(0);
  if((smileyType & SMILEY_SAD) > 0)
  {
    ellipse(0 - 30,0 - 30,20,5);  // linkes augen
    ellipse(0 + 30,0 - 30,20,5);  // rechtes augen
  }
  else if((smileyType & SMILEY_DRUNK) != 0)
  {
    line(-50,-40,-10,-10);
    line(-50,-10,-10,-40);

    line(50,-40,10,-10);
    line(50,-10,10,-40);
  }
  else if((smileyType & SMILEY_ANGRY) != 0) {
    line(-50,-40,-10,-10);
    line(50,-40,10,-10);
  }
  else if((smileyType & SMILEY_OLD) > 0)
  {  
    strokeWeight(5);
    ellipse(0 - 30,0 - 30,20,5);  // linkes augen
    ellipse(0 + 30,0 - 30,20,5);  // rechtes augen
    fill(100, 50);
    ellipse(0-30, 0-30, 50, 50);  //linkes brillenglass
    ellipse(0+30, 0-30, 50, 50);  //linkes brillenglass
    line(-55, -30, -95, -30);    //Brillengestell
    line(55, -30, 95, -30);
    line(-5, -30, 5, -30);
    strokeWeight(15);
  }
  else if((smileyType & SMILEY_ASTOUND) > 0) {
    ellipse(0 - 30,0 - 30,20,20);  // linkes augen
    ellipse(0 + 30,0 - 30,20,20);  // rechtes augen
    //ellipse(0 - 30,0 - 30,20,5);  // linkes augen
    //ellipse(0 + 30,0 - 30,20,5);  // rechtes augen
    strokeWeight(5);
    line(-50,-50,-10,-60);
    line(10, -60,50,-50);
    strokeWeight(15);
  }
  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) != 0)
    arc(0,60,100,100,radians(180+20),radians(360-20));  // mund
  else if((smileyType & SMILEY_DRUNK) != 0)
  {
    line(-50,20,50,20);
    arc(-10,15,50,70,radians(20),radians(180-20));  // mund
  }
  else if((smileyType & (SMILEY_ANGRY | SMILEY_ASTOUND)) != 0)
  {  
    arc(0,60,100,100,radians(180+20),radians(360-20));  // mund
    arc(0,25,100,100,radians(20),radians(180-20));  // mund
  }

  else //happy
  arc(0,0,100,100,radians(20),radians(180-20));  // mund
}