How can I cycle through hex color codes in PHP?

前端 未结 9 2222
野的像风
野的像风 2021-01-06 06:08

I want an array where each field in the array contains a color code

array(0 => \'#4CFF00\', 1 => \'#FFE97F\')

And I want this to go t

9条回答
  •  甜味超标
    2021-01-06 06:33

    You should use a colour model like Hue-Saturation-Value (HSV), and cycle the hue from 0 degrees all the way around the spectrum to 360 degrees, at which whatever saturation and value suited you. (If you want to go from green->green, just start at 120 degrees)

    Here's an illustration which shows the difference between RGB and HSV based gradients: the top gradient is just going from green to red in an RGB model, but the lower one uses HSV, resulting in a more pleasing effect.

提交回复
热议问题