From 0789a7d67f3f610108232fc13a0642e94bb03258 Mon Sep 17 00:00:00 2001 From: James O'Leary Date: Wed, 22 Sep 2021 10:30:15 -0400 Subject: [PATCH 1/3] [CP] Use chroma max of 40 at tone 90 Bug: 199389758 Test: atest ColorSchemeTest Change-Id: I295ef3a6ad4d64c26ef150c853ec9875cf2ad8ff --- .../monet/src/com/android/systemui/monet/Shades.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/Shades.java b/packages/SystemUI/monet/src/com/android/systemui/monet/Shades.java index 498b7dd8658cf..aab3538e3c4c1 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/Shades.java +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/Shades.java @@ -53,10 +53,15 @@ public class Shades { */ public static @ColorInt int[] of(float hue, float chroma) { int[] shades = new int[12]; - shades[0] = ColorUtils.CAMToColor(hue, chroma, 99); - shades[1] = ColorUtils.CAMToColor(hue, chroma, 95); + // At tone 90 and above, blue and yellow hues can reach a much higher chroma. + // To preserve a consistent appearance across all hues, use a maximum chroma of 40. + shades[0] = ColorUtils.CAMToColor(hue, Math.min(40f, chroma), 99); + shades[1] = ColorUtils.CAMToColor(hue, Math.min(40f, chroma), 95); for (int i = 2; i < 12; i++) { float lStar = (i == 6) ? MIDDLE_LSTAR : 100 - 10 * (i - 1); + if (lStar >= 90) { + chroma = Math.min(40f, chroma); + } shades[i] = ColorUtils.CAMToColor(hue, chroma, lStar); } return shades; From 5ebb0fdc76a19cfcde168f146717cd0e3fba0eee Mon Sep 17 00:00:00 2001 From: James O'Leary Date: Wed, 22 Sep 2021 10:31:19 -0400 Subject: [PATCH 2/3] [CP] If there are > 4 colors, maximize difference Bug: 199389755 Test: atest ColorSchemeTest Change-Id: I4c2d76c9c92e96ca8259a4fc991e9e52b9e97ba9 --- .../com/android/systemui/monet/ColorScheme.kt | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt index b8039e13b2a5d..a5e5a8781a0e5 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt @@ -168,26 +168,34 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) { (totalPopulationMeaningless || proportion > 0.01) } // Sort the colors by score, from high to low. - val seeds = mutableListOf() val intToScoreIntermediate = filteredIntToCam.mapValues { score(it.value, intToHueProportion[it.key]!!) } val intToScore = intToScoreIntermediate.entries.toMutableList() intToScore.sortByDescending { it.value } - // Go through the colors, from high score to low score. If there isn't already a seed - // color with a hue close to color being examined, add the color being examined to the - // seed colors. - for (entry in intToScore) { - val int = entry.key - val existingSeedNearby = seeds.find { - val hueA = intToCam[int]!!.hue - val hueB = intToCam[it]!!.hue - hueDiff(hueA, hueB) < 15 } != null - if (existingSeedNearby) { - continue + // Go through the colors, from high score to low score. + // If the color is distinct in hue from colors picked so far, pick the color. + // Iteratively decrease the amount of hue distinctness required, thus ensuring we + // maximize difference between colors. + val minimumHueDistance = 15 + val seeds = mutableListOf() + maximizeHueDistance@ for (i in 90 downTo minimumHueDistance step 1) { + seeds.clear() + for (entry in intToScore) { + val int = entry.key + val existingSeedNearby = seeds.find { + val hueA = intToCam[int]!!.hue + val hueB = intToCam[it]!!.hue + hueDiff(hueA, hueB) < i } != null + if (existingSeedNearby) { + continue + } + seeds.add(int) + if (seeds.size >= 4) { + break@maximizeHueDistance + } } - seeds.add(int) } if (seeds.isEmpty()) { From 323060e996d751407390f302868da1c4d0e21825 Mon Sep 17 00:00:00 2001 From: James O'Leary Date: Thu, 23 Sep 2021 13:29:51 -0400 Subject: [PATCH 3/3] [CP] Adjust chroma/lstar filters for seed colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a set of wallpapers, namely some Landscape wallpapers, that don’t have any colors extracted from them. The wallpaper visually has some color to it, but, the chroma of those colors is low enough that they get filtered out by the low chroma filter. Lower the chroma filter from 15 to 5, and eliminate the tone filter (previously, L >= 10). Scoring compensates for this by prioritizing chromatic colors, thus ensuring these low-chroma options are only used if there’s no better options. Bug: b/200675148 Test: Push landscape wallpapers #912, #914, and #924 from Monet Studio to device. Verify color choices reflect wallpaper and aren't just fallback colors. Change-Id: I080e6cb51978638462a8b0ab41340aa11d495c93 --- .../com/android/systemui/monet/ColorScheme.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt index a5e5a8781a0e5..e026012f9de8b 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt @@ -37,8 +37,7 @@ const val NEUTRAL2_CHROMA = 8.0f const val GOOGLE_BLUE = 0xFF1b6ef3.toInt() -const val MIN_CHROMA = 15 -const val MIN_LSTAR = 10 +const val MIN_CHROMA = 5 public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) { @@ -75,7 +74,14 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) { get() = ColorUtils.setAlphaComponent(if (darkTheme) accent1[2] else accent1[6], 0xFF) init { - val seedArgb = if (seed == Color.TRANSPARENT) GOOGLE_BLUE else seed + val proposedSeedCam = Cam.fromInt(seed) + val seedArgb = if (seed == Color.TRANSPARENT) { + GOOGLE_BLUE + } else if (proposedSeedCam.chroma < 5) { + GOOGLE_BLUE + } else { + seed + } val camSeed = Cam.fromInt(seedArgb) val hue = camSeed.hue val chroma = camSeed.chroma.coerceAtLeast(ACCENT1_CHROMA) @@ -129,9 +135,7 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) { val distinctColors = wallpaperColors.mainColors.map { it.toArgb() }.distinct().filter { - val cam = Cam.fromInt(it) - val lstar = lstarFromInt(it) - cam.chroma >= MIN_CHROMA && lstar >= MIN_LSTAR + Cam.fromInt(it).chroma >= MIN_CHROMA }.toList() if (distinctColors.isEmpty()) { @@ -164,7 +168,7 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) { val cam = it.value val lstar = lstarFromInt(it.key) val proportion = intToHueProportion[it.key]!! - cam.chroma >= MIN_CHROMA && lstar >= MIN_LSTAR && + cam.chroma >= MIN_CHROMA && (totalPopulationMeaningless || proportion > 0.01) } // Sort the colors by score, from high to low.