/**
  * Set the (inline) css for the widget rendering.
  *
  * @param    array  $instance   An array containing settings for the widget.
  * @param    string  $uid   Identifiant of the widget.
  * @param    boolean  $flat_design   Enabling flat design mode.
  * @since    2.0.0
  */
 public function css($instance, $uid, $flat_design)
 {
     require_once LWS_INCLUDES_DIR . 'phpcolors/Color.php';
     try {
         $maxwidth = round($instance['width']);
     } catch (Exception $ex) {
         $maxwidth = 0;
     }
     $txt_color = $instance['txt_color'];
     $color = new Color($instance['bg_color']);
     $opacity = (11 - $instance['bg_opacity']) / 11;
     if ($opacity < 0.1) {
         $opacity = 0;
     }
     if ($color->isDark()) {
         $gradient = $color->makeGradient(20);
     } else {
         $gradient = $color->makeGradient(15);
     }
     $border = new Color($gradient['light']);
     $icon = new Color($txt_color);
     if ($border->isDark()) {
         $ico_color = '#' . $icon->darken(1);
         $unit_color = '#' . $icon->lighten(1);
     } else {
         $ico_color = '#' . $icon->lighten(1);
         $unit_color = '#' . $icon->darken(1);
     }
     if ($color->isDark()) {
         if ($icon->isDark()) {
             $bcc = $icon->darken(4);
         } else {
             $bcc = $icon->darken(30);
         }
     } else {
         if ($icon->isDark()) {
             $bcc = $icon->lighten(4);
         } else {
             $bcc = $icon->lighten(20);
         }
     }
     if ($flat_design) {
         $gradient_dark = Color::hexToRgbString($instance['bg_color'], $opacity);
         $gradient_light = Color::hexToRgbString($instance['bg_color'], $opacity);
         $border_color1 = '#' . $bcc;
         $border_color2 = '#' . $bcc;
     } else {
         $gradient_dark = Color::hexToRgbString('#' . $gradient['dark'], $opacity);
         $gradient_light = Color::hexToRgbString('#' . $gradient['light'], $opacity);
         $border_color1 = '#' . $border->darken();
         $border_color2 = '#' . $border->darken(16);
     }
     $id = $uid;
     $shadows = !$flat_design;
     $borders = $instance['show_borders'];
     include LWS_PUBLIC_DIR . 'partials/live-weather-station-widget-ephemeris-display-css.php';
 }
Exemple #2
0
		background: #<?php 
echo $myBlack->getHex();
?>
;
		color: <?php 
echo $myBlack->isDark() ? "#EEE" : "#333";
?>
;
	}
	
	.testDiv3{
		<?php 
echo $myPurple->getCssGradient();
?>
		color: <?php 
echo $myPurple->isDark() ? "#EEE" : "#333";
?>
;
	}
	.testDiv3.plain{
		background: #<?php 
echo $myPurple->getHex();
?>
;
		color: <?php 
echo $myPurple->isDark() ? "#EEE" : "#333";
?>
;
	}
</style>
<div class="clear"></div>