Cart

Your cart is empty

While developing a Joomla Template I needed lighter and darker border colors of menu items. Border colors should have been darker and lighter version of background color. Based on this thread I have tried and used successfully php to lighten and darken colors. The main php code is below. The key point is using 255 and 0 in php functions to lighten and darken colors.

This is php function to Lighten given colors.

function luminanceLight($hexcolor, $percent)
{
  if ( strlen( $hexcolor ) < 6 ) {
    $hexcolor = $hexcolor[0] . $hexcolor[0] . $hexcolor[1] . $hexcolor[1] . $hexcolor[2] . $hexcolor[2];
  }
  $hexcolor = array_map('hexdec', str_split( str_pad( str_replace('#', '', $hexcolor), 6, '0' ), 2 ) );

  foreach ($hexcolor as $i => $color) {
    $from = $percent < 0 ? 0 : $color;
    $to = $percent < 0 ? $color : 255;
    $pvalue = ceil( ($to - $from) * $percent );
    $hexcolor[$i] = str_pad( dechex($color + $pvalue), 2, '0', STR_PAD_LEFT);
  }

  return '#' . implode($hexcolor);
}

 

and this php function to Darken given colors.

function luminanceDark($hexcolor, $percent)
{
  if ( strlen( $hexcolor ) < 6 ) {
    $hexcolor = $hexcolor[0] . $hexcolor[0] . $hexcolor[1] . $hexcolor[1] . $hexcolor[2] . $hexcolor[2];
  }
  $hexcolor = array_map('hexdec', str_split( str_pad( str_replace('#', '', $hexcolor), 6, '0' ), 2 ) );

  foreach ($hexcolor as $i => $color) {
    $from = $percent < 0 ? 0 : $color;
    $to = $percent < 0 ? $color : 0;
    $pvalue = ceil( ($to - $from) * $percent );
    $hexcolor[$i] = str_pad( dechex($color + $pvalue), 2, '0', STR_PAD_LEFT);
  }

  return '#' . implode($hexcolor);
}

I wanted to have one light and one dark border for menu items originating from background color of navigation menu. I have a $navbar_color.

$navbar_color    = $this->params->get('NavbarColor') ?: '';

So my border colors should be like this. The 0.1 and 0.15 values means 10% lighter and 15% darker colors.

$border_color_light=luminanceLight($navbar_color,0.1);
$border_color_dark=luminanceDark($navbar_color,0.15);

 One last thing you should use that php constants as inline css or dynamic CSS.

Headline JT3

Headline JT3 Module reads content and articles from Joomla and K2 category and shows them at frontend as a Slider with little bottom thumbnails. 

 Details...

Iconic Sticky Panel

 

Iconic Sticky Panel has been developed by Joomlatema.Net and enables you to publish little icons on left or right side of your page refer to Joomla Modules.

Details...

Fixed Bottom Bar JT Free

 

Fixed Bottom  Bar JT Module is a bottom fixed Toolbar which shows a solid bar at the bottom of your site. You can add Joomla Modules up to six modules horizontally aligned.

Details...

Custom Templates

 

Joomlatema.net can create custom joomla templates from scratch or by converting an image file or PSD that you have. Just choose your way and get inspired then we create an elegant joomla template for you...

Details...

 

 

 

JoomlaTema and this site is not affiliated with or endorsed by The Joomla! Project™. Any products and services provided through this site are not supported or warrantied by The Joomla! Project or Open Source Matters, Inc. Use of the Joomla!® name, symbol, logo and related trademarks is permitted under a limited license granted by Open Source Matters, Inc.