Module: Sass::Script::Functions

Defined in:
lib/compass-colors/sass_extensions.rb

Defined Under Namespace

Modules: Colors

Instance Method Summary collapse

Instance Method Details

#darken_percent(color, amount) ⇒ Object

Takes a color object and percent by which to darken it (0 to 100).



26
27
28
29
30
31
32
33
34
35
# File 'lib/compass-colors/sass_extensions.rb', line 26

def darken_percent(color, amount)
  Compass::Util.compass_warn("darken-percent() is deprecated. Please use the scale-color() function provided by sass.")
  if unitless(amount).to_bool
    Compass::Util.compass_warn("Sass's scale-color() function requires a percent instead of a unitless number for the amount.")
    amount = Sass::Script::Number.new(-amount.value, ['%'], [])
  else
    amount = amount.times(Sass::Script::Number.new(-1))
  end
  scale_color(color, "lightness" => amount)
end

#desaturate_percent(color, amount) ⇒ Object

Desaturate (make a color “grayer”) a color by the given percent (0 to 100)



48
49
50
51
52
53
54
55
56
57
# File 'lib/compass-colors/sass_extensions.rb', line 48

def desaturate_percent(color, amount)
  Compass::Util.compass_warn("desaturate-percent() is deprecated. Please use the scale-color() function provided by sass.")
  if unitless(amount).to_bool
    Compass::Util.compass_warn("Sass's scale-color() function requires a percent instead of a unitless number for the amount.")
    amount = Sass::Script::Number.new(-amount.value, ['%'], [])
  else
    amount = amount.times(Sass::Script::Number.new(-1))
  end
  scale_color(color, "saturation" => amount)
end

#lighten_percent(color, amount) ⇒ Object

Takes a color object and percent by which to lighten it (0 to 100).



16
17
18
19
20
21
22
23
# File 'lib/compass-colors/sass_extensions.rb', line 16

def lighten_percent(color, amount)
  Compass::Util.compass_warn("lighten-percent() is deprecated. Please use the scale-color() function provided by sass.")
  if unitless(amount).to_bool
    Compass::Util.compass_warn("Sass's scale-color() function requires a percent instead of a unitless number for the amount.")
    amount = Sass::Script::Number.new(amount.value, ['%'], [])
  end
  scale_color(color, "lightness" => amount)
end

#luminosity(color) ⇒ Object

Return the luminosity of a color as a number between 0 and 100



60
61
62
63
# File 'lib/compass-colors/sass_extensions.rb', line 60

def luminosity(color)
  Compass::Util.compass_warn("luminosity($color) is deprecated. Please use the lightness($color) provided by sass.")
  lightness(color)
end

#saturate_percent(color, amount) ⇒ Object

Saturate (make a color “richer”) a color by the given percent (0 to 100)



38
39
40
41
42
43
44
45
# File 'lib/compass-colors/sass_extensions.rb', line 38

def saturate_percent(color, amount)
  Compass::Util.compass_warn("saturate-percent() is deprecated. Please use the scale-color() function provided by sass.")
  if unitless(amount).to_bool
    Compass::Util.compass_warn("Sass's scale-color() function requires a percent instead of a unitless number for the amount.")
    amount = Sass::Script::Number.new(amount.value, ['%'], [])
  end
  scale_color(color, "saturation" => amount)
end