Well my intentions for this are not in any way apparent in this sketch… but perhaps I can explore this further a little down the line… I would like to grab one of my poems to be superimposed on to a live feed video performance. When the performer speaks and reaches certain frequency levels I would like for some of these words to jitter, enlarge or simply push other words out of the way… and perhaps return to their original state…
CODE:
// Sketch is based off Daniel Shiffmans Examples
// http://www.learningprocessing.com
// Example 17-6: Text breaking up
// Example 17-4: Text mirror
import processing.video.*;
// Size of each cell in the grid, ratio of window size to video size
int videoScale = 10;
// Number of columns and rows in our system
int cols, rows;
// Variable to hold onto capture object
Capture video;
PFont f;
String chars = ” yo naci en un ricon “;
// An array of Letter objects
Letter[] letters;
void setup() {
size(640,480);
// Set up columns and rows
cols = width/videoScale;
rows = height/videoScale;
video = new Capture(this,cols,rows,15);
// Load the font
f = loadFont(“StencilStd-10.vlw”);
// textFont(f);
// Create the array the same size as the String
letters = new Letter[chars.length()];
// Initialize Letters at the correct x location
int x = 0;
for (int a = 0; a < chars.length(); a ++ ) {
// Letter objects are initialized with their location within the String as well as what character they should display.
letters[a] = new Letter(x,100,chars.charAt(a));
// x += textWidth(chars.charAt(a));
}
}
void draw() {
background(0);
// Read image from the camera
if (video.available()) {
video.read();
}
video.loadPixels();
// Use a variable to count through chars in String
int charcount = 0;
// Begin loop for rows
for (int j = 0; j < rows; j ++ ) {
// Begin loop for columns
for (int i = 0; i < cols; i ++ ) {
// Where are we, pixel-wise?
int x = i*videoScale;
int y = j*videoScale;
// Looking up the appropriate color in the pixel array
color c = video.pixels[i + j*video.width];
// Displaying an individual character from the String instead of a rectangle
textFont(f);
fill(c);
// One character from the source text is displayed colored accordingly to the pixel location.
// A counter variableâ charcountâ is used to walk through the source String one character at a time.
text(chars.charAt(charcount),x,y);
// Go on to the next character
charcount = (charcount + 1) % chars.length();
for (int a = 0; a < letters.length; a ++ ) {
// Display all letters
letters[a].display();
// If the mouse is pressed the letters shake
// If not, they return to their original location
if (mousePressed) {
letters[a].shake();
}
else {
letters[a].home();
}
}
}
}
}
