本文整理汇总了PHP中color函数的典型用法代码示例。如果您正苦于以下问题:PHP color函数的具体用法?PHP color怎么用?PHP color使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了color函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: interpolate
/**
* @param int $color1
* @param int $color2
* @param float $factor
* @return int
*/
function interpolate($color1, $color2, $factor)
{
$r = (red($color2) - red($color1)) * $factor + red($color1);
$g = (green($color2) - green($color1)) * $factor + green($color1);
$b = (blue($color2) - blue($color1)) * $factor + blue($color1);
return color($r, $g, $b);
}
示例2: mandel
function mandel($params)
{
$image_x = 4 * $params['w'];
$image_y = 4 * $params['h'];
$image = imagecreatetruecolor($image_x, $image_y);
imagefilledrectangle($image, 0, 0, $image_x, $image_y, 0xffffff);
$f = imagecolorallocate($image, $params['r'], $params['g'], $params['b']);
$color = color($params, $image);
for ($x = 0; $x < $image_x; $x++) {
for ($y = 0; $y < $image_y; $y++) {
$c_r = $x / $params['w'] + -2;
$c_i = $y / $params['h'] + -2;
$z_r = 0;
$z_i = 0;
$i = 0;
while ($z_r * $z_r + $z_i * $z_i < 4 and $i < $params['n']) {
$mod = sqrt($z_r * $z_r + $z_i * $z_i);
$arg = atan2($z_i, $z_r);
$z_r = pow($mod, $params['k']) * cos($params['k'] * $arg) + $c_r;
$z_i = pow($mod, $params['k']) * sin($params['k'] * $arg) + $c_i;
$i++;
}
if ($i == $params['n']) {
imagesetpixel($image, $x, $y, $f);
} else {
imagesetpixel($image, $x, $y, $color[$i]);
}
}
}
return send_image($image);
}
示例3: dirname
require_once dirname(__DIR__) . '/vendor/autoload.php';
class Kolor extends Colors\Color
{
function __invoke($string = null)
{
$obj = new Colors\Color($string);
return $obj;
}
}
$c = new Kolor();
$c = new Colors\Color();
function color($string)
{
return new Colors\Color($string);
}
echo color('Hello World!')->red()->white() . color("some other text 1 ")->green() . color("some other text 2 ")->blue() . color("some other text 3 ")->yellow() . color("some other text 4 ")->white() . PHP_EOL;
exit;
print "we r here \n";
print $c->red("this is red") . "\n";
print $c->bold($c->red("this is red and bold")) . "\n";
print $c("also this is red and bold")->red->bold . "\n";
$c("this is some text");
var_dump($c);
print "===============================================================\n";
$c("this is some text")->red();
var_dump($c);
print "===============================================================\n";
$c("different text");
var_dump($c);
print "===============================================================\n";
$c("different text")->blue();
示例4: getColor
function getColor($current, $max)
{
$color = color($current, $max);
return $color;
}
示例5: makeTD
/**
* Makes an active TD segment with an onclick/onmouseover
*/
function makeTD($name, $description, $color, $imgname = null)
{
$result = "<TD><A onmouseout=\"window.status=''\"";
$result .= " onmouseover=\"window.status='{$description}'\"";
$result .= " onclick=\"alert('{$name}: {$description}')\">";
if (isset($imgname)) {
$result .= makeIMG($imgname, "{$name}: {$description}");
} else {
$result .= color($name, $color);
}
$result .= "</A></TD>\n";
return $result;
}
示例6: important
/**
* @param $message
*/
function important($message)
{
echo color($message, 'green') . "\n";
}
示例7: foreach
use yii\helpers\Url;
?>
<?php
foreach ($menuSub as $sub) {
?>
<tr id="menu-<?php
echo $sub->id;
?>
">
<td>
<?php
echo icon($sub->father_id2, $sub->father_id3);
?>
<span class="<?php
echo color($sub->father_id2, $sub->father_id3);
?>
"><?php
echo name($sub->father_id2, $sub->father_id3);
?>
</span>
</td>
<td>
<span class="label label-default"><?php
echo $sub->name;
?>
</span>
</td>
<td><i class="<?php
echo $sub->icon;
?>
示例8: array
$spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['bonus_healing'] . ' ' . $character->stats['spell_bonus_healing'] . '</span>') . '\')">' . $_LANGUAGE->text['bonus_healing'] . ':</span></td><td class="stats_right">' . $character->stats['spell_bonus_healing'] . '</td></tr>';
$spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['hit_rating'] . ' ' . $character->stats['spell_hit_rating'] . '</span>') . '\')">' . $_LANGUAGE->text['hit_rating'] . ':</span></td><td class="stats_right">' . $character->stats['spell_hit_rating'] . '</td></tr>';
$tmp = array('arcane', 'fire', 'frost', 'nature', 'shadow');
$tip = '<span class="description">';
foreach ($tmp as $tt) {
$tip .= '<img alt="" width="15" height="15" src="' . $_DOMAIN . 'images/res-' . $tt . '.gif"> ' . $_LANGUAGE->text[$tt] . ' ' . $character->stats['spell_crit_' . $tt] . '%<br>';
}
$tip .= '</span>';
$spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['crit_rating'] . ' ' . $character->stats['spell_crit_rating'] . '</span><br>' . $tip) . '\')">' . $_LANGUAGE->text['crit_chance'] . ':</span></td><td class="stats_right">' . $character->stats['spell_crit'] . '%</td></tr>';
$spell .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['mana_regen'] . ' ' . $character->stats['mana_regen'] . '</span><br><span class="description">' . $character->stats['mana_regen'] . ' ' . $_LANGUAGE->text['mana_regen_p_5_s_w_n_t'] . '</span>') . '\')">' . $_LANGUAGE->text['mana_regen'] . ':</span></td><td class="stats_right">' . $character->stats['mana_regen'] . '</td></tr>';
// Defense
$defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['armor'] . ' ' . $character->stats['armor_base'] . ' + ' . color($character->stats['armor_bonus'], 0) . '</span><br><span class="description">' . $_LANGUAGE->text['reduces'] . ' ' . $_LANGUAGE->text['ps_damage_taken'] . ' ' . $_LANGUAGE->text['by'] . ' ' . $character->stats['armor_mod'] . '%</span>') . '\')">
' . $_LANGUAGE->text['armor'] . ':</span></td><td class="stats_right">' . color($character->stats['armor_bonus'], $character->stats['armor_base']) . '</td></tr>';
$defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['dodge'] . ' ' . $character->stats['dodge'] . '%</span>') . '\')">' . $_LANGUAGE->text['dodge'] . ':</span></td><td class="stats_right">' . $character->stats['dodge'] . '%</td></tr>';
$defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['parry'] . ' ' . $character->stats['parry'] . '%</span>') . '\')">' . $_LANGUAGE->text['parry'] . ':</span></td><td class="stats_right">' . $character->stats['parry'] . '%</td></tr>';
$defense .= '<tr><td class="stats_left"><span class="description" onMouseOut="tooltip_hide();"
onMouseOver="tooltip(\'' . $_SYSTEM->htmlcode('<span class="tooltip-header">' . $_LANGUAGE->text['block'] . ' ' . $character->stats['block'] . '%</span>') . '\')">' . $_LANGUAGE->text['block'] . ':</span></td><td class="stats_right">' . $character->stats['block'] . '%</td></tr>';
$tp->assign('base_stats', $base_stats);
$tp->assign('melee', $melee);
$tp->assign('ranged', $ranged);
$tp->assign('spell', $spell);
$tp->assign('defense', $defense);
$_LANGUAGE->translate($tp);
$tp->display();
示例9: testAppliesStyleDirectlyToText
public function testAppliesStyleDirectlyToText()
{
$actual = color()->apply('blue', 'foo');
$expected = (string) color('foo')->blue;
$this->assertSame($expected, $actual);
$actual = color()->white('some white text');
$expected = (string) color('some white text')->white();
$this->assertSame($expected, $actual);
}
示例10: foreach
<ul class="stat-boxes">
<?php
$i = 0;
foreach ($summary_data as $name => $value) {
?>
<li style="color: <?php
echo color($i);
?>
!important;" class="popover-visits">
<div class="left peity_bar_good"><h4><?php
echo lang('reports_' . $name);
?>
</h4></div>
<div class="right">
<strong style="color: <?php
echo color($i);
?>
!important;"><?php
echo str_replace(' ', ' ', to_currency($value));
?>
</strong>
</div>
</li>
<?php
$i++;
}
?>
</ul>
</div>
示例11: letters_list
function letters_list($data = '')
{
$output = '
<table bgcolor="' . COLOR_TABLE_GENERAL . '">
';
$output .= '
<tr>';
// letters
// total 32-95
$offset = 32;
$col = -1;
$color = 0;
$dishes_letters = letters_list_creator();
for ($i = 17; $i <= 92 - $offset; $i++) {
$letter = chr($i + $offset);
if ($letter == "'") {
$letter = "\\'";
}
if ($letter == '%') {
continue;
}
$bgcolor = COLOR_TABLE_GENERAL;
//RTG: if there is some dishes begginnig with this letter
if (in_array($letter, $dishes_letters, false)) {
$letter = htmlentities($letter);
$link = 'orders.php?command=dish_list&data[letter]=' . $letter;
if (isset($data['quantity']) && $data['quantity']) {
$link .= '&data[quantity]=' . $data['quantity'];
}
if (isset($data['priority']) && $data['priority']) {
$link .= '&data[priority]=' . $data['priority'];
}
$bgcolor = color($color++);
$output .= '
<td bgcolor="' . $bgcolor . '" onclick="redir(\'' . $link . '\');return(false);">
<a href="' . $link . '">
<strong>' . $letter . '</strong>
</a>
</td>';
$col++;
} else {
continue;
$output .= '
<td bgcolor="' . $bgcolor . '">
</td>';
}
if (($col + 1) % 6 == 0) {
$color++;
$output .= '
</tr>
<tr>';
}
}
$output .= '
</tr>';
$output .= '
</tbody>
</table>';
return $output;
}
示例12: while
<?php
while (comments()) {
?>
<?php
// Insert default the name if not specified
$name = comment_name();
if (empty($name)) {
$name = 'Anonymous';
}
?>
<article id="comment<?php
echo comment_id();
?>
" class="anchor-comment">
<div class="anchor-comment__avatar mdl-color--<?php
echo color($name);
?>
">
<?php
echo strtoupper(substr($name, 0, 1));
?>
</div>
<header class="anchor-comment__author">
<h5 class="anchor-comment__author-name"><?php
echo $name;
?>
</h5>
<h6 class="anchor-comment__author-time">
<time><?php
echo relative_time(comment_time());
?>
示例13: filter_data
/**
* 处理提交的数据
*/
private function filter_data()
{
$name = isset($this->input['name']) ? trim(urldecode($this->input['name'])) : '';
$description = isset($this->input['description']) ? trim(urldecode($this->input['description'])) : '';
$isupdate = isset($this->input['isupdate']) ? intval($this->input['isupdate']) : 1;
$creditshigher = isset($this->input['creditshigher']) ? intval($this->input['creditshigher']) : '0';
$starnum = isset($this->input['starnum']) ? intval($this->input['starnum']) : 0;
$usernamecolor = isset($this->input['usernamecolor']) ? trim(urldecode($this->input['usernamecolor'])) : '#000000';
$enable = isset($this->input['enable']) ? intval($this->input['enable']) : '1';
//前台是否启用
if (empty($name)) {
$this->errorOutput('用户组名称不能为空');
}
if ($this->input['showcredit']) {
if (empty($this->input['credits_rules_diy'])) {
$this->errorOutput('如无需自定义规则,请<积分规则>选择否!');
}
}
if (!empty($usernamecolor)) {
$_march = '/[^a-zA-Z]/is';
if (!preg_match($_march, $usernamecolor)) {
$usernamecolor = color($usernamecolor);
}
$colorarr = str_split($usernamecolor);
if (count($colorarr) > 7) {
$this->errorOutput('十六进制色值不合法,大于7位');
}
if ($colorarr[0] != '#') {
$this->errorOutput('十六进制色值不合法,开头应该是以#');
}
unset($colorarr[0]);
foreach ($colorarr as $val) {
if ($val >= 'A' && $val <= 'F' || $val >= '0' && $val <= '9' || $val >= 'a' && $val <= 'f') {
continue;
} else {
$this->errorOutput('十六进制色值不合法,参考:#FF0000');
}
}
}
$data = array('name' => $name, 'description' => $description, 'isupdate' => $isupdate, 'starnum' => $starnum, 'usernamecolor' => $usernamecolor, 'enable' => $enable);
if (empty($isupdate)) {
$data['creditshigher'] = $creditshigher;
}
if ($_FILES['icon']) {
$img['Filedata'] = $_FILES['icon'];
if (!$this->settings['App_material']) {
$this->errorOutput('图片服务器未安装!');
}
$material_pic = new material();
$img_info = $material_pic->addMaterial($img);
$img_data = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename']);
$data['icon'] = maybe_serialize($img_data);
} elseif ($this->input['icondel']) {
$data['icon'] = '';
}
return $data;
}
示例14: color
$actions = ['rock', 'paper', 'scissors'];
$results = ['rock' => ['rock' => 0, 'paper' => -1, 'scissors' => 1], 'paper' => ['rock' => 1, 'paper' => 0, 'scissors' => -1], 'scissors' => ['rock' => -1, 'paper' => 1, 'scissors' => 0]];
$resultText = [-1 => color('red') . 'You lose!', 0 => color('purple') . "It's a tie!", 1 => color('green') . 'You win!'];
while ($c = fread(STDIN, 10)) {
$c = strtolower(trim($c));
if (in_array($c, $actions)) {
$cpu = $actions[mt_rand(0, 2)];
echo "The CPU chose {$cpu}\n";
$result = $results[$c][$cpu];
if ($result === 1) {
$wins++;
} else {
if ($result === -1) {
$losses++;
}
}
echo $resultText[$result] . color() . " ({$wins} - {$losses})\n";
if ($wins > 2 || $losses > 2) {
if ($wins > $losses) {
echo color('lightgreen') . "You won!!\n" . color();
} else {
echo color('lightred') . "You lost...\n" . color();
}
break;
} else {
echo "Choose a new action.\n";
}
} else {
echo color('red') . "Wrong action!\n" . color();
}
}
示例15: color
function color($a = NULL)
{
return new Color(mt_rand(20, 180), mt_rand(20, 180), mt_rand(20, 180), $a);
}
function formatLabel($value)
{
return sprintf("%.2f", $value);
}
$graph = new Graph(150, 100);
$graph->setAntiAliasing(TRUE);
$group = new PlotGroup();
$group->setXAxisZero(FALSE);
$group->setBackgroundColor(new Color(197, 180, 210, 80));
$group->setPadding(25, 10, 10, 20);
$group->axis->left->setLabelNumber(2);
$group->axis->left->setLabelPrecision(1);
// Display two lines
for ($n = 0; $n < 2; $n++) {
$x = array();
for ($i = 0; $i < 10; $i++) {
$x[] = cos($i * M_PI / 5) / ($n + 1);
}
$plot = new LinePlot($x);
$plot->setColor(color(10));
// Random line color
$plot->setFillColor(color(90));
// Random background color
$group->add($plot);
}
$graph->add($group);
$graph->draw();