function fn__a_adjust($input) { list($color, $a) = array_pad(Functions::parseArgs($input, true), 2, 0); return Color::test($color) ? Color::colorAdjust($color, array(0, 0, 0, $a)) : ''; }
public static function colorSplit($str) { if ($test = Color::test($str)) { $color = $test['value']; $type = $test['type']; } else { return false; } // If non-alpha color return early. if (!in_array($type, array('hsla', 'rgba'))) { return array($color, 1); } // Strip all whitespace. $color = preg_replace('~\\s+~', '', $color); // Extract alpha component if one is matched. $opacity = 1; if (preg_match(Regex::make('~^(rgb|hsl)a\\(({{number}}%?,{{number}}%?,{{number}}%?),({{number}})\\)$~i'), $color, $m)) { $opacity = floatval($m[3]); $color = "{$m['1']}({$m['2']})"; } // Return color value and alpha component seperated. return array($color, $opacity); }