src/SyHolloway/MrColor/Extension/Toolkit.php
public function getCssGradient(Color $color, $amount = null)
    {
        // Get gradient colors
        if (self::isLight($color)) {
            $lightColor = $color->hex;
            $darkColor = self::darken($color->copy(), $amount)->hex;
        } else {
            $lightColor = self::lighten($color->copy(), $amount)->hex;
            $darkColor = $color->hex;
        }

        /* fallback/image non-cover color */
        $css = "background-color: #" . $color->hex . ";";

        /* IE Browsers */
        $css .= "filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#" . $lightColor . "', endColorstr='#" . $darkColor . "');";

        /* Safari 4+, Chrome 1-9 */
        $css .= "background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#" . $lightColor . "), to(#" . $darkColor . "));";

        /* Safari 5.1+, Mobile Safari, Chrome 10+ */
        $css .= "background-image: -webkit-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        /* Firefox 3.6+ */
        $css .= "background-image: -moz-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        /* IE 10+ */
        $css .= "background-image: -ms-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        /* Opera 11.10+ */
        $css .= "background-image: -o-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        // Return our CSS
        return $css;
    }
public function getCssGradient(Color $color, $amount = null)
    {
        // Get gradient colors
        if (self::isLight($color)) {
            $lightColor = $color->hex;
            $darkColor = self::darken($color->copy(), $amount)->hex;
        } else {
            $lightColor = self::lighten($color->copy(), $amount)->hex;
            $darkColor = $color->hex;
        }

        /* fallback/image non-cover color */
        $css = "background-color: #" . $color->hex . ";";

        /* IE Browsers */
        $css .= "filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#" . $lightColor . "', endColorstr='#" . $darkColor . "');";

        /* Safari 4+, Chrome 1-9 */
        $css .= "background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#" . $lightColor . "), to(#" . $darkColor . "));";

        /* Safari 5.1+, Mobile Safari, Chrome 10+ */
        $css .= "background-image: -webkit-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        /* Firefox 3.6+ */
        $css .= "background-image: -moz-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        /* IE 10+ */
        $css .= "background-image: -ms-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        /* Opera 11.10+ */
        $css .= "background-image: -o-linear-gradient(top, #" . $lightColor . ", #" . $darkColor . ");";

        // Return our CSS
        return $css;
    }
public function getCssGradient ( Color $ color , $ amount = null ) { // Get gradient colors if ( self :: isLight ( $ color ) ) { $ lightColor = $ color -> hex ; $ darkColor = self :: darken ( $ color -> copy ( ) , $ amount ) -> hex ; } else { $ lightColor = self :: lighten ( $ color -> copy ( ) , $ amount ) -> hex ; $ darkColor = $ color -> hex ; } /* fallback/image non-cover color */ $ css = "background-color: #" . $ color -> hex . ";" ; /* IE Browsers */ $ css .= "filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#" . $ lightColor . "', endColorstr='#" . $ darkColor . "');" ; /* Safari 4+, Chrome 1-9 */ $ css .= "background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#" . $ lightColor . "), to(#" . $ darkColor . "));" ; /* Safari 5.1+, Mobile Safari, Chrome 10+ */ $ css .= "background-image: -webkit-linear-gradient(top, #" . $ lightColor . ", #" . $ darkColor . ");" ; /* Firefox 3.6+ */ $ css .= "background-image: -moz-linear-gradient(top, #" . $ lightColor . ", #" . $ darkColor . ");" ; /* IE 10+ */ $ css .= "background-image: -ms-linear-gradient(top, #" . $ lightColor . ", #" . $ darkColor . ");" ; /* Opera 11.10+ */ $ css .= "background-image: -o-linear-gradient(top, #" . $ lightColor . ", #" . $ darkColor . ");" ; // Return our CSS return $ css ; }
Returns the cross browser CSS3 gradient

@param  object  $color  Color object
@param  integer $amount Optional: percentage amount to light/darken the gradient
@return string  CSS3 gradient for chrome, safari, firefox, opera and IE10 with fallbacks
Returns the cross browser CSS3 gradient