| @@ 616-640 (lines=25) @@ | ||
| 613 | return $matches[1] . preg_replace('/0(\{|,[^\)\{]+\{)/', '0%$1', $matches[2]) . $matches[3]; |
|
| 614 | } |
|
| 615 | ||
| 616 | private function rgb_to_hex($matches) |
|
| 617 | { |
|
| 618 | // Support for percentage values rgb(100%, 0%, 45%); |
|
| 619 | if ($this->index_of($matches[1], '%') >= 0){ |
|
| 620 | $rgbcolors = explode(',', str_replace('%', '', $matches[1])); |
|
| 621 | for ($i = 0; $i < count($rgbcolors); $i++) { |
|
| 622 | $rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55); |
|
| 623 | } |
|
| 624 | } else { |
|
| 625 | $rgbcolors = explode(',', $matches[1]); |
|
| 626 | } |
|
| 627 | ||
| 628 | // Values outside the sRGB color space should be clipped (0-255) |
|
| 629 | for ($i = 0; $i < count($rgbcolors); $i++) { |
|
| 630 | $rgbcolors[$i] = $this->clamp_number(intval($rgbcolors[$i], 10), 0, 255); |
|
| 631 | $rgbcolors[$i] = sprintf("%02x", $rgbcolors[$i]); |
|
| 632 | } |
|
| 633 | ||
| 634 | // Fix for issue #2528093 |
|
| 635 | if (!preg_match('/[\s\,\);\}]/', $matches[2])){ |
|
| 636 | $matches[2] = ' ' . $matches[2]; |
|
| 637 | } |
|
| 638 | ||
| 639 | return '#' . implode('', $rgbcolors) . $matches[2]; |
|
| 640 | } |
|
| 641 | ||
| 642 | private function hsl_to_hex($matches) |
|
| 643 | { |
|
| @@ 612-636 (lines=25) @@ | ||
| 609 | return 'filter:progid:DXImageTransform.Microsoft.Matrix(' . self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')'; |
|
| 610 | } |
|
| 611 | ||
| 612 | private function rgb_to_hex($matches) |
|
| 613 | { |
|
| 614 | // Support for percentage values rgb(100%, 0%, 45%); |
|
| 615 | if ($this->index_of($matches[1], '%') >= 0){ |
|
| 616 | $rgbcolors = explode(',', str_replace('%', '', $matches[1])); |
|
| 617 | for ($i = 0; $i < count($rgbcolors); $i++) { |
|
| 618 | $rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55); |
|
| 619 | } |
|
| 620 | } else { |
|
| 621 | $rgbcolors = explode(',', $matches[1]); |
|
| 622 | } |
|
| 623 | ||
| 624 | // Values outside the sRGB color space should be clipped (0-255) |
|
| 625 | for ($i = 0; $i < count($rgbcolors); $i++) { |
|
| 626 | $rgbcolors[$i] = $this->clamp_number(intval($rgbcolors[$i], 10), 0, 255); |
|
| 627 | $rgbcolors[$i] = sprintf("%02x", $rgbcolors[$i]); |
|
| 628 | } |
|
| 629 | ||
| 630 | // Fix for issue #2528093 |
|
| 631 | if (!preg_match('/[\s\,\);\}]/', $matches[2])){ |
|
| 632 | $matches[2] = ' ' . $matches[2]; |
|
| 633 | } |
|
| 634 | ||
| 635 | return '#' . implode('', $rgbcolors) . $matches[2]; |
|
| 636 | } |
|
| 637 | ||
| 638 | private function hsl_to_hex($matches) |
|
| 639 | { |
|