Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db72e3b4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ignore more yellows and greens"

parents 54af450d 47e7cfd8
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -405,12 +405,13 @@ public class Tonal implements ExtractionType {
        return v - (float) Math.floor(v);
    }

    static class TonalPalette {
        final float[] h;
        final float[] s;
        final float[] l;
        final float minHue;
        final float maxHue;
    @VisibleForTesting
    public static class TonalPalette {
        public final float[] h;
        public final float[] s;
        public final float[] l;
        public final float minHue;
        public final float maxHue;

        TonalPalette(float[] h, float[] s, float[] l) {
            if (h.length != s.length || s.length != l.length) {
+18 −12
Original line number Diff line number Diff line
@@ -257,52 +257,58 @@
        <!-- Red Orange -->
        <range h="20, 40"
               s="0.7, 1"
               l="0.28, 0.643"/>
               l="0.2, 0.643"/>
        <range h="20, 40"
               s="0.3, 0.7"
               l="0.414, 0.561"/>
        <range h="20, 40"
               s="0, 3"
               s="0, 0.3"
               l="0.343, 0.584"/>
        <!-- Orange -->
        <range h="40, 60"
               s="0.7, 1"
               l="0.173, 0.349"/>
               l="0.173, 0.38"/>
        <range h="40, 60"
               s="0.3, 0.7"
               l="0.233, 0.427"/>
        <range h="40, 60"
               s="0, 0.3"
               l="0.231, 0.484"/>
               l="0.231, 0.48"/>
        <!-- Yellow 60 -->
        <range h="60, 80"
               s="0.7, 1"
               l="0.488, 0.737"/>
               l="0.15, 0.40"/>
        <range h="60, 80"
               s="0.3, 0.7"
               l="0.673, 0.837"/>
               l="0.15, 0.42"/>
        <range h="60, 80"
               s="0, 0.3"
               l="0.35, 0.57"/>
        <!-- Yellow Green 80 -->
        <range h="80, 100"
               s="0.7, 1"
               l="0.469, 0.61"/>
               l="0.36, 0.65"/>
        <range h="80, 100"
               s="0.3, 0.7"
               l="0.48, 0.57"/>
        <!-- Yellow green 100 -->
        <range h="100, 120"
               s="0.7, 1"
               l="0.388, 0.612"/>
               l="0.388, 0.67"/>
        <range h="100, 120"
               s="0.3, 0.7"
               l="0.424, 0.541"/>
               l="0.424, 0.58"/>
        <!-- Green -->
        <range h="120, 140"
               s="0.7, 1"
               l="0.375, 0.52"/>
               l="0.37, 0.65"/>
        <range h="120, 140"
               s="0.3, 0.7"
               l="0.435, 0.524"/>
               l="0.435, 0.58"/>
        <!-- Green Blue 140 -->
        <range h="140, 160"
               s="0.7, 1"
               l="0.496, 0.641"/>
               l="0.43, 0.641"/>
        <!-- Seaoam -->
        <range h="160, 180"
               s="0.7, 1"
+15 −0
Original line number Diff line number Diff line
@@ -98,6 +98,21 @@ public class TonalTest {
        assertTrue("Blacklisted colors are empty", config.getBlacklistedColors().size() > 1);
    }

    @Test
    public void tonal_rangeTest() {
        Tonal.ConfigParser config = new Tonal.ConfigParser(InstrumentationRegistry.getContext());
        for (Tonal.TonalPalette palette : config.getTonalPalettes()) {
            assertTrue("minHue should be >= to 0.", palette.minHue >= 0);
            assertTrue("maxHue should be <= to 360.", palette.maxHue <= 360);

            assertTrue("S should be >= to 0.", palette.s[0] >= 0);
            assertTrue("S should be <= to 1.", palette.s[1] <= 1);

            assertTrue("L should be >= to 0.", palette.l[0] >= 0);
            assertTrue("L should be <= to 1.", palette.l[1] <= 1);
        }
    }

    @Test
    public void tonal_blacklistTest() {
        // Make sure that palette generation will fail.