Processing 2.1 : Webcam Basics

Here are a few examples of a basic webcam application that I created in Processing 2.1, utilizing the ‘FaceTime HD Camera’ on my MacBook Air. The code maybe helpful for some as a basic introduction into the Processing video library. It’s really simple to get a webcam viewer up and running in Processing with just a few lines of code:

import processing.video.*;
Capture webcam;
int camW = 1280;
int camH = 720;
int stageW = 1280;
int stageH = 720;
void setup()
{
  size(stageW,stageH);
  smooth();
  println(Capture.list());//prints out available cameras
  webcam = new Capture(this, camW, camH, "FaceTime HD Camera (Built-in)", 30);
  webcam.start();
  
}
void draw(){
  
  background(255);
  image(webcam,0,0);
}
void captureEvent(Capture webcam)
{
  webcam.read();
}

If you are new to the Processing language, you are probably wondering what exactly the code above does. Well lets break it down to help understand the basics before we move onto the fun stuff.

The first line of code “imports” the video library, which allows us to access or web cam:

import processing.video.*;

Next, we declare an object of the Capture type, which is used to access our webcam.

Capture webcam;

The next few lines:


int camW = 1280;
int camH = 720;
int stageW = 1280;
int stageH = 720;

are variables for the cameras width and height and the stage/canvas width and height pixel dimensions, which will be useful and reusable in the following applications. Next, we initialize the environment properties and more importantly the Capture object in the setup() function. The setup() function is only called once when the program starts, it’s primary use is to define initial program/sketch environment properties. There can only be one setup() function for each Processing program.

void setup()
{
size(stageW,stageH);
smooth();
println(Capture.list());//prints out available cameras
webcam = new Capture(this, camW, camH, “FaceTime HD Camera (Built-in)”, 30);
webcam.start();

}

With in the setup() function we have a few lines of code that we should step through.
size(); The size function defines the dimension of the display window in units of pixels. The size() function must be the first line of code, or the first code inside setup(), it sets the Processing window size when you run your cool Processing program.

The smooth(); function draws all geometry with anti-aliased edges. The smooth() function will also improve image quality of re-sized images and by default its set to active.

The println() function is a way to write to the console area. This function helps you debug your application. In my code example println(Capture.list()), the console prints out available devices(cameras) on my laptop using the Capture.list() function. The Capture.list() function will retrieve a list of all available capture devices, which is helpful. My web camera was identified as a ‘FaceTime HD Camera’. I provide the info as a parameter to the Capture constructor. You don’t necessarily have to do that, you can use a few lines of code like so :

String[] cameras = Capture.list();
webcam = new Capture(this, cameras[0]);

To initialize the camera directly using an element from the array returned by the Capture.list() method.

The Capture constructor is a datatype for storing and manipulating video frames from an attached capture device. There are many ways to instantiate the Capture constructor, for reference, here they are:


Capture(parent)
Capture(parent, requestConfig);
Capture(parent, requestWidth, requestHeight);
Capture(parent, requestWidth, requestHeight, frameRate);
Capture(parent, requestWidth, requestHeight, cameraName);
Capture(parent, requestWidth, requestHeight, cameraName, frameRate);

You will notice in my code example I used the verbose Capture(parent, requestWidth, requestHeight, cameraName, frameRate); format. Just for clarity, here are the parameters for the Capture constructor:

parent PApplet: typically use “this”
requestWidth int: width of the frame
requestHeight int: height of the frame
cameraName String: name of the camera
frameRate int: number of frames to read per second, usually 30

The next line of code simply starts the camera Capture, by capturing frames from the selected device.

webcam.start();

Next, lets move onto the draw() function. The draw() function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called. This is the primary function that draws the image from the webcam to the screen.

void draw(){

background(255);
image(webcam,0,0);
}

Lets step through the few lines of code for clarity.
The background() function sets the color used for the background of the Processing window.
The image() function draws an image to the display window. There can only be one draw() function for each processing program/sketch.

Last but not least, we need to add the capture event, which is called every time a new frame is available.
void captureEvent(Capture webcam)
{
webcam.read();
}

Now, if you are new to Processing you can simply copy and paste the provided code into an empty Processing sketch (sorry no download) or if you are the ambitious type, you may type the code into a blank sketch (practice makes perfect). Which ever path you take, you are ready to run the program/sketch and hopefully see your pretty face on display. That’s pretty much all you need to do to get your webcam up and running on your display/monitor.

To take this posting a bit further, I provided following code examples to take the basic webcam code above and add simple features such as, a basic user interface to manipulate the webcam feed using Processing filters, the tint function and includes ability to save the manipulated webcam image. I’m not going to go over the code line by line, but I’ll leave you with a tiny bit of info on filters. Processing has a few simple presets that you can play with to help make interesting effects. This helps add some creativity to your webcam image. The following are the presets options:

THRESHOLD
Converts the image to black and white pixels depending if they are above or below the threshold defined by the level parameter. The parameter must be between 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is used.

GRAY
Converts any colors in the image to grayscale equivalents. No parameter is used.

OPAQUE
Sets the alpha channel to entirely opaque. No parameter is used.

INVERT
Sets each pixel to its inverse value. No parameter is used.

POSTERIZE
Limits each channel of the image to the number of colors specified as the parameter. The parameter can be set to values between 2 and 255, but results are most noticeable in the lower ranges.

BLUR
Executes a Guassian blur with the level parameter specifying the extent of the blurring. If no parameter is used, the blur is equivalent to Guassian blur of radius 1. Larger values increase the blur.

ERODE
Reduces the light areas. No parameter is used.

DILATE
Increases the light areas. No parameter is used.

As you can imagine, you can let your mind free to create more than a simple web cam viewer. The following code examples are base effects. I hope I inspire you to take the code, make it better, add Arduino buttons or create random effects. Enjoy!

Blur It Up

import processing.video.*;
Capture webcam;
boolean blured = false;
int camW = 1280;
int camH = 720;
int stageW = 1280;
int stageH = 720;
int interfaceH = 50;
int firstLine = 18;
int secondLine = 34;
int bluredVal = 2;
void setup()
{
  size(stageW,(stageH+interfaceH));
  smooth();
  println(Capture.list());
  webcam = new Capture(this, camW, camH, "FaceTime HD Camera (Built-in)", 30);
  webcam.start();
  
}
void draw(){
  
  background(255);
  image(webcam,0,0);
  isFiltered();
  renderUI();
  
}
void renderUI(){
  int gutter = 15;
  fill(0,0,0);
  noStroke();
  rect(0,camH,stageW,interfaceH);
  fill(255);
  text("Press the B key to activate the Blur filter, use the up and down keys to +/- the value.   Press S to capture the image.", gutter,(camH + firstLine-5)); 
  fill(255,0,0);
  text("Active Filter :                   Value :", gutter,(camH + secondLine));
  renderFilterButtons();
}
void renderFilterButtons(){
  int buttonHeight = 18;
  String blurStr = "BLUR";
  float blurStrW = textWidth(blurStr);
  noFill();
  if(blured){
      stroke(255,0,0);
  }else{
      stroke(255);
  }
  rect(100,(camH+ firstLine + 2),blurStrW+8,buttonHeight);
  fill(255);
  text(blurStr, 100+5,(camH + secondLine));
  
  noFill();
  if(blured){
      stroke(255,0,0);
  }else{
      stroke(255);
  }
  rect(220,(camH+ firstLine + 2),25,buttonHeight);
  fill(255);
  String blurVal = str(bluredVal);
  text(blurVal, 220+5,(camH + secondLine));

  String saveStr = "SAVE";
  float saveStrW = textWidth(saveStr); 
  noFill();
  stroke(255);
  rect(stageW - 45,(camH + (firstLine + 2)),saveStrW+8,buttonHeight);
  fill(255);
  text(saveStr, (stageW - 45)+5,(camH + secondLine));
}
void captureEvent(Capture webcam)
{
  webcam.read();
}
void isFiltered()
{
  if(blured){
    filter(BLUR,bluredVal);
  }
}
void keyPressed()
{
  switch (keyCode){
    case 66:
    if(blured){
      blured = false;
    }else{
      blured = true;
    }
    break;
    case 38:
    if(blured){
      if(bluredVal >=10){
        bluredVal = 10;
      }else{
        bluredVal++;
      }
    }
    break;
    case 40:
    if(blured){
      
      if(bluredVal <=1){
          bluredVal = 1;
      }else{  
          bluredVal--;
      }
    }
    break;
    case 83:
    saveImage();
    break;
    
    default:
    break;
  }
}
void saveImage()
{
    fill(0,0,0);
    noStroke();
    rect(0,camH,stageW,interfaceH);
    fill(255);
    text("BROUGHT TO YOU BY CODING COLOR DOT COM", (stageW/2-120),(stageH + secondLine));
    saveFrame("images/captured-####.jpg");
}

DOWNLOAD – Blur It Up (338)

Posterize Me!

import processing.video.*;
Capture webcam;
boolean posterized = false;
int camW = 1280;
int camH = 720;
int stageW = 1280;
int stageH = 720;
int interfaceH = 50;
int firstLine = 18;
int secondLine = 34;
int posterizeVal = 4;
void setup()
{
  size(stageW,(stageH+interfaceH));
  smooth();
  //println(Capture.list());
  webcam = new Capture(this, camW, camH, "FaceTime HD Camera (Built-in)", 30);
  webcam.start();
  
}
void draw(){
  
  background(255);
  image(webcam,0,0);
  isFiltered();
  renderUI();
  
}
void renderUI(){
  int gutter = 15;
  fill(0,0,0);
  noStroke();
  rect(0,camH,stageW,interfaceH);
  fill(255);
  text("Press the P key to activate the Posterize filter, use the up and down keys to +/- the value. Press S to capture the image.", gutter,(camH + firstLine-5)); 
  fill(255,0,0);
  text("Active Filter :                          Value :", gutter,(camH + secondLine));
  renderFilterButtons();
}
void renderFilterButtons(){
  int buttonHeight = 18;
  String postStr = "Posterize";
  float postStrW = textWidth(postStr);
  noFill();
  if(posterized){
      stroke(255,0,0);
  }else{
      stroke(255);
  }
  rect(100,(camH+ firstLine + 2),postStrW+8,buttonHeight);
  fill(255);
  text(postStr, 100+5,(camH + secondLine));

  noFill();
  if(posterized){
      stroke(255,0,0);
  }else{
      stroke(255);
  }
  rect(250,(camH+ firstLine + 2),30,buttonHeight);
  fill(255);
  String postVal = str(posterizeVal);
  text(postVal, 250+5,(camH + secondLine));

  String saveStr = "SAVE";
  float saveStrW = textWidth(saveStr); 
  noFill();
  stroke(255);
  rect(stageW - 45,(camH + (firstLine + 2)),saveStrW+8,buttonHeight);
  fill(255);
  text(saveStr, (stageW - 45)+5,(camH + secondLine));
}
void captureEvent(Capture webcam)
{
  webcam.read();
}
void isFiltered()
{
  if(posterized){
    filter(POSTERIZE,posterizeVal);
  }
}
void keyPressed()
{
  switch (keyCode){
    case 80:
    if(posterized){
      posterized = false;
    }else{
      posterized = true;
    }
    break;
    case 38:
    if(posterized){
      if(posterizeVal >=254){
        posterizeVal = 255;
      }else{
        posterizeVal++;
      }
    }
    break;
    case 40:
    if(posterized){
      
      if(posterizeVal <=3){
          posterizeVal = 2;
      }else{  
          posterizeVal--;
      }
    }
    break;
    case 83:
    saveImage();
    break;
    default:
    break;
  }
}
void saveImage()
{
    fill(0,0,0);
    noStroke();
    rect(0,camH,stageW,interfaceH);
    fill(255);
    text("BROUGHT TO YOU BY CODING COLOR DOT COM", (stageW/2-120),(stageH + secondLine));
    println("saved");
    
    saveFrame("images/captured-####.jpg");
}

DOWNLOAD – Posterize Me (303)

The Kitchen Sink.

import processing.video.*;
Capture webcam;
boolean blured,dilated,eroded,grayed,inverted,opaqued,posterized,thresholded;
int camW = 1280;
int camH = 720;
int stageW = 1280;
int stageH = 720;
int interfaceH = 50;
int firstLine = 18;
int secondLine = 34;
void setup()
{
  size(stageW,(stageH+interfaceH));
  smooth();
  blured=false;
  dilated=false;
  eroded=false;
  grayed=false;
  inverted=false;
  opaqued=false;
  posterized=false;
  thresholded=false;
  //println(Capture.list());
  webcam = new Capture(this, camW, camH, "FaceTime HD Camera (Built-in)", 30);
  webcam.start();
  
}
void draw(){
  
  background(255);
  image(webcam,0,0);
  isFiltered();
  renderUI();
  
}
void renderUI(){
  int gutter = 15;
  fill(0,0,0);
  noStroke();
  rect(0,camH,stageW,interfaceH);
  fill(255);
  text("Use the keyboard to activate a filter B=Blur, D=Dilate, E=Erode, G=Gray, I=Invert, O=Opaque, P=Posterize, T=Threshold. Press S to capture the image. ", gutter,(camH + firstLine-5)); 
  fill(255,0,0);
  text("Active Filters : ", gutter,(camH + secondLine));
  renderFilterButtons();
}
void renderFilterButtons(){
  String[] filterType = {"BLUR","DILATE","ERODE","GRAY","INVERT","OPAQUE","POSTERIZE","THRESHOLD"};
  int numOfFilters = filterType.length;
  int buttonWidth;
  int buttonHeight = 18;
  int startX = 110;
  String str;
  for(int i=0; i < numOfFilters; i++)
  {
    int xPos;
    switch(i){
      case 0:
      str = filterType[i];
      xPos = startX;
      buttonWidth = 37;
      noFill();
      if(blured){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      break;
      case 1:
      str = filterType[i];
      xPos = startX + 40;
      buttonWidth = 48;
      noFill();
      if(dilated){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      //text
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      //
      break;
      case 2:
      str = filterType[i];
      xPos = startX + 91;
      buttonWidth = 48;
      noFill();
      if(eroded){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      break;
      case 3:
      str = filterType[i];
      xPos = startX + 142;
      buttonWidth = 41;
      noFill();
      if(grayed){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      break;
      case 4:
      str = filterType[i];
      xPos = startX + 186;
      buttonWidth = 51;
      noFill();
      if(inverted){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      break;
      case 5:
      str = filterType[i];
      xPos = startX + 240;
      buttonWidth = 56;
      noFill();
      if(opaqued){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      break;
      case 6:
      str = filterType[i];
      xPos = startX + 299;
      buttonWidth = 70;
      noFill();
      if(posterized){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      break;
      case 7:
      str = filterType[i];
      xPos = startX + 372;
      buttonWidth = 79;
      noFill();
      if(thresholded){
        stroke(255,0,0);
      }else{
        stroke(255);
      }
      rect(xPos,(camH+ firstLine + 2),buttonWidth,buttonHeight);
      fill(255);
      text(str, xPos+5,(camH + secondLine));
      break;
      default:
      break;
    };
      String saveStr = "SAVE";
      int saveButtonWidth = 38;
      int saveXPos = stageW - (saveButtonWidth+10);
      noFill();
      stroke(255);
      rect(saveXPos,(camH+ firstLine + 2),saveButtonWidth,buttonHeight);
      fill(255);
      text(saveStr, saveXPos+5,(camH + secondLine));
    
  };
  

}
void captureEvent(Capture webcam)
{
  webcam.read();
}
void isFiltered()
{
  if(blured){
    filter(BLUR,4);
  }
  if(dilated){
    filter(DILATE);
  }  
  if(eroded){
    filter(ERODE);
  }
  if(grayed){
    filter(GRAY);
  }
  if(inverted){
    filter(INVERT);
  }
  if(opaqued){
    filter(OPAQUE);
  }
  if(posterized){
    filter(POSTERIZE,4);
  }
  if(thresholded){
    filter(THRESHOLD);
  }
}
void keyPressed()
{
  println(keyCode);
  switch (keyCode){
    case 66:
    if(blured){
      blured = false;
    }else{
      blured = true;
    }
    println("blur filter active " + blured );
    break;
    case 68:
    if(dilated){
      dilated = false;
    }else{
      dilated = true;
    }
    println("dilate filter active " + dilated );
    break;
    case 69:
    if(eroded){
      eroded = false;
    }else{
      eroded = true;
    }
    println("erode filter active " + eroded );
    break;
    case 71:
    if(grayed){
      grayed = false;
    }else{
      grayed = true;
    }
    println("gray filter active " + grayed );
    break;
    case 73:
    if(inverted){
      inverted = false;
    }else{
      inverted = true;
    }
    println("invert filter active " + inverted );
    break;
    case 79:
    if(opaqued){
      opaqued = false;
    }else{
      opaqued = true;
    }
    println("Opaque filter active " + opaqued );
    break;
    case 80:
    if(posterized){
      posterized = false;
    }else{
      posterized = true;
    }
    println("Posterize filter active " + posterized );
    break;
    case 84:
    if(thresholded){
      thresholded = false;
    }else{
      thresholded = true;
    }
    println("Threshold filter active " + thresholded );
    break;
    case 83:
    saveImage();
    break;
    default:
    break;
  }
}
void saveImage()
{
    fill(0,0,0);
    noStroke();
    rect(0,camH,stageW,interfaceH);
    fill(255);
    text("BROUGHT TO YOU BY CODING COLOR DOT COM", (stageW/2-120),(stageH + secondLine));
    println("saved");
    
    saveFrame("images/captured-####.jpg");
}

DOWNLOAD – The kitchen sink (267)

Faux Sepia-Tone Effect

import processing.video.*;
Capture webcam;
boolean sepied = false;
int camW = 1280;
int camH = 720;
int stageW = 1280;
int stageH = 720;
int interfaceH = 50;
int firstLine = 18;
int secondLine = 34;
int sepiedVal = 2;
void setup()
{
  size(stageW,(stageH+interfaceH));
  smooth();
  println(Capture.list());
  webcam = new Capture(this, camW, camH, "FaceTime HD Camera (Built-in)", 30);
  webcam.start();
  
}
void draw(){
  
  background(255);
  image(webcam,0,0);
  isFiltered();
  renderUI();
  
}
void renderUI(){
  int gutter = 15;
  fill(0,0,0);
  noStroke();
  rect(0,camH,stageW,interfaceH);
  fill(255);
  text("Press the T key to activate the Sepia-Tone faux filter.   Press S to capture the image.", gutter,(camH + firstLine-5)); 
  fill(255,0,0);
  text("Active Filter : ", gutter,(camH + secondLine));
  renderFilterButtons();
}
void renderFilterButtons(){
  int buttonHeight = 18;
  String sepiaStr = "Sepia-Tone";
  float sepiaStrW = textWidth(sepiaStr);
  noFill();
  if(sepied){
      stroke(255,0,0);
  }else{
      stroke(255);
  }
  rect(100,(camH+ firstLine + 2),sepiaStrW+8,buttonHeight);
  fill(255);
  text(sepiaStr, 100+5,(camH + secondLine));
  
  noFill();
  if(sepied){
      stroke(255,0,0);
  }else{
      stroke(255);
  }
  
  String saveStr = "SAVE";
  float saveStrW = textWidth(saveStr); 
  noFill();
  stroke(255);
  rect(stageW - 45,(camH + (firstLine + 2)),saveStrW+8,buttonHeight);
  fill(255);
  text(saveStr, (stageW - 45)+5,(camH + secondLine));
}
void captureEvent(Capture webcam)
{
  webcam.read();
}
void isFiltered()
{
  if(sepied){
        tint(112, 66, 20);
  }else{
    noTint();
  }
}
void keyPressed()
{
  println(keyCode);
  switch (keyCode){
    case 84:
    if(sepied){
      sepied = false;
    }else{
      sepied = true;
    }
    break;
    case 83:
    saveImage();
    break;
    
    default:
    break;
  }
}
void saveImage()
{
    fill(0,0,0);
    noStroke();
    rect(0,camH,stageW,interfaceH);
    fill(255);
    text("BROUGHT TO YOU BY CODING COLOR DOT COM", (stageW/2-120),(stageH + secondLine));
    saveFrame("images/captured-####.jpg");
}

DOWNLOAD – Faux Sepia-Tone Effect (229)

Tint-O-matic

import processing.video.*;
Capture webcam;
int currentTintClr;
String activeClrStr="None";
boolean isTinted=false;
int tints[]={#ffc0cb,#74e571,#86cdeb, #a386eb, #800000,#ffd700, #000080,#ff6600,#d2691e,#ff69b4};
int camW = 1280;
int camH = 720;
int stageW = 1280;
int stageH = 720;
int interfaceH = 50;
int firstLine = 18;
int secondLine = 34;
void setup()
{
  size(stageW,(stageH+interfaceH));
  smooth();
  println(Capture.list());
  webcam = new Capture(this, camW, camH, "FaceTime HD Camera (Built-in)", 30);
  webcam.start();
  
}
void draw(){
  
  background(255);
  image(webcam,0,0);
  isFiltered();
  renderUI();
  
}
void renderUI(){
  int gutter = 15;
  fill(0,0,0);
  noStroke();
  rect(0,camH,stageW,interfaceH);
  fill(255);
  text("Press the corresponding key to activate tint :  m=magenta, l=lime, b=baby blue, p=purple, r=brick red, g=gold, d=dark blue, o=orange, c=chocolate, h=hot pink n=none.                                            Press S to capture the image.", gutter,(camH + firstLine-5)); 
  fill(255,0,0);
  text("Colors :                                                                         Active : "+ activeClrStr, gutter,(camH + secondLine));
  renderFilterButtons();
  renderPallete();
}
void renderPallete(){
  int sqrDim = 25;
  for (int i=0;i<tints.length;i++) {
    fill(tints[i]);
   // rect(0, i*50, 50, 50);
   rect(65+(i*sqrDim + 5), (camH+ firstLine + 2), sqrDim, sqrDim);
  }
}
void renderFilterButtons(){
  int buttonHeight = 18;
  String saveStr = "SAVE";
  float saveStrW = textWidth(saveStr); 
  noFill();
  stroke(255);
  rect(stageW - 45,(camH + (firstLine + 2)),saveStrW+8,buttonHeight);
  fill(255);
  text(saveStr, (stageW - 45)+5,(camH + secondLine));
}
void captureEvent(Capture webcam)
{
  webcam.read();
}
void isFiltered()
{
  
  if(isTinted){
        tint(currentTintClr);
  }else{
    noTint();
  }

}
void keyPressed()
{
  println(keyCode);
  switch (keyCode){
    case 77:
      isTinted = false;
      activeClrStr = "Magenta";
      currentTintClr = tints[0];
      isTinted = true;

    break;
     case 76:
      isTinted = false;
      activeClrStr = "Lime";
      currentTintClr = tints[1];
      isTinted = true;
    break;
     case 66:
      isTinted = false;
      activeClrStr = "Baby Blue";
      currentTintClr = tints[2];
      isTinted = true;
    break;
     case 80:
      isTinted = false;
      activeClrStr = "Purple";
      currentTintClr = tints[3];
      isTinted = true;
    break;
     case 82:
      isTinted = false;
      activeClrStr = "Brick Red";
      currentTintClr = tints[4];
      isTinted = true;
    break;
     case 71:
      isTinted = false;
      activeClrStr = "Gold";
      currentTintClr = tints[5];
      isTinted = true;
    break;
     case 68:
      isTinted = false;
      activeClrStr = "dark Blue";
      currentTintClr = tints[6];
      isTinted = true;
    break;
     case 79:
      isTinted = false;
      activeClrStr = "Orange";
      currentTintClr = tints[7];
      isTinted = true;
    break;
     case 67:
      isTinted = false;
      activeClrStr = "Chocolate";
      currentTintClr = tints[8];
      isTinted = true;
    break;
    case 72:
      isTinted = false;
      activeClrStr = "Hot Pink";
      currentTintClr = tints[9];
      isTinted = true;
    break;
     case 78:
    if(isTinted){
      activeClrStr = "None";
      isTinted = false;
    }
    break;
    case 83:
    saveImage();
    break;
    
    default:
    break;
  }
}
void saveImage()
{
    fill(0,0,0);
    noStroke();
    rect(0,camH,stageW,interfaceH);
    fill(255);
    text("BROUGHT TO YOU BY CODING COLOR DOT COM", (stageW/2-120),(stageH + secondLine));
    saveFrame("images/captured-####.jpg");
}

DOWNLOAD – Tint-O-Matic (293)

Are you having fun yet?

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: