当前位置: 首页>>代码示例>>PHP>>正文


PHP Color::mix方法代码示例

本文整理汇总了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;
             }
开发者ID:Torchwood7,项目名称:torchwood-site,代码行数:67,代码来源:trait-datas-output.php

示例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>
开发者ID:idealogica,项目名称:color,代码行数:28,代码来源:test.php


注:本文中的Color::mix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。