Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

I am trying to create a sort of photoBooth In Processing

$
0
0
Hi,  I am a new programming student and for my school final I am trying to create a sort of PhotoBooth using the camera on a mac or any kind of computer camera with different filters that are triggered with arrow keys like tints and distortions basically some of the things that are in Mac's Photo Booth I made mock buttons that have a pressed down look too for fun but that doesn't seem to work properly since they are all supposed to be displayed but aren't.


Here are the Files for everything in my program:
Main
Button
Background Picture
  1. import processing.video.*;//opens up processing libraries


    int s;// saved time

    int t = 5000;// 5 seconds

    //class
    Capture video;//class for cideo

    Button[] button = new Button[4];//class will be called button


    PImage img;//class img

    boolean state; // keyPressed
    //===================================
    void setup() {
      size(1500, 1098);
      background(0);

      img = loadImage("Octoton Background Big.jpg"); //image file name
      frameRate(30);
      imageMode(CENTER);
      //Inititialize class
      for (int i = 0; i< button.length; i++) {
        button[i] = new Button(250+(i*75), 250);
      }

      button[0].setColor(0, 255, 0);//green
      button[1].setColor(0, 0, 255);//blue
      button[2].setColor(255, 255, 0);//yellow
      button[3].setColor(142, 56, 142);//purple

      video = new Capture (this, 640, 480, 30);//(video, width, height, frameRate)
      video.start();

      s = millis(); //sets s to millis
      ellipseMode(CENTER);
    }
    //======================END SETUP===================



    void draw () {

      if (keyPressed) {
        if (keyCode == UP) {
          image(img, width/2, height/2);// background drawn 
          //for (int i = 0; i< button.length; i++) {
          button[0].display(true);
          state = true;
        }
      }
      else {
        image(img, width/2, height/2); // background drawn 
        //for (int i = 0; i< button.length; i++) {
        button[0].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }   
      image(video, width/2, height/2+100);

      if (keyPressed) {
        if (keyCode == DOWN) {
          image(img, width/2, height/2);// background drawn 
          //for (int i = 0; i< button.length; i++) {
          button[1].display(true);
          state = true;
        }
      }
      else {
        image(img, width/2, height/2); // background drawn 
        //for (int i = 0; i< button.length; i++) {
        button[1].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }   
      image(video, width/2, height/2+100);
      if (keyPressed) {
        if (keyCode == LEFT) {
          image(img, width/2, height/2);// background drawn 
          //for (int i = 0; i< button.length; i++) {
          button[2].display(true);
          state = true;
        }
      }
      else {
        image(img, width/2, height/2); // background drawn 
        //for (int i = 0; i< button.length; i++) {
        button[2].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }   
      image(video, width/2, height/2+100);
      if (keyPressed) {
        if (keyCode == RIGHT) {
          image(img, width/2, height/2);// background drawn 
          //for (int i = 0; i< button.length; i++) {
          button[3].display(true);
          state = true;
        }
      }
      else {
        image(img, width/2, height/2); // background drawn 
        //for (int i = 0; i< button.length; i++) {
        button[3].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }   
      image(video, width/2, height/2+100);
    }
    //=======================CLASS=================
    class Button {
      color col; // color variable
      int x;
      int y;

      Button(int tempX, int tempY) { // constructor
      x = tempX;
      y = tempY;
      }


      void display(boolean tempState) {


        fill(155);//gray

        ellipse(x, 258, 60, 30); // Base of button

        if (tempState == true) {
          Pressed();
        }
        else {
          notPressed();
        }
      }

      //=======================notPressed=================
      void notPressed () {
        //Button Default

        fill(col);//color set 

        ellipse(x, 254, 50, 20);
        ellipse(x, 253, 50, 20);
        ellipse(x, 252, 50, 20);
        ellipse(x, 251, 50, 20);
        ellipse(x, 250, 50, 20);
        ellipse(x, 249, 50, 20);

        ellipse(x, 248, 50, 20);
        ellipse(x, 247, 50, 20);
        ellipse(x, 246, 50, 20);
        ellipse(x, 245, 50, 20);
      }


      //=======================Pressed=================
      void Pressed() {
        // Button Pressed

          fill(col);//color set

        ellipse(x, 254, 50, 20);
        ellipse(x, 253, 50, 20);
        ellipse(x, 252, 50, 20);
        ellipse(x, 251, 50, 20);
        ellipse(x, 250, 50, 20);
      }

      //=======================setColor=================
      void setColor(int tempR, int tempG, int tempB) {
        col = color(tempR, tempG, tempB);
      }
    }

     


Viewing all articles
Browse latest Browse all 1768

Trending Articles