Non-Linear color interpolation?

前端 未结 5 1133
天涯浪人
天涯浪人 2021-01-11 18:47

If I have a straight line that mesures from 0 to 1, then I have colorA(255,0,0) at 0 on the line, then at 0.3 I have colorB(20,160,0) then at 1 on the line I have colorC(0,0

5条回答
  •  余生分开走
    2021-01-11 19:31

    In the abstract, you're asking for the value of f(0.7) given that f(0.0) = (255, 0, 0), f(0.3) = (20, 160, 0), and f(1.0) = (0, 0, 0). As stated, this isn't well-defined as f could be any of an infinite number of functions.

    Some possible choices for f are:

    1. A series of line segments in RGB space
    2. A series of line segments after mapping to HSV or HSL space
    3. A cubic spline in RGB space.
    4. A cubic spline in HSV/L space.

    But the particular choice of how f should be defined should depend on what you're doing, or how the color stops are defined for your application.

提交回复
热议问题