Advertisement
Guest User

Processing with Syphon Source

a guest
Sep 12th, 2013
2,496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. //Tells Processing we're going to utilize the syphon library
  2. import codeanticode.syphon.*;
  3.  
  4. //Declares the canvas we will draw to, necessary for Syphon
  5. PGraphics canvas;
  6.  
  7. //Declares the Syphon Server
  8. SyphonServer server;
  9.  
  10. void setup() {
  11. //typical size function, with added argument that is necessary for Syphon
  12. size(400,400, P3D);
  13.  
  14. //Sets up the canvas, make it match the desired size of your sketch
  15. canvas = createGraphics(400, 400, P3D);
  16.  
  17. // Create syhpon server to send frames out.
  18. server = new SyphonServer(this, "Processing Syphon");
  19. }
  20.  
  21. void draw() {
  22.   //Tell processing to begin drawing to the canvas instead of to the sketch
  23.   canvas.beginDraw();
  24.  
  25.   //Typical drawing functions, but applied to canvas instead of the sketch itself
  26.   canvas.background(100);
  27.   canvas.stroke(255);
  28.   canvas.line(50, 50, mouseX, mouseY);
  29.  
  30.   //Tell processing we're done drawing to canvas
  31.   canvas.endDraw();
  32.  
  33.   //Draws contents of canvas to our sketch so we can see whats going on
  34.   image(canvas, 0, 0);
  35.  
  36.   //Sends contents of canvas through Syphon Server to MadMapper! Yay!
  37.   server.sendImage(canvas);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement