Module: Compass::Core::SassExtensions::Functions::Colors

### Home Classes Methods

### In Files

- lib/compass/core/sass_extensions/functions/colors.rb

### Methods

- #adjust_lightness
- #adjust_saturation
- #ie_hex_str
- #scale_lightness
- #scale_saturation
- #shade
- #tint

### Class/Module Index

Quicksearch

- Compass
- Compass::BrowserSupport
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Watch
- Compass::Core
- Compass::Core::CanIUse
- Compass::Core::SassExtensions
- Compass::Core::SassExtensions::Functions
- Compass::Core::SassExtensions::Functions::Colors
- Compass::Core::SassExtensions::Functions::Configuration
- Compass::Core::SassExtensions::Functions::Constants
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::Core::SassExtensions::Functions::Display
- Compass::Core::SassExtensions::Functions::Enumerate
- Compass::Core::SassExtensions::Functions::Env
- Compass::Core::SassExtensions::Functions::Files
- Compass::Core::SassExtensions::Functions::FontFiles
- Compass::Core::SassExtensions::Functions::GradientSupport
- Compass::Core::SassExtensions::Functions::GradientSupport::Assertions
- Compass::Core::SassExtensions::Functions::GradientSupport::CSS3AngleToSVGConverter
- Compass::Core::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::Core::SassExtensions::Functions::GradientSupport::Functions
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::Core::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::Core::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::Core::SassExtensions::Functions::ImageSize
- Compass::Core::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::Core::SassExtensions::Functions::ImageSize::JPEG
- Compass::Core::SassExtensions::Functions::InlineImage
- Compass::Core::SassExtensions::Functions::Lists
- Compass::Core::SassExtensions::Functions::Math
- Compass::Core::SassExtensions::Functions::SassDeclarationHelper
- Compass::Core::SassExtensions::Functions::Selectors
- Compass::Core::SassExtensions::Functions::Urls
- Compass::Core::SassExtensions::Functions::Urls::FontUrl
- Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::Core::SassExtensions::Functions::Urls::ImageUrl
- Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::Error
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::HasDeprecatedConstantsFromCore
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::Util
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Tree
- Sass::Tree::Node

No matching classes.

# Compass::Core::SassExtensions::Functions::Colors

### Public Instance Methods

adjust_lightness(color, amount) click to toggle source

a genericized version of lighten/darken so that negative values can be used.

    # File lib/compass/core/sass_extensions/functions/colors.rb, line 4
    def adjust_lightness(color, amount)
      assert_type color, :Color
      assert_type amount, :Number
      color.with(:lightness => Sass::Util.restrict(color.lightness + amount.value, 0..100))
    end

adjust_saturation(color, amount) click to toggle source

a genericized version of saturation/desaturate so that negative values can be used.

    # File lib/compass/core/sass_extensions/functions/colors.rb, line 20
    def adjust_saturation(color, amount)
      assert_type color, :Color
      assert_type amount, :Number
      color.with(:saturation => Sass::Util.restrict(color.saturation + amount.value, 0..100))
    end

ie_hex_str(color) click to toggle source

returns an IE hex string for a color with an alpha channel suitable for passing to IE filters.

    # File lib/compass/core/sass_extensions/functions/colors.rb, line 51
    def ie_hex_str(color)
      assert_type color, :Color
      alpha = (color.alpha * 255).round
      alphastr = alpha.to_s(16).rjust(2, '0')
      identifier("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
    end

scale_lightness(color, amount) click to toggle source

Scales a color's lightness by some percentage. If the amount is negative, the color is scaled darker, if positive, it is scaled lighter. This will never return a pure light or dark color unless the amount is 100%.

    # File lib/compass/core/sass_extensions/functions/colors.rb, line 13
    def scale_lightness(color, amount)
      assert_type color, :Color
      assert_type amount, :Number
      color.with(:lightness => scale_color_value(color.lightness, amount.value))
    end

scale_saturation(color, amount) click to toggle source

Scales a color's saturation by some percentage. If the amount is negative, the color is desaturated, if positive, it is saturated. This will never return a pure saturated or desaturated color unless the amount is 100%.

    # File lib/compass/core/sass_extensions/functions/colors.rb, line 29
    def scale_saturation(color, amount)
      assert_type color, :Color
      assert_type amount, :Number
      color.with(:saturation => scale_color_value(color.saturation, amount.value))
    end

shade(color, percentage) click to toggle source

    # File lib/compass/core/sass_extensions/functions/colors.rb, line 35
    def shade(color, percentage)
      assert_type color, :Color
      assert_type percentage, :Number
      black = rgb_color(0, 0, 0)
      mix(black, color, percentage)
    end

tint(color, percentage) click to toggle source

    # File lib/compass/core/sass_extensions/functions/colors.rb, line 42
    def tint(color, percentage)
      assert_type color, :Color
      assert_type percentage, :Number
      white = rgb_color(255, 255, 255)
      mix(white, color, percentage)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.