Problem implementing a color picker
I'm implementing a color picker user interface and i'm having some issues.
The way i doing it is creating a projected color cube (hexagon) on which the user can navigate with a crosshair and then click to pick the color.
My problem is to determine as fast as possible the color given the position of the cross-hair (i don´t want to use readPixel() type functions ).
I thought of determining on which of the four triangles of the hexagon i was in and then do an interpolation, but i have no clue in how to do the interpolation part.
So my question is:
What is the best way to find out the color of a point inside a triangle?
Thanks for all the help you can give :D
You should be able to do this by decomposing the hexagon into a set of triangles, and then using the barycentric coordinates of the cursor position with respect to these triangles to determine the color. In pseudocode:
for each triangle compute barycentric coordinates corresponding to cursor position if cursor is in triangle (as indicated by barycentric coordinates) compute color from barycentric coordinates and colors associated with triangle vertices return color end ifend for
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement