from method

ColorModel from(
  1. ColorModel color
)

Converts color to this color space.

Implementation

ColorModel from(cm.ColorModel color) {
  late ColorModel newColor;

  switch (this) {
    case ColorSpace.cmyk:
      newColor = CmykColor.from(color);
      break;
    case ColorSpace.hsb:
      newColor = HsbColor.from(color);
      break;
    case ColorSpace.hsi:
      newColor = HsiColor.from(color);
      break;
    case ColorSpace.hsl:
      newColor = HslColor.from(color);
      break;
    case ColorSpace.hsp:
      newColor = HspColor.from(color);
      break;
    case ColorSpace.lab:
      newColor = LabColor.from(color);
      break;
    case ColorSpace.oklab:
      newColor = OklabColor.from(color);
      break;
    case ColorSpace.rgb:
      newColor = RgbColor.from(color);
      break;
    case ColorSpace.xyz:
      newColor = XyzColor.from(color);
      break;
  }

  return newColor;
}