Skip to main content
gamedev.net
🔒 Locked

How to normalize gradient?

Started by raydog Aug 3, 2005 at 9:40 PM 1 replies 1.7k views
Original Post
raydog
raydog
I have this linear rainbow gradient that I want to normalize so I can access it, but I don't really know how to do it. Like I want to pass a value, t=0 to 1, where 0 would return the starting color and t=1 would return the ending color. (gradient has more than two colors). No actual index array is being used. All I have is a couple defined colors that make up a linear gradient. All color values are floating-point. I'm trying to figure out something that will return a color given t=0 to 1.
ajas95
ajas95
HSV = Hue Saturation Value

Hue = rainbow color
Saturation = uhhh. How far away from 'grey' the color is...
Value = how light or dark.

So you convert your start & end colors to HSV, then interpolate HSV based on t, and compute the RGB from that. Seriously. I'm not kidding. Google HSV RGB conversion. Colors are a weird thing.
raydog
raydog
Thanks, I figured out a another way to do it with colors of my choice.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.