@VisibleForTesting
    static int parseRgb(Slice color)
    {
        if (color.length() != 4 || color.getByte(0) != '#') {
            return -1;
        }

        int red = Character.digit((char) color.getByte(1), 16);
        int green = Character.digit((char) color.getByte(2), 16);
        int blue = Character.digit((char) color.getByte(3), 16);

        if (red == -1 || green == -1 || blue == -1) {
            return -1;
        }

        // replicate the nibbles to turn a color of the form #rgb => #rrggbb (css semantics)
        red = (red << 4) | red;
        green = (green << 4) | green;
        blue = (blue << 4) | blue;

        return (int) rgb(red, green, blue);
    }
@Test
    public void testParseRgb()
    {
        assertEquals(parseRgb(toSlice("#000")), 0x00_00_00);
        assertEquals(parseRgb(toSlice("#FFF")), 0xFF_FF_FF);
        assertEquals(parseRgb(toSlice("#F00")), 0xFF_00_00);
        assertEquals(parseRgb(toSlice("#0F0")), 0x00_FF_00);
        assertEquals(parseRgb(toSlice("#00F")), 0x00_00_FF);
        assertEquals(parseRgb(toSlice("#700")), 0x77_00_00);
        assertEquals(parseRgb(toSlice("#070")), 0x00_77_00);
        assertEquals(parseRgb(toSlice("#007")), 0x00_00_77);

        assertEquals(parseRgb(toSlice("#cde")), 0xCC_DD_EE);
    }