Skip to content

Instantly share code, notes, and snippets.

@rasshofer
Created October 16, 2014 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasshofer/d7c872f1e30861b34285 to your computer and use it in GitHub Desktop.
Save rasshofer/d7c872f1e30861b34285 to your computer and use it in GitHub Desktop.
Convert CMYK to RGB within SCSS
@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);
}
div {
color: cmyk(0, 92, 79, 0);
}
@rasshofer
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment