/** * Teleprompter * * Simple program to scroll a text file vertically, on a blue * background. Intended for use with a partially-silvered * mirror, as a teleprompter. * * For remote control, uses application iRed Lite to * interface with Mac Remote: * http://www.filewell.com/iRedLite/ * * robert.twomey@gmail.com * */ PFont fontA; int offset=0; int i=0; int j=0; final int NUMCHARS=20; final int NUMLINES=6; final int FONT_SIZE=100; final int LINE_SPACING=120; int textX, textY; // variables controlling text motion and position boolean pause = false; int speed=2; int [] positions; int n; String lines[] = { "" }; void setDrawingPositions() { textX=width/2-NUMCHARS*int(textWidth("X"))/2; textY=height/2-NUMLINES*LINE_SPACING/2; println(textX+" "+textY); }; void setup() { size(screen.width, screen.height); background(0,0,64); smooth(); // Load the font. Fonts must be placed within the data // directory of your sketch. A font must first be created // using the 'Create Font...' option in the Tools menu. // Uncomment the following two lines to see the available fonts //String[] fontList = PFont.list(); //println(fontList); textAlign(LEFT); fontA = createFont("Helvetica-Bold", 255); fill(255); textFont(fontA, FONT_SIZE); setDrawingPositions(); loadText("/Users/rtwomey/script/script_statements.txt"); //language/nltk2.0/mmpi2_as_questions.txt"); //String lines[] = loadStrings("two stroke engine2.txt"); //String lines[] = loadStrings("script.txt"); //String lines[] = loadStrings("SCIP.txt"); //textMode(SCREEN); i=0; offset=0; j=0; pause=false; n=0; positions = new int[1]; positions[0]=0; } void draw_prompter() { // draw NUMLINES lines of text on screen with current vertical offset int li=i; int lj=j; int c=0; int rememberSpace; int k; for(c=0;c<=NUMLINES;c++) { if(li < lines[lj].length()-NUMCHARS) { k=1; rememberSpace=0; while(k1) { j=positions[positions.length-1]; i=0; offset=0; positions = shorten(positions); } else { j=0; }; i=0; break; default: break; }; println(j+", lastj= "+positions[positions.length-1]); } else { if(key==' ') { pause = (pause == true) ? false : true; }; } } void draw() { background(0,0,64); fill(255); draw_prompter(); if(pause==false) { offset-=speed; if(abs(offset)>int(LINE_SPACING)) { offset=0; if(speed > 0) { i+=NUMCHARS; if(i>lines[j].length()) { j++; i=0; }; } else { i-=NUMCHARS; if(i<0) { j--; if(j<0) j=lines.length-NUMLINES; i=0; }; }; }; }; } void loadText(String filename) { lines = loadStrings(filename); if(lines != null){ println("there are " + lines.length + " lines:"); } else { println("error, no text in file "+filename+". exiting."); exit(); }; for(int i=0;i