Simple question about the Sharedcanvas client\server from the net examples.

edited October 2013 in How To...

Hello Guys,

I'm new to processing and having some issues with a code. I'm trying to make a simple event to 'erase' or 'clear' both client and server at the same time.

If someone could help me out that would be awesome!!

Answers

  • Currently, the only information sent is mouse coordinates, separated by spaces.

    You can add a prefix to indicate the kind of action:

    s.write("D " + pmouseX + " " + pmouseY + " " + mouseX + " " + mouseY + "\n");
    

    (I used D as Draw, but you can use the full word or something else)

    Then you will have the action in data[0], so you must use the data in the other slots:

    if (data[0].equals("D"))
    {
      stroke(0);
      line(data[1], data[2], data[3], data[4]);
    }
    else if (data[0].equals("C")) // Clear
    {
       background(255); // Erase screen
    }
    

    Make an action, eg. keyPressed(), to send the "C" order, and you are done.

  • Thanks a lot!!! It worked.

Sign In or Register to comment.