import processing.opengl.*; int count = 50; int move = 5; float[] lineDepth = new float[4]; int[] lineX = new int[4]; float[] lineSpeed = new float[4]; String[] lines = {"A", "Word", "on", "Statistics"}; int lineHeight = 50; int wordIndex = 0; String[] words = {"A WORD ON STATISTICS","Out of every hundred people,","those who always know better:","fifty-two.","","Unsure of every step:","almost all the rest.","","Ready to help,","if it doesn't take long:","forty-nine.","","Always good,","because they cannot be otherwise:","four -- well, maybe five.","","Able to admire without envy:","eighteen.","","Led to error","by youth (which passes):","sixty, plus or minus.","","Those not to be messed with:","four-and-forty.","","Living in constant fear","of someone or something:","seventy-seven.","","Capable of happiness:","twenty-some-odd at most.","","Harmless alone,","turning savage in crowds:","more than half, for sure.","","Cruel","when forced by circumstances:","it's better not to know,","not even approximately.","","Wise in hindsight:","not many more","than wise in foresight.","","Getting nothing out of life except things:","thirty","(though I would like to be wrong).","","Balled up in pain","and without a flashlight in the dark:","eighty-three, sooner or later.","","Those who are just:","quite a few, thirty-five.","","But if it takes effort to understand:","three.","","Worthy of empathy:","ninety-nine.","","Mortal:","one hundred out of one hundred --","a figure that has never varied yet."}; void setup() { size(567, 350, OPENGL); background(120); stroke(153, 153, 0); PFont fontA = loadFont("Garamond-BookCon.vlw.gz"); textFont(fontA,40); smooth(); frameRate(60); // set up the speeds for (int i = 0; i < lineSpeed.length; i++) { lineSpeed[i] = 1; lineX[i] = 170; } } void draw() { float diceRoll = 20 + random(10); background(diceRoll); int whiteIndex = (int) random(40); int lineY = 0; java.util.TreeMap map = new java.util.TreeMap(); for (int i = 0; i < lineSpeed.length; i++) { map.put(new Float((lineDepth[i] + lineSpeed[i]/1.5)), new Integer(i)); } java.util.Iterator iter = map.values().iterator(); while (iter.hasNext()) { Integer index = (Integer) iter.next(); int i = index.intValue(); pushMatrix(); lineDepth[i] = lineDepth[i] + (lineSpeed[i]/1.5); if (lineDepth[i] > 250 || lineDepth[i] < -100) { if (lineDepth[i] > 250) lineDepth[i] = 250; if (lineDepth[i] < -100) lineDepth[i] = -100; float sign = 0; sign = (lineSpeed[i] > 0 ? 1 : -1); sign = -sign; float newSpeed = 0; while (newSpeed == 0) { newSpeed = (random(100)/100) + 1; } lineSpeed[i] = newSpeed * sign; wordIndex++; if (wordIndex >= words.length) wordIndex = 0; lines[i] = words[wordIndex]; } translate(-50,100,lineDepth[i]); if (whiteIndex == i) { fill(255,255,255); } else { fill(200,200,200); } String word = lines[i]; diceRoll = random(100); if (diceRoll > 50 && diceRoll < 54 && word.length() > 1) { int randomLetterIndex = 0; randomLetterIndex = (int) random(word.length()); word = word.substring(0,randomLetterIndex) + "1" + word.substring(randomLetterIndex + 1); } text(word,lineX[i],lineHeight * i); lineY += lineHeight; popMatrix(); } }