The 'best' solution depends on many things, your skill, the performance of the system, and the other tasks it needs to do in the available time. There are some examples of doing data transfer between Processing and the Arduino in the Arduino example programs. So it is worth looking through them.
There seems to be some inconsistencies in your question.
You wrote "It sends the 99.0 data to Arduino", which has a decimal point.
Yet the code is printing an int
i.e.
int value = int(red(c1[0]));
myPort.write(value);
Further, the processing code only looks at the red component of c1[0]:
int value = int(red(c1[0]));
so it can only send a sequence of '9'. So that looks like a bug.
There are a few basic strategies to write data that can be easily read. Two popular ways are:
- send fixed length messages, or prefix a message with the size of the
data, and have a fixed format of data. For example, use a one byte
count to say how many colours are being sent, then send three bytes,
in the same order, for each colour
- use non-data bytes to separate the data. For example use a ','
between R, G or B and '\n' to mark the end of the data. To keep
things simple, never use those values as data values. That is pretty
much how programming languages work. It is much more complex to read
than fixed format data, but can give more flexibility.
Data is often sent as printable characters (e.g. 173 would be three bytes havig the ASCII values '1', '7', '3'). If it is fixed format, it would always be three bytes. For your purposes, I'd probably send each data byte as two hex characters (ASCII '0' to '9' and 'A' to 'F'. This is slightly more complex than pure binary. However it is fixed format, and more importantly it is easier to test by hand using the Arduino serial monitor, you can just type stuff and it is relatively easy to do.
Pure binary data is much more difficult to fully test, and often relies on a piece of software which also needs testing.
Summary: There are a couple of ways, it is hard to say which is best. For simplicity try to make it simple by being fixed format.