本文整理汇总了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);
}
示例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);
}