summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2019-08-09 10:35:56 -0700
committerWill Thompson <wjt@endlessos.org>2021-01-08 11:32:02 +0000
commit3908fa39f70b7b6285dbaaa8a1218df61229708c (patch)
tree2a3e582d8e98d51ffeb5fe80306b719e7c425005
parenta97a0af38e00310dfdb30795539179fb3c647b2c (diff)
downloadgnome-initial-setup-3908fa39f70b7b6285dbaaa8a1218df61229708c.tar.gz
Add darker border to generated avatar
This was part of the original designs for this feature (https://gitlab.gnome.org/Teams/Design/os-mockups/raw/master/initial-setup/user-account-default-picture.png) and makes it look a bit more deliberate if there's no text in the avatar.
-rw-r--r--gnome-initial-setup/pages/account/um-utils.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gnome-initial-setup/pages/account/um-utils.c b/gnome-initial-setup/pages/account/um-utils.c
index a120382..7ffa1dc 100644
--- a/gnome-initial-setup/pages/account/um-utils.c
+++ b/gnome-initial-setup/pages/account/um-utils.c
@@ -484,6 +484,7 @@ generate_username_choices (const gchar *name,
}
#define IMAGE_SIZE 512
+#define IMAGE_BORDER_WIDTH 7.2 /* At least 1px when avatar rendered at 72px */
/* U+1F464 "bust in silhouette"
* U+FE0E Variant Selector 15 to force text style (monochrome) emoji
@@ -583,6 +584,13 @@ get_color_for_name (const gchar *name)
return color;
}
+static void
+darken_color (GdkRGBA *color, gdouble fraction) {
+ color->red = CLAMP (color->red + color->red * fraction, 0, 255);
+ color->green = CLAMP (color->green + color->green * fraction, 0, 255);
+ color->blue = CLAMP (color->blue + color->blue * fraction, 0, 255);
+}
+
cairo_surface_t *
generate_user_picture (const gchar *name) {
PangoFontDescription *font_desc;
@@ -603,6 +611,13 @@ generate_user_picture (const gchar *name) {
cairo_set_source_rgb (cr, color.red/255.0, color.green/255.0, color.blue/255.0);
cairo_fill (cr);
+ cairo_arc (cr, IMAGE_SIZE / 2, IMAGE_SIZE / 2, IMAGE_SIZE / 2 - IMAGE_BORDER_WIDTH / 2,
+ 0, 2 * G_PI);
+ darken_color (&color, -0.3);
+ cairo_set_source_rgb (cr, color.red / 255.0, color.green / 255.0, color.blue / 255.0);
+ cairo_set_line_width (cr, IMAGE_BORDER_WIDTH);
+ cairo_stroke (cr);
+
/* Draw the initials on top */
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
layout = pango_cairo_create_layout (cr);