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


PHP Color::getHex方法代码示例

本文整理汇总了PHP中Color::getHex方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::getHex方法的具体用法?PHP Color::getHex怎么用?PHP Color::getHex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Color的用法示例。


在下文中一共展示了Color::getHex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hsl2hex

function hsl2hex(Rule $rule)
{
    $hsl_patt = Regex::make('~{{ LB }}hsl({{ parens }})~i');
    foreach ($rule->declarations->filter(array('skip' => false)) as $declaration) {
        if (isset($declaration->functions['hsl'])) {
            $declaration->value = preg_replace_callback($hsl_patt, function ($m) {
                $color = new Color($m[0]);
                return $color->getHex();
            }, $declaration->value);
        }
    }
}
开发者ID:MrHidalgo,项目名称:css-crush,代码行数:12,代码来源:hsl2hex.php

示例2: Color

        $menu_is = 'dark';
        $menu_background_hover_color = '#' . $mbhc->lighten(5);
        //$menu_background_hover_color = "#628394";
    }
}
if (!$nav_icon_hover_color) {
    $nihc = new Color($nav_bg);
    if ($nihc->isLight()) {
        $nav_icon_hover_color = '#' . $nihc->darken(10);
    } else {
        $nav_icon_hover_color = '#' . $nihc->lighten(10);
    }
}
if (!$link_hover_color) {
    $lhc = new Color($link_color);
    $lcolor = $lhc->getHex();
    if ($lhc->isLight($lcolor, 75)) {
        $link_hover_color = '#' . $lhc->darken(5);
    } else {
        $link_hover_color = '#' . $lhc->lighten(5);
    }
}
// Convert $bg_image_options into css
switch ($bg_image_option) {
    case "stretch":
        $background_size_img = "100%";
        break;
    case "cover":
        $background_size_img = "cover";
        break;
    case "repeat":
开发者ID:rabuzarus,项目名称:frio,代码行数:31,代码来源:style.php

示例3: test

 /**
  * The whole test.
  */
 public function test()
 {
     $tests = ['#000000', '#000', '000000', 0, [0, 0, 0], new Color('#000000')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(0, $color->getRed());
         $this->assertEquals(0, $color->getGreen());
         $this->assertEquals(0, $color->getBlue());
         $this->assertEquals('000000', $color->getHex());
         $this->assertEquals([0, 0, 0], $color->getRgb());
         $this->assertEquals(0, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#000000', $output);
         $this->assertEquals('000000', $color->toGrayScale()->getHex());
         $this->assertEquals('ffffff', $color->toInverse()->getHex());
     }
     $color = new Color();
     $color->setRed('00')->setGreen('00')->setBlue('00');
     $this->assertEquals('000000', $color->getHex());
     $tests = ['#ffffff', '#FfFFffF', '#fff', 'ffffff', 0xffffff, [255, 255, 255], [260, 320, 1024], new Color('#ffffff')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(255, $color->getRed());
         $this->assertEquals(255, $color->getGreen());
         $this->assertEquals(255, $color->getBlue());
         $this->assertEquals('ffffff', $color->getHex());
         $this->assertEquals([255, 255, 255], $color->getRgb());
         $this->assertEquals(1, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#ffffff', $output);
         $this->assertEquals('ffffff', $color->toGrayScale()->getHex());
         $this->assertEquals('000000', $color->toInverse()->getHex());
     }
     $color = new Color();
     $color->setRed('FF')->setGreen('FF')->setBlue('FF');
     $this->assertEquals('ffffff', $color->getHex());
     $tests = ['#239416', '239416', 0x239416, [35, 148, 22], new Color('#239416')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(35, $color->getRed());
         $this->assertEquals(148, $color->getGreen());
         $this->assertEquals(22, $color->getBlue());
         $this->assertEquals('239416', $color->getHex());
         $this->assertEquals([35, 148, 22], $color->getRgb());
         $this->assertEquals(0, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#239416', $output);
         $this->assertEquals('616161', $color->toGrayScale()->getHex());
         $this->assertEquals('dc6be9', $color->toInverse()->getHex());
     }
     $tests = ['#22FF66', '#22Ff66', '#2f6', '2F6', '22FF66', '22fF66', 0x22ff66, [34, 255, 102], new Color('#22FF66')];
     foreach ($tests as $test) {
         $color = new Color($test);
         $this->assertEquals(34, $color->getRed());
         $this->assertEquals(255, $color->getGreen());
         $this->assertEquals(102, $color->getBlue());
         $this->assertEquals('22ff66', $color->getHex());
         $this->assertEquals([34, 255, 102], $color->getRgb());
         $this->assertEquals(1, $color->getBinary());
         ob_start();
         echo $color;
         $output = ob_get_clean();
         $this->assertEquals('#22ff66', $output);
         $this->assertEquals('b8b8b8', $color->toGrayScale()->getHex());
         $this->assertEquals('dd0099', $color->toInverse()->getHex());
     }
     $color = new Color();
     $color->setRed('23')->setGreen('94')->setBlue('16');
     $this->assertEquals('239416', $color->getHex());
     $invalids = ['#FFBBC', '#FBCA', '0000', '0', 'AB'];
     foreach ($invalids as $invalid) {
         try {
             $color = new Color($invalid);
             $this->fail(sprintf('%s expected for value %s', \InvalidArgumentException::class, $invalid));
         } catch (\PHPUnit_Framework_AssertionFailedError $e) {
             throw $e;
         } catch (\Exception $e) {
             // Correctly thrown exception
             $this->assertInstanceOf(\InvalidArgumentException::class, $e);
         }
     }
 }
开发者ID:jyxo,项目名称:php,代码行数:91,代码来源:ColorTest.php

示例4:

?>
;
	}
	
	.testDiv3{
		<?php 
echo $myPurple->getCssGradient();
?>
		color: <?php 
echo $myPurple->isDark() ? "#EEE" : "#333";
?>
;
	}
	.testDiv3.plain{
		background: #<?php 
echo $myPurple->getHex();
?>
;
		color: <?php 
echo $myPurple->isDark() ? "#EEE" : "#333";
?>
;
	}
</style>
<div class="clear"></div>
<div class="block testDiv">phpColor Gradient #<?php 
echo $myBlue->getHex();
?>
</div>
<div class="block testDiv plain">Plain #<?php 
echo $myBlue->getHex();
开发者ID:robertkraig,项目名称:phpColors,代码行数:31,代码来源:demo.php

示例5: prepareSensorList

 /**
  * Prepare sensor list
  *
  * @param $sensor_feature_code
  * @param $handler_id_code
  *
  * @return array
  */
 private function prepareSensorList($sensor_feature_code, $handler_id_code)
 {
     date_default_timezone_set('UTC');
     $start_datetime = strtotime($this->date_from . ' ' . $this->time_from);
     $end_datetime = strtotime($this->date_to . ' ' . $this->time_to);
     $qb = new CDbCriteria();
     $qb->with = ['sensor.station' => ['select' => array('station.station_id_code', 'station.color'), 'condition' => 'station.station_id IN (' . implode(',', $this->station_id) . ')'], 'sensor.handler' => ['select' => false, 'condition' => "handler.handler_id_code LIKE '" . $handler_id_code . "'"]];
     $qb->select = ['t.feature_code', 't.feature_display_name'];
     $qb->addCondition("t.feature_code LIKE '{$sensor_feature_code}'");
     $features = StationSensorFeature::model()->long()->findAll($qb);
     if ($features) {
         $i = 0;
         foreach ($features as $feature) {
             $colorWorker = new Color($feature->sensor->station->color);
             $series_names[$i] = array();
             $series_names[$i]['name'] = $feature->sensor->station->station_id_code . ', ' . $feature->sensor->sensor_id_code . ', ' . $this->getGroupSensorsFeaturesList()[$handler_id_code]['sensor_features'][$feature->feature_code];
             $series_names[$i]['params']['color'] = '#' . $colorWorker->getHex();
             $i++;
             $colorWorker = new Color($feature->sensor->station->color);
         }
         $qb = new CDbCriteria();
         $qb->select = 't.sensor_feature_normalized_value, t.sensor_feature_value, t.measuring_timestamp';
         $qb->addCondition('t.sensor_feature_id = :sensor_feature_id');
         $qb->addBetweenCondition('t.measuring_timestamp', date('Y-m-d H:i:s', $start_datetime), date('Y-m-d H:i:s', $end_datetime));
         $qb->order = 't.measuring_timestamp ASC';
         foreach ($features as $feature) {
             $qb->params[':sensor_feature_id'] = $feature->sensor_feature_id;
             $found_data = SensorData::model()->long()->findAll($qb);
             $tmp = array();
             if ($this->accumulation_period != 0) {
                 foreach ($found_data as $data) {
                     $period = $start_datetime + (intval((strtotime($data->measuring_timestamp) - $start_datetime) / ($this->accumulation_period * 60)) + 1) * $this->accumulation_period * 60;
                     $period = $period > $end_datetime ? $end_datetime : $period;
                     $period *= 1000;
                     $tmp[$period] = ['x' => $period, 'y' => $tmp[$period] ? $tmp[$period]['y'] : 0 + floatval($data->sensor_feature_value)];
                 }
             } else {
                 foreach ($found_data as $data) {
                     $period = strtotime($data->measuring_timestamp) * 1000;
                     $tmp[$period] = ['x' => $period, 'y' => floatval($data->sensor_feature_value)];
                 }
             }
             $series_data[] = array_values($tmp);
         }
     }
     return ['series_names' => isset($series_names) ? $series_names : [], 'series_data' => isset($series_data) ? $series_data : []];
 }
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:55,代码来源:AWSGraphForm.php


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