fromColor method

ColorModel fromColor(
  1. Color color
)

Converts color to a ColorModel in this color space.

Implementation

ColorModel fromColor(Color color) {
  late ColorModel newColor;

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

  return newColor;
}