Class: Compass::SassExtensions::Functions::GradientSupport::RadialGradient

Inherits:
Sass::Script::Literal
  • Object
show all
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

Constants::POSITIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#assert_type

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_stopsObject

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

#positionObject

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_sizeObject

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

#childrenObject



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(options = self.options)
  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(options = self.options)
  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.options = options}
  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(options = self.options)
  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(options = self.options)
  s = "radial-gradient("
  s << position.to_s(options) << ", " if position
  s << shape_and_size.to_s(options) << ", " if shape_and_size
  s << color_stops.to_s(options)
  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(options = self.options)
  # XXX Add shape support if possible
  radial_svg_gradient(color_stops, position || _center_position)
end