ICM Final Project: Intertext

Posted by on Dec 13, 2006

So here’s the results of a semesters worth of coding. Special thanks and three cheers to Daniel Shiffman for being an amazing instructor and all round super guy. I’m taking Programming A to Z with him next semester. Programming was the not something I expected to enjoy at ITP, but after Shiffman’s ICM class I’m looking forward to getting closer to attaining pure command line functionality (just like Roy).

See my previous ICM posts for more background info on the project.

A low-res movie of my project in action:

Some photos of the completed project:
ulytest4.jpg

ulytest3.jpg

ulytest5.jpg

ulytest1.jpg

The arduous process of hollowing a book:
ulyguts.jpg

ulyguts2.jpg

ulyguts4.jpg

ulyguts3.jpg

My Processing code:

//F_Proj

import processing.video.*;
PImage img;
int counter = 0;
int charcount = 0;
int scl;
float rowheight;
Capture video;
String chars;
PFont f;
ArrayList letters;
int index = 0;

//_____________________

void setup(){
size (640,480);
img = loadImage(“largejoyce!.jpg”);
println(img.width + ” ” + img.height);
String[] Text = loadStrings(“Ulysses.txt”);
video = new Capture (this, 320, 240, 60);
scl = width/img.width;
scl = width/video.width;
background (0);
f =loadFont(“Arial-Black-12.vlw”);

chars = join (Text, “”);
createGrid(11.5);
}

//_________________________

void draw(){
background (0);

if (video.available()){
video.read ();
}

for (int i = 0; i Letter current = (Letter) letters.get(i);
current.updateColor();
current.display();
}
}

//________________________________________________

void createGrid(float rowheight) {
letters = new ArrayList();
textFont (f,rowheight);

for (float y =0; y float x = 0;

while (x < width) {
int pixelx = constrain(int(x/2),0,video.width-1);
int pixely = constrain(int(y/2),0,video.height-1);
println(pixelx + " " + pixely);
fill(video.pixels[pixelx+pixely*video.width]);
int i = int(x) / scl;
int j = int(y) / scl;
Letter newletter = new Letter(x,y,chars.charAt(charcount),video.pixels[pixelx+pixely*video.width]);
letters.add(newletter);
counter++;
x += textWidth(chars.charAt(charcount));
charcount = (charcount +1) % chars.length();
}
}
}

///Letter Tab
//establishing the text's letters to be used as pixels
class Letter {
float x,y;
float orig_x, orig_y;
char c;
color clr;

Letter(float x_, float y_, char c_, color clr_) {
x=x_;
y=y_;
orig_x = x_;
orig_y = y_;
c=c_;
clr = clr_;
}

void display(){
textFont (f,13);
fill(clr);
text(c,x,y);
}

//Where the image to video exchange and pixel movement is occuring/being called.
void updateColor() {
int pixelx = constrain(int(x/2),0,video.width-1);
int pixely = constrain(int(y/2),0,video.height-1);

float m = millis();
if (m<5000){
clr = img.pixels[pixelx+pixely*img.width];

}

if (m>7000 && m<12000){
CalX1();
CalY1();
CalX2();
CalY2();
}

if (m>12000 && m<25000){
reCalX1();
reCalY2();
reCalX2();
reCalY1();
}

if (m>10000){
clr = video.pixels[pixelx+pixely*video.width];
}
}

//———————————————-

//Text Movement Tab

//*****************move the image bearing text away

void CalX1(){
if (x> width/2) {
x= x+10;
}
}

void CalX2(){
if (x<= width/2) {
x=x-10;
}
}

void CalY1(){
if (y >=height/2){
y=y+10;
}
}

void CalY2(){
if (y <= height/2){
y=y-10;
}
}

//************spit back the viewer bearing text

void reCalX1(){
if (x> width/2) {
x= x-10;
if (x<=orig_x){
x=orig_x;
}
}
}

void reCalX2(){
if (x x=x+10;
if (x>=orig_x){
x=orig_x;
}
}
}

void reCalY1(){
if (y>(height/2)) {
y=y-10;
if (y<=orig_y){
y=orig_y;
}
}
}

void reCalY2(){
if (y < height/2){
y=y+10;
if (y>=orig_y){
y=orig_y;
}
}
}

}