Smooth color transition algorithm

前端 未结 5 728
感情败类
感情败类 2020-12-09 18:41

I am looking for a general algorithm to smoothly transition between two colors.

For example, this image is taken from Wikipedia and shows a transition from orange to

5条回答
  •  再見小時候
    2020-12-09 19:08

    The HSV color space is not a very good color space to use for smooth transitions. This is because the h value, hue, is just used to arbitrarily define different colors around the 'color wheel'. That means if you go between two colors far apart on the wheel, you'll have to dip through a bunch of other colors. Not smooth at all.

    It would make a lot more sense to use RGB (or CMYK). These 'component' color spaces are better defined to make smooth transitions because they represent how much of each 'component' a color needs.

    A linear transition (see @trumpetlicks answer) for each component value, R, G and B should look 'pretty good'. Anything more than 'pretty good' is going to require an actual human to tweak the values because there are differences and asymmetries to how our eyes perceive color values in different color groups that aren't represented in either RBG or CMYK (or any standard).

    The wikipedia image is using the algorithm that Photoshop uses. Unfortunately, that algorithm is not publicly available.

提交回复
热议问题