I'm writing a color blending program that will run on my university's multi-touch surface. I first wrote it to run on a computer, with the intention of implementing TUIO later. Currently, it runs perfectly using a mouse, but I'm having some weird problems after implementing TUIO.
In my original program (using the mouse), I've got this code:
// Executes if the mouse is over one of the circles
The above code will change the color of the object ("c") to whatever color the mouse was over.
Now, I had to change it up a bit when implementing TUIO, but it's essentially the same code:
// tcur is the TuioCursor, and the X and Y must be multiplied by the width and height of the screen to get the correct values
float curX = tcur.getX()*wid;
float curY = tcur.getY()*hgt;
// This for loop checks if the current TUIO cursor is over any of the circles
// This functions the same as the above "if (overCircle)" code
for (int i = 0; i < circles.size(); i++){
Circle d = (Circle)circles.get(i);
// If the TUIO cursor was over one of the circles, gets the color of that circle
if (d.isOver(curX, curY)){
c.circleColor = get((int)curX, (int)curY); // These must be cast to int because get() doesn't take float
break;
}
}
Now, the problem I'm running into, is that the second piece of code I posted returns black every time (a really big negative integer, around -16777xx or something like that.)
I've checked, and the X and Y values are correct in the second code (no weird values), so I'm really stumped here.
Sorry if that was unclear at all, I can clarify if needed. Does anyone have any idea of what I should do?
So, bit of an intro here (this is my first post): I'm a freshman computer science student taking a CS elective course called "Interactive and Generative Art." We're doing a lot of stuff in Processing, and for a project, I'm making a color blending program.
I'm using the ellipse function to make the colored circles. So my red circle is:
"fill(255, 0, 0);
ellipse(redX, redY, diameter, diameter);" etc. etc.
The blend function I'm currently using is
"gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);"
That works perfectly for some combinations, for example:
It takes the red circle (255, 0, 0) and the blue circle (0, 0, 255) and comes up with a purple circle (like it should)(255, 0, 255).
But when I blend say, red (255, 0, 0) and yellow (255, 255, 0) I run into problems, because it produces (510, 255, 0). From my observations, it treats anything above 255 as 255, so the result is still yellow.
Does anyone have any suggestions? If the colors were (red, yellow, blue) instead of (red, green, blue) it seems like it'd work almost perfectly, but that's not the case.
Sorry if that's a bit unclear, I can clarify if needed.
Thanks in advance!