Fix broken linear gradients with svg enabled.

This commit is contained in:
Chris Eppstein 2011-04-24 18:59:07 -07:00
parent 85268281bc
commit 5962a85a99
3 changed files with 13 additions and 8 deletions

View File

@ -62,7 +62,10 @@ module Compass::SassExtensions::Functions::GradientSupport
end
def angle?(value)
value.is_a?(Sass::Script::Number) && value.numerator_units.size == 1 && value.numerator_units.first == "deg" && value.denominator_units.empty?
value.is_a?(Sass::Script::Number) &&
value.numerator_units.size == 1 &&
value.numerator_units.first == "deg" &&
value.denominator_units.empty?
end
end
@ -457,7 +460,7 @@ module Compass::SassExtensions::Functions::GradientSupport
def linear_svg(color_stops, x1, y1, x2, y2)
transform = ''
if angle?
if angle?(position_or_angle)
transform = %Q{ gradientTransform = "rotate(#{position_or_angle.value})"}
end
gradient = %Q{<linearGradient id="grad" gradientUnits="userSpaceOnUse" x1="#{x1}" y1="#{y1}" x2="#{x2}" y2="#{y2}"#{transform}>#{color_stops_svg(color_stops)}</linearGradient>}

View File

@ -93,11 +93,13 @@
background-image: linear-gradient(-45deg, #dddddd, #aaaaaa); }
.bg-radial-gradient-with-angle-and-shape {
background-image: -webkit-gradient(radial, 45deg, 0, 45deg, 100, color-stop(0%, #dddddd), color-stop(100%, #aaaaaa));
background-image: -webkit-radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px);
background-image: -moz-radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px);
background-image: -o-radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px);
background-image: radial-gradient(45deg, ellipse cover, #dddddd, #aaaaaa 100px); }
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9ImVsbGlwc2UiIGN5PSJjb3ZlciIgcj0iMTAwIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZGRkZGRkIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjYWFhYWFhIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');
background-size: 100%;
background-image: -webkit-gradient(radial, ellipse cover, 0, ellipse cover, 100, color-stop(0%, #dddddd), color-stop(100%, #aaaaaa));
background-image: -webkit-radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px);
background-image: -moz-radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px);
background-image: -o-radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px);
background-image: radial-gradient(ellipse cover, #dddddd, #aaaaaa 100px); }
.bg-all-gradient-types {
background-image: url('/images/4x6.png?busted=true'), url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2RkZGRkZCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2FhYWFhYSIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='), url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHJhZGlhbEdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iMTAwIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZGRkZGRkIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjYWFhYWFhIi8+PC9yYWRpYWxHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');

View File

@ -38,7 +38,7 @@ $experimental-support-for-svg: true
+background-image(linear-gradient(-45deg, #ddd, #aaa))
.bg-radial-gradient-with-angle-and-shape
+background-image(radial-gradient(45deg, ellipse cover, #ddd, #aaa 100px))
+background-image(radial-gradient(ellipse cover, #ddd, #aaa 100px))
.bg-all-gradient-types
+background-image(image-url("4x6.png"), linear-gradient(top left, #ddd, #aaa), radial-gradient(center center, #ddd, #aaa 100px))