This commit is contained in:
2026-09-04 17:12:52 +07:00
parent 1d224218df
commit 1496b7afeb
24 changed files with 270 additions and 645 deletions
+4 -3
View File
@@ -14,6 +14,9 @@ const ACCENT_PROBABILITY: f32 = 0.25;
/// Each left-half cell is mirrored to a right-half one.
const MIN_FILLED: usize = 5;
/// Side length of the avatar in pixels, no setter.
const AVATAR_SIZE: Pixels = px(16.);
/// A deterministic, offline pixel-art avatar.
/// An 8×8 grid with horizontal mirror symmetry.
/// Seeded from a stable string such as the repository id and owner public key.
@@ -21,7 +24,6 @@ const MIN_FILLED: usize = 5;
#[derive(IntoElement)]
pub struct PixelAvatar {
seed: u64,
size: Pixels,
style: StyleRefinement,
}
@@ -31,7 +33,6 @@ impl PixelAvatar {
pub fn new(seed: impl AsRef<str>) -> Self {
Self {
seed: fnv1a(seed.as_ref().as_bytes()),
size: px(16.),
style: StyleRefinement::default(),
}
}
@@ -79,7 +80,7 @@ impl RenderOnce for PixelAvatar {
.grid()
.grid_cols(GRID_SIZE as u16)
.grid_rows(GRID_SIZE as u16)
.size(self.size)
.size(AVATAR_SIZE)
.flex_shrink_0()
.overflow_hidden()
.bg(main.opacity(0.16))