示例#1
0
 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()));
 }
示例#2
0
        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);
        }
示例#3
0
 /**
  * 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);
 }
示例#4
0
        /**
         * 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);
        }