/** * 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.*; OscP5 oscP5; PFont fontA; final int FONT_SIZE=50; final color BG=#000000;//#FFFFFF; final color TXT=#FFFFFF;//#000000; final color TEXT2=#FFFFFF; final int margin = 30; int fadePrompt=0; int fadeResponse=0; String prompt=""; String response=""; void setup() { size(1024, 1280);//1280, 1024); //size(screen.width, screen.height); 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(CENTER, CENTER); fontA = createFont("Helvetica-Bold", 255); fill(TXT); textFont(fontA, FONT_SIZE); /* start oscP5, listening for incoming messages at port 12000 */ oscP5 = new OscP5(this, 12000); } void drawPrompt(String prompt, int fade) { // background(BG); fill(TXT, 255); // text(prompt, 50, 50, 690, 430); text(prompt, margin, margin, width-2*margin, (0.75*height)-2*margin); } void drawResponse(String response, int fade) { background(BG); fill(TEXT2, fade); text(response, margin, (height*0.50)+margin, width-2*margin, (0.25*height)-2*margin); } /* incoming osc message are forwarded to the oscEvent method. */ void oscEvent(OscMessage theOscMessage) { /* print the address pattern and the typetag of the received OscMessage */ // println("### received an osc message."); // println(" addrpattern: "+theOscMessage.addrPattern()); // println(" typetag: "+theOscMessage.typetag()); String addrpat = theOscMessage.addrPattern(); String strval = theOscMessage.get(0).stringValue(); //println(theOscMessage.toString()); //theOscMessage.print(); //theOscMessage.printData(); if (match(addrpat, "/promptme")!=null) { println("Received: "+strval); prompt=strval; fadePrompt=128; //drawPrompt(strval); } if (match(addrpat, "/showresponse")!=null) { println("Received: "+strval); response=strval; fadeResponse=192; //drawResponse(strval); } } void draw() { if (fadePrompt>0) { drawPrompt(prompt, fadePrompt); fadePrompt--; }; if (fadeResponse>0) { drawResponse(response, fadeResponse); fadeResponse--; }; }