Пример #1
0
 function query_parsed_init()
 {
     global $gantry;
     $browser = $gantry->browser;
     // Colors
     $linkColor = new Color($gantry->get('linkcolor'));
     $css = 'a, ul.menu li .separator {color:' . $gantry->get('linkcolor') . ';}';
     $css .= '.button, .readon, .readmore, button.validate, #member-profile a, #member-registration a, .formelm-buttons button, .btn-primary {border-color:' . $linkColor->darken('20%') . ';}';
     // Gradients
     $css .= '.button, .readon, .readmore, button.validate, #member-profile a, #member-registration a, .formelm-buttons button, .btn-primary {background-color: ' . $linkColor->lighten('4%') . '; ' . $this->_createGradient('top', $linkColor->lighten('4%'), '1', '0%', $linkColor->darken('9%'), '1', '100%') . '}' . "\n";
     $css .= '.button:hover, .readon:hover, .readmore:hover, button.validate:hover, #member-profile a:hover, #member-registration a:hover, .formelm-buttons button:hover, .btn-primary:hover {background-color: ' . $linkColor->lighten('10%') . '; ' . $this->_createGradient('top', $linkColor->lighten('10%'), '1', '0%', $linkColor->darken('3%'), '1', '100%') . '}' . "\n";
     $css .= '.button:active, .readon:active, .readmore:active, button.validate:active, #member-profile a:active, #member-registration a:active, .formelm-buttons button:active, .btn-primary:active {background-color: ' . $linkColor->darken('2%') . '; ' . $this->_createGradient('top', $linkColor->darken('2%'), '1', '0%', $linkColor->lighten('8%'), '1', '100%') . '}' . "\n";
     // Logo
     $css .= $this->buildLogo();
     $this->_disableRokBoxForiPhone();
     $gantry->addInlineStyle($css);
     if ($gantry->get('layout-mode') == "responsive") {
         $gantry->addLess('mediaqueries.less', 'mediaqueries.css', 9);
     }
     if ($gantry->get('layout-mode') == "960fixed") {
         $gantry->addLess('960fixed.less');
     }
     if ($gantry->get('layout-mode') == "1200fixed") {
         $gantry->addLess('1200fixed.less');
     }
     // add inline css from the Custom CSS field
     $gantry->addInlineStyle($gantry->get('customcss'));
 }
 /**
  * Get attributes for steel meter shortcodes.
  *
  * @return  string  $attributes The attributes of the value queryed by the shortcode.
  * @since    2.2.0
  */
 public function steelmeter_attributes($attributes)
 {
     require_once LWS_INCLUDES_DIR . 'phpcolors/Color.php';
     $result = array();
     $values = $this->steelmeter_value($attributes, true);
     $result['minValue'] = $values['min'];
     $result['maxValue'] = $values['max'];
     $min = $values['min'];
     $max = $values['max'];
     if (strpos($attributes['design'], 'windcompass') !== false) {
         $min = 0;
         $max = 360;
     }
     $digital = strpos($attributes['design'], 'digital') > -1;
     if (strpos($attributes['design'], '-1-4') !== false) {
         $result['gaugeType'] = 'steelseries.GaugeType.TYPE1';
     }
     if (strpos($attributes['design'], '-2-4') !== false) {
         $result['gaugeType'] = 'steelseries.GaugeType.TYPE2';
     }
     if (strpos($attributes['design'], '-3-4') !== false) {
         $result['gaugeType'] = 'steelseries.GaugeType.TYPE3';
     }
     if (strpos($attributes['design'], '-4-4') !== false) {
         $result['gaugeType'] = 'steelseries.GaugeType.TYPE4';
     }
     if (strpos($attributes['design'], '-left') !== false) {
         $result['orientation'] = 'steelseries.Orientation.WEST';
     }
     if (strpos($attributes['design'], '-right') !== false) {
         $result['orientation'] = 'steelseries.Orientation.EAST';
     }
     if (strpos($attributes['design'], 'windcompass-modern') !== false) {
         $result['pointSymbolsVisible'] = false;
     }
     $result['frameDesign'] = 'steelseries.FrameDesign.' . $attributes['frame'];
     $result['backgroundColor'] = 'steelseries.BackgroundColor.' . $attributes['background'];
     if ($attributes['orientation'] != 'AUTO') {
         $result['tickLabelOrientation'] = 'steelseries.TickLabelOrientation.' . $attributes['orientation'];
     }
     $result['pointerType'] = 'steelseries.PointerType.' . $attributes['main_pointer_type'];
     $result['pointerTypeLatest'] = 'steelseries.PointerType.' . $attributes['main_pointer_type'];
     $result['pointerColor'] = 'steelseries.ColorDef.' . $attributes['main_pointer_color'];
     $result['pointerTypeAverage'] = 'steelseries.PointerType.' . $attributes['aux_pointer_type'];
     $result['pointerColorAverage'] = 'steelseries.ColorDef.' . $attributes['aux_pointer_color'];
     $knob = explode('-', $attributes['knob']);
     $result['knobType'] = 'steelseries.KnobType.' . $knob[0];
     $result['knobStyle'] = 'steelseries.KnobStyle.' . $knob[1];
     if ($attributes['lcd'] == 'NONE') {
         $result['lcdVisible'] = false;
     } else {
         $result['lcdColor'] = 'steelseries.LcdColor.' . $attributes['lcd'];
     }
     if ($attributes['alarm'] != 'NONE') {
         $result['userLedVisible'] = true;
         $result['userLedColor'] = 'steelseries.LedColor.' . $attributes['alarm'];
     }
     if ($attributes['trend'] != 'NONE') {
         $result['trendVisible'] = true;
         $result['trendColors'] = '[steelseries.LedColor.' . $attributes['trend'] . ', steelseries.LedColor.' . $attributes['trend'] . ', steelseries.LedColor.' . $attributes['trend'] . ']';
     }
     if ($attributes['minmax'] == 'cursor') {
         $result['minMeasuredValueVisible'] = true;
         $result['maxMeasuredValueVisible'] = true;
     }
     if ($attributes['index_style'] != 'NONE') {
         $style = explode('-', $attributes['index_style']);
         $tcolor = new Color(Color::nameToHex($attributes['index_color']));
         $alpha = 0;
         $lighten = 1;
         if (isset($style[1])) {
             switch (strtolower($style[1])) {
                 case 'translucent':
                     $alpha = 0.1;
                     if ($tcolor->isVeryDark()) {
                         $lighten = 40;
                     } else {
                         $lighten = 20;
                     }
                     break;
                 case 'liquid':
                     $alpha = 0.25;
                     if ($tcolor->isVeryDark()) {
                         $lighten = 28;
                     } else {
                         $lighten = 15;
                     }
                     break;
                 case 'soft':
                     $alpha = 0.5;
                     if ($tcolor->isVeryDark()) {
                         $lighten = 15;
                     } else {
                         $lighten = 10;
                     }
                     break;
                 case 'hard':
                     $alpha = 0.9;
                     $lighten = 1;
                     break;
             }
         }
         if (isset($style[0])) {
             switch (strtolower($style[0])) {
                 case 'fixed':
                     if ($digital) {
                         $color = new Color(Color::nameToHex($attributes['index_color']));
                         $rgb1 = Color::hexToRgb($color->lighten($lighten));
                         $result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1)])';
                         $result['useValueGradient'] = true;
                     } else {
                         $rgb = Color::nameToRgb($attributes['index_color']);
                         $result['section'] = '[steelseries.Section(' . $min . ', ' . $max . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $alpha . ')")]';
                         $result['useSectionColors'] = true;
                     }
                     break;
                 case 'fadein':
                     if ($digital) {
                         $color = new Color(Color::nameToHex($attributes['index_color']));
                         $rgb1 = Color::hexToRgb($color->lighten($lighten * 2));
                         $rgb2 = Color::nameToRgb($attributes['index_color']);
                         $result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb2['R'] . ',' . $rgb2['G'] . ',' . $rgb2['B'] . ', 1)])';
                         $result['useValueGradient'] = true;
                     } else {
                         $rgb = Color::nameToRgb($attributes['index_color']);
                         $s = '';
                         $step = 20;
                         $size = ($max - $min) / $step;
                         for ($i = 0; $i < $step; $i++) {
                             $mi = $min + $i * $size;
                             $ma = $min + ($i + 1) * $size;
                             $a = $alpha - $alpha * ($step - $i) * 0.9 / $step;
                             $s = $s . 'steelseries.Section(' . $mi . ', ' . $ma . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $a . ')"),';
                         }
                         $result['section'] = '[' . substr($s, 0, strlen($s) - 1) . ']';
                         $result['useSectionColors'] = true;
                     }
                     break;
                 case 'fadeout':
                     if ($digital) {
                         $color = new Color(Color::nameToHex($attributes['index_color']));
                         $rgb2 = Color::hexToRgb($color->lighten($lighten * 2));
                         $rgb1 = Color::nameToRgb($attributes['index_color']);
                         $result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb2['R'] . ',' . $rgb2['G'] . ',' . $rgb2['B'] . ', 1)])';
                         $result['useValueGradient'] = true;
                     } else {
                         $rgb = Color::nameToRgb($attributes['index_color']);
                         $s = '';
                         $step = 20;
                         $size = ($max - $min) / $step;
                         for ($i = 0; $i < $step; $i++) {
                             $mi = $min + $i * $size;
                             $ma = $min + ($i + 1) * $size;
                             $a = $alpha - $alpha * $i * 0.9 / $step;
                             $s = $s . 'steelseries.Section(' . $mi . ', ' . $ma . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $a . ')"),';
                         }
                         $result['section'] = '[' . substr($s, 0, strlen($s) - 1) . ']';
                         $result['useSectionColors'] = true;
                     }
                     break;
                 case 'complementary':
                     if ($digital) {
                         $color = new Color(Color::nameToHex($attributes['index_color']));
                         $rgb1 = Color::nameToRgb($attributes['index_color']);
                         $rgb2 = Color::hexToRgb($color->complementary());
                         $result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb2['R'] . ',' . $rgb2['G'] . ',' . $rgb2['B'] . ', 1)])';
                         $result['useValueGradient'] = true;
                     } else {
                         $color2 = new Color(Color::nameToHex($attributes['index_color']));
                         $color = new Color($color2->complementary());
                         $rgb2 = $color->complementary();
                         $s = '';
                         $step = 20;
                         $size = ($max - $min) / $step;
                         for ($i = 0; $i < $step; $i++) {
                             $rgb = Color::hexToRgb($color->mix($rgb2, round(200 / $step * $i) - 100));
                             $mi = $min + $i * $size;
                             $ma = $min + ($i + 1) * $size;
                             $s = $s . 'steelseries.Section(' . $mi . ', ' . $ma . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $alpha . ')"),';
                         }
                         $result['section'] = '[' . substr($s, 0, strlen($s) - 1) . ']';
                         $result['useSectionColors'] = true;
                     }
                     break;
                 case 'invcomplementary':
                     if ($digital) {
                         $color = new Color(Color::nameToHex($attributes['index_color']));
                         $rgb2 = Color::nameToRgb($attributes['index_color']);
                         $rgb1 = Color::hexToRgb($color->complementary());
                         $result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb1['R'] . ',' . $rgb1['G'] . ',' . $rgb1['B'] . ', 1), new steelseries.rgbaColor(' . $rgb2['R'] . ',' . $rgb2['G'] . ',' . $rgb2['B'] . ', 1)])';
                         $result['useValueGradient'] = true;
                     } else {
                         $color = new Color(Color::nameToHex($attributes['index_color']));
                         $rgb2 = $color->complementary();
                         $s = '';
                         $step = 20;
                         $size = ($max - $min) / $step;
                         for ($i = 0; $i < $step; $i++) {
                             $rgb = Color::hexToRgb($color->mix($rgb2, round(200 / $step * $i) - 100));
                             $mi = $min + $i * $size;
                             $ma = $min + ($i + 1) * $size;
                             $s = $s . 'steelseries.Section(' . $mi . ', ' . $ma . ', "rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', ' . $alpha . ')"),';
                         }
                         $result['section'] = '[' . substr($s, 0, strlen($s) - 1) . ']';
                         $result['useSectionColors'] = true;
                     }
                     break;
             }
         }
     } else {
         if ($digital) {
             $rgb = Color::nameToRgb('antiquewhite');
             $result['valueGradient'] = 'new steelseries.gradientWrapper(' . $min . ', ' . $max . ', [0,1], [new steelseries.rgbaColor(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', 1), new steelseries.rgbaColor(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ', 1)])';
             $result['useValueGradient'] = true;
         }
     }
     $result['foregroundType'] = 'steelseries.ForegroundType.' . $attributes['glass'];
     switch ($attributes['size']) {
         case 'small':
             $result['size'] = 150;
             break;
         case 'medium':
             $result['size'] = 200;
             break;
         case 'large':
             $result['size'] = 250;
             break;
         case 'macro':
             $result['size'] = 300;
             break;
     }
     $result['thresholdVisible'] = false;
     $result['ledVisible'] = false;
     $result['niceScale'] = false;
     if ($digital) {
         $result['valueColor'] = 'steelseries.ColorDef.WHITE';
     }
     $result['lcdDecimals'] = $values['decimals'];
     $result['titleString'] = '"' . $values['type'] . '"';
     $result['unitString'] = '"• ' . $values['unit'] . ' •"';
     $result['digitalFont'] = true;
     if (strpos($attributes['design'], 'digital') !== false) {
         unset($result['titleString']);
         $result['unitString'] = '"' . $values['type'] . ' • ' . $values['unit'] . '"';
     }
     if (strpos($attributes['design'], 'meter-') !== false) {
         unset($result['titleString']);
         $result['niceScale'] = true;
     }
     if (strpos($attributes['design'], 'windcompass') !== false) {
         unset($result['titleString']);
         unset($result['unitString']);
         $result['lcdTitleStrings'] = '["' . __('Wind', 'live-weather-station') . '", "' . __('Gust', 'live-weather-station') . '"]';
     }
     if (strpos($attributes['design'], 'altimeter') !== false) {
         unset($result['titleString']);
         $result['unitString'] = '"' . $values['type'] . '"';
     }
     if (strpos($attributes['design'], 'windcompass-vintage') !== false) {
         $result['roseVisible'] = true;
         $result['degreeScale'] = false;
     }
     if (strpos($attributes['design'], 'windcompass-standard') !== false) {
         $result['roseVisible'] = true;
     }
     return $result;
 }
 /**
  * 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';
 }
Пример #4
0
}
if (!$nav_icon_hover_color) {
    $nihc = new Color($nav_bg);
    if ($nihc->isLight()) {
        $nav_icon_hover_color = '#' . $nihc->darken(10);
    } else {
        $nav_icon_hover_color = '#' . $nihc->lighten(10);
    }
}
if (!$link_hover_color) {
    $lhc = new Color($link_color);
    $lcolor = $lhc->getHex();
    if ($lhc->isLight($lcolor, 75)) {
        $link_hover_color = '#' . $lhc->darken(5);
    } else {
        $link_hover_color = '#' . $lhc->lighten(5);
    }
}
// Convert $bg_image_options into css
switch ($bg_image_option) {
    case "stretch":
        $background_size_img = "100%";
        break;
    case "cover":
        $background_size_img = "cover";
        break;
    case "repeat":
        $background_size_img = "auto";
        break;
    case "contain":
        $background_size_img = "contain";
Пример #5
0
 public function testShouldLigtenColor()
 {
     $color = new Color('000');
     $this->assertEquals(new Color('222'), $color->lighten(34));
     $this->assertEquals(new Color('fff'), $color->lighten(300));
 }
 public static function generate_css_color($selector, $style, $mod_name, $color_offset = 0, $opacity = 1, $before = '', $after = '')
 {
     $mod = get_theme_mod($mod_name);
     if (!empty($mod)) {
         $value = $mod;
         if (substr($value, 0, 1) != '#') {
             $value = '#' . $value;
         }
         $color = new Color($value);
         if ($color_offset > 0) {
             $value = '#' . $color->lighten(abs($color_offset));
         } elseif ($color_offset < 0) {
             $value = '#' . $color->darken(abs($color_offset));
         }
         if (abs($opacity) < 1) {
             $rgb = new Color($value);
             $rgb = $rgb->getRgb();
             $value = 'rgba( ' . $rgb['R'] . ', ' . $rgb['G'] . ', ' . $rgb['B'] . ', ' . $opacity . ' )';
         }
         echo $selector . '{ ' . $style . ': ' . $before . ' ' . $value . ' ' . $after . ' }';
     }
 }