mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
[color] allow alpha to omitted when converting from strings
Parse #rgb and #rrggbb in addition to forms with the alpha channel specified. This allows conversion of colour strings from documents such as CSS where the alpha channel is not specified when using '#' notation.
This commit is contained in:
parent
9e03d92316
commit
eb8daac4b0
@ -430,6 +430,28 @@ clutter_color_from_string (ClutterColor *color,
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
else if (strlen (str) == 7)
|
||||||
|
{
|
||||||
|
/* #rrggbb */
|
||||||
|
color->red = (result >> 24) & 0xff;
|
||||||
|
color->green = (result >> 16) & 0xff;
|
||||||
|
color->blue = (result >> 8) & 0xff;
|
||||||
|
|
||||||
|
color->alpha = 0xff;
|
||||||
|
}
|
||||||
|
else if (strlen (str) == 4)
|
||||||
|
{
|
||||||
|
/* #rgb */
|
||||||
|
color->red = ((result >> 12) & 0xf);
|
||||||
|
color->green = ((result >> 8) & 0xf);
|
||||||
|
color->blue = ((result >> 4) & 0xf);
|
||||||
|
|
||||||
|
color->red = (color->red << 4) | color->red;
|
||||||
|
color->green = (color->green << 4) | color->green;
|
||||||
|
color->blue = (color->blue << 4) | color->blue;
|
||||||
|
|
||||||
|
color->alpha = 0xff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user