eriknau

photobooth

Apr 22nd, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var capture;
  2. var frame;
  3. function setup() {
  4.   createCanvas(600, 450);
  5.   capture = createCapture(VIDEO);
  6.   capture.size(width, height);
  7.   capture.hide();
  8.   frame = loadImage("frame.png"); //you need a local image that is your frame border
  9. }
  10.  
  11. function draw() {
  12.   background(255);
  13.   image(capture, 0, 0, width, height);
  14.  
  15.   if (keyIsPressed) {  //uses MaKey MaKey so limited input
  16.     if (keyCode == UP_ARROW) colorize();
  17.     if (keyCode == LEFT_ARROW) filter(POSTERIZE, 5);
  18.     if (keyCode == RIGHT_ARROW) filter(INVERT);
  19.     if (keyCode == DOWN_ARROW) showText();
  20.     if (key === ' ') image(frame,0,0,width,height);
  21.   }
  22. }
  23.  
  24. function showText() {
  25.   fill(255, 255, 0, 150);
  26.   textSize(150);
  27.   textAlign(CENTER);
  28.   text("COOL", width/2, height / 2);
  29. }
  30.  
  31. function colorize() {
  32.   fill(0,0,255,100);
  33.   rect(0,0,width,height);
  34. }
  35.  
  36. function mouseReleased() {
  37.   save("photobooth.png");
  38. }
Advertisement
Add Comment
Please, Sign In to add comment