// Kinetic Type // by Zach Lieberman // Using the charWidth() function with push() pop() defines the // curves of the lines of type. // Created Spring 2002 // Updated 18 January 2003 Line ln; Line lns[]; BFont f; int clicks = 0; String words[] = { "Howling wind gusts of 50 mph brought down power lines yesterday", "A high wind warning with sustained winds of at least 40 mph with gusts to 50 mph", "A wind advisory was also in effect", "Planes were grounded up and down the East Coast with outbound flights facing delays of 30 minutes to more than two hours", "Inbound flights were delayed 15 minutes to an hour by squalls", "The high winds were whipped up in the afternoon by a low pressure system moving from the Great Lakes across northern New England", "Massachusetts Electric crews were on a rollar-coaster ride trying to keep up with the number of outages, which soared to 7,000 in the early afternoon, dropped to less than 1,000 and rose again to 7,000 by early evening", "Blustery winds leveled power lines across Route 9 in Framingham, forcing police to close down the highway for several hours" }; void setup() { size(900, 300); framerate(30); // array of line objects lns = new Line[8]; // load the font. fonts are located within the // main Processing directory/folder and they // must be placed within the data directory // of your sketch for them to load f = loadFont("Univers66.vlw.gz"); textFont(f, 1f); // white type, black background fill(255); // creating the line objects for(int i = 0; i < 8; i++) { // for every line in the array, create a Line object to animate // i * 70 is the spacing ln = new Line(words[i], 0, i * 70, f); lns[i] = ln; } } void loop() { background(0); translate((float)(width / 2.0) - 1150, (height / 2.0) - 240 - (10*clicks), -450-(30 * clicks)); rotateX(0 +.01 * clicks); rotateY(0.33 +.02 * clicks); rotateZ(0 +.01 * clicks); // now animate every line object & draw it... for(int i = 0; i < 8; i++) { float f1 = sin((i + 1.0) * (millis() / 10000.0) * TWO_PI); float f2 = sin((8.0 - i) * (millis() / 10000.0) * TWO_PI); Line line = lns[i]; push(); translate(0.0, line.yPosition, 0.0); for(int j = 0; j < line.myLetters.length; j++) { if(j != 0) translate(f.width(line.myLetters[j - 1].myChar) * 75, 0.0, 0.0); rotateY(f1 * 0.001 * f2 * clicks); push(); scale(75.0, 75.0, 75.0); text(line.myLetters[j].myChar, 0.0, 0.0); pop(); } pop(); } } class Letter { char myChar; float x; float y; Letter(char c, float f, float f1) { myChar = c; x = f; y = f1; } } class Word { String myName; int x; Word(String s) { myName = s; } } class Line { String myString; int xPosition; int yPosition; int highlightNum; BFont f; float speed; float curlInX; Letter myLetters[]; Line(String s, int i, int j, BFont bagelfont) { myString = s; xPosition = i; yPosition = j; f = bagelfont; myLetters = new Letter[s.length()]; float f1 = 0.0F; for(int k = 0; k < s.length(); k++) { char c = s.charAt(k); f1 += bagelfont.width(c); Letter letter = new Letter(c, f1, 0.0); myLetters[k] = letter; } curlInX = 0.1; } } void mouseReleased() { clicks++; }