toSpace method

SassColor toSpace(
  1. ColorSpace space, {
  2. bool legacyMissing = true,
})

Converts this color to space.

If legacyMissing is false, this will convert missing channels in legacy color spaces to zero if a conversion occurs. Otherwise, they remain missing after the conversion.

Implementation

SassColor toSpace(ColorSpace space, {bool legacyMissing = true}) {
  if (this.space == space) return this;

  var converted = this
      .space
      .convert(space, channel0OrNull, channel1OrNull, channel2OrNull, alpha);
  return !legacyMissing &&
          converted.isLegacy &&
          (converted.isChannel0Missing ||
              converted.isChannel1Missing ||
              converted.isChannel2Missing ||
              converted.isAlphaMissing)
      ? SassColor.forSpaceInternal(converted.space, converted.channel0,
          converted.channel1, converted.channel2, converted.alpha)
      : converted;
}