Lighting with Processing
Setting Up Processing
1 Download Processing. Place Processing in the Applications folder on your computer (or Program Files for Windows). When you double click Processing, it should install and launch the application with a new empty sketch. A sketch is where you will write your code. We’ll be writing code in Java inside of Processing.
Basics
You will have two basic parts in Processing, the “setup” and the “draw” loop. The setup loop runs once when launching your script, whereas the draw loop runs repeatedly. This allows you to save computing power by sticking parts of the code that only need to run at the start in the setup loop. The draw loop will continually update so it can change over time, or get realtime information such as the location of your mouse or update a camera feed.
void setup() {
size(1280, 960);
}
void draw() {
background(0);
ellipse(mouseX,mouseY,500,510);
}
Light
//images below from left to right
background(0);
background(0,255,0);
background(255,255,0);
fill()
noFill()
stroke()brightness()
color()
hue()
saturation()
Time
Changing ellipse size, location, stroke weight, background color by time parameters.
day()
hour()
millis()
minute()
month()
second()
year()
For Next Class
2 With the help of the tutorials above, please create you own combination of colors, shape, time, Processing’s movie input, and video camera input to create your own lighting phenomena. Please also use one new function not referenced in this tutorial from the Processing Documentation, such as text()
.
3 Document your lighting effects through videos and gifs. Extra bonus points for testing some light projection with a projector! Can you play with aspects of the room to get your projection to align with the space?
Some other useful tips
If you are looking for more examples — you can find some great things to try under File
> Examples
.
This brings up a lot of various examples which you can play around with and learn how different bits of code are functioning.
Some useful things to know about the code:
//these two slashes create a comment in your code//print allows you to see the values of a parameter in the console. For example, the print below prints the second. If you add this in the draw loop you should see a continual printing of the current second.
print(second());
Bonus: Referencing Your Webcam (not required)
For help with a video tutorial, follow Daniel Shiffman’s tutorial:
To get started you will need this library to capture video feed from your camera: Sketch > Library > Import Library > Video Library
Capture
— captures live feed from a camera source or webcamVideo
— takes in a video sourceCapture
andVideo
have the same functionality as aPImage
Some new concepts to understand. These Java functions require self referencing thru the use of this
.
import processing.video.*;Capture video;void setup() {
size(500,500);
video = new Capture(this,displayWidth,displayHeight,30);
video.start();
}void captureEvent(Capture video){
video.read();
}void draw(){
background(0);
image(video, 0, 0, mouseX, mouseY);
}
Referencing A Movie
To use the video referencing you’ll need to add your video file into a folder in your sketch folder named “data”.
import processing.video.*;Movie video;void setup() {
size(1500,1500);
video = new Movie(this, "boat.mov");
video.loop();
}void movieEvent(Movie video){
video.read();
}void draw(){
background(0);
image(video, 0, 0);
}