Color Picker?

for example, i have a cube in my game, and a color setting, then i hover my cursor to any color i want and then i cclicked the color to assign it to three property(R,G and B), something like in Windows Paint

the question is “How can i do that?”
i dont want to make the player clicking 6 buttons to adjust three property manualy
i wanted the player just cliking what color he want, then use it.

Maybe with bgui?

Edit: my bad, doesn’t work lke that…

I do not think there is anything that let you determine the rendered color. Maybe you can use the video texture module. I do not know.

But from what you request you do not need that, as it is not a color picker operation. It is a way to enter various parameters to finally get the r,g,b components of a color. You can even enter other parameters as long as they are convertible to r,g,b.

Your image shows you have:
Three textboxes to directly enter r,g,b
Three textboxes to enter h, s, l

One 2d grid to pick h, s (h=x, s=y) and one 1d grid to pick l (l=y).

Nothing of that requires to determine the color below the selection. The grids simply show the color you would get when you select the specific point. If you show an image or a black background it would still return the according parameters. The color ramps are “just” helpers for the user.

Okay, this time i got it!

I use “math” to get the colors.
It is more accurate than the image on the plane.
The mouse over hit position is in world Position.
SO, this works only when the plane and camera are not rotated.
The hit location should be calculated with the corners to get the off-set on the plane(in math terms).

Took the idea by reversing the algorithm from here:


color_picker.blend (512 KB)

Just replace the pos = … line with this:

pos = sens.hitObject.worldTransform.inverted() * sens.hitPosition