chriseppstein-compass-colors 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 1
3
+ :patch: 3
4
4
  :major: 0
data/example/config.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # Require any additional compass plugins here.
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'compass-colors')
3
+
2
4
  project_type = :stand_alone
3
5
  # Set this to the root of your project when deployed:
4
6
  http_path = "/"
@@ -5,28 +5,28 @@ module Sass::Script::Functions
5
5
  # Takes a color object and amount by which to lighten it (0 to 100).
6
6
  def lighten(color, amount)
7
7
  hsl = Compass::Colors::HSL.from_color(color)
8
- hsl.l *= (amount.value / 100.0) + 1.0
8
+ hsl.l += (1 - hsl.l) * (amount.value / 100.0)
9
9
  hsl.to_color
10
10
  end
11
11
 
12
12
  # Takes a color object and amount by which to darken it (0 to 100).
13
13
  def darken(color, amount)
14
14
  hsl = Compass::Colors::HSL.from_color(color)
15
- hsl.l *= (-amount.value / 100.0) + 1.0
15
+ hsl.l *= 1.0 - (amount.value / 100.0)
16
16
  hsl.to_color
17
17
  end
18
18
 
19
19
  # Saturate (make a color "richer") a color by the given amount (0 to 100)
20
20
  def saturate(color, amount)
21
21
  hsl = Compass::Colors::HSL.from_color(color)
22
- hsl.s *= (amount.value / 100.0) + 1.0
22
+ hsl.s += (1 - hsl.s) * (amount.value / 100.0)
23
23
  hsl.to_color
24
24
  end
25
25
 
26
26
  # Desaturate (make a color "grayer") a color by the given amount (0 to 100)
27
27
  def desaturate(color, amount)
28
28
  hsl = Compass::Colors::HSL.from_color(color)
29
- hsl.s *= (-amount.value / 100.0) + 1.0
29
+ hsl.s *= (1.0 - (amount.value / 100.0))
30
30
  hsl.to_color
31
31
  end
32
32
 
@@ -11,18 +11,18 @@ require 'compass-colors'
11
11
  describe "sass extensions" do
12
12
  it "should lighten red into pink" do
13
13
  pink = invoke(:lighten, color(255,0,0), number(50))
14
- pink.to_s.should == "#ff8080"
14
+ pink.should be_approximately_the_same_color_as(color(255,127,127))
15
15
  end
16
16
 
17
17
  it "should darken red into maroon" do
18
18
  maroon = invoke(:darken, color(255,0,0), number(50))
19
- maroon.to_s.should == "maroon"
19
+ maroon.should be_approximately_the_same_color_as(color(127,0,0))
20
20
  end
21
21
 
22
- it "should darken this blue into darker blue and then lighten it back again" do
23
- darker = invoke(:darken, color(0x4D, 0xA3, 0x78), number(50))
22
+ it "should darken white into gray and back again" do
23
+ darker = invoke(:darken, color(0xff, 0xff, 0xff), number(50))
24
24
  lighter_again = invoke(:lighten, darker, number(100))
25
- color(0x4D, 0xA3, 0x78).should be_approximately_the_same_color_as(lighter_again)
25
+ color(0xff, 0xff, 0xff).should be_approximately_the_same_color_as(lighter_again)
26
26
  end
27
27
 
28
28
  it "shouldn't saturate fully saturated colors" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chriseppstein-compass-colors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Eppstein