import processing.net.*;
String serverAddress = " IP ";
PImage palett;
Client c;
void setup() {
c = new Client(this, serverAddress, 25565);
size(740, 480);
palett = loadImage("palett.png");
noStroke();
frameRate(-1);
background(255);
w = 5;
}
int x;
int y, w;
String r = "0", g = "0", b = "0";
color col = 0;
void draw() {
image(palett, 640, 0);
if (mousePressed) {
if (mouseButton == RIGHT) {
col = get(mouseX, mouseY);
}
if (mouseButton == LEFT) {
w = pmouseX-mouseX;
if(w < 0)w = -w;
w = pmouseY-mouseY;
if(w < 0)w = -w;
if(w > 10)w = 10;
if(w < 1)w = 1;
w = 4;
c.write(mouseX + "," + mouseY + "," +red(col)+","+green(col)+","+blue(col)+","+w+","+'\n');
fill(col);
rect(mouseX-w*2, mouseY-w*2, w*2, w*2);
}
}
fill(int(r), int(g), int(b));
rect(x-w, y-w, w*2, w*2);
String s = c.readStringUntil('\n');
if (s != null) {
if (s.equals("end") == true) {
//x = 0;
//y = 0;
} else {
if (splitTokens(s, ",").length > 6) {
x = int(splitTokens(s, ",")[0]);
y = int(splitTokens(s, ",")[1]);
r = splitTokens(s, ",")[2];
g = splitTokens(s, ",")[3];
b = splitTokens(s, ",")[4];
w = int(splitTokens(s, ",")[5]);
}
}
}
}