… | |
… | |
740 | { |
740 | { |
741 | rgba c; |
741 | rgba c; |
742 | char eos; |
742 | char eos; |
743 | int skip; |
743 | int skip; |
744 | |
744 | |
|
|
745 | c.a = rgba::MAX_CC; |
|
|
746 | |
745 | // parse the nonstandard "[alphapercent]" prefix |
747 | // parse the nonstandard "[alphapercent]" prefix |
746 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
748 | if (1 <= sscanf (name, "[%hd]%n", &c.a, &skip)) |
747 | { |
749 | { |
748 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
750 | c.a = lerp<int, int, int> (0, rgba::MAX_CC, c.a); |
749 | name += skip; |
751 | name += skip; |
750 | } |
752 | } |
751 | else |
|
|
752 | c.a = rgba::MAX_CC; |
|
|
753 | |
753 | |
754 | // parse the non-standard "#aarrggbb" format |
|
|
755 | if (name[0] == '#' && strlen (name) == 1+2+2+2+2 && 4 == sscanf (name+1, "%2hx%2hx%2hx%2hx%c", &c.a, &c.r, &c.g, &c.b, &eos)) |
|
|
756 | { |
|
|
757 | c.r <<= 8; |
|
|
758 | c.g <<= 8; |
|
|
759 | c.b <<= 8; |
|
|
760 | c.a <<= 8; |
|
|
761 | } |
|
|
762 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
754 | // parse the non-standard "rgba:rrrr/gggg/bbbb/aaaa" format |
763 | else if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) |
755 | if (strlen (name) != 4+5*4 || 4 != sscanf (name, "rgba:%4hx/%4hx/%4hx/%4hx%c", &c.r, &c.g, &c.b, &c.a, &eos)) |
764 | { |
756 | { |
765 | XColor xc; |
757 | XColor xc; |
766 | |
758 | |
767 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
759 | if (XParseColor (screen->dpy, screen->cmap, name, &xc)) |
768 | { |
760 | { |