April 3, 2008

digital book – text display

I have been doing research on electronic ink displays and exploring gestures for generating electricity. I have been working on the Processing end of things and figured out how to load, format and display a whole lot of text. For now, I’m using the < and > keys to navigate, but eventually it will be done tangibly. Here is a screenshot:

void setup() {
size (450, 600);
frameRate(10);
/*
println(Serial.list()); // Set up the serial communication
port = new Serial(this, Serial.list()[1], 9600); // Open the port that the board is connected to (in this case COM4 = [1])
// and use the same speed (9600 bps)
*/
font = loadFont(“BookAntiqua-10.vlw”);
title = loadFont(“BookAntiqua-BoldItalic-48.vlw”);
String lines[] = loadStrings(“ulysses_text only.txt”); // Loads the book from a text file and seperates each line into a String in an array
println(“there are ” + lines.length + ” lines”); // prints the number of lines
}

void draw() {
background (250); // sets the background color
fill (0); // sets the text color
smooth(); // anti-aliasing
String lines[] = loadStrings(“ulysses_text only.txt”); // for some reason, the only way I can get this to work is by reloading the strings every frame