From 306644e58114c9eaa86d02f26f8fed71e37a4a18 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Thu, 12 Nov 2026 20:26:58 +0700 Subject: [PATCH] core: round avatar and pixel avatar corners --- crates/core/src/avatar.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/core/src/avatar.rs b/crates/core/src/avatar.rs index 2bbd9a5..2fc4333 100644 --- a/crates/core/src/avatar.rs +++ b/crates/core/src/avatar.rs @@ -92,12 +92,13 @@ impl gpui::Styled for Avatar { impl RenderOnce for Avatar { fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { let theme = cx.theme(); + let side = theme.sizes.resolve(self.size).avatar_size; + let radius = if self.fully_rounded { theme.radius.full } else { - theme.radius.control + theme.radius.sm }; - let side = theme.sizes.resolve(self.size).avatar_size; let base = h_flex() .id(ElementId::from(self.id.clone())) @@ -112,10 +113,12 @@ impl RenderOnce for Avatar { .refine_style(&self.style); match self.picture { - Some(url) => base.child(gpui::img(url).size_full()), + Some(url) => base.child(gpui::img(url).size_full().rounded(radius)), None => base.child(PixelAvatar { seed: fnv1a(self.id.as_bytes()), side, + radius, + fully_rounded: self.fully_rounded, }), } .into_any_element() @@ -127,6 +130,8 @@ impl RenderOnce for Avatar { struct PixelAvatar { seed: u64, side: gpui::Pixels, + radius: gpui::Pixels, + fully_rounded: bool, } impl RenderOnce for PixelAvatar { @@ -153,6 +158,12 @@ impl RenderOnce for PixelAvatar { .to_hsla() }; + let inset = if self.fully_rounded { + self.side / GRID_SIZE as f32 + } else { + gpui::Pixels::ZERO + }; + for row in 0..GRID_SIZE { for col in 0..GRID_SIZE { let value = pattern[row * GRID_SIZE + col]; @@ -176,6 +187,8 @@ impl RenderOnce for PixelAvatar { .grid_rows(GRID_SIZE as u16) .size(self.side) .flex_none() + .p(inset) + .rounded(self.radius) .bg(gpui::Hsla { a: PIXEL_AVATAR_TINT_ALPHA, ..main