header('Content-type: ' . $mime_type); while (!feof($file)) { print $buffer = fread($file, $send_buffer_size); } fclose($file); exit; } // check font availability $font_found = is_readable($font_file); if (!$font_found) { fatal_error($font_file); //fatal_error('Error: The server is missing the specified font.') ; } // create image $background_rgb = hex_to_rgb($background_color); $font_rgb = hex_to_rgb($font_color); $dip = get_dip($font_file, $font_size); $box = @ImageTTFBBox($font_size, 0, $font_file, $text); $image = @ImageCreate(abs($box[2] - $box[0]), abs($box[5] - $dip)); if (!$image || !$box) { fatal_error('Error: The server could not create this heading image.'); } // allocate colors and draw text $background_color = @ImageColorAllocate($image, $background_rgb['red'], $background_rgb['green'], $background_rgb['blue']); $font_color = ImageColorAllocate($image, $font_rgb['red'], $font_rgb['green'], $font_rgb['blue']); ImageTTFText($image, $font_size, 0, -$box[0], abs($box[5] - $box[3]) - $box[1], $font_color, $font_file, $text); // set transparency if ($transparent_background) { ImageColorTransparent($image, $background_color); } //header('Content-type: ' . $mime_type) ;
function process_layer_style($layer) { $output = array(); if (isset($layer->backgroundcolor)) { if (isset($layer->backgroundtransparent)) { $rgb = hex_to_rgb($layer->backgroundcolor); $alpha = $layer->backgroundtransparent / 100; $output[] = "background: rgb({$rgb[0]}, {$rgb[1]}, {$rgb[2]});background: rgba({$rgb[0]}, {$rgb[1]}, {$rgb[2]}, {$alpha});"; } else { if (is_string($layer->backgroundcolor)) { $output[] = "background: #{$layer->backgroundcolor};"; } else { $output[] = "background: #000;"; } } } if (isset($layer->opacity)) { $opacity = $layer->opacity / 100; $data = "opacity: {$opacity};"; $data .= '-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . $layer->opacity . ')";'; $data .= "filter: alpha(opacity={$layer->opacity});"; $output[] = $data; } # Process style for layer border if (isset($layer->borderposition) && isset($layer->borderwidth) && $layer->borderposition > 0 && $layer->borderwidth > 0) { $color = isset($layer->bordercolor) ? $layer->bordercolor : "000"; $border_style = isset($layer->borderstyle) ? $layer->borderstyle : "solid"; # Process border layer position $positions = process_layer_border_position($layer->borderposition); if (count($positions) == 4) { $output[] = "border: {$layer->borderwidth}px {$border_style} #{$color};"; } else { foreach ($positions as $position) { $output[] = "border-{$position}: {$layer->borderwidth}px {$border_style} #{$color};"; } } } if (isset($layer->bordertopleftradius) && $layer->bordertopleftradius > 0) { $output[] = "-webkit-border-top-left-radius: {$layer->bordertopleftradius}px; -moz-border-radius-topleft: {$layer->bordertopleftradius}px; border-top-left-radius: {$layer->bordertopleftradius}px;"; } if (isset($layer->bordertoprightradius) && $layer->bordertoprightradius > 0) { $output[] = "-webkit-border-top-right-radius: {$layer->bordertoprightradius}px; -moz-border-radius-topright: {$layer->bordertoprightradius}px; border-top-right-radius: {$layer->bordertoprightradius}px;"; } if (isset($layer->borderbottomleftradius) && $layer->borderbottomleftradius > 0) { $output[] = "-webkit-border-bottom-left-radius: {$layer->borderbottomleftradius}px; -moz-border-radius-bottomleft: {$layer->borderbottomleftradius}px; border-bottom-left-radius: {$layer->borderbottomleftradius}px;"; } if (isset($layer->borderbottomrightradius) && $layer->borderbottomrightradius > 0) { $output[] = "-webkit-border-bottom-right-radius: {$layer->borderbottomrightradius}px; -moz-border-radius-bottomright: {$layer->borderbottomrightradius}px; border-bottom-right-radius: {$layer->borderbottomrightradius}px;"; } # Process styles for text layer if ($layer->type == 'text') { if (isset($layer->color) && $layer->color !== '') { $output[] = "color: #{$layer->color};"; } if (isset($layer->bordercolor) && $layer->bordercolor !== '') { $output[] = "border-color: #{$layer->bordercolor};"; } if (isset($layer->textalign) && $layer->textalign !== '') { $output[] = "text-align: {$layer->textalign};"; } if (isset($layer->fontsize) && $layer->fontsize !== '') { $fontsize = $layer->fontsize / 12; $output[] = "font-size: {$fontsize}em;"; } if (isset($layer->fontweight) && $layer->fontweight !== '') { $font_weight = (int) $layer->fontweight; $font_style = str_replace($font_weight, '', $layer->fontweight); $output[] = "font-weight: {$font_weight};"; $output[] = "font-style: {$font_style};"; } if (isset($layer->fontfamily) && $layer->fontfamily !== '') { $output[] = "font-family: {$layer->fontfamily};"; } /* if ( isset( $layer->fontstyle ) && $layer->fontstyle !== '' ) { $output[] = "font-style: {$layer->fontstyle};"; } */ if (isset($layer->textdecoration) && $layer->textdecoration !== '') { $output[] = "text-decoration: {$layer->textdecoration};"; } if (isset($layer->texttransform) && $layer->texttransform !== '') { $output[] = "text-transform: {$layer->texttransform};"; } } return implode(' ', $output); }
$output[$lines - 1] = substr($text, 0, $t); $text = ltrim(substr($text, $t)); $output[] = $text; $box = ImageTTFBBox($size, 0, $font, $output[$lines]); $width = abs($box[0]) + abs($box[2]); } // catch one line $lines++; if (!$output) { $output[] = $text; } // Create the image $im = imagecreate($maxwidth, $height * $lines); // Create some colors $color = hex_to_rgb($color); $bgcolor = hex_to_rgb($bgcolor); $color1 = imagecolorallocate($im, $bgcolor[0], $bgcolor[1], $bgcolor[2]); $color2 = imagecolorallocate($im, $color[0], $color[1], $color[2]); if ($transbg == "on") { imagecolortransparent($im, $color1); } if ($aa == "off") { $color2 = -$color2; } // Output all the line of text as placed in array $i = 0; foreach ($output as $value) { $box = ImageTTFBBox($size, 0, $font, $value); $w = abs($box[0] - $box[2]); $x = 0; if ($align == 'right') {
/** * * @param string $hex * * @return Color * * @throws Exceptions\InvalidRGBValuesException * @throws Exceptions\InvalidHexValueException */ private function hexToRGB($hex) { if (!$this->isHexValid($hex)) { throw new Exceptions\InvalidHexValueException(); } return hex_to_rgb($hex); }
} if (isset($_GET["height"])) { $height = $_GET["height"]; } else { $height = "120"; } // Legal directions: top-down, down-top, left-right, right-left, topleft-bottomright, topright-bottomleft // bottomleft-topright, bottomright-topleft, middle-outwards, inwards-middle, radial-outwards, inwards-radial if (isset($_GET["direction"])) { $direction = $_GET["direction"]; } else { $direction = "top-down"; } $grad_image = imagecreatetruecolor($width, $height); $rgb_start = hex_to_rgb($req_start); $rgb_finish = hex_to_rgb($req_finish); $startx = 0; $endx = $width; $starty = 0; $endy = $height; switch ($direction) { case "top-down": $start = $rgb_start; $finish = $rgb_finish; $limit = $height; break; case "down-top": $start = $rgb_finish; $finish = $rgb_start; $limit = $height; break;
/** * retrieve backgroundimage color * @param string $id_post - current post if null */ function backgroundimage_get_color($id_post = null) { $background_color_code = ""; if (empty($id_post) || !is_numeric($id_post)) { $_queried_post = get_queried_object(); if (is_home()) { // blog page $id_post = get_option('page_for_posts'); } else { if (!is_404() && $_queried_post) { $id_post = $_queried_post->ID; } } } if ($id_post && (is_single() || is_page() || is_home())) { $background_color_code = get_post_meta($id_post, BACKGROUNDCOLOR_CODE, true); if (!empty($background_color_code)) { $background_color_code = hex_to_rgb($background_color_code, true); } } return $background_color_code; }
protected function hex_to_rgb($hex, $string = FALSE) { if (defined('STRICT_TYPES') && CAMEL_CASE == '1') { return self::parameters(['hex' => DT::STRING, 'hex' => DT::BOOL])->call(__FUNCTION__)->with($hex)->returning([DT::STRING, DT::TYPE_ARRAY]); } else { return hex_to_rgb($hex, $string); } }
private static function css_from_option($option, $default_value, $css, $type, $filter = false) { $value = self::get_css_option($option, $default_value); $output = ""; if ($type === 'color_rgba' && isset($value['color'])) { $rgb = hex_to_rgb($value['color']); $alpha = $value['alpha']; if (is_array($rgb) && !empty($alpha)) { $value = "rgba(" . implode(",", $rgb) . "," . $alpha . ")"; } } if ($value !== false) { if ($filter !== false) { $value = apply_filters('village_css_filter_' . $filter, $value, $option); } // Stop the output if $value is empty for some reason if (empty($value)) { return $output; } foreach ($css as $selector => $properties) { $output .= "{$selector} {"; foreach ($properties as $property => $value_template) { if (is_string($value)) { $value = str_replace('%%value%%', $value, $value_template); $output .= "{$property}: {$value};"; } } $output .= "} "; } } return $output; }
function proud_customize_css() { // See below, @TODO test for darkness $header_rgb = hex_to_rgb(get_theme_mod('color_topnav', '#000000')); // Set up navbar background, allow transparent alter $navbar_background = get_theme_mod('color_topnav', '#000000'); if (proud_navbar_transparent()) { $navbar_background_opaque = 'rgba(' . implode(',', $header_rgb) . ',1)'; } ?> <!-- proud custom theme settings --> <style type="text/css"> .menu-box, .navbar-default { background-color: <?php echo $navbar_background; ?> !important; } .navbar.navbar-default { border-color: <?php echo $navbar_background; ?> !important; } <?php if (proud_navbar_transparent()) { ?> #navbar-transparent-mask, .scrolled.proud-navbar-transparent .navbar-default, .search-active.proud-navbar-transparent .navbar-default, .active-311.proud-navbar-transparent .navbar-default, .jumbotron-inverse .jumbotron-bg-mask { background-color: <?php echo $navbar_background_opaque; ?> !important; } .scrolled .navbar.navbar-default { border-color: <?php echo $navbar_background_opaque; ?> !important; } <?php } ?> .nav-contain .nav-pills li a, .agency-icon { background-color: <?php echo get_theme_mod('color_topnav', '#000000'); ?> !important; } .navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:focus, .navbar-default .navbar-nav>.active>a:hover { background-color: rgba(0,0,0,0.4); } .jumbotron:not(.jumbotron-image), .nav-contain .nav-pills li.active a, .btn-primary { background-color: <?php echo get_theme_mod('color_highlight', '#000000'); ?> !important; border-color: <?php echo get_theme_mod('color_highlight', '#000000'); ?> !important; } a.card-btn { color: <?php echo get_theme_mod('color_highlight', '#000000'); ?> ; } .widget-proud-social-app .nav-pills>li>a { color: <?php echo get_theme_mod('color_topnav', '#000000'); ?> ; } .card .social-card-header, .card .social-card-header .post-link a { background-color: rgba(<?php echo $header_rgb['r'] . ',' . $header_rgb['g'] . ',' . $header_rgb['b']; ?> , 1); } a{ color: <?php echo get_theme_mod('color_link', '#0071bc'); ?> ; } .footer-actions { background-color: <?php echo get_theme_mod('color_footer_actions', '#FFFFFF'); ?> ; } .page-footer { background-color: <?php echo get_theme_mod('color_footer', '#333333'); ?> ; } </style> <?php }
} if (!isset($data['main_content_bg']) || $data['main_content_bg'] == '') { $data['main_content_bg'] = '#ffffff'; } if ($data['main_content_opacity'] || $data['main_content_bg']) { $nohash = substr($data['main_content_bg'], 1); $ie_opacity = $data['main_content_opacity'] * 100; if ($ie_opacity == 100) { $ie_opacity = 'FF'; } if ($data['main_content_opacity'] == '0' || $data['main_content_opacity'] == 0) { $transparent_ie = 'background:transparent\\9;'; } else { $transparent_ie = "-ms-filter: \"progid:DXImageTransform.Microsoft.gradient(startColorstr=#" . $ie_opacity . $nohash . ",endColorstr=#" . $ie_opacity . $nohash . ")\"; \n filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#" . $ie_opacity . $nohash . ",endColorstr=#" . $ie_opacity . $nohash . "); zoom: 1; "; } $output .= "\n #main {\n " . $transparent_ie . "\n background: rgba( " . hex_to_rgb($data['main_content_bg']) . ", " . $data['main_content_opacity'] . ");\n \n }\n "; } if (isset($data['custom_bg']) && substr($data['custom_bg'], -6, 6) != '/0.png') { $output .= "\n body, #wrap-wide {\n background-image: url(" . $data['custom_bg'] . ");\n }\n "; } if ($data['body_font']) { $output .= "\n body {\n font-size:{$data['body_font']['size']} ;\n font-family: " . trim_google_font($data['body_font']['face']) . ", sans-serif;\n color:{$data['body_font']['color']};\n }\n "; } if ($data['link_color']) { $output .= ' a:link, a:visited { color: ' . $data['link_color'] . '; }'; } if ($data['link_hover_color']) { $output .= '