class Sass::Script::Color
def piecewise(other, operation)
def piecewise(other, operation) other_num = other.is_a? Number other_val = other.value if other_num && !other.unitless? raise Sass::SyntaxError.new("Cannot add a number with units (#{other}) to a color (#{self}).") end rgb = [] for i in (0...3) res = @value[i].send(operation, other_num ? other_val : other_val[i]) rgb[i] = [ [res, 255].min, 0 ].max end Color.new(rgb) end