如何在PHP中循环使用十六进制颜色代码? [英] How can I cycle through hex color codes in PHP?

查看:280
本文介绍了如何在PHP中循环使用十六进制颜色代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个数组,其中数组中的每个字段都包含一个颜色代码。

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

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

green-> blue - > dark blue - > purple - > yellow - > orange - > red - > brown - > 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?

推荐答案

您应该使用一个颜色模型,例如色相饱和度值(HSV),并将色相从0度周围循环光谱到360度,无论饱和度和价值适合你。 (如果你想从绿色→绿色,只需从120度开始)

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)

这里有一个插图,显示了RGB和基于HSV的渐变之间的区别:顶部渐变在RGB模型中只是从绿色到红色,但是下面的一个使用HSV,从而产生更令人愉快的效果。

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.

这篇关于如何在PHP中循环使用十六进制颜色代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆