Created
October 16, 2014 16:23
-
-
Save rasshofer/d7c872f1e30861b34285 to your computer and use it in GitHub Desktop.
Convert CMYK to RGB within SCSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@function cmyk($c, $m, $y, $k) { | |
$c: $c / 100; | |
$m: $m / 100; | |
$y: $y / 100; | |
$k: $k / 100; | |
$r: 255 * (1 - $c) * (1 - $k); | |
$g: 255 * (1 - $m) * (1 - $k); | |
$b: 255 * (1 - $y) * (1 - $k); | |
@return rgb($r, $g, $b); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div { | |
color: cmyk(0, 92, 79, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please note that converting colors from CMYK to RGB isn’t easy at all and that the resulting colors may look radically different compared to the original CMYK colors. This function simply makes use of a common conversion algorithm. However, this algorithm may convert a CMYK color to an RGB color that is outside of the CMYK color gamut.