Sha256: f21607213d47b48b48bff7646db87a3e40c4005c5f82793419929cbc706002a8
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
module Facades module SassExt module Color # Check the luminance of color. This differs from lightness as it returns the actual values as 'light' and 'dark' def luminance(color) assert_type color, :Color result = ((color.red * 299) + (color.green * 587) + (color.blue * 114) / 1000) Sass::Script::String.new( result >= 160 ? 'light' : 'dark') end # Tint a color by mixing it with white def tint(color, dilution = Sass::Script::Number.new(50)) assert_type color, :Color white = Sass::Script::Color.new([255, 255, 255, 1]) assert_type dilution, :Number mix(color, white, Sass::Script::Number.new(100 - dilution.value)) end # Shade a color by mixing it with black def shade(color, dilution = Sass::Script::Number.new(50)) assert_type color, :Color black = Sass::Script::Color.new([0, 0, 0, 1]) assert_type dilution, :Number mix(color, black, Sass::Script::Number.new(100 - dilution.value)) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facades-0.0.6 | lib/facades/sass_ext/color.rb |
facades-0.0.5 | lib/facades/sass_ext/color.rb |
facades-0.0.4 | lib/facades/sass_ext/color.rb |
facades-0.0.3 | lib/facades/sass_ext/color.rb |