protected function get_button_style() { if ('custom' != $this->atts['color_mode'] || !$this->atts['color']) { return ''; } if (in_array($this->atts['style'], array('light', 'link'))) { $style = ' style="color: ' . $this->atts['color'] . ';"'; } else { if ('3d' == $this->config->get('buttons.style')) { if (false !== strpos($this->atts['color'], 'rgb')) { $color = new Color(Color::rgbToHex($this->atts['color'])); } else { $color = new Color($this->atts['color']); } $style = ' style="background: ' . $this->atts['color'] . '; border-bottom-color: #' . $color->darken(18) . ';"'; } else { $style = ' style="background: ' . $this->atts['color'] . ';"'; } } return $style; }
protected function minifyColors() { static $keywords_patt, $functions_patt; $minified_keywords = Color::getMinifyableKeywords(); if (!$keywords_patt) { $keywords_patt = '~(?<![\\w-\\.#])(' . implode('|', array_keys($minified_keywords)) . ')(?![\\w-\\.#\\]])~iS'; $functions_patt = Regex::make('~{{ LB }}(rgb|hsl)\\(([^\\)]{5,})\\)~iS'); } $this->string->pregReplaceCallback($keywords_patt, function ($m) use($minified_keywords) { return $minified_keywords[strtolower($m[0])]; }); $this->string->pregReplaceCallback($functions_patt, function ($m) { $args = Functions::parseArgs(trim($m[2])); if (stripos($m[1], 'hsl') === 0) { $args = Color::cssHslToRgb($args); } return Color::rgbToHex($args); }); }
public function testRGBtoHex() { $this->assertEquals('#9358cb', Color::rgbToHex(['R' => 147, 'G' => 88, 'B' => 203])); }
protected function darken_color($color = '', $amount = 18) { if ($color) { if (false !== strpos($color, 'rgb')) { $color_obj = new Color(Color::rgbToHex($color)); } else { $color_obj = new Color($color); } return '#' . $color_obj->darken($amount); } return ''; }