Exemplo n.º 1
0
 /**
  * Copy a {@link Swatch}'s HSL values into a new float[].
  */
 private static float[] copyHslValues(Swatch color)
 {
     float[] newHsl = new float[3];
     Array.Copy(color.getHsl(), 0, newHsl, 0, 3);
     return(newHsl);
 }
Exemplo n.º 2
0
 /**
  * @return true if we have already selected {@code swatch}
  */
 private Boolean isAlreadySelected(Swatch swatch)
 {
     return(mVibrantSwatch == swatch || mDarkVibrantSwatch == swatch ||
            mLightVibrantSwatch == swatch || mMutedSwatch == swatch ||
            mDarkMutedSwatch == swatch || mLightMutedColor == swatch);
 }
Exemplo n.º 3
0
        /**
         * Try and generate any missing swatches from the swatches we did find.
         */
        private Boolean generateEmptySwatches()
        {
            if (mVibrantSwatch == null)
            {
                if (mDarkVibrantSwatch != null)
                {
                    float[] newHsl = copyHslValues(mDarkVibrantSwatch);
                    newHsl[2]      = TARGET_NORMAL_LUMA;
                    mVibrantSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
                else if (mLightVibrantSwatch != null)
                {
                    float[] newHsl = copyHslValues(mLightVibrantSwatch);
                    newHsl[2]      = TARGET_NORMAL_LUMA;
                    mVibrantSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
            }

            if (mDarkVibrantSwatch == null)
            {
                if (mVibrantSwatch != null)
                {
                    float[] newHsl = copyHslValues(mVibrantSwatch);
                    newHsl[2]          = TARGET_DARK_LUMA;
                    mDarkVibrantSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
                else if (mLightVibrantSwatch != null)
                {
                    float[] newHsl = copyHslValues(mLightVibrantSwatch);
                    newHsl[2]          = TARGET_DARK_LUMA;
                    mDarkVibrantSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
            }

            if (mLightVibrantSwatch == null)
            {
                if (mVibrantSwatch != null)
                {
                    float[] newHsl = copyHslValues(mVibrantSwatch);
                    newHsl[2]           = TARGET_LIGHT_LUMA;
                    mLightVibrantSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
                else if (mDarkVibrantSwatch != null)
                {
                    float[] newHsl = copyHslValues(mDarkVibrantSwatch);
                    newHsl[2]           = TARGET_LIGHT_LUMA;
                    mLightVibrantSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
            }

            if (mMutedSwatch == null)
            {
                if (mDarkMutedSwatch != null)
                {
                    float[] newHsl = copyHslValues(mDarkMutedSwatch);
                    newHsl[2]    = TARGET_NORMAL_LUMA;
                    mMutedSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
                else if (mLightMutedColor != null)
                {
                    float[] newHsl = copyHslValues(mLightMutedColor);
                    newHsl[2]    = TARGET_NORMAL_LUMA;
                    mMutedSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
            }

            if (mDarkMutedSwatch == null)
            {
                if (mMutedSwatch != null)
                {
                    float[] newHsl = copyHslValues(mMutedSwatch);
                    newHsl[2]        = TARGET_DARK_LUMA;
                    mDarkMutedSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
                else if (mLightMutedColor != null)
                {
                    float[] newHsl = copyHslValues(mLightMutedColor);
                    newHsl[2]        = TARGET_DARK_LUMA;
                    mDarkMutedSwatch = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
            }

            if (mLightMutedColor == null)
            {
                if (mMutedSwatch != null)
                {
                    float[] newHsl = copyHslValues(mMutedSwatch);
                    newHsl[2]        = TARGET_LIGHT_LUMA;
                    mLightMutedColor = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
                else if (mDarkMutedSwatch != null)
                {
                    float[] newHsl = copyHslValues(mDarkMutedSwatch);
                    newHsl[2]        = TARGET_LIGHT_LUMA;
                    mLightMutedColor = new Swatch(ColorUtils.HSLtoRGB(newHsl), 0);
                }
            }

            return(checkAnySwtchEmpty());
        }
Exemplo n.º 4
0
 private static Boolean shouldIgnoreColor(Swatch color)
 {
     return(shouldIgnoreColor(color.getHsl()));
 }