本文整理汇总了PHP中hex2rgb函数的典型用法代码示例。如果您正苦于以下问题:PHP hex2rgb函数的具体用法?PHP hex2rgb怎么用?PHP hex2rgb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hex2rgb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grad
function grad($c1, $c2, $dir = 'top')
{
$c1 = trim($c1, '#');
$c2 = trim($c2, '#');
$c1b = substr($c1, -6);
$c2b = substr($c2, -6);
if (strlen($c1) < 7) {
$a1 = $a2 = 'FF';
} else {
$a1 = substr($c1, 0, 2);
$a2 = substr($c2, 0, 2);
}
$a1b = $a1;
$a2b = $a2;
if ($a1 == 'FF') {
$a1b = 100;
}
if ($a2 == 'FF') {
$a2b = 100;
}
$a = hex2rgb($c1b) . ',' . $a1b / 100;
$b = hex2rgb($c2b) . ',' . $a2b / 100;
#if($c1=='00e6e6e6')die("</style>startColorstr='#$a1$c1b',endColorstr='#$a2$c2b'");
return "background:-webkit-gradient(linear,left {$dir},left bottom,from(rgba({$a})),to(rgba({$b})));background:-moz-linear-gradient(rgba({$a}) 0%,rgba({$b}) 100%);background:-ms-linear-gradient({$dir},rgba({$a}) 0%,rgba({$b}) 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$a1}{$c1b}',endColorstr='#{$a2}{$c2b}',GradientType=0);";
}
示例2: ht_theme_styles
/**
* Enqueues styles for front-end.
*/
function ht_theme_styles()
{
global $wp_styles;
/*
* Loads our main stylesheet.
*/
wp_enqueue_style('theme-style', get_stylesheet_uri());
/*
* Loads our Google Font.
*/
$subsets = 'latin,latin-ext';
$protocol = is_ssl() ? 'https' : 'http';
$query_args = array('family' => 'Open+Sans:400,400italic,600,600italic', 'subset' => $subsets);
wp_enqueue_style('theme-font', esc_url(add_query_arg($query_args, "{$protocol}://fonts.useso.com/css")), array(), null);
/*
* Add font awesome CSS
*/
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array('theme-style'));
/*
* Add Lightbox CSS
*/
wp_enqueue_style('magnific-popup', get_template_directory_uri() . '/css/magnific-popup.css', array('theme-style'));
/*
* Load theme custom colors
*/
//Theme variables from theme customizer
$ht_styling_themecolor = get_theme_mod('ht_styling_themecolor', '#EC4B36');
// Convert theme colors from hex to rgb
$ht_styling_themecolor_rgb = hex2rgb($ht_styling_themecolor);
// Add custom styles
$custom_css = "\r\r\n\ta, a:visited, a:hover, \r\r\n\t.comment-action i {color: {$ht_styling_themecolor};}\r\r\n\tinput[type='submit'], \r\r\n\tinput[type='button'], \r\r\n\t.paging-navigation li a:hover, \r\r\n\t.hentry .entry-header:after, \r\r\n\t.hentry .entry-footer:before, \r\r\n\t.hentry .hentry-box > .entry-quote, \r\r\n\t.hentry .entry-link, \r\r\n\t.hentry .entry-status,\r\r\n\t#site-header #logo,\r\r\n\t.hentry .entry-date,\r\r\n\t.paging-navigation:after,\r\r\n\t#timeline > li .hentry:before {\r\r\n\t\tbackground: {$ht_styling_themecolor};\r\r\n\t}\r\r\n\t.entry-content a:hover, \r\r\n\t.entry-content blockquote, \r\r\n\tp.pullquote-left, \r\r\n\tp.pullquote-right,\r\r\n\t#social-icons li a:hover,\r\r\n\t#nav-primary > ul > li:hover > a {\r\r\n\t\tborder-color: {$ht_styling_themecolor};\r\r\n\t}\r\r\n\t#social-icons li a:hover,\r\r\n\t#nav-primary > ul > li:hover > a,\r\r\n\t#nav-primary ul ul li a:hover {\r\r\n\t\tcolor: {$ht_styling_themecolor};\r\r\n\t}\r\r\n\t.hentry .entry-thumb-caption, .gallery .gallery-item-caption {\r\r\n\tbackground: {$ht_styling_themecolor};\r\r\n\tbackground: rgba({$ht_styling_themecolor_rgb[0]},{$ht_styling_themecolor_rgb[1]},{$ht_styling_themecolor_rgb[2]},0.8);\r\r\n\t}\r\r\n\t";
wp_add_inline_style('theme-style', $custom_css);
}
示例3: ApplyParameters
function ApplyParameters($input)
{
global $parameters;
$textfx = array("", "text-shadow: 1px 1px black;", "text-shadow: -1px -1px black, 0px -1px black, 1px -1px black, 1px 0px black, 1px 1px black, 0px 1px black, -1px 1px black, -1px 0px black;");
$metafonts = array("serif", "sans-serif", "fantasy", "monospace");
$lines = explode("\n", str_replace("\r", "", $input));
$output = "";
foreach ($lines as $line) {
foreach ($parameters as $id => $settings) {
$value = $_POST[$id];
if ($settings['type'] == "percentage") {
$value = $_POST[$id] / 100;
} else {
if ($settings['type'] == "textfx") {
$value = $textfx[$value];
}
}
$line = str_replace("[" . $id . "]", $value, $line);
if ($settings['type'] == "color") {
$line = str_replace("[" . $id . "_RGB]", hex2rgb($value), $line);
}
if ($settings['type'] == "font") {
if (in_array($value, $metafonts)) {
$line = str_replace("\"", "", $line);
}
}
}
if (strpos($line, ": ;") === FALSE && strpos($line, ": !important;") === FALSE && strpos($line, ": px;") === FALSE && strpos($line, ": em;") === FALSE && strpos($line, ": 0px;") === FALSE && strpos($line, ": 0em;") === FALSE && !(strpos($line, "rgba(") !== FALSE && strpos($line, ", 0);") !== FALSE)) {
$output .= $line . "\n";
}
}
return $output;
}
示例4: index
/**
* 输出图片
*
* @param string $size [description]
* @param string $bgcolor [description]
* @param string $color [description]
* @param string $text [description]
* @param [type] $fontsize [description]
* @return [type] [description]
*/
public function index($size = '100x100', $bgcolor = 'ccc', $color = '555', $text = '', $fontsize = NULL)
{
$cache_filepath = storage_path('placeholders/' . md5(serialize(func_get_args())) . '.png');
if (!file_exists($cache_filepath)) {
// Dimensions
list($width, $height) = explode('x', $size);
empty($height) && ($height = $width);
$bgcolor = hex2rgb($bgcolor);
$color = hex2rgb($color);
empty($text) && ($text = $width . ' x ' . $height);
//$hash_key = md5(serialize(compact('width','height','bgcolor','color','text')));
// Create image
$image = imagecreate($width, $height);
// Colours
$setbg = imagecolorallocate($image, $bgcolor['r'], $bgcolor['g'], $bgcolor['b']);
$fontcolor = imagecolorallocate($image, $color['r'], $color['g'], $color['b']);
// Text positioning
empty($fontsize) && ($fontsize = $width > $height ? $height / 10 : $width / 10);
$font = APPPATH . 'static/common/fonts/msyh.ttf';
$fontbox = calculate_textbox($fontsize, 0, $font, $text);
// Generate text
function_exists('imageantialias') && imageantialias($image, true);
imagettftext($image, $fontsize, 0, ceil(($width - $fontbox['width']) / 2 + $fontbox['left']), ceil(($height - $fontbox['height']) / 2 + $fontbox['top']), $fontcolor, $font, $text);
// Render image
imagepng($image, $cache_filepath);
imagedestroy($image);
}
return response()->preview($cache_filepath, ['Content-Type' => 'image/png']);
}
示例5: getTextColor
public function getTextColor()
{
if (!\thebuggenie\core\framework\Context::isCLI()) {
\thebuggenie\core\framework\Context::loadLibrary('ui');
}
$rgb = hex2rgb($this->_itemdata);
return 0.299 * $rgb['red'] + 0.587 * $rgb['green'] + 0.114 * $rgb['blue'] > 170 ? '#333' : '#FFF';
}
示例6: getColorForGradient
function getColorForGradient($color, $opacity)
{
$color = trim($color);
if (substr($color, 0, 1) == '#') {
$rgb = hex2rgb($color);
$color = 'rgba(' . implode(',', $rgb) . ',' . number_format($opacity, 2, '.', '') . ')';
}
return $color;
}
示例7: redimensionner_image
function redimensionner_image($image_source, $largeur_max, $hauteur_max, $sauvegarder = false, $image_destination = '', $fix = false, $fix_couleur = 'f00')
{
list($largeur_source, $hauteur_source, $type_source, ) = getimagesize($image_source);
$mime_source = image_type_to_mime_type($type_source);
$largeur_final = $largeur_max;
$hauteur_final = $hauteur_max;
/* Origine de l'image : Par défaut à zéro */
$origine_x = 0;
$origine_y = 0;
if ($largeur_source < $largeur_final) {
$largeur_final = $largeur_source;
}
// Teste les dimensions tenant dans la zone
$test_h = round($largeur_final / $largeur_source * $hauteur_source);
$test_w = round($hauteur_final / $hauteur_source * $largeur_source);
if (!$hauteur_final) {
// Si Height final non précisé (0)
$hauteur_final = $test_h;
} elseif (!$largeur_final) {
// Sinon si Width final non précisé (0)
$largeur_final = $test_w;
} elseif ($test_h > $hauteur_final) {
// Sinon test quel redimensionnement tient dans la zone
$largeur_final = $test_w;
} else {
$hauteur_final = $test_h;
}
if ($mime_source == 'image/jpeg') {
$img_in = imagecreatefromjpeg($image_source);
} elseif ($mime_source == 'image/png') {
$img_in = imagecreatefrompng($image_source);
} elseif ($mime_source == 'image/gif') {
$img_in = imagecreatefromgif($image_source);
} else {
return false;
}
if ($fix) {
$img_out = imagecreatetruecolor($largeur_max, $hauteur_max);
if ($largeur_final < $largeur_max) {
$origine_x = round(($largeur_max - $largeur_final) / 2);
}
if ($hauteur_final < $hauteur_max) {
$origine_y = round(($hauteur_max - $hauteur_final) / 2);
}
$couleurs = hex2rgb($fix_couleur);
$fond = ImageColorAllocate($img_out, $couleurs[0], $couleurs[1], $couleurs[2]);
imagefill($img_out, 0, 0, $fond);
} else {
$img_out = imagecreatetruecolor($largeur_final, $hauteur_final);
}
imagecopyresampled($img_out, $img_in, $origine_x, $origine_y, 0, 0, $largeur_final, $hauteur_final, imagesx($img_in), imagesy($img_in));
if ($sauvegarder) {
imagejpeg($img_out, $image_destination);
} else {
imagejpeg($img_out, null, 100);
}
}
示例8: rgba
function rgba($color, $opacity = 1, $retAsStr = false, $sep = ',')
{
if (substr($color, 0, 1) == '#') {
$color = substr($color, 1);
}
$color = hex2rgb($color);
$color = array_merge($color, array('alpha' => $opacity));
return $retAsStr ? implode($sep, $color) : $color;
}
示例9: hexalpha2rgba
/**
* Convert hexadecimal/alpha colors to rgba
*
* @since IS Simple 1.0
*
* @param array $hexalpha Array where $hexalpha['color'] is the hexadecimal color and
* $hexalpha['alpha'] is the opacity code
* @return string Hexadecial/alpha color array converted to rgba color code
* ============================================================================
*/
function hexalpha2rgba($hexalpha)
{
$hex = $hexalpha['color'];
$rgb = hex2rgb($hex);
$alpha = $hexalpha['alpha'];
$rgba = $rgb . ',' . $alpha;
return $rgba;
// Return string separated by commas
}
示例10: rgbConvert
function rgbConvert($str)
{
//echo($str.strpos($str,","));
if (strpos($str, ",")) {
//echo "rgb2array";
return rgb2array($str);
} else {
//echo "hex2rgb";
return hex2rgb($str);
}
}
示例11: getShadow
function getShadow($b, $t)
{
$b = hex2rgb($b);
$t = hex2rgb($t);
$c = array();
foreach ($b as $k => $v) {
$a = abs($t[$k] - $v);
array_push($c, abs($a - ($a < 16 || $a > 239 ? round($a / 2) : 0)));
}
return 'rgb(' . implode(',', $c) . ')';
}
示例12: color_check
function color_check($colors, $alpha)
{
$opacity = array('1', '1.0');
if ($colors != '') {
if (!in_array($alpha, $opacity)) {
$color = 'rgba(' . hex2rgb($colors) . ',' . $alpha . ')';
} else {
$color = $colors;
}
} else {
$color = '';
}
return $color;
}
示例13: colourBlend
function colourBlend($col1, $col2, $factor)
{
$col1RGB = hex2rgb(prepareHex($col1));
$col2RGB = hex2rgb(prepareHex($col2));
$blend = array();
//echo ('/*');
for ($i = 0; $i < 3; $i++) {
$min = min($col1RGB[$i], $col2RGB[$i]);
$max = max($col1RGB[$i], $col2RGB[$i]);
$blend[$i] = round($min + ($max - $min) * $factor);
//echo ($i .': min '. $min . ', max '. $max .' = '. $blend[$i].'\n\r' );
}
//echo ('*/');
return rgb2hex($blend);
}
示例14: addMCColorString
/**
* Add a Minecraft color coded string to an image.
* @param $img
* @param $font
* @param $fontSize
* @param $startX
* @param $startY
* @param $string
*/
function addMCColorString(&$img, $font, $fontSize, $startX, $startY, $string)
{
$MCColors = ["0" => "#000000", "1" => "#0000AA", "2" => "#008000", "3" => "#00AAAA", "4" => "#AA0000", "5" => "#AA00AA", "6" => "#FFAA00", "7" => "#AAAAAA", "8" => "#555555", "9" => "#5555FF", "a" => "#3CE63C", "b" => "#55FFFF", "c" => "#FF5555", "d" => "#FF55FF", "e" => "#FFFF55", "f" => "#FFFFFF"];
if (strpos($string, "§") === false) {
$string = '§7' . $string;
}
$currentX = $startX;
$currentY = $startY + 16;
foreach (explode("§", $string) as $part) {
$rgb = hex2rgb($MCColors[substr($part, 0, 1)]);
$color = imagecolorallocate($img, $rgb[0], $rgb[1], $rgb[2]);
$part = substr($part, 1);
$bbox = imagettftext($img, $fontSize, 0, $currentX, $currentY, $color, $font, $part);
$currentX += $bbox[4] - $bbox[0];
}
}
示例15: Scaffold_background_rgba
function Scaffold_background_rgba($params)
{
$color_names = get_color_names();
$params = explode(',', $params);
if (color_type($params[0]) == 'hexadecimal') {
$rgb = hex2rgb($params[0]);
$rgba = array($rgb[0], $rgb[1], $rgb[2], $params[1]);
} else {
if (color_type($params[0]) == 'colorname') {
$rgba = array($color_names[$params[0]][0], $color_names[$params[0]][1], $color_names[$params[0]][2], $params[1]);
} else {
$rgba = $params;
}
}
list($r, $g, $b, $a) = $rgba;
return Rgba::create_rgba($r, $g, $b, $a);
}