/** * Line brush * *

Elie Zananiri
* CART 253, Winter 2008

*/ PFont f; String[] textFile; // contents of external file split by line int textIndex = 0; // tracks the current location in the textFile array void setup() { size(400, 400); smooth(); frameRate(30); background(0); // load and set the font f = loadFont("Skia-48.vlw"); textFont(f, 12); // load the contents of the external file into the String array textFile = loadStrings("hamsters.txt"); fill(255); } void draw() { // keep the motor running } void mouseDragged() { sprayText(); } void keyPressed() { if (key == ' ') { // clear screen background(0); } } /* writes a line of text at the mouse position */ void sprayText() { text(textFile[textIndex], mouseX, mouseY); textIndex++; // if we reach the end of the array, reset index to the beginning if (textIndex >= textFile.length) { textIndex = 0; } }