cmykToHex function

String cmykToHex(
  1. CMYK cmyk
)

Implementation

String cmykToHex(CMYK cmyk) {
  double c = cmyk.c / 100;
  double m = cmyk.m / 100;
  double y = cmyk.y / 100;
  double k = cmyk.k / 100;
  Function toHex = (double x) {
    var hex = (x * 255).round().toRadixString(16);
    return hex.length == 1 ? '0' + hex : hex;
  };
  return "#" +
      toHex((1 - c) * (1 - k)) +
      toHex((1 - m) * (1 - k)) +
      toHex((1 - y) * (1 - k));
}