Class: Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Inherits:
-
Sass::Script::Literal
- Object
- Sass::Script::Literal
- Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Includes:
- Constants, Assertions, Functions, Gradient, InlineImage
- Defined in:
- lib/compass/sass_extensions/functions/gradient_support.rb,
lib/compass/sass_extensions/functions/gradient_support.rb
Constant Summary
Constants included from Constants
Instance Attribute Summary collapse
-
#color_stops ⇒ Object
Returns the value of attribute color_stops.
-
#position ⇒ Object
Returns the value of attribute position.
-
#shape_and_size ⇒ Object
Returns the value of attribute shape_and_size.
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(position, shape_and_size, color_stops) ⇒ RadialGradient
constructor
A new instance of RadialGradient.
- #to_css2(options = self.options) ⇒ Object
- #to_owg(options = self.options) ⇒ Object
- #to_pie(options = self.options) ⇒ Object
- #to_s(options = self.options) ⇒ Object
- #to_svg(options = self.options) ⇒ Object
Methods included from InlineImage
#inline_font_files, #inline_image
Methods included from Constants
#is_position, #is_position_list, #is_url, #opposite_position
Methods included from Functions
#color_stops_in_percentages, #grad_color_stops, #grad_end_position, #grad_point, #grad_position, #linear_end_position, #linear_gradient, #linear_svg_gradient, #radial_gradient, #radial_svg_gradient
Methods included from Assertions
Methods included from Gradient
#angle?, #has_aspect?, included, #inspect, #supports?
Constructor Details
#initialize(position, shape_and_size, color_stops) ⇒ RadialGradient
Returns a new instance of RadialGradient.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 92 def initialize(position, shape_and_size, color_stops) unless color_stops.value.size >= 2 raise Sass::SyntaxError, "At least two color stops are required for a radial-gradient" end if angle?(position) raise Sass::SyntaxError, "CSS no longer allows angles in radial-gradients." end self.position = position self.shape_and_size = shape_and_size self.color_stops = color_stops end |
Instance Attribute Details
#color_stops ⇒ Object
Returns the value of attribute color_stops.
86 87 88 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 86 def color_stops @color_stops end |
#position ⇒ Object
Returns the value of attribute position.
86 87 88 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 86 def position @position end |
#shape_and_size ⇒ Object
Returns the value of attribute shape_and_size.
86 87 88 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 86 def shape_and_size @shape_and_size end |
Instance Method Details
#children ⇒ Object
88 89 90 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 88 def children [color_stops, position, shape_and_size].compact end |
#to_css2(options = self.options) ⇒ Object
138 139 140 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 138 def to_css2( = self.) Sass::Script::String.new("") end |
#to_owg(options = self.options) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 116 def to_owg( = self.) args = [ grad_point(position || _center_position), Sass::Script::String.new("0"), grad_point(position || _center_position), grad_end_position(color_stops, Sass::Script::Bool.new(true)), grad_color_stops(color_stops) ] args.each {|a| a. = } Sass::Script::String.new("-webkit-gradient(radial, #{args.join(', ')})") end |
#to_pie(options = self.options) ⇒ Object
133 134 135 136 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 133 def to_pie( = self.) Compass::Logger.new.record(:warning, "PIE does not support radial-gradient.") Sass::Script::String.new("-pie-radial-gradient(unsupported)") end |
#to_s(options = self.options) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 104 def to_s( = self.) s = "radial-gradient(" s << position.to_s() << ", " if position s << shape_and_size.to_s() << ", " if shape_and_size s << color_stops.to_s() s << ")" end |
#to_svg(options = self.options) ⇒ Object
128 129 130 131 |
# File 'lib/compass/sass_extensions/functions/gradient_support.rb', line 128 def to_svg( = self.) # XXX Add shape support if possible radial_svg_gradient(color_stops, position || _center_position) end |