Exemplo n.º 1
0
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);";
}
Exemplo n.º 2
0
/**
 * 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);
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
 /**
  * 输出图片
  * 
  * @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']);
 }
Exemplo n.º 5
0
 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';
 }
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;
}
Exemplo n.º 7
0
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);
    }
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
/**
 * 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
}
Exemplo n.º 10
0
function rgbConvert($str)
{
    //echo($str.strpos($str,","));
    if (strpos($str, ",")) {
        //echo "rgb2array";
        return rgb2array($str);
    } else {
        //echo "hex2rgb";
        return hex2rgb($str);
    }
}
Exemplo n.º 11
0
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) . ')';
}
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
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);
}
Exemplo n.º 14
0
/**
 * 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];
    }
}
Exemplo n.º 15
0
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);
}
Exemplo n.º 16
0
 function tm_color_gradient($basic_hexa, $step_rgb)
 {
     $basic_rbg = hex2rgb($basic_hexa);
     $r = $basic_rbg[0] - $step_rgb[0];
     if ($r < 0) {
         $r = 0;
     }
     $g = $basic_rbg[1] - $step_rgb[1];
     if ($g < 0) {
         $g = 0;
     }
     $b = $basic_rbg[2] - $step_rgb[2];
     if ($b < 0) {
         $b = 0;
     }
     return rgb2hexa(array($r, $g, $b));
 }
Exemplo n.º 17
0
function generateImage($str)
{
    $secret = "SECRET_STRING";
    if (!isset($str)) {
        $str = sha1(rand(-99999, 99999) . $secret);
    } else {
        $str = sha1($str . $secret);
    }
    $WH = 200;
    $im = imagecreatetruecolor($WH, $WH);
    $im1 = imagecreatetruecolor($WH, $WH);
    $im2 = imagecreatetruecolor($WH, $WH);
    $im3 = imagecreatetruecolor($WH, $WH);
    $im4 = imagecreatetruecolor($WH, $WH);
    for ($i = 0; $i < 6 * $WH + 1; $i++) {
        $str .= sha1($str . $secret);
    }
    $arr = array();
    for ($i = 0; $i < round(strlen($str) / 6, 0); $i++) {
        $arr[] = hex2rgb(substr($str, $i * 6, 6));
    }
    for ($i = 0; $i < $WH / 2; $i++) {
        $r = $arr[$i][0];
        $g = $arr[$i][1];
        $b = $arr[$i][2];
        $color = imagecolorallocate($im, $r, $g, $b);
        imagefilledrectangle($im1, $i, $i, $WH - $i, $WH - $i, $color);
        $color = imagecolorallocate($im, $b, $r, $g);
        imagefilledrectangle($im2, $i, $i, $WH - $i, $WH - $i, $color);
        $color = imagecolorallocate($im, $g, $r, $b);
        imagefilledrectangle($im3, $i, $i, $WH - $i, $WH - $i, $color);
        $color = imagecolorallocate($im, $r, $b, $g);
        imagefilledrectangle($im4, $i, $i, $WH - $i, $WH - $i, $color);
    }
    imagecopy($im, $im1, 0, 0, 0, 0, $WH / 2, $WH / 2);
    imagecopy($im, $im2, $WH / 2, 0, $WH / 2, 0, $WH / 2, $WH / 2);
    imagecopy($im, $im3, 0, $WH / 2, 0, $WH / 2, $WH / 2, $WH / 2);
    imagecopy($im, $im4, $WH / 2, $WH / 2, $WH / 2, $WH / 2, $WH, $WH);
    return $im;
}
        }
    }
    $textShadow .= ' ';
    if (stripos($textShadowLocation, 'top') !== false) {
        $textShadow .= '-' . $textShadowDistance;
    } else {
        if (stripos($textShadowLocation, 'bottom') !== false) {
            $textShadow .= $textShadowDistance;
        } else {
            $textShadow .= '0';
        }
    }
    $textShadow .= ' ';
    $textShadow .= $textShadowBlur;
    $textShadow .= ' ';
    $rgb = hex2rgb($textShadowColor);
    $rgb[] = $textShadowOpacity;
    $textShadow .= 'rgba(' . implode(',', $rgb) . ')';
} else {
    $textShadow .= $textShadowLocation;
}
?>
<html>
	<head>
		<?php 
if ($fontType == 'google') {
    $weight = $fontWeight;
    if ($weight == 'normal') {
        $weight = array('400');
    } else {
        if ($weight == 'bold') {
Exemplo n.º 19
0
 protected function drawTriggers()
 {
     if ($this->m_showTriggers != 1) {
         return;
     }
     //		if($this->num != 1) return; // skip multiple graphs
     $opposite = hex2rgb(GRAPH_TRIGGER_LINE_OPPOSITE_COLOR);
     $oppColor = imagecolorallocate($this->im, $opposite[0], $opposite[1], $opposite[2]);
     foreach ($this->triggers as $tnum => $trigger) {
         if ($trigger['skipdraw']) {
             continue;
         }
         $triggerColor = $this->getColor($trigger['color']);
         $lineStyle = array($triggerColor, $triggerColor, $triggerColor, $triggerColor, $triggerColor, $oppColor, $oppColor, $oppColor);
         //			SDI($trigger['color']);
         dashedline($this->im, $this->shiftXleft, $trigger['y'], $this->sizeX + $this->shiftXleft, $trigger['y'], $lineStyle);
         dashedline($this->im, $this->shiftXleft, $trigger['y'] + 1, $this->sizeX + $this->shiftXleft, $trigger['y'] + 1, $lineStyle);
     }
 }
Exemplo n.º 20
0
function drawMapHighligts(&$im, $map, $mapInfo)
{
    $selements = $map['selements'];
    foreach ($selements as $selementId => $selement) {
        if (isset($selement['elementsubtype']) && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS) {
            continue;
        }
        $elementInfo = $mapInfo[$selementId];
        $img = get_png_by_selement($elementInfo);
        $iconX = imagesx($img);
        $iconY = imagesy($img);
        if ($map['highlight'] % 2 == SYSMAP_HIGHLIGHT_ON) {
            $hl_color = null;
            $st_color = null;
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_ON) {
                $hl_color = hex2rgb(getSeverityColor($elementInfo['priority']));
            }
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_MAINTENANCE) {
                $st_color = hex2rgb('FF9933');
            }
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_DISABLED) {
                $st_color = hex2rgb('EEEEEE');
            }
            $mainProblems = array(SYSMAP_ELEMENT_TYPE_HOST_GROUP => 1, SYSMAP_ELEMENT_TYPE_MAP => 1);
            if (isset($mainProblems[$selement['elementtype']])) {
                if (!is_null($hl_color)) {
                    $st_color = null;
                }
            } elseif (!is_null($st_color)) {
                $hl_color = null;
            }
            if (!is_null($st_color)) {
                $r = $st_color[0];
                $g = $st_color[1];
                $b = $st_color[2];
                imagefilledrectangle($im, $selement['x'] - 2, $selement['y'] - 2, $selement['x'] + $iconX + 2, $selement['y'] + $iconY + 2, imagecolorallocatealpha($im, $r, $g, $b, 0));
                // shadow
                imagerectangle($im, $selement['x'] - 2 - 1, $selement['y'] - 2 - 1, $selement['x'] + $iconX + 2 + 1, $selement['y'] + $iconY + 2 + 1, imagecolorallocate($im, 120, 120, 120));
                imagerectangle($im, $selement['x'] - 2 - 2, $selement['y'] - 2 - 2, $selement['x'] + $iconX + 2 + 2, $selement['y'] + $iconY + 2 + 2, imagecolorallocate($im, 220, 220, 220));
            }
            if (!is_null($hl_color)) {
                $r = $hl_color[0];
                $g = $hl_color[1];
                $b = $hl_color[2];
                imagefilledellipse($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20, $iconX + 20, imagecolorallocatealpha($im, $r, $g, $b, 0));
                imageellipse($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20 + 1, $iconX + 20 + 1, imagecolorallocate($im, 120, 120, 120));
                $config = select_config();
                if (isset($elementInfo['ack']) && $elementInfo['ack'] && $config['event_ack_enable']) {
                    imagesetthickness($im, 5);
                    imagearc($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20 - 3, $iconX + 20 - 3, 0, 359, imagecolorallocate($im, 50, 150, 50));
                    imagesetthickness($im, 1);
                }
            }
        }
    }
}
Exemplo n.º 21
0
function gd_gradient_fill($im, $direction, $start, $end)
{
    switch ($direction) {
        case 'horizontal':
            $line_numbers = imagesx($im);
            $line_width = imagesy($im);
            list($r1, $g1, $b1) = hex2rgb($start);
            list($r2, $g2, $b2) = hex2rgb($end);
            break;
        case 'vertical':
            $line_numbers = imagesy($im);
            $line_width = imagesx($im);
            list($r1, $g1, $b1) = hex2rgb($start);
            list($r2, $g2, $b2) = hex2rgb($end);
            break;
        case 'ellipse':
        case 'circle':
            $line_numbers = sqrt(pow(imagesx($im), 2) + pow(imagesy($im), 2));
            $center_x = imagesx($im) / 2;
            $center_y = imagesy($im) / 2;
            list($r1, $g1, $b1) = hex2rgb($end);
            list($r2, $g2, $b2) = hex2rgb($start);
            break;
        case 'square':
        case 'rectangle':
            $width = imagesx($im);
            $height = imagesy($im);
            $line_numbers = max($width, $height) / 2;
            list($r1, $g1, $b1) = hex2rgb($end);
            list($r2, $g2, $b2) = hex2rgb($start);
            break;
        case 'diamond':
            list($r1, $g1, $b1) = hex2rgb($end);
            list($r2, $g2, $b2) = hex2rgb($start);
            $width = imagesx($im);
            $height = imagesy($im);
            if ($height > $width) {
                $rh = 1;
            } else {
                $rh = $width / $height;
            }
            if ($width > $height) {
                $rw = 1;
            } else {
                $rw = $height / $width;
            }
            $line_numbers = min($width, $height);
            break;
        default:
            list($r, $g, $b) = hex2rgb($start);
            $col = imagecolorallocate($im, $r, $g, $b);
            imagefill($im, 0, 0, $col);
            return true;
    }
    for ($i = 0; $i < $line_numbers; $i = $i + 1) {
        if ($r2 - $r1 != 0) {
            $r = $r1 + ($r2 - $r1) * ($i / $line_numbers);
        } else {
            $r = $r1;
        }
        if ($g2 - $g1 != 0) {
            $g = $g1 + ($g2 - $g1) * ($i / $line_numbers);
        } else {
            $g1;
        }
        if ($b2 - $b1 != 0) {
            $b = $b1 + ($b2 - $b1) * ($i / $line_numbers);
        } else {
            $b = $b1;
        }
        $fill = imagecolorallocate($im, $r, $g, $b);
        switch ($direction) {
            case 'vertical':
                imageline($im, 0, $i, $line_width, $i, $fill);
                break;
            case 'horizontal':
                imageline($im, $i, 0, $i, $line_width, $fill);
                break;
            case 'ellipse':
            case 'circle':
                imagefilledellipse($im, $center_x, $center_y, $line_numbers - $i, $line_numbers - $i, $fill);
                break;
            case 'square':
            case 'rectangle':
                imagefilledrectangle($im, $i * $width / $height, $i * $height / $width, $width - $i * $width / $height, $height - $i * $height / $width, $fill);
                break;
            case 'diamond':
                imagefilledpolygon($im, array($width / 2, $i * $rw - 0.5 * $height, $i * $rh - 0.5 * $width, $height / 2, $width / 2, 1.5 * $height - $i * $rw, 1.5 * $width - $i * $rh, $height / 2), 4, $fill);
                break;
            default:
        }
    }
}
Exemplo n.º 22
0
                                                                                     }      
                                                                                 }
                                                                                 else{
                                                                                     $product["description_type"] = "";
                                                                                     $product["color_type"] = "";
                                                                                     $product["name_type"] = "";
                                                                                 }
         */
         $product["description_type"] = "";
         $product["color_type"] = "";
         $product["name_type"] = "";
         $get_type = searchJson_type($response_type, $id_type);
         $product["name_type"] = $get_type[0];
         $product["description_type"] = $get_type[1];
         $product["color_type"] = trim(strtolower($get_type[2]));
         $product_rgb = hex2rgb($product["color_type"]);
         $product["color_type_hsl"] = RGB_TO_HSV($product_rgb[0], $product_rgb[1], $product_rgb[2]);
         $product_hsl = RGB_TO_HSV($product_rgb[0], $product_rgb[1], $product_rgb[2]);
         $product["color_type_hsl_android"] = $product_hsl[0];
         // push single into final response array
         array_push($response["centres"], $product);
     }
     // success
     $response["success"] = 1;
     // echoing JSON response
     echo json_encode($response);
 } else {
     // no found
     $response["success"] = 0;
     $response["message"] = "No found";
     echo json_encode($response);
Exemplo n.º 23
0
 /**
  *  Retourne un tableau avec les arguments a ajouter dans la page
  *  $bgmax["head"]  : chaine a ajouter dans head
  *  $bgmax["body"]  : chaine a ajouter dans body a la position module  
  **/
 public static function getBgMaxInfos(&$params, $modTitle)
 {
     $app = JFactory::getApplication();
     // tableau pour retour
     $bgmax = array("head" => "", "body" => "");
     // DEBUG affiche la totalite des parametres pour analyse
     $bgmaxDebug = $params->get('bgmaxDebug');
     if ($bgmaxDebug == '2') {
         $user = JFactory::getUser();
         if (!$user->id) {
             $bgmaxDebug = false;
         }
     }
     /****
      *  PERIODE : DOIT-ON PUBLIER ?
      ****/
     // attention, ambiguite si date fin vide et heure indiquee:
     // on traite comme periode horaire journaliere
     $ok = false;
     $debDate = str_replace('/', '-', substr($params->get('debDate'), 0, 10));
     // compatibilite ancienne version
     $debDate = formatDate($debDate);
     $debTime = $params->get('debTime', '00:00');
     $endDate = str_replace('/', '-', substr($params->get('endDate'), 0, 10));
     // compatibilite ancienne version
     $endDate = formatDate($endDate);
     $endTime = $params->get('endTime', '23:59');
     // Pour faciliter les calculs, on force la date debut/fin à une date infinie si une date de fin/debut complete est indiquee. le cas d'une heure sans date n'est pas geree
     if (strlen($endDate) == 10 && strlen($debDate) == 0) {
         $debDate = '1900-01-01';
     }
     if (strlen($debDate) == 10 && strlen($endDate) == 0) {
         $endDate = '2900-01-01';
     }
     // il faut que les 2 dates soient exprimees de la même maniere!
     if (strlen($debDate) != strlen($endDate)) {
         $app->enqueueMessage('Les dates DEBUT et FIN doivent avoir le meme format');
     }
     // la date et heure actuelle au format pour comparaison
     // $nowDate = (strlen($debDate)==1) ? date('N'): formatDate(substr(date('d-m-Y'),0, strlen($debDate)));
     // $nowTime = date('H:i');
     $config = JFactory::getConfig();
     $now = JFactory::getDate('now', $config->get('offset'));
     $nowDate = strlen($debDate) == 1 ? $now->format('N', true) : formatDate(substr($now->format('d-m-Y', true), 0, strlen($debDate)));
     $nowTime = $now->format('H:i', true);
     // Analyse
     if (strlen($debDate) == 0) {
         // permanent ou période horaire
         if ($debTime > $endTime) {
             //18:00 -> 8:00 sur 2 jours
             $ok = $nowTime >= $debTime || $nowTime <= $endTime;
             $period_msg = 'Day 1 ' . $debTime . ' <= ' . $nowTime . ' <= Day 2 ' . $endTime . '<br>';
         } else {
             // 08:00 ->  18:00 sur la journee
             $ok = $nowTime >= $debTime && $nowTime <= $endTime;
             $period_msg = 'Same day ' . $debTime . ' <= ' . $nowTime . ' <= ' . $endTime . '<br>';
         }
     } else {
         // maj date pour calcul sur 2 ans
         if ($debDate > $endDate) {
             $inc = array(0, 7, 31, 0, 0, 12);
             $tmp = explode('-', $endDate);
             $tmp[0] += $inc[strlen($debDate)];
             $endDate = implode('-', $tmp);
             // actu date courante
             if ($nowDate < $debDate) {
                 $tmp = explode('-', $nowDate);
                 $tmp[0] += $inc[strlen($debDate)];
                 $nowDate = implode('-', $tmp);
             }
         }
         if ($params->get('period_mode')) {
             $ok = $debDate <= $nowDate && $nowDate <= $endDate && ($debTime <= $nowTime && $nowTime <= $endTime);
             $period_msg = $debDate . ' <= ' . $nowDate . ' <= ' . $endDate . ' AND ' . ($debTime . ' <= ' . $nowTime . ' <= ' . $endTime) . '<br>';
         } else {
             $ok = $debDate . $debTime <= $nowDate . $nowTime && $nowDate . $nowTime <= $endDate . $endTime;
             $period_msg = $debDate . $debTime . ' <= ' . ($nowDate . $nowTime) . ' <= ' . ($endDate . $endTime) . '<br>';
         }
     }
     if (!$ok) {
         if ($bgmaxDebug) {
             $msg = '#NO# BGMAX - ' . $modTitle . ': <br>' . $period_msg;
             $app->enqueueMessage($msg);
         }
         return;
     }
     /****
      *  MOBILE  : DOIT-ON PUBLIER ?
      ****/
     switch ($bgFilter = $params->get('filterMobile')) {
         case 'always':
             $ok = true;
             break;
         case 'mobile':
             $ok = isMobile();
             break;
         case 'desktop':
             $ok = !isMobile();
             break;
     }
     if (!$ok) {
         if ($bgmaxDebug) {
             $msg = '#NO# BGMAX - ' . $modTitle . ': ';
             $msg .= 'view only on ' . $params->get('filterMobile');
             $app->enqueueMessage($msg);
         }
         return;
     }
     /****
      *  CONTENU  : DOIT-ON PUBLIER ?
      ****/
     if (($bgFilter = $params->get('filterContent')) || $bgmaxDebug) {
         $bg_id = JRequest::getVar('id', 0, 'get', 'int');
         $bg_menuid = JRequest::getVar('Itemid', 0, 'get', 'int');
         $bg_option = trim(JRequest::getVar('option', 0));
         $bg_layout = trim(JRequest::getVar('layout', 0));
         $bg_view = trim(JRequest::getVar('view', 0));
         $bg_artid = '';
         $bg_catid = '';
         switch ($bg_view) {
             case 'article':
                 $bg_artid = $bg_id;
                 $bg_id = '';
                 $database = JFactory::getDBO();
                 $query = "SELECT catid FROM #__content WHERE id=" . $bg_artid;
                 $database->setQuery($query);
                 $row = $database->loadObject();
                 $bg_catid = $row != null ? $row->catid : '';
                 break;
             case 'categories':
                 $bg_catid = intval(JRequest::getVar('id', 0));
                 break;
         }
         $context = $bg_option;
         $context .= '+menuid=' . $bg_menuid;
         $context .= '+view=' . $bg_view;
         if ($bg_layout) {
             $context .= '+layout=' . $bg_layout;
         }
         if ($bg_id) {
             $context .= '+id=' . $bg_id;
         }
         if ($bg_artid) {
             $context .= '+artid=' . $bg_artid;
         }
         if ($bg_catid) {
             $context .= '+catid=' . $bg_catid;
         }
         /*
         Si une des lignes de critere correspond, le module sera affiche 
         un '-' inverse la condition
         exemple, on affiche le module si :
         view=blog -menuid=2  // vue blog non appell� par menu 2
         catid=3    // OU articles de categorie 3
         -artid=2   // MAIS PAS si article d'ID 2 
         */
         if ($bgFilter) {
             $context = '+' . $context . '+';
             // pour recherche
             $arr = explode("\n", $bgFilter);
             foreach ($arr as &$lign) {
                 $ok = true;
                 $mots = explode(" ", $lign);
                 foreach ($mots as $mot) {
                     if ($mot) {
                         if ($mot[0] == "-") {
                             if (stristr($context, '+' . substr($mot, 1) . '+')) {
                                 $ok = false;
                                 break;
                             }
                         } elseif ($mot[0] == "+") {
                             if (!stristr($context, '+' . substr($mot, 1) . '+')) {
                                 $ok = false;
                                 break;
                             }
                         } else {
                             if (!stristr($context, '+' . $mot . '+')) {
                                 $ok = false;
                                 break;
                             }
                         }
                     }
                 }
                 // foreach mot
                 if ($ok) {
                     break;
                 }
                 // si ligne OK, on affiche
             }
             if (!$ok) {
                 if ($bgmaxDebug) {
                     $msg = '#ERR# BGMAX - ' . $modTitle . ': <br>';
                     $msg .= 'Context:' . $context;
                     $msg .= '<br />Filters: ' . nl2br($bgFilter, ' || ');
                     $app->enqueueMessage($msg);
                 }
                 return;
             }
         }
         // if debug or Filtercontent
     }
     // if critere ou debug
     /*************************************
      *            ON AFFICHE 
      *************************************/
     if ($bgmaxDebug) {
         $msg = JText::_('INFO_DEBUG') . '#OK# BGMAX - ' . $modTitle . ': <br>' . $period_msg;
         if (isset($context)) {
             $msg .= 'Context:' . $context;
         }
         $app->enqueueMessage($msg);
     }
     /****
      *   QUELLE IMAGE AFFICHER ?  
      *   Ordre des priorites :
      *   1 - celle indiquee dans la zone texte 
      *   2 - au hasard dans le dossier indique
      *   3 - aucune, uniquement la couleur               		
      ****/
     /* 1 */
     $bgImage = $params->get('image_path', '');
     if ($bgImage) {
         // chemin relatif a la racine
         $bgImageAbs = JPATH_ROOT . strtr('/' . $bgImage, '/', DIRECTORY_SEPARATOR);
         $bgImage = trim(JURI::base(), '/') . '/' . $bgImage;
         /* 2 */
     } elseif ($params->get('image_url', '')) {
         $bgImageAbs = $params->get('image_url', '');
         $bgImage = $bgImageAbs;
         /* 3 */
     } elseif ($params->get('RandomFolder', '-1') != '-1') {
         $rep = '/images/bgmax/' . $params->get('RandomFolder') . '/';
         $bgImage = getRandomImage(JPATH_ROOT . strtr($rep, '/', DIRECTORY_SEPARATOR));
         if ($bgImage) {
             $bgImageAbs = JPATH_ROOT . strtr($rep . $bgImage, '/', DIRECTORY_SEPARATOR);
             $bgImage = trim(JURI::base(), '/') . $rep . $bgImage;
         }
     }
     if ($bgmaxDebug) {
         $app->enqueueMessage("Image (abs): " . $bgImageAbs);
     }
     /****
      *  couleur de fond
      ****/
     $bodyColor = hex2hex($params->get('bodyColor', '#FFFFFF'));
     if ($bgImage && $params->get('bodyColorAuto', '0') == '1') {
         $bodyColor = colorImageBottom($bgImageAbs);
     }
     /****
      *   TAILLE, POSITION ET EFFETS 
      ****/
     $bgMode = $params->get('mode', 'max');
     // max, full ou none
     $bgEnlarge = $params->get('enlarge', '1');
     $bgReduce = $params->get('reduce', '1');
     $bgPosition = $params->get('position', 'absolute');
     $bgHAlign = $params->get('align', 'center');
     $bgVAlign = $params->get('vertAlign', 'top');
     $bgFadeActive = $params->get('fadeActive', '0');
     $bgFadeAfter = $params->get('fadeAfter', '0');
     $bgFadeDuration = $params->get('fadeDuration', '1000');
     $bgFadeFrame = $params->get('fadeframeRate', '30');
     $bgZIndex = $params->get('zIndex', '-1');
     $bgFFHack = $params->get('ffHack', '0px');
     /****
      *  BLOC CONTENU
      ****/
     $contentSelector = $params->get('contentSelector', '');
     $contentColor = hex2hex($params->get('contentColor', ''));
     $contentOpacity = trim($params->get('contentOpacity', '100'), '%');
     $contentWidth = $params->get('contentWidth', '');
     $contentAlign = $params->get('contentAlign', '');
     /****
      * CODE COMPLEMENTAIRE
      ****/
     if ($headOther = $params->get('headOther', '')) {
         $headOther = "<style type='text/css'>" . $headOther . "</style>";
         if ($bgmaxDebug) {
             $app->enqueueMessage('Complementary code: <code>' . htmlspecialchars($headOther) . '</code>');
         }
     }
     $headFile = $params->get('headFile', '-1');
     if ($headFile != '-1') {
         $headFile = JPATH_ROOT . strtr('/images/bgmax/' . $headFile, '/', DIRECTORY_SEPARATOR);
         if (file_exists($headFile)) {
             $code = file($headFile);
             $headOther = implode('', $code);
             if ($bgmaxDebug) {
                 $app->enqueueMessage('headfile: ' . $headFile . '<code>' . htmlspecialchars($headOther) . '</code>');
             }
         } else {
             $app->enqueueMessage('headFile: ' . $headFile . ' **NOT FIND**', 'error');
         }
     }
     /****
      *   Traitement de l'ajout image
      ****/
     if (strstr($bgMode, 'repeat') || $bgMode == 'cover' || $bgImage == "") {
         //-------------------------------------------
         //-----> Affichage image SANS le script bgmax
         //-------------------------------------------
         if ($bgImage) {
             $str = 'background:';
             $str .= '#' . $bodyColor;
             $str .= ' url(' . $bgImage . ')';
             if ($bgMode == 'cover') {
                 $str .= ' no-repeat';
                 $str2 = ' background-size:cover !important;';
             } else {
                 $str .= ' ' . $bgMode;
                 $str2 = '';
             }
             $str .= ' ' . $bgHAlign . ' ' . $bgVAlign;
             if ($bgPosition == 'fixed') {
                 $str .= ' fixed';
             }
             $str .= ' !important;';
             $bgmax["head"] .= '<style type="text/css">body {' . $str . $str2 . '} </style>';
         }
     } else {
         //-------------------------------------------
         //-----> Affichage image AVEC le script bgmax
         //-------------------------------------------
         // Appel du script JS dans HEAD
         $site_base = JURI::base();
         if (substr($site_base, -1) == "/") {
             $site_base = substr($site_base, 0, -1);
         }
         $bgmax["head"] = '<script type="text/javascript" src="' . $site_base . '/modules/mod_bgmax/bgMax.min.js"></script>';
         // Definir la couleur sous image
         if ($bodyColor) {
             $bgmax["head"] .= '<style type="text/css">body {background-color:#' . $bodyColor . ' !important;}</style>';
         }
         // Appel de la fonction JS dans BODY
         $str = "";
         if ($bgMode == 'full') {
             $str .= 'mode:"full",';
         }
         if ($bgEnlarge != '1') {
             $str .= 'enlarge:0,';
         }
         if ($bgReduce != '1') {
             $str .= 'reduce:0,';
         }
         if ($bgPosition != 'absolute') {
             $str .= 'position:"fixed",';
         }
         if ($bgHAlign != 'center') {
             $str .= 'align:"' . $bgHAlign . '",';
         }
         switch ($bgVAlign) {
             case "center":
                 $str .= 'vertAlign:"middle",';
                 break;
             case "bottom":
                 $str .= 'vertAlign:"bottom",';
                 break;
         }
         if ($bgZIndex != '-1') {
             $str .= 'zIndex:' . $bgZIndex . ',';
         }
         if ($bgFFHack != '0px') {
             $str .= 'ffHack:"' . $bgFFHack . '",';
         }
         if ($bgFadeActive == '1') {
             $str .= 'fadeAfter:' . $bgFadeAfter . ',';
             $str .= 'fadeOptions:{duration:' . $bgFadeDuration . ',';
             $str .= 'frameRate:' . $bgFadeFrame . '}';
         }
         $str = trim($str, ",");
         if ($str) {
             $str = ", {" . $str . "}";
         }
         $bgmax["body"] = '<script type="text/javascript">bgMax.init("' . $bgImage . '"' . $str . ');</script>';
     }
     // if
     /*****
      *   STYLE COMMUN (AVEC ou SANS BGMAX)
      *****/
     $str = "";
     // bloc qui contient tout le contenu
     if ($contentSelector) {
         $str .= '<style type="text/css">';
         $str .= $contentSelector . ' {';
         if ($contentWidth) {
             $str .= 'width:' . $contentWidth . ';';
             switch ($contentAlign) {
                 case 'left':
                     $str .= 'margin-left: 0;';
                     break;
                 case 'center':
                     $str .= 'margin: 0 auto;';
                     break;
                 case 'right':
                     $str .= 'margin-right: 0; margin-left: auto;';
                     break;
             }
         }
         if ($contentColor) {
             $str .= 'background-color: #' . $contentColor . ';';
         }
         if ($contentOpacity == '0') {
             $str .= 'background-color: transparent;';
         } else {
             if ($contentOpacity != '100') {
                 $str .= 'background-color: rgba(';
                 $str .= hex2rgb($contentColor) . ',';
                 $str .= $contentOpacity / 100 . ') !important;';
             }
         }
         $str .= '}</style>';
         // si transparence: hack pour IE
         if ($contentOpacity != '0' && $contentOpacity != '100') {
             $sval = dechex($contentOpacity * 2.55);
             $sval .= $contentColor;
             $str .= '<!--[if lte IE 8]> <style type="text/css">';
             $str .= $contentSelector . ' {';
             $str .= 'background:transparent; ';
             $str .= 'filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#' . $sval . ',endColorstr=#' . $sval . ');';
             $str .= 'zoom: 1;';
             $str .= '} </style> <![endif]-->';
         }
     }
     // fin if $contentSelector
     /*******
      * COMPLEMENT DE CODE POUR HEAD
      *******/
     if ($headOther) {
         $str .= $headOther;
     }
     $bgmax["head"] .= $str;
     if ($bgmaxDebug) {
         $app->enqueueMessage('----------------------------');
         foreach ($bgmax as $key => $value) {
             $app->enqueueMessage($key . ' => <code>' . htmlentities($value) . '</code>');
         }
     }
     return $bgmax;
 }
Exemplo n.º 24
0
 $custom_project_type = get_post_meta($post->ID, '_az_project_type', true);
 $external_url = get_post_meta($post->ID, '_az_external_project_url', true);
 $fancy_gallery = get_post_meta($post->ID, '_az_fancy_gallery', true);
 $fancy_video = get_post_meta($post->ID, '_az_fancy_video', true);
 $fancy_image_popup = get_post_meta($post->ID, '_az_fancy_image_full', true);
 $fancy_image_gallery = get_post_meta($post->ID, '_az_fancy_image_gallery', true);
 $images = explode(',', $fancy_image_gallery);
 $customFancyImg = !empty($fancy_image_popup) ? $fancy_image_popup : $img_url[0];
 if (!empty($fancy_gallery)) {
     $fancy_gallery = 'data-fancybox-group="' . strtolower($fancy_gallery) . '"';
 }
 $portfolio_hover_class = $portfolio_hover_color = $portfolio_hover_text = $portfolio_hover_line = $portfolio_hover_icon = $portfolio_general_class = null;
 if ($portfolio_colorize == true) {
     $colorize_project = get_post_meta($post->ID, '_az_project_colorize', true);
     $colorize_project_opacity = get_post_meta($post->ID, '_az_project_colorize_opacity', true);
     $rgb = implode(',', hex2rgb($colorize_project));
     if (!empty($colorize_project)) {
         $portfolio_hover_color = ' style="background-color: rgba(' . $rgb . ', ' . $colorize_project_opacity . ');"';
         $portfolio_hover_text = ' class="colorize-portfolio"';
         $portfolio_hover_class = $portfolio_hover_line = $portfolio_hover_icon = $portfolio_general_class = ' colorize-portfolio';
     } else {
         $portfolio_hover_color = ' style="background-color: rgba(255,255,255, ' . $colorize_project_opacity . ');"';
         $portfolio_general_class = ' colorize-portfolio';
     }
 }
 $portfolio_scroll_thumb_width = $portfolio_scroll_thumb_width_result = null;
 if ($portfolio_layout == "scrollable-portfolio") {
     $portfolio_scroll_thumb_width = get_post_meta($post->ID, '_az_project_scrollable_width', true);
     if (!empty($portfolio_scroll_thumb_width)) {
         $portfolio_scroll_thumb_width_result = ' style="width: ' . $portfolio_scroll_thumb_width . 'px;"';
     } else {
Exemplo n.º 25
0
        echo $qode_options_passage['menu_letter_spacing'];
        ?>
px;<?php 
    }
    ?>
}
<?php 
}
if (!empty($qode_options_passage['menu_lineheight'])) {
    ?>

.drop_down2 .second,
.drop_down .second
{
	top: <?php 
    echo $qode_options_passage['menu_lineheight'];
    ?>
px;
}
.header_right_widget{
	line-height: <?php 
    echo $qode_options_passage['menu_lineheight'];
    ?>
px;
}
<?php 
}
?>

<?php 
if (!empty($qode_options_passage['menu_color']) || !empty($qode_options_passage['menu_fontsize']) || !empty($qode_options_passage['menu_fontstyle']) || !empty($qode_options_passage['menu_fontweight']) || !empty($qode_options_passage['menu_letter_spacing']) || $qode_options_passage['menu_google_fonts'] != "-1") {
Exemplo n.º 26
0
     }
 }
 //create image
 $im = imagecreatetruecolor(150, 190);
 //load font
 $fonts = array(1 => 'msmincho.gdf', 2 => 'smallfont.gdf', 3 => 'visitort2.gdf');
 $font = imageloadfont("fonts/" . $fonts[$var['font']]);
 //define colors
 //border color
 list($br, $bg, $bb) = hex2rgb($var['bColor']);
 $bColor = imagecolorallocate($im, $br, $bg, $bb);
 //background color
 list($bgr, $bgg, $bgb) = hex2rgb($var['bgColor']);
 $bgColor = imagecolorallocate($im, $bgr, $bgg, $bgb);
 //font color
 list($fr, $fg, $fb) = hex2rgb($var['fontColor']);
 $fontColor = imagecolorallocate($im, $fr, $fg, $fb);
 //fill avatar body with the background color
 imagefilledrectangle($im, 0, 0, 150, 190, $bgColor);
 //draw border
 imagerectangle($im, 0, 0, 149, 189, $bColor);
 //add smile
 $smile = imagecreatefrompng("templates/pack" . $var['pack'] . "/" . ($var['smile'] == 225 ? rand(1, 20) : $var['smile']) . ".png");
 $smile_pos = array(1 => array('x' => '-15', 'y' => '18'), 2 => array('x' => '-9', 'y' => '12'), 3 => array('x' => '-11', 'y' => '11'), 4 => array('x' => '-10', 'y' => '12'));
 imagecopy($im, $smile, $smile_pos[$var['pack']]['y'], $smile_pos[$var['pack']]['x'], 0, 0, 128, 128);
 //country
 if ($use_country) {
     $country = imagecreatefrompng("flags/" . $_flag . ".png");
     imagecopy($im, $country, $_flag_xy[0], $_flag_xy[1], 0, 0, 16, 11);
 }
 //add username if the option is true
Exemplo n.º 27
0
function echo_hex($color2hex)
{
    $color_array = hex2rgb($color2hex);
    for ($i = 0; $i < 3; $i++) {
        if ($i == 2) {
            echo $color_array[$i];
        } else {
            echo $color_array[$i] . ',';
        }
    }
}
Exemplo n.º 28
0
/**
 *  Gets Export data from FCExporter - main module and build the export binary/objct.
 *  @param	$stream 	(string) export image data in FusionCharts compressed format
 *      	$meta		{array)	Image meta data in keys "width", "heigth" and "bgColor"
 *              $exportParams   {array} Export related parameters
 *  @return 			image object/binary
 */
function exportProcessor($stream, $meta, $exportParams)
{
    // get mime type list parsing MIMETYPES constant declared in Export Resource PHP file
    $ext = strtolower($exportParams["exportformat"]);
    $mimeList = bang(@MIMETYPES);
    $mimeType = $mimeList[$ext];
    // prepare variables
    if (get_magic_quotes_gpc()) {
        $stream = stripslashes($stream);
    }
    // create a new export data
    $tempFileName = md5(rand());
    $tempOutputFile = TEMP_PATH . "{$tempFileName}.{$ext}";
    $tempInputSVGFile = TEMP_PATH . "{$tempFileName}.svg";
    if ($ext != 'svg') {
        // width format for batik
        $width = @$meta['width'];
        if ($width) {
            $width = "-w {$width}";
        }
        //batik bg color format
        $bg = @$meta['bgColor'];
        if ($bg) {
            $bg = "-bg 255." . hex2rgb($bg, ".");
        }
        // generate the temporary file
        if (!file_put_contents($tempInputSVGFile, $stream)) {
            die("Couldn't create temporary file. Check that the directory permissions for\r\n\t\t\tthe " . TEMP_PATH . " directory are set to 777.");
        }
        // do the conversion
        $command = "java -jar " . BATIK_PATH . " -m {$mimeType} {$width} {$bg} {$tempInputSVGFile}";
        $output = shell_exec($command);
        // catch error
        if (!is_file($tempOutputFile) || filesize($tempOutputFile) < 10) {
            $return_binary = "{$output}";
            raise_error($output, true);
        } else {
            $return_binary = file_get_contents($tempOutputFile);
        }
        // delete temp files
        if (file_exists($tempInputSVGFile)) {
            unlink($tempInputSVGFile);
        }
        if (file_exists($tempOutputFile)) {
            unlink($tempOutputFile);
        }
        // SVG can be streamed back directly
    } else {
        if ($ext == 'svg') {
            $return_binary = $stream;
        } else {
            raise_error("Invalid Export Format.", true);
        }
    }
    // return export ready binary data
    return @$return_binary;
}
Exemplo n.º 29
0
    }
    $rgb1 = hsl2rgb($h1, $s1, $l1);
    $r1 = $rgb1[0];
    $g1 = $rgb1[1];
    $b1 = $rgb1[2];
    $hex1 = rgb2hex($r1, $g1, $b1);
    $hex1 = substr($hex1, 1);
    // remove '#'
    rgb_sample($r1, $g1, $b1, 'First color');
}
// second color validation
if (!isset($_GET['mode2']) && $_GET['hex2'] || $_GET['mode2'] == 'hex2' && !$_GET['hex2'] == '') {
    $modehex2 = ' checked="checked" ';
    $modergb2 = $modehsl2 = '';
    $hex2 = strtolower($_GET['hex2']);
    $rgb2 = hex2rgb($hex2);
    $r2 = $rgb2[0];
    $g2 = $rgb2[1];
    $b2 = $rgb2[2];
    $hsl2 = rgb2hsl($r2, $g2, $b2);
    $h2 = $hsl2[0];
    $s2 = $hsl2[1];
    $l2 = $hsl2[2];
    rgb_sample($r2, $g2, $b2, 'Second color');
} elseif (!isset($_GET['mode2']) && $_GET['r2'] && $_GET['g2'] && $_GET['b2'] || $_GET['mode2'] == 'rgb2' && is_numeric($_GET['r2']) && is_numeric($_GET['g2']) && is_numeric($_GET['b2'])) {
    $modergb2 = ' checked="checked" ';
    $modehex2 = $modehsl2 = '';
    $r2 = $_GET['r2'];
    $g2 = $_GET['g2'];
    $b2 = $_GET['b2'];
    if ($r2 < 0) {
Exemplo n.º 30
0
    $angle = rand($captcha_config['angle_min'], $captcha_config['angle_max']) * (rand(0, 1) == 1 ? -1 : 1);
    // Select font randomly
    $font = $captcha_config['fonts'][rand(0, count($captcha_config['fonts']) - 1)];
    // Verify font file exists
    if (!file_exists($font)) {
        throw new Exception('Font file not found: ' . $font);
    }
    //Set the font size.
    $font_size = rand($captcha_config['min_font_size'], $captcha_config['max_font_size']);
    $text_box_size = imagettfbbox($font_size, $angle, $font, $captcha_config['code']);
    // Determine text position
    $box_width = abs($text_box_size[6] - $text_box_size[2]);
    $box_height = abs($text_box_size[5] - $text_box_size[1]);
    $text_pos_x_min = 0;
    $text_pos_x_max = $bg_width - $box_width;
    $text_pos_x = rand($text_pos_x_min, $text_pos_x_max);
    $text_pos_y_min = $box_height;
    $text_pos_y_max = $bg_height - $box_height / 2;
    $text_pos_y = rand($text_pos_y_min, $text_pos_y_max);
    // Draw shadow
    if ($captcha_config['shadow']) {
        $shadow_color = hex2rgb($captcha_config['shadow_color']);
        $shadow_color = imagecolorallocate($captcha, $shadow_color['r'], $shadow_color['g'], $shadow_color['b']);
        imagettftext($captcha, $font_size, $angle, $text_pos_x + $captcha_config['shadow_offset_x'], $text_pos_y + $captcha_config['shadow_offset_y'], $shadow_color, $font, $captcha_config['code']);
    }
    // Draw text
    imagettftext($captcha, $font_size, $angle, $text_pos_x, $text_pos_y, $color, $font, $captcha_config['code']);
    // Output image
    header("Content-type: image/png");
    imagepng($captcha);
}