compass/src/test/testData/gems/compass-0.13.alpha.2/lib/compass/sass_extensions/functions/gradient_support.rb
def normalize_stops(color_list)
      positions = color_list.value.map{|obj| obj.dup}
      # fill in the start and end positions, if unspecified
      positions.first.stop = Sass::Script::Number.new(0) unless positions.first.stop
      positions.last.stop = Sass::Script::Number.new(100, ["%"]) unless positions.last.stop
      # fill in empty values
      for i in 0...positions.size
        if positions[i].stop.nil?
          num = 2.0
          for j in (i+1)...positions.size
            if positions[j].stop
              positions[i].stop = positions[i-1].stop.plus((positions[j].stop.minus(positions[i-1].stop)).div(Sass::Script::Number.new(num)))
              break
            else
              num += 1
            end
          end
        end
      end
      # normalize unitless numbers
      positions.each do |pos|
        if pos.stop.unitless? && pos.stop.value <= 1
          pos.stop = pos.stop.times(Sass::Script::Number.new(100, ["%"]))
        elsif pos.stop.unitless?
          pos.stop = pos.stop.times(Sass::Script::Number.new(1, ["px"]))
        end
      end
      if (positions.last.stop.eq(Sass::Script::Number.new(0, ["px"])).to_bool ||
         positions.last.stop.eq(Sass::Script::Number.new(0, ["%"])).to_bool)
         raise Sass::SyntaxError.new("Color stops must be specified in increasing order")
       end
      if defined?(Sass::Script::List)
        Sass::Script::List.new(positions, color_list.separator)
      else
        color_list.class.new(*positions)
      end
    end
# given a position list, return a corresponding position in percents
# otherwise, returns the original argument
given a position list, return a corresponding position in percents
otherwise, returns the original argument
given a position list return a corresponding position in percents otherwise returns the original argument
def normalize_stops(color_list)
      positions = color_list.value.map{|obj| obj.dup}
      positions.first.stop = Sass::Script::Number.new(0) unless positions.first.stop
      positions.last.stop = Sass::Script::Number.new(100, ["%"]) unless positions.last.stop
      for i in 0...positions.size
        if positions[i].stop.nil?
          num = 2.0
          for j in (i+1)...positions.size
            if positions[j].stop
              positions[i].stop = positions[i-1].stop.plus((positions[j].stop.minus(positions[i-1].stop)).div(Sass::Script::Number.new(num)))
              break
            else
              num += 1
            end
          end
        end
      end
      positions.each do |pos|
        if pos.stop.unitless? && pos.stop.value <= 1
          pos.stop = pos.stop.times(Sass::Script::Number.new(100, ["%"]))
        elsif pos.stop.unitless?
          pos.stop = pos.stop.times(Sass::Script::Number.new(1, ["px"]))
        end
      end
      if (positions.last.stop.eq(Sass::Script::Number.new(0, ["px"])).to_bool ||
         positions.last.stop.eq(Sass::Script::Number.new(0, ["%"])).to_bool)
         raise Sass::SyntaxError.new("Color stops must be specified in increasing order")
       end
      if defined?(Sass::Script::List)
        Sass::Script::List.new(positions, color_list.separator)
      else
        color_list.class.new(*positions)
      end
    end
def normalize_stops ( color_list ) positions = color_list . value . map { | obj | obj . dup } positions . first . stop = Sass :: Script :: Number . new ( 0 ) unless positions . first . stop positions . last . stop = Sass :: Script :: Number . new ( 100 , [ "%" ] ) unless positions . last . stop for i in 0 ... positions . size if positions [ i ] . stop . nil? num = 2.0 for j in ( i + 1 ) ... positions . size if positions [ j ] . stop positions [ i ] . stop = positions [ i - 1 ] . stop . plus ( ( positions [ j ] . stop . minus ( positions [ i - 1 ] . stop ) ) . div ( Sass :: Script :: Number . new ( num ) ) ) break else num += 1 end end end end positions . each do | pos | if pos . stop . unitless? && pos . stop . value <= 1 pos . stop = pos . stop . times ( Sass :: Script :: Number . new ( 100 , [ "%" ] ) ) elsif pos . stop . unitless? pos . stop = pos . stop . times ( Sass :: Script :: Number . new ( 1 , [ "px" ] ) ) end end if ( positions . last . stop . eq ( Sass :: Script :: Number . new ( 0 , [ "px" ] ) ) . to_bool || positions . last . stop . eq ( Sass :: Script :: Number . new ( 0 , [ "%" ] ) ) . to_bool ) raise Sass :: SyntaxError . new ( "Color stops must be specified in increasing order" ) end if defined? ( Sass :: Script :: List ) Sass :: Script :: List . new ( positions , color_list . separator ) else color_list . class . new ( * positions ) end end
given a position list, return a corresponding position in percents
otherwise, returns the original argument
given a position list return a corresponding position in percents otherwise returns the original argument
# fill in the start and end positions, if unspecified # fill in empty values # normalize unitless numbers
color_list