本文整理汇总了PHP中Color::fromHSV方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::fromHSV方法的具体用法?PHP Color::fromHSV怎么用?PHP Color::fromHSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color::fromHSV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_palette
/**
* Getting a color palette
* For now we only have a hsv palette, could be extended with more options
*
* Potential options:
* Standard CKEditor color palette
* http://stackoverflow.com/questions/13455922/display-only-few-desired-colors-in-a-ckeditor-palette
* 000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF
*
* Consider adding color names like this:
* http://stackoverflow.com/questions/2993970/function-that-converts-hex-color-values-to-an-approximate-color-name
*
* Color variation:
* http://stackoverflow.com/questions/1177826/simple-color-variation
*
* @param int $numColors Number of colors - default: 30
* @return null
*/
public static function get_palette($numColors = 50, $type = 'hsv')
{
//overwriting with the palette from the calendar settings
$s = CalendarConfig::subpackage_settings('colors');
$arr = $s['basepalette'];
return $arr;
if ($type == 'hsv') {
$s = 1;
$v = 1;
$arr = array();
for ($i = 0; $i <= $numColors; $i++) {
$c = new Color();
$h = $i / $numColors;
$hex = $c->fromHSV($h, $s, $v)->toHexString();
$arr[$hex] = $hex;
}
return $arr;
} elseif ($type == 'websafe') {
//websafe colors
$cs = array('00', '33', '66', '99', 'CC', 'FF');
$arr = array();
for ($i = 0; $i < 6; $i++) {
for ($j = 0; $j < 6; $j++) {
for ($k = 0; $k < 6; $k++) {
$c = $cs[$i] . $cs[$j] . $cs[$k];
$arr["{$c}"] = "#{$c}";
}
}
}
return $arr;
}
}
示例2: Color
<code><strong>Varying Value</strong> // Hue = 2/3, Saturation = 1.0</code>
</p>
<?php
$s = 1;
$h = 2 / 3.0;
for ($i = 0; $i <= 100; $i++) {
$c = new Color();
$v = $i / 100.0;
$hex = $c->fromHSV($h, $s, $v)->toHexString();
echo "<b style='background:{$hex}'></b>";
}
?>
<br />
<?php
for ($i = 0; $i <= 100; $i++) {
$s = 1;
$h = 2 / 3.0;
$c = new Color();
$v = $i / 100.0;
$hex = $c->fromHSV($h, $s, $v)->toHexString();
$rgb = new Color($hex);
list($h, $s, $v) = $rgb->toHSV();
$c = new Color();
$c->fromHSV($h, $s, $v)->toHexString();
echo "<b style='background:{$hex}'></b>";
}
?>
</body>