private bool ShouldBeScoredForTarget(Swatch swatch, Target target) { // Check whether the HSL values are within the correct ranges, and this color hasn't // been used yet. float[] hsl = swatch.GetHsl(); return(hsl[1] >= target.GetMinimumSaturation() && hsl[1] <= target.GetMaximumSaturation() && hsl[2] >= target.GetMinimumLightness() && hsl[2] <= target.GetMaximumLightness() && !_usedColors.Get(swatch.GetArgb())); }
private Swatch GenerateScoredTarget(Target target) { Swatch maxScoreSwatch = GetMaxScoredSwatchForTarget(target); if (maxScoreSwatch != null && target.IsExclusive()) { // If we have a swatch, and the target is exclusive, add the color to the used list _usedColors.Append(maxScoreSwatch.GetArgb(), true); } return(maxScoreSwatch); }
/** * Returns the color of the dominant swatch from the palette, as an RGB packed int. * * @param defaultColor value to return if the swatch isn't available * @see #getDominantSwatch() */ public Color GetDominantColor(Color defaultColor) { return(_dominantSwatch?.GetArgb() ?? defaultColor); }
/** * Returns the selected color for the given target from the palette as an RGB packed int. * * @param defaultColor value to return if the swatch isn't available */ private Color GetColorForTarget(Target target, Color defaultColor) { Swatch swatch = GetSwatchForTarget(target); return(swatch?.GetArgb() ?? defaultColor); }