Jump to content
  • Advertisement
Sign in to follow this  
jdub

How do I interpolate colors

This topic is 3328 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what algorithm can I use interpolate from one RGB color to another?

Share this post


Link to post
Share on other sites
Advertisement
Linear interpolation will go the trick.

c = (1 - t) * c0 + t * c1

EDIT: SiCrane beat me to it.

Share this post


Link to post
Share on other sites
Another way of doing the same maths is

Out = C0 + (C1-C0) * t

Where t = 0 to 1

And as SiCrane said , you have to treat the R,G,B parts separately.

Share this post


Link to post
Share on other sites
Linear interpolation of each RGB component is the most straightforward, and the results are often acceptable.

If you need a 'better' interpolation, you can convert the RGB colour to HSV, interpolate the HSV, and convert back to RGB for display.

Share this post


Link to post
Share on other sites
really? just interpolating the rgb elements separately will do it? I thought there was more to it.

Share this post


Link to post
Share on other sites
If the colors are similar, then just interpolating the components is
probably acceptable. If the colors are very different, it's a different
story. There is no "right" way to interpolate from red to blue, you have
to decide what sort of intermediate colors you want.

Share this post


Link to post
Share on other sites
Quote:
Original post by ddyer
If the colors are similar, then just interpolating the components is
probably acceptable. If the colors are very different, it's a different
story. There is no "right" way to interpolate from red to blue, you have
to decide what sort of intermediate colors you want.
If you are approaching colour from an artists perspective, HSV interpolation works pretty well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!