How can I cycle through hex color codes in PHP?

colors, php

Solution

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.

Problem

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 through the whole spectrum of colors starting from green to black. green-> blue -> dark blue -> purple -> yellow -> orange -> red -> brown ->black This order doesn't need to be exactly the same, but I think you get the picture. Can anybody help with this? Is there a website that has done this before?

Original source