使用PHP获取颜色阴影 [英] Get Color Shade with PHP
本文介绍了使用PHP获取颜色阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用PHP从给定的十六进制值得到更明亮的十六进制颜色阴影输出。例如,我给出颜色#cc6699
作为输入,我想要#ee88aa
作为输出颜色。我将如何在PHP中这样做?
I want to get brighter hex colour shade output from a given hex value with PHP. For example, I give the colour #cc6699
as input, and I want #ee88aa
as the output colour. How would I go about doing this in PHP?
推荐答案
您需要将颜色转换为RGB,
You need to convert the color to RGB, make the additions, and convert back:
// Convert string to 3 decimal values (0-255)
$rgb = array_map('hexdec', str_split("cc6699", 2));
// Modify color
$rgb[0] += 34;
$rgb[1] += 34;
$rgb[2] += 17;
// Convert back
$result = implode('', array_map('dechex', $rgb));
echo $result;
这篇关于使用PHP获取颜色阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文