protected Color ResolveColor(string hexColor) { var resultColor = DefaultGridLinesColor; if (string.IsNullOrEmpty(hexColor)) { return(resultColor); } var colorObject = model.CreateInstance(model.Types[ChartingConstants.HexColorDataType]); colorObject[ChartingConstants.HexColorPropertyName] = hexColor; return(colorConverter.Convert(colorObject)); }
/// <summary> /// Transforms XYZ color to destination reference white. /// </summary> public XYZ Transform(XYZ sourceColor, XYZ sourceWhitePoint, XYZ targetWhitePoint) { if (sourceColor == null) { throw new ArgumentNullException(nameof(sourceColor)); } if (sourceWhitePoint == null) { throw new ArgumentNullException(nameof(sourceWhitePoint)); } if (targetWhitePoint == null) { throw new ArgumentNullException(nameof(targetWhitePoint)); } if (sourceWhitePoint.Equals(targetWhitePoint)) { return(sourceColor); } var sourceColorLMS = _conversionToLMS.Convert(sourceColor); if (sourceWhitePoint != _lastSourceWhitePoint || targetWhitePoint != _lastTargetWhitePoint) { var sourceWhitePointLMS = _conversionToLMS.Convert(sourceWhitePoint); var targetWhitePointLMS = _conversionToLMS.Convert(targetWhitePoint); _cachedDiagonalMatrix = Matrix.Diagonal(targetWhitePointLMS.L / sourceWhitePointLMS.L, targetWhitePointLMS.M / sourceWhitePointLMS.M, targetWhitePointLMS.S / sourceWhitePointLMS.S); _lastSourceWhitePoint = sourceWhitePoint; _lastTargetWhitePoint = targetWhitePoint; } var targetColorLMS = new LMS(_cachedDiagonalMatrix.Multiply(sourceColorLMS.Vector)); var targetColor = _conversionToXYZ.Convert(targetColorLMS); return(targetColor); }
public double ColourfulConvert() { return(ColourfulConverter.Convert(XYZColor).L); }
public RGBColor ColourfulConvert() { return(ColourfulConverter.Convert(RGBColor)); }
/// <summary> /// See https://en.wikipedia.org/wiki/CIELAB_color_space /// </summary> private static LabColor ToLabColor(int r, int g, int b) => converter.Convert(new RGBColor((double)r / 255, (double)g / 255, (double)b / 255));