Fade a color to white (increasing brightness)

前端 未结 4 2052
温柔的废话
温柔的废话 2021-02-04 18:20

I want to make a text box in .NET \"glow\" yellow, and then \"fade\" to white (basically, by incrementally increasing the brightness). I think Stackoverflow does this after you\

4条回答
  •  無奈伤痛
    2021-02-04 18:34

    Just interpolate between the colors based on the time.

    If your orange color is (r1,g1,b1) and you wish to fade to a different color (r2,g2,b2), the formula for linear interpolation is (r1 + (r2-r1) * t, g1 + (g2-g1) * t, b1 + (b2-b1) * t), where t is in the range of [0.0 1.0].

    In your example, your first color is probably something like (255,200,0) and your second color would be (255,255,255).

    If you wish for smoother transitions, look up different ways of interpolation.

提交回复
热议问题