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


PHP color函数代码示例

本文整理汇总了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);
}
开发者ID:codeagent,项目名称:treemap,代码行数:13,代码来源:helpers.php

示例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);
}
开发者ID:lleaff,项目名称:Backito,代码行数:31,代码来源:mandel.php

示例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();
开发者ID:robertblackwell,项目名称:litetest,代码行数:31,代码来源:c.php

示例4: getColor

function getColor($current, $max)
{
    $color = color($current, $max);
    return $color;
}
开发者ID:OneCommunity,项目名称:HGN,代码行数:5,代码来源:hoursChartUsers.php

示例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;
}
开发者ID:BlueAndi,项目名称:vscp_software,代码行数:16,代码来源:index.php

示例6: important

/**
 * @param $message
 */
function important($message)
{
    echo color($message, 'green') . "\n";
}
开发者ID:rjsmelo,项目名称:tiki,代码行数:7,代码来源:svntools.php

示例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;
    ?>
开发者ID:aiyeyun,项目名称:grab,代码行数:31,代码来源:menuSub.php

示例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();
开发者ID:demonreborn,项目名称:miniarmory,代码行数:31,代码来源:character.php

示例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);
 }
开发者ID:SainsburysTests,项目名称:sainsburys-12,代码行数:9,代码来源:ColorTest.php

示例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(' ', '&nbsp;', to_currency($value));
    ?>
</strong>

                    </div>
                </li>
    <?php 
    $i++;
}
?>

        </ul>
    </div>	
开发者ID:ekchanthorn,项目名称:demo_loan,代码行数:31,代码来源:tabular.php

示例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&amp;data[letter]=' . $letter;
            if (isset($data['quantity']) && $data['quantity']) {
                $link .= '&amp;data[quantity]=' . $data['quantity'];
            }
            if (isset($data['priority']) && $data['priority']) {
                $link .= '&amp;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 . '">
			&nbsp;
			</td>';
        }
        if (($col + 1) % 6 == 0) {
            $color++;
            $output .= '
		</tr>
		<tr>';
        }
    }
    $output .= '
	</tr>';
    $output .= '
	</tbody>
</table>';
    return $output;
}
开发者ID:jaimeivan,项目名称:smart-restaurant,代码行数:61,代码来源:categories_waiter.php

示例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());
            ?>
开发者ID:EricHripko,项目名称:MaterialAnchor,代码行数:31,代码来源:article.php

示例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;
 }
开发者ID:h3len,项目名称:Project,代码行数:60,代码来源:member_group_update.php

示例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();
    }
}
开发者ID:Joimer,项目名称:ConsoleGames,代码行数:31,代码来源:rps.php

示例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();
开发者ID:BackupTheBerlios,项目名称:horux-svn,代码行数:31,代码来源:mini-006.php


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