本文整理汇总了PHP中Converter::HEX2RGB方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::HEX2RGB方法的具体用法?PHP Converter::HEX2RGB怎么用?PHP Converter::HEX2RGB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::HEX2RGB方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: substr
$bg = Request::get('bg', '333333', false);
$color = Request::get('color', 'FFFFAA', false);
$padding = Request::get('padding', 0);
$width = Request::get('width', 100) + $padding * 2;
$height = Request::get('height', 30) + $padding * 2;
$size = Request::get('size', 16);
$length = Request::get('length', 7);
$font = Request::get('font', 'special-elite-regular.ttf', false);
$text = substr(str_shuffle($str), 0, $length);
Session::set(Guardian::$captcha, $text);
if ($bg !== 'false' && ($bg = Converter::HEX2RGB($bg))) {
$bg = array($bg['r'], $bg['g'], $bg['b'], $bg['a']);
} else {
$bg = $bg !== 'false' ? array(51, 51, 51, 1) : array(0, 0, 0, 0);
}
if ($color = Converter::HEX2RGB($color)) {
$color = array($color['r'], $color['g'], $color['b'], $color['a']);
} else {
$color = array(255, 255, 170, 1);
}
$image = imagecreatetruecolor($width, $height);
$font = strpos($font, '/') === false ? ASSET . DS . '__captcha' . DS . $font : ROOT . DS . File::path($font);
imagefill($image, 0, 0, 0x7fff0000);
imagealphablending($image, true);
imagesavealpha($image, true);
$bg = imagecolorallocatealpha($image, $bg[0], $bg[1], $bg[2], 127 - $bg[3] * 127);
$color = imagecolorallocatealpha($image, $color[0], $color[1], $color[2], 127 - $color[3] * 127);
imagefilledrectangle($image, 0, 0, $width, $height, $bg);
// center the image text ...
$xi = imagesx($image);
$yi = imagesy($image);
示例2: merge
/**
* ====================================================================
* COMBINE MULTIPLE IMAGE FILE(S) INTO A SINGLE IMAGE (SPRITE)
* ====================================================================
*
* -- CODE: -----------------------------------------------------------
*
* Image::take(array(
* 'icon-1.png',
* 'icon-2.png',
* 'icon-3.png'
* ))->merge(0, 'vertical')->saveAs('sprites.png');
*
* --------------------------------------------------------------------
*
*/
public static function merge($gap = 0, $orientation = 'vertical', $bg = false, $alpha_for_hex = 1)
{
$bucket = array();
$width = 0;
$height = 0;
$max_width = array();
$max_height = array();
$orientation = strtolower($orientation);
self::$open = (array) self::$open;
foreach (self::getInfo() as $info) {
$bucket[] = array('width' => $info['width'], 'height' => $info['height']);
$max_width[] = $info['width'];
$max_height[] = $info['height'];
$width += $info['width'] + $gap;
$height += $info['height'] + $gap;
}
if (!$bg) {
$bg = array(0, 0, 0, 0);
// transparent
}
if (is_array($bg)) {
if (count($bg) === 3) {
$bg[] = 1;
// missing alpha channel
}
list($r, $g, $b, $a) = array_values($bg);
} else {
$bg = (string) $bg;
if ($bg[0] === '#' && ($color = Converter::HEX2RGB($bg))) {
$r = $color['r'];
$g = $color['g'];
$b = $color['b'];
$a = $alpha_for_hex;
} else {
if ($color = Converter::RGB($bg)) {
$r = $color['r'];
$g = $color['g'];
$b = $color['b'];
$a = $color['a'];
}
}
}
$a = 127 - $a * 127;
if ($orientation[0] === 'v') {
$pallete = imagecreatetruecolor(max($max_width), $height - $gap);
} else {
$pallete = imagecreatetruecolor($width - $gap, max($max_height));
}
$bg = imagecolorallocatealpha($pallete, $r, $g, $b, $a);
imagefill($pallete, 0, 0, $bg);
imagealphablending($pallete, true);
imagesavealpha($pallete, true);
$start_width_from = 0;
$start_height_from = 0;
for ($i = 0, $count = count(self::$open); $i < $count; ++$i) {
self::gen(self::$open[$i]);
imagealphablending(self::$GD, false);
imagesavealpha(self::$GD, true);
imagecopyresampled($pallete, self::$GD, $start_width_from, $start_height_from, 0, 0, $bucket[$i]['width'], $bucket[$i]['height'], $bucket[$i]['width'], $bucket[$i]['height']);
$start_width_from += $orientation[0] === 'h' ? $bucket[$i]['width'] + $gap : 0;
$start_height_from += $orientation[0] === 'v' ? $bucket[$i]['height'] + $gap : 0;
}
self::twin($pallete, 'png');
return new static();
}