class Sass::Script::Color

def with(attrs)

Raises:
  • (ArgumentError) - if both RGB and HSL keys are specified

Returns:
  • (Color) - The new Color object

Parameters:
  • attrs ({Symbol => Numeric}) --
def with(attrs)
  attrs = attrs.reject {|k, v| v.nil?}
  hsl = !([:hue, :saturation, :lightness] & attrs.keys).empty?
  rgb = !([:red, :green, :blue] & attrs.keys).empty?
  if hsl && rgb
    raise ArgumentError.new("Color#with may not have both HSL and RGB keys specified")
  end
  if hsl
    [:hue, :saturation, :lightness].each {|k| attrs[k] ||= send(k)}
  elsif rgb
    [:red, :green, :blue].each {|k| attrs[k] ||= send(k)}
  else
    # If we're just changing the alpha channel,
    # keep all the HSL/RGB stuff we've calculated
    attrs = @attrs.merge(attrs)
  end
  attrs[:alpha] ||= alpha
  Color.new(attrs, :allow_both_rgb_and_hsl)
end