• fullscreen
  • ICM_week4.pde
  • functions_extracode.pde
  • //Intro to Computational Media, Homework 4 (based 0ff of homework2)
    //Zena Koo and Mark Breneman
    //camera 
    
    float cameraBodyX=random(150, 350);
    float cameraBodyY=cameraBodyX;
    float cameraBodyW=400;
    float cameraBodyH=250;
    
    float shutterX=cameraBodyX+40;
    float shutterY=cameraBodyX-130;
    float shutterW=120;
    float shutterH=60;
    
    float flashFrameX=shutterX;
    float flashFrameY=shutterY-5;
    float flashFrameW=85;
    float flashFrameH=20;
    
    float outerLensX=flashFrameX;
    float outerLensY=outerLensX-45;
    float outerLensW=130;
    float outerLensH=outerLensW;
    
    float innerLensX=outerLensX;
    float innerLensY=outerLensY;
    float innerLensW=50;
    float innerLensH=innerLensW;
    
    float cameraButtonX=cameraBodyX-140;
    float cameraButtonY=cameraButtonX+8;
    float cameraButtonW=60;
    int cameraButtonH=15;
    
    float innerFlashSize = 0;
    float flashX = innerLensX;
    float flashY = flashFrameY;
    
    void setup() {
      size(500, 500);
    }
    
    void draw() {
      background(255);
      drawCamera();
    //  while drawCamera() {
    
        drawFlashes();
      }
    
    
    
    
    
    
    
    
    
    void drawCamera() {
     
      fill(0);
      rectMode(CENTER);
      fill(0);
      background(255);
      smooth();
      strokeWeight(1);
      stroke(0);
      rect(cameraBodyX, cameraBodyY, cameraBodyW, cameraBodyH);
      fill(0);
      rect(shutterX, shutterY, shutterW, shutterH);
      fill(255);
      rect(flashFrameX, flashFrameY, flashFrameW, flashFrameH);
      fill(127);
      ellipse(outerLensX, outerLensY, outerLensW, outerLensH);
      fill(0);
      ellipse(innerLensX, innerLensY, innerLensW, innerLensH);
      //Camera Button
      fill(0, 0, 0);
      rect(cameraButtonX, cameraButtonY, cameraButtonW, cameraButtonH); 
      
    if (mousePressed==true) {
        cameraButtonY=cameraButtonY+7;
        strokeWeight(20); //thick strokeweight
        stroke(255, 255, 0, 63); //yellow outline of flash with 25percent transparency - alpha
        fill(255, 255, 255, 50); //white flash fill with low transparency
        ellipse(flashX, flashY, innerFlashSize, innerFlashSize); 
        //^flash ellipse originating from middle of rectangle inner flash
        innerFlashSize = innerFlashSize + 20;
        //^flash increases in size at whatever rate specified, in this case 20
      }
      else {
        cameraButtonY=cameraButtonX+8;
        innerFlashSize=0;
      }
    }
    
    void drawFlashes(){
          strokeWeight(20); //thick strokeweight
        stroke(255, 255, 0, 63); //yellow outline of flash with 25percent transparency - alpha
        fill(255, 255, 255, 50); //white flash fill with low transparency
        ellipse(flashX, flashY, innerFlashSize, innerFlashSize); 
        //^flash ellipse originating from middle of rectangle inner flash
        innerFlashSize = innerFlashSize + 20;
      
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Zena Koo

    Camera with Functions

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    ICM at ITP, week 4, learning functions. Having trouble with them being embedded within each other. Renamed all coordinates as variables in relation to each other. I would like to do more with this, but don't have the time.

    You need to login/register to comment.