Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » RGB Values Not Making Sense
- MrBucket-Youtube
-
79 posts
RGB Values Not Making Sense
I made a script in the project https://scratch.mit.edu/projects/704138486/
which is supposed to compare a color value to the 7 colors of the rainbow and find which value its closest to, and it almost works, but it chooses the wrong value that is actually 3rd place for it, oh and its stuck as the last color for the color selector.
which is supposed to compare a color value to the 7 colors of the rainbow and find which value its closest to, and it almost works, but it chooses the wrong value that is actually 3rd place for it, oh and its stuck as the last color for the color selector.
- awesome-llama
-
1000+ posts
RGB Values Not Making Sense
A basic colour comparison can be done in RGB colour space. You need to separate the colour channels.
Then you can find the difference per channel and get a single final value through a method such as what Wikipedia provides:

If you are needing to compare colours so that the difference matches what humans see perceptually, you would have to convert the RGB values into a different set of channels, such as L*a*b* though be warned when you reach this or even more accurate colour spaces, the maths gets a bit complicated and there's a lot of theoretical knowledge you would need beforehand.
Then you can find the difference per channel and get a single final value through a method such as what Wikipedia provides:
If you are needing to compare colours so that the difference matches what humans see perceptually, you would have to convert the RGB values into a different set of channels, such as L*a*b* though be warned when you reach this or even more accurate colour spaces, the maths gets a bit complicated and there's a lot of theoretical knowledge you would need beforehand.
- deck26
-
1000+ posts
RGB Values Not Making Sense
I think you need to make the scanning sprite's costume a little bigger.
- MrBucket-Youtube
-
79 posts
RGB Values Not Making Sense
Thank you. A basic colour comparison can be done in RGB colour space. You need to separate the colour channels.
Then you can find the difference per channel and get a single final value through a method such as what Wikipedia provides:
If you are needing to compare colours so that the difference matches what humans see perceptually, you would have to convert the RGB values into a different set of channels, such as L*a*b* though be warned when you reach this or even more accurate colour spaces, the maths gets a bit complicated and there's a lot of theoretical knowledge you would need beforehand.
- Discussion Forums
- » Help with Scripts
-
» RGB Values Not Making Sense