Created
September 2, 2010 01:19
-
-
Save deathbob/561670 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import processing.video.*; | |
| import processing.net.*; | |
| Client myClient; | |
| Server myServer; | |
| //int dataIn; | |
| String whatClientSaid; | |
| String clientImageUrl; | |
| String clientName; | |
| String temp; | |
| PImage clientImage; | |
| int text_x = 0; | |
| int text_y = 100; | |
| Capture cam; | |
| PFont fontA; | |
| char dataIn; | |
| int text_box_x; | |
| int text_box_y; | |
| int fill_alpha; | |
| void setup(){ | |
| size(1024, 768); | |
| text_box_x = width; | |
| text_box_y = height; | |
| frameRate(24); | |
| whatClientSaid = "Pickles and Pie"; | |
| cam = new Capture(this, width, height); | |
| myServer = new Server(this, 2000); | |
| myClient = new Client(this, "127.0.0.1", 2000); | |
| // fontA = loadFont("Helvetica-32.vlw"); | |
| // fontA = loadFont("Tungsten-Medium-32.vlw"); | |
| // fontA = loadFont("Tungsten-Bold-72.vlw"); | |
| fontA = loadFont("Tungsten-Black-72.vlw"); | |
| //String[] devices = Capture.list(); | |
| //println(devices); | |
| //cam.settings(); | |
| textAlign(LEFT); | |
| // Set the font and its size (in units of pixels) | |
| textFont(fontA, 72); | |
| } | |
| void draw(){ | |
| if (cam.available() == true){ | |
| cam.read(); | |
| image(cam, 0,0); | |
| } | |
| // text_x += 5; | |
| // text_y += 5; | |
| // text | |
| // Get the next available client | |
| Client thisClient = myServer.available(); | |
| // If the client is not null, and says something, display what it said | |
| if (thisClient !=null) { | |
| String temp = thisClient.readString(); | |
| if (temp != null) { | |
| println(temp); | |
| int uname_end = temp.indexOf(','); | |
| clientName = temp.substring(0, uname_end); | |
| String rest = temp.substring(uname_end + 1); | |
| println(rest); | |
| int image_end = rest.indexOf(','); | |
| clientImageUrl = rest.substring(0, image_end); | |
| println(clientImageUrl); | |
| whatClientSaid = rest.substring(image_end + 1); | |
| fill_alpha = 255; | |
| clientImage = loadImage(clientImageUrl, "png"); | |
| } | |
| } | |
| fill(0,0,0,fill_alpha); | |
| fill_alpha -= 2; | |
| if (fill_alpha < 1){ | |
| fill_alpha = 255; | |
| } | |
| if (whatClientSaid != null){ | |
| fill(0,0,0, fill_alpha); | |
| text(whatClientSaid, text_x + 1, text_y + 1, text_box_x + 1, text_box_y + 1); | |
| fill(255,255,255, fill_alpha); | |
| text(whatClientSaid, text_x, text_y, text_box_x, text_box_y); | |
| if (clientImage != null){ | |
| image(clientImage, 0, 0, 100, 100); | |
| } | |
| if (clientName != null){ | |
| //println(clientName); | |
| fill(255,255, 255); | |
| text(clientName, 100, 72); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment