compass-colors 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +3 -3
- data/lib/compass-colors/sass_extensions.rb +26 -4
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -4,28 +4,44 @@ module Sass::Script::Functions
|
|
4
4
|
# Takes a color object and amount by which to lighten it (0 to 100).
|
5
5
|
def lighten(color, amount)
|
6
6
|
hsl = Compass::Colors::HSL.from_color(color)
|
7
|
-
|
7
|
+
if percentage?(amount)
|
8
|
+
hsl.l += (1 - hsl.l) * (amount.value / 100.0)
|
9
|
+
else
|
10
|
+
hsl.l += amount.value
|
11
|
+
end
|
8
12
|
hsl.to_color
|
9
13
|
end
|
10
14
|
|
11
15
|
# Takes a color object and amount by which to darken it (0 to 100).
|
12
16
|
def darken(color, amount)
|
13
17
|
hsl = Compass::Colors::HSL.from_color(color)
|
14
|
-
|
18
|
+
if percentage?(amount)
|
19
|
+
hsl.l *= 1.0 - (amount.value / 100.0)
|
20
|
+
else
|
21
|
+
hsl.l -= amount.value
|
22
|
+
end
|
15
23
|
hsl.to_color
|
16
24
|
end
|
17
25
|
|
18
26
|
# Saturate (make a color "richer") a color by the given amount (0 to 100)
|
19
27
|
def saturate(color, amount)
|
20
28
|
hsl = Compass::Colors::HSL.from_color(color)
|
21
|
-
|
29
|
+
if percentage?(amount)
|
30
|
+
hsl.s += (1 - hsl.s) * (amount.value / 100.0)
|
31
|
+
else
|
32
|
+
hsl.s += amount.value
|
33
|
+
end
|
22
34
|
hsl.to_color
|
23
35
|
end
|
24
36
|
|
25
37
|
# Desaturate (make a color "grayer") a color by the given amount (0 to 100)
|
26
38
|
def desaturate(color, amount)
|
27
39
|
hsl = Compass::Colors::HSL.from_color(color)
|
28
|
-
|
40
|
+
if percentage?(amount)
|
41
|
+
hsl.s *= (1.0 - (amount.value / 100.0))
|
42
|
+
else
|
43
|
+
hsl.s -= amount.value
|
44
|
+
end
|
29
45
|
hsl.to_color
|
30
46
|
end
|
31
47
|
|
@@ -70,4 +86,10 @@ module Sass::Script::Functions
|
|
70
86
|
adjust_hue color, 180
|
71
87
|
end
|
72
88
|
|
89
|
+
private
|
90
|
+
|
91
|
+
def percentage?(amount)
|
92
|
+
amount.numerator_units == ["%"] || (amount.unitless? && amount.value > 1 && amount.value < 100)
|
93
|
+
end
|
94
|
+
|
73
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compass-colors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Eppstein
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-14 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|