本文整理汇总了PHP中Color::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::parse方法的具体用法?PHP Color::parse怎么用?PHP Color::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color::parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loop_color_range
function loop_color_range()
{
$args = func_get_args();
$source_colors = array();
while ($args && ($color = Color::parse($args[0]))) {
$source_colors[] = $color;
array_shift($args);
}
$steps = max(1, isset($args[0]) ? (int) $args[0] : 1);
$generated_colors = array();
foreach ($source_colors as $index => $source_color) {
$generated_colors[] = new Color($source_color);
// Generate the in-between colors.
$next_source_color = isset($source_colors[$index + 1]) ? $source_colors[$index + 1] : null;
if (!$next_source_color) {
break;
}
for ($i = 0; $i < $steps; $i++) {
$rgba = array();
foreach ($source_color as $component_index => $component_value) {
if ($component_diff = $next_source_color[$component_index] - $component_value) {
$component_step = $component_diff / ($steps + 1);
$rgba[] = min(round($component_value + $component_step * ($i + 1), 2), 255);
} else {
$rgba[] = $component_value;
}
}
$generated_colors[] = new Color($rgba);
}
}
return $generated_colors;
}
示例2: color_capture
function color_capture($process)
{
$captured_keywords = $process->string->captureDirectives('color', array('singles' => true));
if ($captured_keywords) {
$native_keywords = Color::getKeywords();
$custom_keywords = array();
$process->colorKeywords = $native_keywords;
foreach ($captured_keywords as $key => $value) {
$value = $process->functions->apply($value);
if (!isset($native_keywords[$key]) && ($rgba = Color::parse($value))) {
$custom_keywords[] = $key;
$process->stat['colors'][$key] = new Color($rgba);
$process->colorKeywords[$key] = $rgba;
}
}
if ($custom_keywords) {
$GLOBALS['CSSCRUSH_COLOR_PATT'] = Regex::make('~{{ LB }}(?<color_keyword>' . implode('|', $custom_keywords) . '){{ RB }}~iS');
}
}
}