color-schemer 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ Compass::Frameworks.register("color-schemer", :path => "#{File.dirname(__FILE__)
4
4
 
5
5
  module ColorSchemer
6
6
 
7
- VERSION = "0.2.2"
7
+ VERSION = "0.2.3"
8
8
  DATE = "2011-09-15"
9
9
 
10
10
  end
@@ -1,45 +1,20 @@
1
1
  @function cs-colorblind($color, $mode: $cs-colorblind) {
2
2
 
3
- $severity: 66%;
3
+ // Refrence: http://www.w3.org/TR/AERT#color-contrast
4
4
 
5
- // Protanopia - no red
6
- @if $mode == protanopia {
7
- @return $color - #f00;
8
- }
9
-
10
- // Deuteranopia - no green
5
+ // Deuteranopia
11
6
  @if $mode == deuteranopia {
12
- @return $color - #0f0;
13
- }
14
-
15
- // Tritanopia - no blue
16
- @if $mode == tritanopia {
17
- @return $color - #00f;
18
- }
19
-
20
- // Protanomaly - low red
21
- @if $mode == protanomaly {
22
- @return $color - shade(#f00, 100% - $severity);
23
- }
24
-
25
- // Deuteranomaly - low green
26
- @if $mode == deuteranomaly {
27
- @return $color - shade(#0f0, 100% - $severity);
28
- }
29
-
30
- // Tritanomaly - low blue
31
- @if $mode == tritanomaly {
32
- @return $color - shade(#00f, 100% - $severity);
7
+ @return $color;
33
8
  }
34
9
 
35
- // Typical Monochromacy
36
- @if $mode == monochromacy {
37
- @return desaturate($color, 100%);
10
+ // Protanopia
11
+ @if $mode == protanopia {
12
+ @return $color;
38
13
  }
39
14
 
40
- // Atypical Monochromacy
41
- @if $mode == amonochromacy {
42
- @return desaturate($color, $severity);
15
+ // Tritanopia
16
+ @if $mode == tritanopia {
17
+ @return $color;
43
18
  }
44
19
 
45
20
 
@@ -11,24 +11,17 @@ $ryb-interpolation: #FF0000 #FF4900 #FF7400 #FF9200 #FFAA00 #FFBF00 #FFD300 #FFE
11
11
  }
12
12
 
13
13
  // Find the RYB hue instead of RGB hue of a color.
14
- // slow dumb loop at the moment.
15
- @function ryb-hue($color) {
16
-
17
- // find offset
18
- $hue: find-ryb(hue($color)) - hue($color);
19
14
 
20
- // apply the offset difference
21
- $hue: hue($color) - $hue;
15
+ // map of the RYB offset
16
+ $ryb-offset: 0 1 2 3 5 6 7 8 9 10 11 13 14 15 16 17 18 19 19 20 21 21 22 23 23 24 25 25 26 27 27 28 28 29 29 30 30 31 31 32 32 32 33 33 34 34 35 35 35 36 36 37 37 37 38 38 38 39 39 40 40 40 41 41 41 42 42 42 43 43 43 44 44 44 45 45 45 46 46 46 47 47 47 47 48 48 48 49 49 49 50 50 50 51 51 51 52 52 52 53 53 53 54 54 54 55 55 55 56 56 56 57 57 57 58 58 59 59 59 60 60 61 61 62 63 63 64 65 65 66 67 68 68 69 70 70 71 72 72 73 73 74 75 75 76 77 77 78 79 79 80 81 82 82 83 84 85 86 87 88 88 89 90 91 92 93 95 96 98 100 102 104 105 107 109 111 113 115 116 118 120 122 125 127 129 131 134 136 138 141 143 145 147 150 152 154 156 158 159 161 163 165 166 168 170 171 173 175 177 178 180 182 184 185 187 189 191 192 194 196 198 199 201 203 205 206 207 208 209 210 212 213 214 215 216 217 218 219 220 221 222 223 224 226 227 228 229 230 232 233 234 235 236 238 239 240 241 242 243 244 245 246 247 248 249 250 251 251 252 253 254 255 256 257 257 258 259 260 260 261 262 263 264 264 265 266 267 268 268 269 270 271 272 273 274 274 275 276 277 278 279 280 282 283 284 286 287 289 290 292 293 294 296 297 299 300 302 303 305 307 309 310 312 314 316 317 319 321 323 324 326 327 328 329 330 331 332 333 334 336 337 338 339 340 341 342 343 344 345 347 348 349 350 352 353 354 355 356 358 359 360;
22
17
 
23
- // Make within the range of 360 if not already.
24
- @while $hue >= 360deg {
25
- $hue: $hue - 360;
26
- }
27
- @while $hue < 0deg {
28
- $hue: $hue + 360;
18
+ // loop through the map to find the matching hue.
19
+ @function ryb-hue($color) {
20
+ @for $i from 1 through length($ryb-offset) {
21
+ @if nth($ryb-offset, $i) > hue($color) {
22
+ @return $i - 2deg;
23
+ }
29
24
  }
30
-
31
- @return $hue;
32
25
  }
33
26
 
34
27
  // Changes the hue of a color.
@@ -42,19 +35,7 @@ $ryb-interpolation: #FF0000 #FF4900 #FF7400 #FF9200 #FFAA00 #FFBF00 #FFD300 #FFE
42
35
  // Start at the current hue and loop in the adjustment.
43
36
  $hue-adjust: (ryb-hue($color) + $degrees) / 1deg;
44
37
 
45
- $lightness: lightness($color);
46
- $saturation: saturation($color);
47
-
48
- // Set hue of new color
49
- $new-color: set-hue(red, hue(cs-interpolate($hue-adjust)));
50
-
51
- // Add back lightness
52
- $new-color: set-lightness($new-color, $lightness);
53
-
54
- // Add back saturation
55
- $new-color: set-saturation($new-color, $saturation);
56
-
57
- @return $new-color;
38
+ @return hsl(hue(cs-interpolate($hue-adjust)), saturation($color), lightness($color));
58
39
  }
59
40
 
60
41
  @function ryba($red, $yellow, $blue, $alpha) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color-schemer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: