sass 3.3.0.alpha.144 → 3.3.0.alpha.149
Sign up to get free protection for your applications and to get access to all the features.
- data/REVISION +1 -1
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/lib/sass/script/color.rb +179 -158
- data/test/sass/functions_test.rb +4 -4
- data/test/sass/script_test.rb +3 -0
- metadata +3 -3
data/REVISION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
c2ce041855863e29ff5ca89fe6345fe322a1ea0e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.3.0.alpha.
|
1
|
+
3.3.0.alpha.149
|
data/VERSION_DATE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
25 May 2013 00:06:51 GMT
|
data/lib/sass/script/color.rb
CHANGED
@@ -18,160 +18,166 @@ module Sass::Script
|
|
18
18
|
|
19
19
|
# A hash from color names to `[red, green, blue]` value arrays.
|
20
20
|
COLOR_NAMES = map_vals({
|
21
|
-
'aliceblue'
|
22
|
-
'antiquewhite'
|
23
|
-
'aqua'
|
24
|
-
'aquamarine'
|
25
|
-
'azure'
|
26
|
-
'beige'
|
27
|
-
'bisque'
|
28
|
-
'black'
|
29
|
-
'blanchedalmond'
|
30
|
-
'blue'
|
31
|
-
'blueviolet'
|
32
|
-
'brown'
|
33
|
-
'burlywood'
|
34
|
-
'cadetblue'
|
35
|
-
'chartreuse'
|
36
|
-
'chocolate'
|
37
|
-
'coral'
|
38
|
-
'cornflowerblue'
|
39
|
-
'cornsilk'
|
40
|
-
'crimson'
|
41
|
-
'cyan'
|
42
|
-
'darkblue'
|
43
|
-
'darkcyan'
|
44
|
-
'darkgoldenrod'
|
45
|
-
'darkgray'
|
46
|
-
'darkgrey'
|
47
|
-
'darkgreen'
|
48
|
-
'darkkhaki'
|
49
|
-
'darkmagenta'
|
50
|
-
'darkolivegreen'
|
51
|
-
'darkorange'
|
52
|
-
'darkorchid'
|
53
|
-
'darkred'
|
54
|
-
'darksalmon'
|
55
|
-
'darkseagreen'
|
56
|
-
'darkslateblue'
|
57
|
-
'darkslategray'
|
58
|
-
'darkslategrey'
|
59
|
-
'darkturquoise'
|
60
|
-
'darkviolet'
|
61
|
-
'deeppink'
|
62
|
-
'deepskyblue'
|
63
|
-
'dimgray'
|
64
|
-
'dimgrey'
|
65
|
-
'dodgerblue'
|
66
|
-
'firebrick'
|
67
|
-
'floralwhite'
|
68
|
-
'forestgreen'
|
69
|
-
'fuchsia'
|
70
|
-
'gainsboro'
|
71
|
-
'ghostwhite'
|
72
|
-
'gold'
|
73
|
-
'goldenrod'
|
74
|
-
'gray'
|
75
|
-
'
|
76
|
-
'
|
77
|
-
'
|
78
|
-
'
|
79
|
-
'
|
80
|
-
'
|
81
|
-
'
|
82
|
-
'
|
83
|
-
'
|
84
|
-
'
|
85
|
-
'
|
86
|
-
'
|
87
|
-
'
|
88
|
-
'
|
89
|
-
'
|
90
|
-
'
|
91
|
-
'
|
92
|
-
'
|
93
|
-
'
|
94
|
-
'
|
95
|
-
'
|
96
|
-
'
|
97
|
-
'
|
98
|
-
'
|
99
|
-
'
|
100
|
-
'
|
101
|
-
'
|
102
|
-
'
|
103
|
-
'
|
104
|
-
'
|
105
|
-
'
|
106
|
-
'
|
107
|
-
'
|
108
|
-
'
|
109
|
-
'
|
110
|
-
'
|
111
|
-
'
|
112
|
-
'
|
113
|
-
'
|
114
|
-
'
|
115
|
-
'
|
116
|
-
'
|
117
|
-
'
|
118
|
-
'
|
119
|
-
'
|
120
|
-
'
|
121
|
-
'
|
122
|
-
'
|
123
|
-
'
|
124
|
-
'
|
125
|
-
'
|
126
|
-
'
|
127
|
-
'
|
128
|
-
'
|
129
|
-
'
|
130
|
-
'
|
131
|
-
'
|
132
|
-
'
|
133
|
-
'
|
134
|
-
'
|
135
|
-
'
|
136
|
-
'
|
137
|
-
'
|
138
|
-
'
|
139
|
-
'
|
140
|
-
'
|
141
|
-
'
|
142
|
-
'
|
143
|
-
'
|
144
|
-
'
|
145
|
-
'
|
146
|
-
'
|
147
|
-
'
|
148
|
-
'
|
149
|
-
'
|
150
|
-
'
|
151
|
-
'
|
152
|
-
'
|
153
|
-
'
|
154
|
-
'
|
155
|
-
'
|
156
|
-
'
|
157
|
-
'
|
158
|
-
'
|
159
|
-
'
|
160
|
-
'
|
161
|
-
'
|
162
|
-
'
|
163
|
-
'
|
164
|
-
'
|
165
|
-
'
|
166
|
-
'
|
167
|
-
|
168
|
-
|
169
|
-
|
21
|
+
'aliceblue' => 0xF0F8FFFF,
|
22
|
+
'antiquewhite' => 0xFAEBD7FF,
|
23
|
+
'aqua' => 0x00FFFFFF,
|
24
|
+
'aquamarine' => 0x7FFFD4FF,
|
25
|
+
'azure' => 0xF0FFFFFF,
|
26
|
+
'beige' => 0xF5F5DCFF,
|
27
|
+
'bisque' => 0xFFE4C4FF,
|
28
|
+
'black' => 0x000000FF,
|
29
|
+
'blanchedalmond' => 0xFFEBCDFF,
|
30
|
+
'blue' => 0x0000FFFF,
|
31
|
+
'blueviolet' => 0x8A2BE2FF,
|
32
|
+
'brown' => 0xA52A2AFF,
|
33
|
+
'burlywood' => 0xDEB887FF,
|
34
|
+
'cadetblue' => 0x5F9EA0FF,
|
35
|
+
'chartreuse' => 0x7FFF00FF,
|
36
|
+
'chocolate' => 0xD2691EFF,
|
37
|
+
'coral' => 0xFF7F50FF,
|
38
|
+
'cornflowerblue' => 0x6495EDFF,
|
39
|
+
'cornsilk' => 0xFFF8DCFF,
|
40
|
+
'crimson' => 0xDC143CFF,
|
41
|
+
'cyan' => 0x00FFFFFF,
|
42
|
+
'darkblue' => 0x00008BFF,
|
43
|
+
'darkcyan' => 0x008B8BFF,
|
44
|
+
'darkgoldenrod' => 0xB8860BFF,
|
45
|
+
'darkgray' => 0xA9A9A9FF,
|
46
|
+
'darkgrey' => 0xA9A9A9FF,
|
47
|
+
'darkgreen' => 0x006400FF,
|
48
|
+
'darkkhaki' => 0xBDB76BFF,
|
49
|
+
'darkmagenta' => 0x8B008BFF,
|
50
|
+
'darkolivegreen' => 0x556B2FFF,
|
51
|
+
'darkorange' => 0xFF8C00FF,
|
52
|
+
'darkorchid' => 0x9932CCFF,
|
53
|
+
'darkred' => 0x8B0000FF,
|
54
|
+
'darksalmon' => 0xE9967AFF,
|
55
|
+
'darkseagreen' => 0x8FBC8FFF,
|
56
|
+
'darkslateblue' => 0x483D8BFF,
|
57
|
+
'darkslategray' => 0x2F4F4FFF,
|
58
|
+
'darkslategrey' => 0x2F4F4FFF,
|
59
|
+
'darkturquoise' => 0x00CED1FF,
|
60
|
+
'darkviolet' => 0x9400D3FF,
|
61
|
+
'deeppink' => 0xFF1493FF,
|
62
|
+
'deepskyblue' => 0x00BFFFFF,
|
63
|
+
'dimgray' => 0x696969FF,
|
64
|
+
'dimgrey' => 0x696969FF,
|
65
|
+
'dodgerblue' => 0x1E90FFFF,
|
66
|
+
'firebrick' => 0xB22222FF,
|
67
|
+
'floralwhite' => 0xFFFAF0FF,
|
68
|
+
'forestgreen' => 0x228B22FF,
|
69
|
+
'fuchsia' => 0xFF00FFFF,
|
70
|
+
'gainsboro' => 0xDCDCDCFF,
|
71
|
+
'ghostwhite' => 0xF8F8FFFF,
|
72
|
+
'gold' => 0xFFD700FF,
|
73
|
+
'goldenrod' => 0xDAA520FF,
|
74
|
+
'gray' => 0x808080FF,
|
75
|
+
'grey' => 0x808080FF,
|
76
|
+
'green' => 0x008000FF,
|
77
|
+
'greenyellow' => 0xADFF2FFF,
|
78
|
+
'honeydew' => 0xF0FFF0FF,
|
79
|
+
'hotpink' => 0xFF69B4FF,
|
80
|
+
'indianred' => 0xCD5C5CFF,
|
81
|
+
'indigo' => 0x4B0082FF,
|
82
|
+
'ivory' => 0xFFFFF0FF,
|
83
|
+
'khaki' => 0xF0E68CFF,
|
84
|
+
'lavender' => 0xE6E6FAFF,
|
85
|
+
'lavenderblush' => 0xFFF0F5FF,
|
86
|
+
'lawngreen' => 0x7CFC00FF,
|
87
|
+
'lemonchiffon' => 0xFFFACDFF,
|
88
|
+
'lightblue' => 0xADD8E6FF,
|
89
|
+
'lightcoral' => 0xF08080FF,
|
90
|
+
'lightcyan' => 0xE0FFFFFF,
|
91
|
+
'lightgoldenrodyellow' => 0xFAFAD2FF,
|
92
|
+
'lightgreen' => 0x90EE90FF,
|
93
|
+
'lightgray' => 0xD3D3D3FF,
|
94
|
+
'lightgrey' => 0xD3D3D3FF,
|
95
|
+
'lightpink' => 0xFFB6C1FF,
|
96
|
+
'lightsalmon' => 0xFFA07AFF,
|
97
|
+
'lightseagreen' => 0x20B2AAFF,
|
98
|
+
'lightskyblue' => 0x87CEFAFF,
|
99
|
+
'lightslategray' => 0x778899FF,
|
100
|
+
'lightslategrey' => 0x778899FF,
|
101
|
+
'lightsteelblue' => 0xB0C4DEFF,
|
102
|
+
'lightyellow' => 0xFFFFE0FF,
|
103
|
+
'lime' => 0x00FF00FF,
|
104
|
+
'limegreen' => 0x32CD32FF,
|
105
|
+
'linen' => 0xFAF0E6FF,
|
106
|
+
'magenta' => 0xFF00FFFF,
|
107
|
+
'maroon' => 0x800000FF,
|
108
|
+
'mediumaquamarine' => 0x66CDAAFF,
|
109
|
+
'mediumblue' => 0x0000CDFF,
|
110
|
+
'mediumorchid' => 0xBA55D3FF,
|
111
|
+
'mediumpurple' => 0x9370DBFF,
|
112
|
+
'mediumseagreen' => 0x3CB371FF,
|
113
|
+
'mediumslateblue' => 0x7B68EEFF,
|
114
|
+
'mediumspringgreen' => 0x00FA9AFF,
|
115
|
+
'mediumturquoise' => 0x48D1CCFF,
|
116
|
+
'mediumvioletred' => 0xC71585FF,
|
117
|
+
'midnightblue' => 0x191970FF,
|
118
|
+
'mintcream' => 0xF5FFFAFF,
|
119
|
+
'mistyrose' => 0xFFE4E1FF,
|
120
|
+
'moccasin' => 0xFFE4B5FF,
|
121
|
+
'navajowhite' => 0xFFDEADFF,
|
122
|
+
'navy' => 0x000080FF,
|
123
|
+
'oldlace' => 0xFDF5E6FF,
|
124
|
+
'olive' => 0x808000FF,
|
125
|
+
'olivedrab' => 0x6B8E23FF,
|
126
|
+
'orange' => 0xFFA500FF,
|
127
|
+
'orangered' => 0xFF4500FF,
|
128
|
+
'orchid' => 0xDA70D6FF,
|
129
|
+
'palegoldenrod' => 0xEEE8AAFF,
|
130
|
+
'palegreen' => 0x98FB98FF,
|
131
|
+
'paleturquoise' => 0xAFEEEEFF,
|
132
|
+
'palevioletred' => 0xDB7093FF,
|
133
|
+
'papayawhip' => 0xFFEFD5FF,
|
134
|
+
'peachpuff' => 0xFFDAB9FF,
|
135
|
+
'peru' => 0xCD853FFF,
|
136
|
+
'pink' => 0xFFC0CBFF,
|
137
|
+
'plum' => 0xDDA0DDFF,
|
138
|
+
'powderblue' => 0xB0E0E6FF,
|
139
|
+
'purple' => 0x800080FF,
|
140
|
+
'red' => 0xFF0000FF,
|
141
|
+
'rosybrown' => 0xBC8F8FFF,
|
142
|
+
'royalblue' => 0x4169E1FF,
|
143
|
+
'saddlebrown' => 0x8B4513FF,
|
144
|
+
'salmon' => 0xFA8072FF,
|
145
|
+
'sandybrown' => 0xF4A460FF,
|
146
|
+
'seagreen' => 0x2E8B57FF,
|
147
|
+
'seashell' => 0xFFF5EEFF,
|
148
|
+
'sienna' => 0xA0522DFF,
|
149
|
+
'silver' => 0xC0C0C0FF,
|
150
|
+
'skyblue' => 0x87CEEBFF,
|
151
|
+
'slateblue' => 0x6A5ACDFF,
|
152
|
+
'slategray' => 0x708090FF,
|
153
|
+
'slategrey' => 0x708090FF,
|
154
|
+
'snow' => 0xFFFAFAFF,
|
155
|
+
'springgreen' => 0x00FF7FFF,
|
156
|
+
'steelblue' => 0x4682B4FF,
|
157
|
+
'tan' => 0xD2B48CFF,
|
158
|
+
'teal' => 0x008080FF,
|
159
|
+
'thistle' => 0xD8BFD8FF,
|
160
|
+
'tomato' => 0xFF6347FF,
|
161
|
+
'transparent' => 0x00000000,
|
162
|
+
'turquoise' => 0x40E0D0FF,
|
163
|
+
'violet' => 0xEE82EEFF,
|
164
|
+
'wheat' => 0xF5DEB3FF,
|
165
|
+
'white' => 0xFFFFFFFF,
|
166
|
+
'whitesmoke' => 0xF5F5F5FF,
|
167
|
+
'yellow' => 0xFFFF00FF,
|
168
|
+
'yellowgreen' => 0x9ACD32FF
|
169
|
+
}) do |color|
|
170
|
+
rgba = (0..3).map {|n| color >> (n << 3) & 0xff}.reverse
|
171
|
+
rgba[-1] = rgba[-1] / 255.0
|
172
|
+
rgba
|
173
|
+
end
|
174
|
+
|
175
|
+
# A hash from `[red, green, blue, alpha]` value arrays to color names.
|
170
176
|
COLOR_NAMES_REVERSE = map_hash(hash_to_a(COLOR_NAMES)) {|k, v| [v, k]}
|
171
177
|
|
172
178
|
# Constructs an RGB or HSL color object,
|
173
179
|
# optionally with an alpha channel.
|
174
|
-
#
|
180
|
+
#
|
175
181
|
# The RGB values must be between 0 and 255.
|
176
182
|
# The saturation and lightness values must be between 0 and 100.
|
177
183
|
# The alpha value must be between 0 and 1.
|
@@ -295,7 +301,7 @@ module Sass::Script
|
|
295
301
|
#
|
296
302
|
# @return [Fixnum]
|
297
303
|
def alpha
|
298
|
-
@attrs[:alpha]
|
304
|
+
@attrs[:alpha].to_f
|
299
305
|
end
|
300
306
|
|
301
307
|
# Returns whether this color object is translucent;
|
@@ -314,6 +320,14 @@ module Sass::Script
|
|
314
320
|
[red, green, blue].freeze
|
315
321
|
end
|
316
322
|
|
323
|
+
# Returns the red, green, blue, and alpha components of the color.
|
324
|
+
#
|
325
|
+
# @return [Array<Fixnum>] A frozen four-element array of the red, green,
|
326
|
+
# blue, and alpha values (respectively) of the color
|
327
|
+
def rgba
|
328
|
+
[red, green, blue, alpha].freeze
|
329
|
+
end
|
330
|
+
|
317
331
|
# Returns the hue, saturation, and lightness components of the color.
|
318
332
|
#
|
319
333
|
# @return [Array<Fixnum>] A frozen three-element array of the
|
@@ -322,6 +336,14 @@ module Sass::Script
|
|
322
336
|
[hue, saturation, lightness].freeze
|
323
337
|
end
|
324
338
|
|
339
|
+
# Returns the hue, saturation, lightness, and alpha components of the color.
|
340
|
+
#
|
341
|
+
# @return [Array<Fixnum>] A frozen four-element array of the hue,
|
342
|
+
# saturation, lightness, and alpha values (respectively) of the color
|
343
|
+
def hsla
|
344
|
+
[hue, saturation, lightness].freeze
|
345
|
+
end
|
346
|
+
|
325
347
|
# The SassScript `==` operation.
|
326
348
|
# **Note that this returns a {Sass::Script::Bool} object,
|
327
349
|
# not a Ruby boolean**.
|
@@ -490,10 +512,9 @@ module Sass::Script
|
|
490
512
|
#
|
491
513
|
# @return [String] The string representation
|
492
514
|
def to_s(opts = {})
|
493
|
-
return rgba_str if alpha?
|
494
515
|
return smallest if options[:style] == :compressed
|
495
|
-
return COLOR_NAMES_REVERSE[
|
496
|
-
hex_str
|
516
|
+
return COLOR_NAMES_REVERSE[rgba] if COLOR_NAMES_REVERSE[rgba]
|
517
|
+
return alpha? ? rgba_str : hex_str
|
497
518
|
end
|
498
519
|
alias_method :to_sass, :to_s
|
499
520
|
|
@@ -507,9 +528,9 @@ module Sass::Script
|
|
507
528
|
private
|
508
529
|
|
509
530
|
def smallest
|
510
|
-
|
511
|
-
return
|
512
|
-
color.size <=
|
531
|
+
small_explicit_str = alpha? ? rgba_str : hex_str.gsub(/^#(.)\1(.)\2(.)\3$/, '#\1\2\3')
|
532
|
+
return small_explicit_str unless (color = COLOR_NAMES_REVERSE[rgba]) &&
|
533
|
+
color.size <= small_explicit_str.size
|
513
534
|
return color
|
514
535
|
end
|
515
536
|
|
@@ -526,7 +547,7 @@ module Sass::Script
|
|
526
547
|
def piecewise(other, operation)
|
527
548
|
other_num = other.is_a? Number
|
528
549
|
if other_num && !other.unitless?
|
529
|
-
raise Sass::SyntaxError.new("Cannot add a number with units (#{other}) to a color (#{self}).")
|
550
|
+
raise Sass::SyntaxError.new("Cannot add a number with units (#{other}) to a color (#{self}).")
|
530
551
|
end
|
531
552
|
|
532
553
|
result = []
|
data/test/sass/functions_test.rb
CHANGED
@@ -379,8 +379,8 @@ class SassFunctionTest < Test::Unit::TestCase
|
|
379
379
|
assert_equal("rgba(0, 0, 0, 0.3)", evaluate("transparentize(rgba(0, 0, 0, 0.5), 0.2)"))
|
380
380
|
assert_equal("rgba(0, 0, 0, 0.1)", evaluate("transparentize(rgba(0, 0, 0, 0.2), 0.1)"))
|
381
381
|
assert_equal("rgba(0, 0, 0, 0.2)", evaluate("fade-out(rgba(0, 0, 0, 0.5), 0.3px)"))
|
382
|
-
assert_equal("
|
383
|
-
assert_equal("
|
382
|
+
assert_equal("transparent", evaluate("fade_out(rgba(0, 0, 0, 0.2), 0.2)"))
|
383
|
+
assert_equal("transparent", evaluate("transparentize(rgba(0, 0, 0, 0.2), 1)"))
|
384
384
|
assert_equal("rgba(0, 0, 0, 0.2)", evaluate("transparentize(rgba(0, 0, 0, 0.2), 0)"))
|
385
385
|
assert_equal("rgba(0, 0, 0, 0.2)", evaluate("transparentize($color: rgba(0, 0, 0, 0.2), $amount: 0)"))
|
386
386
|
assert_equal("rgba(0, 0, 0, 0.2)", evaluate("fade-out($color: rgba(0, 0, 0, 0.2), $amount: 0)"))
|
@@ -815,8 +815,8 @@ class SassFunctionTest < Test::Unit::TestCase
|
|
815
815
|
|
816
816
|
def test_grayscale
|
817
817
|
assert_equal("#bbbbbb", evaluate("grayscale(#abc)"))
|
818
|
-
assert_equal("
|
819
|
-
assert_equal("
|
818
|
+
assert_equal("grey", evaluate("grayscale(#f00)"))
|
819
|
+
assert_equal("grey", evaluate("grayscale(#00f)"))
|
820
820
|
assert_equal("white", evaluate("grayscale(white)"))
|
821
821
|
assert_equal("black", evaluate("grayscale(black)"))
|
822
822
|
assert_equal("black", evaluate("grayscale($color: black)"))
|
data/test/sass/script_test.rb
CHANGED
@@ -46,6 +46,8 @@ class SassScriptTest < Test::Unit::TestCase
|
|
46
46
|
assert_equal "white", resolve("white")
|
47
47
|
assert_equal "white", resolve("#ffffff")
|
48
48
|
assert_equal "#fffffe", resolve("white - #000001")
|
49
|
+
assert_equal "transparent", resolve("transparent")
|
50
|
+
assert_equal "transparent", resolve("rgba(0, 0, 0, 0)")
|
49
51
|
end
|
50
52
|
|
51
53
|
def test_rgba_color_literals
|
@@ -95,6 +97,7 @@ class SassScriptTest < Test::Unit::TestCase
|
|
95
97
|
assert_equal "navy", resolve("#000080", :style => :compressed)
|
96
98
|
assert_equal "navy #fff", resolve("#000080 white", :style => :compressed)
|
97
99
|
assert_equal "This color is #fff", resolve('"This color is #{ white }"', :style => :compressed)
|
100
|
+
assert_equal "transparent", resolve("rgba(0, 0, 0, 0)", :style => :compressed)
|
98
101
|
end
|
99
102
|
|
100
103
|
def test_compressed_comma
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 592302631
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 3
|
9
9
|
- 0
|
10
10
|
- alpha
|
11
|
-
-
|
12
|
-
version: 3.3.0.alpha.
|
11
|
+
- 149
|
12
|
+
version: 3.3.0.alpha.149
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Nathan Weizenbaum
|