ok所以我创建了一个配色方案,以突出显示输入数据(文本)的某些部分。
但是我需要制作一个Legend,告诉用户每种颜色的含义。这是我到目前为止: ` / 输入 /
<div style="text-color: hsl($col,35%, 100%);">/*input*/</div>
<div style="text-color: hsl($col,45%, 50%);">/*input*/</div>
<div style="text-color: hsl($col,50%, 100%);">/*input*/</div>
<div style="text-color: hsl($col,55%, 100%);">/*input*/</div>
<div style="text-color: hsl($col,60%, 100%);">/*input*/</div>
<div style="text-color: hsl($col,70%, 100%);">/*input*/</div>
<div style="text-color: hsl($col,80%, 100%);">/*input*/</div>
<div style="text-color: hsl($col,90%, 100%);">/*input*/</div>
<div style="text-color: hsl($col,100%, 100%);">/*input*/</div>
` 其中input-将是颜色的标签,例如这意味着强大的结果。 $ col是一个变量,每次都会改变颜色,例如0 =红色等。
我需要知道如何将我在这里的颜色变成一个html页面上的图例。
请帮忙吗?
感谢:)
答案 0 :(得分:0)
我猜你试图将你的/ 输入 /占位符替换为颜色的实际名称,即栗色,黑色,黄色等。 您可能最终会编写自己的替换代码。颜色名称可在http://www.imagemagick.org/script/color.php或此处http://www.w3schools.com/cssref/css_colornames.asp获取。 如果您有ImageMagick,您可以创建单个像素图像并使用http://www.php.net/manual/en/imagickpixel.getcolorasstring.php来检索颜色名称,据我记得 - 您应该缓存结果,但是...... 我不知道任何其他内置函数,但你可以检查一些类存储库,如phpclasses.org。
希望有所帮助, 斯蒂芬