- Home /
Convert RGB to RYB color scheme?
Hi,
I have a game where I want to collect color from cubes when breaking them.
I need to gain the color on a scale from 0 to 1 (Colors in scripting are made that way so that parts easy) so that for example, if you break a green block, you get half the green in yellow, half in blue. This also needs to work with all colors.
EDIT
This is what I have so far:
float Yellow = (1 - GetComponent <SpriteRenderer> ().color.r) * (1 - GetComponent <SpriteRenderer> ().color.b);
float Blue = (1 - GetComponent <SpriteRenderer> ().color.r) * (1 - Yellow);
float Red = (1 - Yellow) * (1 - Blue);
float Green = Yellow - Red;
Managers [2].GetComponent <ColorManager> ().Red += Red;
Managers [2].GetComponent <ColorManager> ().Yellow += Yellow;
Managers [2].GetComponent <ColorManager> ().Blue += Blue;
Managers [2].GetComponent <ColorManager> ().Green += Green;
Thanks in advance :-)
I don't quite get what color system RYB should be ... Yellow is a composite color in the additive system (made from Red and Green). The RGB colors are the primary colors in the additive system and usually aren't "broken" into other colors. The only logical splitting you could do is split them into the secondary colors (So Green would split into Cyan and Yellow).
If you want to support every color you would need to use all 3 primary colors and all 3 secondary colors. So the full Hue circle (R$$anonymous$$BCGY).
However it's still not clear what exactly you want to get from a certain color. If you just want two colors that define a given color, you probably want to perform a Hue-shift by +- 60°
@Bunny83 I just want to display how much color I have on R, Y and B. I also want to make it so that you can use that to make new blocks.
And I already set everything up red yellow and blue so it would really suck if I couldnt convert it.
Red/Yellow/Blue isn't a useful colour space. Do you mean Cyan/$$anonymous$$agenta/Yellow, which is a common subtractive colour space? And if so, the conversion is fairly common, and quite easy:
Red = (1 - Cyan)
Green = (1 - $$anonymous$$agenta)
Blue = (1 - Yellow)
Your answer
Follow this Question
Related Questions
rgb value detail 0 Answers
My foreach or the Resources.LoadAll Is not getting the information I need 2 Answers
how to change color in unity scripting overtime?,how to change color gradually with C# 2 Answers
Color of some instantiated objects differs from the normal ones. 1 Answer
Material color won't update! 2 Answers