2
例如:混合两种颜色(GD)
$im = imagecreatefrompng("php.png");
$rgb = imagecolorat($im, 10, 15);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
(从PHP DOC)
颜色我想补充:
$r2 = rand(0, 255);
$g2 = rand(0, 255);
$b2 = rand(0, 255);
$color = imagecolorallocatealpha($im, $r2, $g2, $b2, 0);
imagesetpixel($im, 10, 15, $color);
所以原来的颜色($ R,$ g,$ b)被替换为新的颜色($ r2,$ g2,$ b2)。
但我怎么能添加只是一定量的$ R2,$ G2和$ B2的,不能完全替代。
因此,如果原始颜色是红色,而我生成的第二个随机颜色是绿色,我只想添加第二种颜色的10%或15%。