⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sharedcanvasclient.pde

📁 This is processing for java examples.
💻 PDE
字号:
/** * Shared Drawing Canvas (Client)  * by Alexander R. Galloway.  *  * The Processing Client class is instantiated by specifying a remote  * address and port number to which the socket connection should be made.  * Once the connection is made, the client may read (or write) data to the server. * Before running this program, start the Shared Drawing Canvas (Server) program. */import processing.net.*;Client c;String input;int data[];void setup() {  size(450, 255);  background(204);  stroke(0);  frameRate(5); // Slow it down a little  // Connect to the server's IP address and port  c = new Client(this, "127.0.0.1", 12345); // Replace with your server's IP and port}void draw() {  if (mousePressed == true) {    // Draw our line    stroke(255);    line(pmouseX, pmouseY, mouseX, mouseY);    // Send mouse coords to other person    c.write(pmouseX + " " + pmouseY + " " + mouseX + " " + mouseY + "\n");  }  // Receive data from server  if (c.available() > 0) {    input = c.readString();    input = input.substring(0, input.indexOf("\n")); // Only up to the newline    data = int(split(input, ' ')); // Split values into an array    // Draw line using received coords    stroke(0);    line(data[0], data[1], data[2], data[3]);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -