# Matching an HSV color with a blended color

This is hard to explain but I am going to try, then I will explain it as pure mathematics.

Look at this image. So basically this is a moving line, each frame a new segment is added and the previous frame is faded by an amount decided by fps. (There are dots to make things neat but I'm not showing them for simplicity).

So based on the FPS a number is calculated (0.05 if perfect FPS ) and as a result the previous frame gets a black plane drawn over it with an opacity of 0.05.

As you can see this causes an issue because of the segments. My solution is to give each vertex a color, however I don't know how to calculate that color. The line color is defined by HSV, and the fading is decided by RGB. Furthermore I am pretty sure fading with the transparent plane creates an exponential effect, however HSV.V works linearly.

My question is if I know on a given frame that the fading plane will have an opacity of 0.05 how can I calculate an equivalent HSV color to what the previous frame will be after fading? That way the bottom two vertices can be a darker color and interpolation can fix it.

The formula that decides the opacity of the black is as follows.

(dt / (1 / 60)) * 0.5

• "As you can see this causes an issue because of the segments.". Could you describe what problem you are seeing? What about the picture should be different? Commented May 25, 2016 at 21:28
• @Trichoplax the line has clear segments inside of it. The line should be smooth. Commented May 25, 2016 at 21:30
• Do you mean that there should be no visible colour difference between the segments? Commented May 25, 2016 at 21:50
• @trichoplax I just want the color to be smooth. I want the new segment to math nicely with the previous faded one. Just so that everything looks continuous in both shape and color. Commented May 25, 2016 at 22:22

The opacity acts linearly through the colors, i.e. it affects R G B similarily, so it should affects the value V the same way. You just want to have an intensity factor decay as $0.95^n$.