??? 06/10/10 06:33 Read: times |
#176579 - You don't have paletted device so stop thinking about index Responding to: ???'s previous message |
How do you get from black to white? Magic index 0..124? Or simply increasing the red, green and blue channels at the same time until reaching the intensity level you want?
How to you get black to red? Magic index 0..124? Or simply increasing the red channel 0, 1, 2, 3, 4 while keeping green and blue at zero? How do you get black to blue? ... As long as you lock yourself into thinking about some magic index 0..124 you will stumble into problem after problem after problem after problem. Do not think of an index. Think about percentages of red, green and blue. That is all that matters. An index is only meaningful if you have a paletted device - a device that can show a small number of colors at the same time, but can select these colors from a much larger set. You can at any time select any color from the full color resolution you have available. For that reason, a palette will not make sense. Just work with target color as RGB triplet. Using another color space helps when compute in-between colors, but in the end you still need to convert to RGB since your hardware controls RGB hardware. Look at that video again. Look at the edges of a color circle. What do you think it would look like if you ignore your 0..124 index and just walk around on the border of that color circle? Guess what - it would look very much like the linked video. The biggest difference is that the video shows that they are also walking towards the center of the color circle, allowing them to get smooth toning from cyan or maybe magenta and animating towards white. How to go from black to any color? Just start at the apex of the HSV cone and walk towards any point of the base of the cone. The video claims that they have defined 16 colors. The colors are located somewhere in the color space and they are pseudo-randomly or sequentially selecting one of these 16 colors as new target color. They then compute in-between colors to smoothly transform from one clor to another. No index involved somewhere. Just in-between computations. The results will vary if you use RGB or HSV color space or if you use any of the other, less common, color spaces. The conversion formulas to go from HSV values into RGB values is trivial, and the HSV values allows you to perform all the animation you want by just slowly changing one or two of the parameters. If you do read the page, you'll see the formulas. It's very easy to convert from floating point formulas into integer formulas. And it is also easy to either tabulate sin and/or cos for the angle around the cone. But you can also "cheat" and see the cone as having 6 sides instead of being round. Then it's enough to know which of the 6 pizza slices you are inside. The approximation with a six-sided pyramid will still give excellent color transitions. Sample code? Huge amounts available on the net. |