[Compass Core] Added a color-stop function to simplify the creation of gradients with multiple stop points.

This commit is contained in:
Chris Eppstein 2009-11-21 09:26:54 -08:00
parent c1052c3d3e
commit 11a354e47e
2 changed files with 12 additions and 1 deletions

View File

@ -1,7 +1,7 @@
module Compass::SassExtensions::Functions
end
%w(selectors enumerate urls display inline_image).each do |func|
%w(selectors enumerate urls display inline_image color_stop).each do |func|
require "compass/sass_extensions/functions/#{func}"
end
@ -11,6 +11,7 @@ module Sass::Script::Functions
include Compass::SassExtensions::Functions::Urls
include Compass::SassExtensions::Functions::Display
include Compass::SassExtensions::Functions::InlineImage
include Compass::SassExtensions::Functions::ColorStop
end
# Wierd that this has to be re-included to pick up sub-modules. Ruby bug?

View File

@ -0,0 +1,10 @@
module Compass::SassExtensions::Functions::ColorStop
def color_stop(*args)
raise Sass::SyntaxError, "An even number of arguments must be passed to color-stop()" unless args.size % 2 == 0
stops = []
while args.size > 0
stops << "color-stop(#{args.shift}, #{args.shift})"
end
Sass::Script::String.new(stops.join(", "))
end
end