Merge pull request #7 from timhettler/master
Avoiding divide by zero error
Grady Kuhnline
9 years ago
0 | // Import the Compass Plugin | |
0 | 1 | //-------------------------------- |
1 | 2 | // Normal |
2 | 3 | //-------------------------------- |
367 | 368 | |
368 | 369 | $bm-hsv: nth($foreground-hsv, 1), nth($foreground-hsv, 2), nth($background-hsv, 3); |
369 | 370 | $bm-color: hsv-to-color($bm-hsv); |
370 | ||
371 | ||
371 | 372 | @return blend-normal(rgba(red($bm-color), green($bm-color), blue($bm-color), opacity($foreground)), $background); |
372 | 373 | } |
373 | 374 | |
417 | 418 | |
418 | 419 | $bm-hsv: nth($background-hsv, 1), nth($background-hsv, 2), nth($foreground-hsv, 3); |
419 | 420 | $bm-color: hsv-to-color($bm-hsv); |
420 | ||
421 | ||
421 | 422 | @return blend-normal(rgba(red($bm-color), green($bm-color), blue($bm-color), opacity($foreground)), $background); |
422 | 423 | } |
423 | 424 | |
430 | 431 | |
431 | 432 | $bm-hsv: nth($background-hsv, 1), nth($foreground-hsv, 2), nth($background-hsv, 3); |
432 | 433 | $bm-color: hsv-to-color($bm-hsv); |
433 | ||
434 | ||
434 | 435 | @return blend-normal(rgba(red($bm-color), green($bm-color), blue($bm-color), opacity($foreground)), $background); |
435 | 436 | } |
436 | 437 | |
469 | 470 | $ss: $s * $v; |
470 | 471 | $ll: (2 - $s) * $v; |
471 | 472 | |
472 | @if $ll <= 1 { | |
473 | @if $ll <= 1 and $ll != 0 { | |
473 | 474 | $ss: $ss / $ll; |
474 | 475 | } @else if ($ll == 2) { |
475 | 476 | $ss: 0; |
512 | 513 | } |
513 | 514 | |
514 | 515 | $v: ($ll + $ss) / 2; |
515 | $s: (2 * $ss) / ($ll + $ss); | |
516 | $s: if($ll + $ss == 0, 0, (2 * $ss) / ($ll + $ss)); | |
516 | 517 | |
517 | 518 | @return 360deg * $h / (3.1415 * 2), percentage(max(0, min(1, $s))), percentage(max(0, min(1, $v))); |
518 | 519 | } |