/** * 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 * */ import oscP5.*; import netP5.*; OscP5 oscP5; NetAddress myRemoteLocation; PFont fontA; int offset=0; int i=0; int j=0; final int NUMCHARS=25; final int NUMLINES=5; final int FONT_SIZE=50; final int LINE_SPACING=60; final color BG=#FFFFFF; final color TXT=#000000; int textX, textY; // variables controlling text motion and position boolean pause = false; int speed=2; int [] positions; int n; String lines[] = { "" }; //ArrayList 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); size(740, 480); background(BG); 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(TXT); textFont(fontA, FONT_SIZE); setDrawingPositions(); /* start oscP5, listening for incoming messages at port 12000 */ oscP5 = new OscP5(this, 12000); // the port supercollider is listening on 57120 myRemoteLocation = new NetAddress("127.0.0.1", 57120 ); //loadText("/Users/rtwomey/code/language/nltk2.0/mmpi2_as_questions.txt"); loadText("/Users/rtwomey/script/script_statements.txt"); //loadText("/Users/rtwomey/script/mmpi2questions.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=true; n=0; positions = new int[1]; positions[0]=0; } void draw_prompter() { // draw NUMLINES lines of text on screen with current vertical offset int rememberSpace; int k; offset=LINE_SPACING; int c; int li=i; int lj=j; 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(BG); fill(TXT); text("RESPOND TO THE PROMPT:", 30, 60); 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