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 mUsedColors.Add(maxScoreSwatch.GetRgb(), true); } return(maxScoreSwatch); }
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(); bool a = false; mUsedColors.TryGetValue(swatch.GetRgb(), out a); return(hsl[1] >= target.GetMinimumSaturation() && hsl[1] <= target.GetMaximumSaturation() && hsl[2] >= target.GetMinimumLightness() && hsl[2] <= target.GetMaximumLightness() && !a); }
/// <summary> /// Returns the selected color for the given target from the palette as an RGB packed int. /// </summary> /// <param name="target"></param> /// <param name="defaultColor"></param> /// <returns></returns> public int GetColorForTarget(Target target, int defaultColor = DefaultColorValue) { Swatch swatch = GetSwatchForTarget(target); return(swatch != null?swatch.GetRgb() : defaultColor); }
/// <summary> /// Returns the color of the dominant swatch from the palette, as an RGB packed int. /// </summary> /// <param name="defaultColor">value to return if the swatch isn't available</param> /// <returns></returns> public int GetDominantColorValue(int defaultColor = DefaultColorValue) { return(mDominantSwatch != null?mDominantSwatch.GetRgb() : defaultColor); }
private bool ShouldIgnoreColor(Swatch color) { return(ShouldIgnoreColor(color.GetRgb(), color.GetHsl())); }