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


PHP Color::StringToRgb24方法代码示例

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


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

示例1: contrastColors

 static function contrastColors($string, $background)
 {
     $background = Color::StringToRgb24($background);
     return preg_replace_callback('/(?<!\\$)((?:\\$\\$)*)(\\$[0-9a-f][^\\$]{0,2})/iu', function ($matches) use($background) {
         $color = Color::StringToRgb24($matches[2]);
         $color = Color::Contrast($color, $background);
         $color = Color::Rgb24ToRgb12($color);
         $color = Color::Rgb12ToString($color);
         return $matches[1] . '$' . $color;
     }, $string);
 }
开发者ID:kremsy,项目名称:manialib,代码行数:11,代码来源:Formatting.php

示例2: onImageQuality

 /**
  * Draw a string with on an image using quality method. Slow with big text size
  * @param string $string The style-coded string to draw
  * @param imageResource $image The image to draw on
  * @param string $fontName The TTF font to use, which has been declared previously
  * @param int $x X position
  * @param int $y Y position
  * @param int $size Font size
  * @param string $defaultColor Default text color in 3 or 6 hexadecimal characters
  * @param int $precision Higher value means higher precision (but also longer execution time), usual values are 1 to 3
  */
 static function onImageQuality($string, $image, $fontName, $x = 0, $y = 0, $size = 10, $defaultColor = '000', $precision = 2)
 {
     $defaultColor = Color::StringToRgb24($defaultColor);
     $factor = 1 << ($precision > 31 ? 31 : $precision);
     $tokens = self::parseString($string);
     $rawText = '';
     foreach ($tokens as $token) {
         $rawText .= $token->text;
     }
     $maxBBox = imagettfbbox($size, 0, self::$fonts[$fontName]->getFile(), $rawText);
     $brush = imagecreatetruecolor($maxBBox[2] * 2, -$maxBBox[5] + 5);
     imagefill($brush, 0, 0, 0x7fffffff);
     $hugeBrush = imagecreatetruecolor(imagesx($brush) * $factor, imagesy($brush) * $factor);
     imagefill($hugeBrush, 0, 0, 0x7fffffff);
     $xOffset = 0;
     foreach ($tokens as $token) {
         $xOffset += $token->onImage($hugeBrush, $fontName, $xOffset, imagesy($hugeBrush) * 0.75, $factor * $size, $defaultColor, $factor);
     }
     $brushX = $x + imagesx($brush) / 2;
     $brushY = $y - imagesy($brush) * 0.25;
     imagecopyresampled($brush, $hugeBrush, 0, 0, 0, 0, imagesx($brush), imagesy($brush), imagesx($hugeBrush), imagesy($hugeBrush));
     imagesetbrush($image, $brush);
     imageline($image, $brushX, $brushY, $brushX, $brushY, IMG_COLOR_BRUSHED);
 }
开发者ID:maniaplanet,项目名称:manialib,代码行数:35,代码来源:StyleParser.php


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