本文整理汇总了PHP中Color::hexToRgb方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::hexToRgb方法的具体用法?PHP Color::hexToRgb怎么用?PHP Color::hexToRgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color::hexToRgb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
public static function parse($str)
{
if ($test = Color::test($str)) {
$color = $test['value'];
$type = $test['type'];
} else {
return false;
}
$rgba = false;
switch ($type) {
case 'hex':
$rgba = Color::hexToRgb($color);
break;
case 'rgb':
case 'rgba':
case 'hsl':
case 'hsla':
$function = $type;
$vals = substr($color, strlen($function) + 1);
// Trim function name and start paren.
$vals = substr($vals, 0, strlen($vals) - 1);
// Trim end paren.
$vals = array_map('trim', explode(',', $vals));
// Explode to array of arguments.
// Always set the alpha channel.
$vals[3] = isset($vals[3]) ? floatval($vals[3]) : 1;
if (strpos($function, 'rgb') === 0) {
$rgba = Color::normalizeCssRgb($vals);
} else {
$rgba = Color::cssHslToRgb($vals);
}
break;
case 'keyword':
$keywords = self::getKeywords();
$rgba = $keywords[$color];
break;
}
return $rgba;
}
示例2: steelmeter_attributes
//.........这里部分代码省略.........
if ($tcolor->isVeryDark()) {
$lighten = 40;
} else {
$lighten = 20;
}
break;
case 'liquid':
$alpha = 0.25;
if ($tcolor->isVeryDark()) {
$lighten = 28;
} else {
$lighten = 15;
}
break;
case 'soft':
$alpha = 0.5;
if ($tcolor->isVeryDark()) {
$lighten = 15;
} else {
$lighten = 10;
}
break;
case 'hard':
$alpha = 0.9;
$lighten = 1;
break;
}
}
if (isset($style[0])) {
switch (strtolower($style[0])) {
case 'fixed':
if ($digital) {
$color = new Color(Color::nameToHex($attributes['index_color']));
$rgb1 = Color::hexToRgb($color->lighten($lighten));
$result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1)])';
$result['useValueGradient'] = true;
} else {
$rgb = Color::nameToRgb($attributes['index_color']);
$result['section'] = '[steelseries.Section(' . $min . ', ' . $max . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $alpha . ')")]';
$result['useSectionColors'] = true;
}
break;
case 'fadein':
if ($digital) {
$color = new Color(Color::nameToHex($attributes['index_color']));
$rgb1 = Color::hexToRgb($color->lighten($lighten * 2));
$rgb2 = 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 * ($step - $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 'fadeout':
if ($digital) {