# I have a beginning colour and I have an ending colour... how do I get the colour now?

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

## Recommended Posts

My particle system is really starting to look cool, but I need to add the ability to morph between colours. Like my fire might start off as a really bright yellow and then fade into a darker red (as it invariably leaves the middle), but I dunno how to do that. Let's say my start colour is 255, 255, 32 and I want to go to 196, 96, 16 and I know this operation is going to take 3 seconds. What equation can I use? Please don't throw too much math jargon at me, I'm not a very good math student.

##### Share on other sites
difference in r: 255 - 196 = 059
difference in g: 255 - 096 = 159
difference in b: 032 - 016 = 016

difference PER SECOND r: 059 / 3
difference PER SECOND g: 159 / 3
difference PER SECOND b: 016 / 3

difference PER MILLISECOND r: 059 / 3000
difference PER MILLISECOND g: 159 / 3000
difference PER MILLISECOND b: 016 / 3000

You would use the elapsed frame-time to calculate how much difference (delta or step) you have to add to the 'now'-rgb.

##### Share on other sites
Pipo DeClown's solution is the simple way to do it, but you have to be careful because it will also affect the brightness and saturation of the color. For example, going from bright yellow (255, 255, 0) to bright blue (0, 0, 255) will go through medium gray (128, 128, 128) and that might be a problem.

If this is going to be a problem, then you need to convert from RGB to HSV (hue-saturation-value), do the interpolation, and convert back.

##### Share on other sites
Heck, even I didn't think of that, and I use the same basic linear interpolation for colour values. Thanks, JB.

##### Share on other sites
Quote:
 Original post by JohnBoltonIf this is going to be a problem, then you need to convert from RGB to HSV (hue-saturation-value), do the interpolation, and convert back.

Wouldn't that instead make e.g. blending from red to cyan, making it change color from red->purple->blue->cyan (or the other way around the hue).

Which in my eyes would be worse, but of course, it all depends on the situation perhaps.

EDIT: Lab, could that be something which would make nice fadings? I guess that would make it span through a few colors as well, anyone ever tried? (Playing some with photoshop it actually seems to produce sane results, however, there is of course some blending with other colors, but I don't know could be something)

##### Share on other sites
To my mind, interpolating through the colour cube as described is the most logical thing to do. If you want it to look different you just add more points to interpolate between.

##### Share on other sites
Quote:
 Original post by RAZORUNREALTo my mind, interpolating through the colour cube as described is the most logical thing to do. If you want it to look different you just add more points to interpolate between.

Am I sleepy, or isn't that the same thing as just interpolating normal RGB-values? (or perhaps that is what it means)

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633767
• Total Posts
3013737
×