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


PHP Color类代码示例

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


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

示例1: interpolate

 public static function interpolate(Color $color1, Color $color2, $part = 0.5)
 {
     $color = new Color();
     $hsv = ['h' => null, 's' => null, 'v' => null];
     $color1Hsv = $color1->getHsv();
     $color2Hsv = $color2->getHsv();
     foreach ($hsv as $key => $value) {
         if ($color1Hsv[$key] < $color2Hsv[$key]) {
             $outLength = 1 - $color2Hsv[$key] + $color1Hsv[$key];
             if ($key == 'h' && $outLength < 0.5) {
                 $hsv[$key] = $color2Hsv[$key] + $outLength * $part;
                 if ($hsv[$key] > 1) {
                     $hsv[$key]--;
                 }
             } else {
                 $hsv[$key] = ($color2Hsv[$key] - $color1Hsv[$key]) * $part + $color1Hsv[$key];
             }
         } else {
             $outLength = 1 - $color1Hsv[$key] + $color2Hsv[$key];
             if ($key == 'h' && $outLength < 0.5) {
                 $hsv[$key] = $color1Hsv[$key] + $outLength * $part;
                 if ($hsv[$key] > 1) {
                     $hsv[$key]--;
                 }
             } else {
                 $hsv[$key] = ($color1Hsv[$key] - $color2Hsv[$key]) * $part + $color2Hsv[$key];
             }
         }
     }
     $color->setHsv($hsv);
     return $color;
 }
开发者ID:intaro,项目名称:color-interpolator,代码行数:32,代码来源:ColorInterpolator.php

示例2: getColorValue

 /**
  *
  * @param Color $c
  *
  * @return string
  */
 public function getColorValue(Color $c = null)
 {
     if ($c) {
         return $c->toString();
     }
     return null;
 }
开发者ID:appshed,项目名称:extension-api,代码行数:13,代码来源:CSSDocument.php

示例3: 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;
     }
 }
开发者ID:andrewandante,项目名称:silverstripe-calendar,代码行数:50,代码来源:ColorpaletteHelper.php

示例4: testColor

 public function testColor()
 {
     $redColor = new Color('red');
     $blueColor = new Color('blue');
     $this->assertSame('red', (string) $redColor);
     $this->assertSame(100, $redColor->compareTo($redColor));
     $this->assertSame(29, $redColor->compareTo($blueColor));
 }
开发者ID:pdt256,项目名称:bestmatch,代码行数:8,代码来源:ColorTest.php

示例5: PageContent

function PageContent()
{
    ?>
    
            <div class="layout center-flex">

                <?php 
    $aLabels = array();
    $aLinks = array();
    $aLabels[0] = 'Home';
    $aLinks[0] = 'mainpage.php';
    $aLabels[1] = 'Category List';
    $aLinks[1] = 'category_list.php';
    $aLabels[2] = 'Color';
    $aLinks[2] = '';
    echo Helpers::CreateBreadCrumbs($aLabels, $aLinks);
    ?>

                <div class="bigbotspace flex-container space-between">
                    <p class="larger auto heading">Color</p>
                    <!--
                    <a href="category_admin.php" class="button_link"><button class="">Add New Color</button></a>
                    -->
                </div>
            </div>
    
            <div class="layout">
    
                <table class="tablestyle" id="list_table">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Overview Text</th>
                            <th>Images</th>
                            <th class="mid">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
    $objColor = new Color();
    $oColor = $objColor->GetAllColorByCategoryId($_REQUEST['cat']);
    $objColorImage = new ColorImage();
    foreach ($oColor as $color) {
        echo '<tr id="img_' . $color->Id . '">' . PHP_EOL;
        echo '<td>' . $color->Id . '</td>' . PHP_EOL;
        echo '<td>' . substr($color->OverviewText, 0, 200) . '</td>' . PHP_EOL;
        echo '<td>(<a href="colorimage_list.php?cat=' . $_REQUEST['cat'] . '&color=' . $color->Id . '">' . $objColorImage->getCountColorImageByColorId($color->Id) . '</a>)</td>' . PHP_EOL;
        echo '<td class="mid"><a href="color_admin.php?cat=' . $_REQUEST['cat'] . '&id=' . $color->Id . '"><img src="img/edit-icon.png" /></a></td>' . PHP_EOL;
        echo '</tr>' . PHP_EOL;
    }
    ?>
                    </tbody>
                </table>
    
            </div> <!-- layout -->
    
<?php 
}
开发者ID:brandfeverinc,项目名称:coke-cooler,代码行数:58,代码来源:color_list.php

示例6: newImage

 /**
  * Creates new image instance
  *
  * @param  integer $width
  * @param  integer $height
  * @param  string  $background
  * @return \Intervention\Image\Image
  */
 public function newImage($width, $height, $background = null)
 {
     // create empty resource
     $core = imagecreatetruecolor($width, $height);
     $image = new \Intervention\Image\Image(new static(), $core);
     // set background color
     $background = new Color($background);
     imagefill($image->getCore(), 0, 0, $background->getInt());
     return $image;
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:18,代码来源:Driver.php

示例7: __construct

 public function __construct()
 {
     $this->measure = 0;
     $this->title = Marker::$defaultTitle;
     $color = new Color();
     $color->setR(Marker::$defaultColor[0]);
     $color->setG(Marker::$defaultColor[1]);
     $color->setB(Marker::$defaultColor[2]);
     $this->color = $color;
 }
开发者ID:stdtabs,项目名称:phptabs,代码行数:10,代码来源:Marker.php

示例8: __construct

 function __construct(Color $color1, Color $color2, $direction = 0)
 {
     $this->direction = $direction;
     $cs = $color1->getRGBA();
     $cd = $color2->getRGBA();
     $cf = array($cs[0], $cs[1], $cs[2]);
     $cl = array($cd[0], $cd[1], $cd[2]);
     $cd = array($cl[0] - $cf[0], $cl[1] - $cf[1], $cl[2] - $cf[2]);
     $this->colors = array('first' => $cf, 'last' => $cl, 'delta' => $cd);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:10,代码来源:gradient.php

示例9: colorGradientPalette

 public static function colorGradientPalette(Color $color1, Color $color2, $shades)
 {
     $palette = new Palette();
     $RFactor = ($color2->getR() - $color1->getR()) / $shades;
     $GFactor = ($color2->getG() - $color1->getG()) / $shades;
     $BFactor = ($color2->getB() - $color1->getB()) / $shades;
     for ($i = 0; $i <= $shades - 1; $i++) {
         $palette->colors[$i] = new Color($color1->getR() + $RFactor * $i, $color1->getG() + $GFactor * $i, $color1->getB() + $BFactor * $i);
     }
     return $palette;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:11,代码来源:Palette.php

示例10: postAgregacolor

 public function postAgregacolor()
 {
     $color = new Color();
     $color->nombre = Input::get('nombre_color');
     $color->save();
     $material_color = new MaterialColor();
     $material_color->color_id = $color->id;
     $material_color->material_id = Input::get('material_id');
     $material_color->save();
     return Redirect::action('InventarioRecubControlador@getColores');
 }
开发者ID:grupoim,项目名称:bifrost_free,代码行数:11,代码来源:InventarioRecubControlador.php

示例11: _configure

 private function _configure()
 {
     TileCache::$daysToRemember = $this->_conf->get('tile_cache_days_of_memory');
     TileCache::$numberOfFilesToDelete = $this->_conf->get('tile_cache_number_of_files_to_delete');
     TilesGetter::$limitOfTiles = $this->_conf->get('max_number_of_tiles_per_map');
     $defaultColor = new Color();
     $defaultColor->setColor($this->_conf->get('default_drawings_color'));
     DrawRequest::$defaultColor = $defaultColor;
     DrawRequest::$defaultThickness = new ParamThickness($this->_conf->get('default_path_thickness'));
     DrawRequest::$defaultTransparency = new ParamTransparency($this->_conf->get('default_drawings_transparency'));
     ParamPatternUrl::$patternMap = $this->_conf->get('pattern_point_image_map');
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:12,代码来源:MapModule.php

示例12: 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

示例13: makeHue

 public function makeHue()
 {
     if ($this->hasErrors() || (string) $this->hue != '') {
         return;
     }
     if (!is_array($this->rgb) || count($this->rgb) !== 3) {
         return;
     }
     list($r, $g, $b) = $this->rgb;
     $color = new \Color();
     $color->fromRgbInt($r, $g, $b);
     $hsv = $color->toHsvFloat();
     $this->hue = (int) round($hsv['hue']);
 }
开发者ID:ExceptionError,项目名称:stat.ink,代码行数:14,代码来源:TeamColorForm.php

示例14: _admin_color

function _admin_color($loff = 0, $satc = null, $sat_abs = false)
{
    // nacteni a uprava barev
    $h = $GLOBALS['hue'];
    if ($GLOBALS['dark']) {
        $l = $GLOBALS['light'] - $loff;
    } else {
        $l = $GLOBALS['light'] + $loff;
    }
    $s = isset($satc) ? $sat_abs ? $satc : $GLOBALS['sat'] * $satc : $GLOBALS['sat'];
    // vytvoreni hex kodu barvy
    $color = new Color(array($h, $l, $s), 1);
    return $color->getRGBStr();
}
开发者ID:sunlight-cms,项目名称:sunlight-cms-7,代码行数:14,代码来源:style.css.php

示例15: search_data

 public static function search_data($vehicle_data, $driver = NULL)
 {
     if (!empty($vehicle_data)) {
         $vehicles_vin = $vehicle_data->vehicles_vin;
         $vehicles_model_id = $vehicle_data->vehicles_model_id;
         $vehicles_use_type_id = $vehicle_data->vehicles_use_type;
         $vehicle_color = Color::find($vehicle_data->vehicles_color)->colors_name;
         $owner = $vehicle_data->owners;
         foreach ($owner as $own) {
             $owner_names['name'][] = $own->drivers_fname . " " . $own->drivers_lname;
         }
         if (!isset($owner_names)) {
             $owner_names = null;
         }
         $model = Model::find($vehicles_model_id);
         $model_make_id = $model->model_make_id;
         $model_name = $model->model_name;
         $vehicle_use_types_name = VehicleUseType::find($vehicles_use_type_id)->vehicle_use_types_name;
         $result_data[] = array('id' => $vehicle_data->id, 'vin_number' => $vehicles_vin, 'model_make_id' => $model_make_id, 'model_name' => $model_name, 'color' => $vehicle_color, 'owner' => $owner_names, 'vehicle_use_types_name' => $vehicle_use_types_name);
         if ($driver) {
             return $result_data;
         }
         Helpers::response_data('200', 'success', $result_data);
     } else {
         Helpers::response_data('404', 'No record found', NULL);
     }
 }
开发者ID:abhikalotra,项目名称:Samples1,代码行数:27,代码来源:helpers.php


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