本文整理汇总了PHP中Color::mix方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::mix方法的具体用法?PHP Color::mix怎么用?PHP Color::mix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color::mix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: steelmeter_attributes
//.........这里部分代码省略.........
$rgb1 = Color::nameToRgb($attributes['index_color']);
$result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb2['R'] . ',' . $rgb2['G'] . ',' . $rgb2['B'] . ', 1)])';
$result['useValueGradient'] = true;
} else {
$rgb = Color::nameToRgb($attributes['index_color']);
$s = '';
$step = 20;
$size = ($max - $min) / $step;
for ($i = 0; $i < $step; $i++) {
$mi = $min + $i * $size;
$ma = $min + ($i + 1) * $size;
$a = $alpha - $alpha * $i * 0.9 / $step;
$s = $s . 'steelseries.Section(' . $mi . ', ' . $ma . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $a . ')"),';
}
$result['section'] = '[' . substr($s, 0, strlen($s) - 1) . ']';
$result['useSectionColors'] = true;
}
break;
case 'complementary':
if ($digital) {
$color = new Color(Color::nameToHex($attributes['index_color']));
$rgb1 = Color::nameToRgb($attributes['index_color']);
$rgb2 = Color::hexToRgb($color->complementary());
$result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb2['R'] . ',' . $rgb2['G'] . ',' . $rgb2['B'] . ', 1)])';
$result['useValueGradient'] = true;
} else {
$color2 = new Color(Color::nameToHex($attributes['index_color']));
$color = new Color($color2->complementary());
$rgb2 = $color->complementary();
$s = '';
$step = 20;
$size = ($max - $min) / $step;
for ($i = 0; $i < $step; $i++) {
$rgb = Color::hexToRgb($color->mix($rgb2, round(200 / $step * $i) - 100));
$mi = $min + $i * $size;
$ma = $min + ($i + 1) * $size;
$s = $s . 'steelseries.Section(' . $mi . ', ' . $ma . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $alpha . ')"),';
}
$result['section'] = '[' . substr($s, 0, strlen($s) - 1) . ']';
$result['useSectionColors'] = true;
}
break;
case 'invcomplementary':
if ($digital) {
$color = new Color(Color::nameToHex($attributes['index_color']));
$rgb2 = Color::nameToRgb($attributes['index_color']);
$rgb1 = Color::hexToRgb($color->complementary());
$result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb2['R'] . ',' . $rgb2['G'] . ',' . $rgb2['B'] . ', 1)])';
$result['useValueGradient'] = true;
} else {
$color = new Color(Color::nameToHex($attributes['index_color']));
$rgb2 = $color->complementary();
$s = '';
$step = 20;
$size = ($max - $min) / $step;
for ($i = 0; $i < $step; $i++) {
$rgb = Color::hexToRgb($color->mix($rgb2, round(200 / $step * $i) - 100));
$mi = $min + $i * $size;
$ma = $min + ($i + 1) * $size;
$s = $s . 'steelseries.Section(' . $mi . ', ' . $ma . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $alpha . ')"),';
}
$result['section'] = '[' . substr($s, 0, strlen($s) - 1) . ']';
$result['useSectionColors'] = true;
}
break;
}
示例2: implode
<?php
// test.php for color
require_once 'Color.php';
$c = new Color('F00');
?>
<div style="width: 100px; height: 100px; background:<?php
echo $c;
?>
"><?php
echo implode(',', $c->hsl);
?>
</div>
<div style="width: 100px; height: 100px; background:<?php
echo $c->mix('#0F0');
?>
"><?php
echo implode(',', $c->hsl);
?>
</div>
<div style="width: 100px; height: 100px; background:<?php
echo $c->mix('#00F');
?>
"><?php
echo implode(',', $c->hsl);
?>
</div>