Drawing Shapes With Server Input
in
Programming Questions
•
1 year ago
Hi all,
I have processing set up as a client.
A GET is sent to my server.
Processing then receives:
"R"
channel_1
channel_2
I can print these values in the processing monitor, but i cannot seem to use the values to determine a shape characteristic. Processing receives the values I am interested in, please see the println in my code.
I have had the shapes working before i implemented a GET command.
There is probably something fundamental (knowledge and experience) I am missing.
I have tried creating the rectangles in various places of the code with my channel as the variable.
Can anyone spot where I have gone wrong? (I appreciate the code is not structured nicely, I am very new too this)
Many thanks.
I have processing set up as a client.
A GET is sent to my server.
Processing then receives:
"R"
channel_1
channel_2
I can print these values in the processing monitor, but i cannot seem to use the values to determine a shape characteristic. Processing receives the values I am interested in, please see the println in my code.
I have had the shapes working before i implemented a GET command.
- import processing.net.*;
Client myClient;
String inString;
int dataIn;
int serverreq = 1;
int speed = 500;
int channel_1 = 0;
int channel_2 = 0;
void setup()
{
size(500, 500);
myClient = new Client(this, "192.168.0.6", 80);
}
void draw()
{
for(int i = 5; i>4; i++)
{
myClient.write('X');
delay(speed);
inString = myClient.readString();
// if (myClient.available() > 0) {
String[]data = split(inString, ",");
//println(data[0]);
//println(data[1]);
//println(data[2]);}
int[]intValues = int(data);
if("R".equals(data[0]))
{
channel_1 = (int)intValues[1];
channel_2 = (int)intValues[2];
print(channel_1);
print(",");
print(channel_2);
println(",");
// in the monitor it prints my data values as expected.
}
else
{
println("Frame error!");
}
}
rect(100,400,100,-channel_1); //
rect(250,400,100,-channel_2); // << Darn graphs wont draw :(
}
There is probably something fundamental (knowledge and experience) I am missing.
I have tried creating the rectangles in various places of the code with my channel as the variable.
Can anyone spot where I have gone wrong? (I appreciate the code is not structured nicely, I am very new too this)
Many thanks.
1