Codebase list compass-blend-modes-plugin / f5b77d3
Merge pull request #7 from timhettler/master Avoiding divide by zero error Grady Kuhnline 9 years ago
2 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
00 module Compass
11 module BlendModes
2 VERSION = '0.0.2'
2 VERSION = '0.0.3'
33 end
44 end
0 // Import the Compass Plugin
01 //--------------------------------
12 // Normal
23 //--------------------------------
367368
368369 $bm-hsv: nth($foreground-hsv, 1), nth($foreground-hsv, 2), nth($background-hsv, 3);
369370 $bm-color: hsv-to-color($bm-hsv);
370
371
371372 @return blend-normal(rgba(red($bm-color), green($bm-color), blue($bm-color), opacity($foreground)), $background);
372373 }
373374
417418
418419 $bm-hsv: nth($background-hsv, 1), nth($background-hsv, 2), nth($foreground-hsv, 3);
419420 $bm-color: hsv-to-color($bm-hsv);
420
421
421422 @return blend-normal(rgba(red($bm-color), green($bm-color), blue($bm-color), opacity($foreground)), $background);
422423 }
423424
430431
431432 $bm-hsv: nth($background-hsv, 1), nth($foreground-hsv, 2), nth($background-hsv, 3);
432433 $bm-color: hsv-to-color($bm-hsv);
433
434
434435 @return blend-normal(rgba(red($bm-color), green($bm-color), blue($bm-color), opacity($foreground)), $background);
435436 }
436437
469470 $ss: $s * $v;
470471 $ll: (2 - $s) * $v;
471472
472 @if $ll <= 1 {
473 @if $ll <= 1 and $ll != 0 {
473474 $ss: $ss / $ll;
474475 } @else if ($ll == 2) {
475476 $ss: 0;
512513 }
513514
514515 $v: ($ll + $ss) / 2;
515 $s: (2 * $ss) / ($ll + $ss);
516 $s: if($ll + $ss == 0, 0, (2 * $ss) / ($ll + $ss));
516517
517518 @return 360deg * $h / (3.1415 * 2), percentage(max(0, min(1, $s))), percentage(max(0, min(1, $v)));
518519 }