use crate::config::PlayerThumbStyle; use crate::engine::theme::YmPalette; use crate::engine::types::{Color, Pos2, Rect, Vec2}; use crate::engine::{css_rgba, UiContext}; use crate::icons::Icon; /// Draws the progress trail + live animated companion on the top edge of `PlayerBar`. /// Called only when `style != PlayerThumbStyle::Standard`. #[allow(clippy::too_many_arguments)] pub fn render_player_bar_companion( ctx: &mut UiContext, pal: &YmPalette, style: PlayerThumbStyle, bar_left: f32, bar_right: f32, bar_y: f32, progress: f32, playing: bool, time: f32, ) { let frac = progress.clamp(0.0, 1.0); let track_w = (bar_right - bar_left).max(1.0); let fill_x = bar_left + track_w * frac; let anim_t = if playing { time } else { 0.0 }; // Subtle base track along top edge let track_r = Rect::from_xywh(bar_left, bar_y - 1.5, track_w, 3.0); ctx.dl().push_rect(track_r, 1.5, css_rgba(255, 255, 255, 34)); // Themed progress trail behind the companion let fill_w = (fill_x - bar_left).max(0.0); if fill_w > 1.0 { match style { PlayerThumbStyle::Standard => {} PlayerThumbStyle::Duck => { ctx.dl() .push_rect(Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0), 1.5, pal.yellow); } PlayerThumbStyle::Car => { ctx.dl().push_rect( Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0), 1.5, Color::rgb(0xE8, 0x22, 0x38), ); // Tiny drifting exhaust puffs while driving if playing && fill_w > 48.0 { for k in 0..3 { let phase = ((anim_t * 2.4 + k as f32 * 0.33) % 1.0).clamp(0.0, 1.0); let px = fill_x - 30.0 - phase * 24.0; let py = bar_y - 5.0 - phase * 6.0; let a = ((1.0 - phase) * 90.0).round() as u8; if px > bar_left { ctx.dl() .push_circle(Pos2::new(px, py), 2.0 + phase * 2.5, css_rgba(220, 224, 232, a)); } } } } PlayerThumbStyle::Claudik => { ctx.dl().push_rect( Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0), 1.5, Color::rgb(0xD9, 0x77, 0x57), ); } PlayerThumbStyle::Antigravity => { ctx.dl().push_gradient_rect( Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0), 1.5, Color::rgb(0x9B, 0x84, 0xEC), Color::rgb(0x52, 0xB6, 0xFF), Vec2::new(1.0, 0.0), ); // Twinkling cosmic star dust trailing behind Antigravity let count = ((fill_w / 22.0) as usize).min(6); for k in 0..count { let phase = ((anim_t * 1.6 + k as f32 * 0.27) % 1.0).clamp(0.0, 1.0); let sx = fill_x - 16.0 - k as f32 * 18.0 - phase * 10.0; let sy = bar_y - 6.0 - ((k as f32 * 1.9 + anim_t * 3.0).sin() * 4.5).abs(); let twinkle = 0.35 + 0.65 * ((anim_t * 5.0 + k as f32 * 1.7).sin() * 0.5 + 0.5); if sx > bar_left + 4.0 { let col = if k % 2 == 0 { Color::rgb(0x9B, 0x84, 0xEC).scale_alpha(twinkle * 0.85) } else { Color::rgb(0x6C, 0xD4, 0xFF).scale_alpha(twinkle * 0.85) }; ctx.dl().push_rect(Rect::from_xywh(sx.round(), sy.round(), 2.0, 2.0), 0.0, col); } } } PlayerThumbStyle::Ferris => { ctx.dl().push_rect( Rect::from_xywh(bar_left, bar_y - 1.5, fill_w, 3.0), 1.5, Color::rgb(0xF7, 0x4C, 0x00), ); } PlayerThumbStyle::Nyan => { // Classic 6-stripe waving pixel rainbow trail! let stripes = [ Color::rgb(0xFF, 0x26, 0x26), Color::rgb(0xFF, 0x99, 0x00), Color::rgb(0xFF, 0xEE, 0x00), Color::rgb(0x33, 0xDD, 0x33), Color::rgb(0x1E, 0x9E, 0xFF), Color::rgb(0x7A, 0x44, 0xFF), ]; let seg_w = 10.0f32; let max_trail = (fill_w - 6.0).max(0.0); let num_segs = (max_trail / seg_w).ceil() as usize; let wave_step = (anim_t * 8.0).floor() as i32; for s in 0..num_segs { let sx = bar_left + s as f32 * seg_w; let sw = (fill_x - 6.0 - sx).min(seg_w); if sw <= 0.5 { break; } let dy = if ((s as i32 + wave_step) & 1) == 0 { -1.0 } else { 1.0 }; for (ci, &col) in stripes.iter().enumerate() { let sy = bar_y - 11.0 + ci as f32 * 2.0 + dy; ctx.dl() .push_rect(Rect::from_xywh(sx, sy, sw + 0.5, 2.0), 0.0, col); } } } } } // Draw the companion anchored cleanly at `(fill_x, bar_y)` match style { PlayerThumbStyle::Standard => {} PlayerThumbStyle::Duck => { let bob = if playing { (anim_t * 9.0).sin().abs() * -2.0 } else { 0.0 }; let sz = 32.0; let r = Rect::from_xywh(fill_x - sz * 0.5, bar_y - sz + 3.0 + bob, sz, sz); ctx.draw_icon(Icon::ThumbDuck, r, Color::WHITE); } PlayerThumbStyle::Car => { let vib = if playing { (anim_t * 28.0).sin() * 0.6 } else { 0.0 }; let w = 68.0; let h = 21.0; let r = Rect::from_xywh(fill_x - w * 0.52, bar_y - h + 2.0 + vib, w, h); // Warm headlight beam ahead of the car when playing if playing && r.right() < bar_right { let beam_w = (bar_right - r.right()).min(26.0); ctx.dl().push_gradient_rect( Rect::from_xywh(r.right() - 2.0, bar_y - 10.0 + vib, beam_w, 8.0), 2.0, css_rgba(255, 240, 160, 95), css_rgba(255, 240, 160, 0), Vec2::new(1.0, 0.0), ); } ctx.draw_icon(Icon::ThumbCar, r, Color::WHITE); } PlayerThumbStyle::Claudik => { let step = if playing { ((anim_t * 7.0).floor() as u32) & 1 } else { 0 }; let bob = if playing && step == 1 { -1.5 } else { 0.0 }; draw_claudik_sprite(ctx, Pos2::new(fill_x, bar_y + bob), 2.5, step == 1); } PlayerThumbStyle::Antigravity => { let hover = if playing { (anim_t * 4.5).sin() * 2.2 - 3.5 } else { -2.5 }; draw_antigravity_sprite(ctx, Pos2::new(fill_x, bar_y + hover), 2.5, anim_t, true); } PlayerThumbStyle::Ferris => { let step = if playing { ((anim_t * 8.0).floor() as u32) & 1 } else { 0 }; let bob = if playing && step == 1 { -1.0 } else { 0.0 }; draw_ferris_sprite(ctx, Pos2::new(fill_x, bar_y + bob), 2.2, step == 1); } PlayerThumbStyle::Nyan => { let step = if playing { ((anim_t * 9.0).floor() as u32) & 1 } else { 0 }; let bob = if playing && step == 1 { -1.5 } else { 0.0 }; draw_nyan_sprite(ctx, Pos2::new(fill_x, bar_y + bob), 2.0, step == 1); } } } /// Draws the centered preview inside Settings -> «Вид плеера» card (`preview_r`). pub fn render_thumb_preview( ctx: &mut UiContext, pal: &YmPalette, style: PlayerThumbStyle, preview_r: Rect, time: f32, ) { let cx = preview_r.center_x(); let cy = preview_r.center_y(); match style { PlayerThumbStyle::Standard => { let bar_w = 60.0; ctx.dl().push_rect( Rect::from_center_size(Pos2::new(cx, cy), Vec2::new(bar_w, 5.0)), 2.5, pal.border_control, ); ctx.dl().push_rect( Rect::from_xywh(cx - bar_w * 0.5, cy - 2.5, bar_w * 0.52, 5.0), 2.5, pal.yellow, ); ctx.dl().push_circle(Pos2::new(cx, cy), 10.0, pal.yellow); } PlayerThumbStyle::Duck => { ctx.draw_icon( Icon::ThumbDuck, Rect::from_center_size(Pos2::new(cx, cy + 2.0), Vec2::splat(48.0)), Color::WHITE, ); } PlayerThumbStyle::Car => { ctx.draw_icon( Icon::ThumbCar, Rect::from_center_size(Pos2::new(cx, cy + 4.0), Vec2::new(82.0, 26.0)), Color::WHITE, ); } PlayerThumbStyle::Claudik => { draw_claudik_sprite(ctx, Pos2::new(cx, cy + 16.0), 3.6, false); } PlayerThumbStyle::Antigravity => { draw_antigravity_sprite(ctx, Pos2::new(cx - 2.0, cy + 16.0), 3.5, time, true); } PlayerThumbStyle::Ferris => { draw_ferris_sprite(ctx, Pos2::new(cx, cy + 15.0), 3.2, false); } PlayerThumbStyle::Nyan => { // Mini rainbow preview behind Nyan Cat let stripes = [ Color::rgb(0xFF, 0x26, 0x26), Color::rgb(0xFF, 0x99, 0x00), Color::rgb(0xFF, 0xEE, 0x00), Color::rgb(0x33, 0xDD, 0x33), Color::rgb(0x1E, 0x9E, 0xFF), Color::rgb(0x7A, 0x44, 0xFF), ]; for (ci, &col) in stripes.iter().enumerate() { ctx.dl().push_rect( Rect::from_xywh(cx - 40.0, cy - 8.0 + ci as f32 * 2.5, 24.0, 2.5), 0.0, col, ); } draw_nyan_sprite(ctx, Pos2::new(cx + 8.0, cy + 12.0), 2.7, false); } } } /// Crisp pixel helper anchored at bottom-center `origin`, unit size `p` logical px. #[inline] fn px_rect(ctx: &mut UiContext, origin: Pos2, p: f32, gx: f32, gy: f32, gw: f32, gh: f32, col: Color) { ctx.dl().push_rect( Rect::from_xywh( (origin.x + gx * p).round(), (origin.y - gy * p).round(), (gw * p).round().max(1.0), (gh * p).round().max(1.0), ), 0.0, col, ); } /// Pixel-art Claudik (Claude Code terracotta buddy `#D97757`, matching user's reference!). fn draw_claudik_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, alt_step: bool) { let body = Color::rgb(0xD9, 0x77, 0x57); let eye = Color::rgb(0x1B, 0x1D, 0x24); // Main blocky head/body (10×6 pixels) px_rect(ctx, origin, p, -5.0, 8.0, 10.0, 6.0, body); // Little side pixel arms let arm_y = if alt_step { 4.5 } else { 4.0 }; px_rect(ctx, origin, p, -6.5, arm_y, 1.5, 1.5, body); px_rect(ctx, origin, p, 5.0, arm_y, 1.5, 1.5, body); // Vertical dark eyes px_rect(ctx, origin, p, -3.0, 6.5, 1.0, 2.0, eye); px_rect(ctx, origin, p, 2.0, 6.5, 1.0, 2.0, eye); // 4 cute little legs with walk alternation let (l1, l2) = if alt_step { (1.4, 2.0) } else { (2.0, 1.4) }; px_rect(ctx, origin, p, -4.0, 2.0, 1.0, l1, body); px_rect(ctx, origin, p, -2.0, 2.0, 1.0, l2, body); px_rect(ctx, origin, p, 1.0, 2.0, 1.0, l1, body); px_rect(ctx, origin, p, 3.0, 2.0, 1.0, l2, body); } /// Pixel-art Antigravity cosmic violet cat-bot (`#9B84EC`) + tiny succulent pot & floating aura! fn draw_antigravity_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, time: f32, with_plant: bool) { let body = Color::rgb(0x9B, 0x84, 0xEC); let hi = Color::rgb(0xC2, 0xB3, 0xFF); let eye = Color::rgb(0x17, 0x18, 0x22); // Soft cyan-violet anti-gravity glow underneath let pulse = 0.55 + 0.35 * (time * 4.5).sin(); ctx.dl().push_rect( Rect::from_xywh((origin.x - 4.0 * p).round(), (origin.y + 0.5 * p).round(), (8.0 * p).round(), (1.0 * p).round().max(2.0)), 2.0, Color::rgb(0x52, 0xB6, 0xFF).scale_alpha(pulse * 0.65), ); // Pointed cat ears px_rect(ctx, origin, p, -5.0, 9.5, 1.5, 2.0, body); px_rect(ctx, origin, p, -3.5, 8.5, 1.0, 1.0, body); px_rect(ctx, origin, p, 3.5, 9.5, 1.5, 2.0, body); px_rect(ctx, origin, p, 2.5, 8.5, 1.0, 1.0, body); // Main body px_rect(ctx, origin, p, -5.0, 7.5, 10.0, 5.5, body); // Subtle top sheen px_rect(ctx, origin, p, -2.5, 7.5, 5.0, 0.8, hi); // Dark pixel eyes with tiny sparkle px_rect(ctx, origin, p, -3.0, 6.0, 1.2, 2.0, eye); px_rect(ctx, origin, p, 1.8, 6.0, 1.2, 2.0, eye); // 4 floating legs px_rect(ctx, origin, p, -4.0, 2.0, 1.0, 1.8, body); px_rect(ctx, origin, p, -2.0, 2.0, 1.0, 1.8, body); px_rect(ctx, origin, p, 1.0, 2.0, 1.0, 1.8, body); px_rect(ctx, origin, p, 3.0, 2.0, 1.0, 1.8, body); // Cute tiny potted cactus/succulent friend on the right (matching Screenshot 3!) if with_plant { px_rect(ctx, origin, p, 5.2, 1.8, 3.2, 1.2, Color::rgb(0x8D, 0x55, 0x2B)); px_rect(ctx, origin, p, 5.7, 0.8, 2.2, 0.8, Color::rgb(0x6E, 0x40, 0x1E)); px_rect(ctx, origin, p, 6.2, 4.4, 1.2, 2.6, Color::rgb(0x6D, 0xE8, 0x7A)); px_rect(ctx, origin, p, 7.6, 3.2, 0.9, 1.4, Color::rgb(0x52, 0xC9, 0x60)); } } /// Pixel-art Ferris the Rust Crab (`#F74C00`) scuttling along the progress bar! fn draw_ferris_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, alt_step: bool) { let shell = Color::rgb(0xF7, 0x4C, 0x00); let dark = Color::rgb(0xC2, 0x35, 0x00); let white = Color::WHITE; let pupil = Color::rgb(0x16, 0x16, 0x1A); // Raised crab claws let claw_dy = if alt_step { 0.7 } else { 0.0 }; px_rect(ctx, origin, p, -7.2, 7.5 + claw_dy, 2.2, 2.4, shell); px_rect(ctx, origin, p, 5.0, 7.5 + claw_dy, 2.2, 2.4, shell); px_rect(ctx, origin, p, -6.5, 5.2, 1.8, 1.4, dark); px_rect(ctx, origin, p, 4.7, 5.2, 1.8, 1.4, dark); // Spiky rounded crab carapace px_rect(ctx, origin, p, -5.0, 7.2, 10.0, 5.0, shell); px_rect(ctx, origin, p, -3.5, 8.2, 7.0, 1.2, shell); // Googly eyes px_rect(ctx, origin, p, -3.0, 6.0, 2.0, 2.0, white); px_rect(ctx, origin, p, 1.0, 6.0, 2.0, 2.0, white); px_rect(ctx, origin, p, -2.0, 5.5, 1.0, 1.2, pupil); px_rect(ctx, origin, p, 2.0, 5.5, 1.0, 1.2, pupil); // Cute smile px_rect(ctx, origin, p, -1.0, 3.4, 2.0, 0.8, dark); // Scuttling legs let off = if alt_step { 0.5 } else { 0.0 }; px_rect(ctx, origin, p, -4.5 + off, 2.2, 1.2, 2.0, dark); px_rect(ctx, origin, p, -2.0 - off, 2.2, 1.2, 2.0, dark); px_rect(ctx, origin, p, 0.8 + off, 2.2, 1.2, 2.0, dark); px_rect(ctx, origin, p, 3.3 - off, 2.2, 1.2, 2.0, dark); } /// Pixel-art Nyan Cat zooming along the rainbow progress bar! fn draw_nyan_sprite(ctx: &mut UiContext, origin: Pos2, p: f32, alt_step: bool) { let crust = Color::rgb(0xF6, 0xCC, 0x8F); let icing = Color::rgb(0xFF, 0x99, 0xD6); let sprinkle = Color::rgb(0xFF, 0x33, 0x88); let cat = Color::rgb(0x9A, 0x9E, 0xA8); let dark = Color::rgb(0x1C, 0x1E, 0x24); let blush = Color::rgb(0xFF, 0x85, 0xA1); // Tail wagging on left let ty = if alt_step { 6.2 } else { 4.8 }; px_rect(ctx, origin, p, -8.0, ty, 2.5, 1.4, cat); // Pop-tart body px_rect(ctx, origin, p, -5.8, 8.6, 8.8, 6.8, crust); px_rect(ctx, origin, p, -4.8, 7.6, 6.8, 4.8, icing); // Sprinkles px_rect(ctx, origin, p, -3.8, 6.6, 1.0, 1.0, sprinkle); px_rect(ctx, origin, p, -1.5, 5.4, 1.0, 1.0, sprinkle); px_rect(ctx, origin, p, 0.2, 6.8, 1.0, 1.0, sprinkle); // Cat head on right px_rect(ctx, origin, p, 1.2, 7.8, 5.4, 4.8, cat); px_rect(ctx, origin, p, 1.5, 9.2, 1.5, 1.5, cat); px_rect(ctx, origin, p, 4.8, 9.2, 1.5, 1.5, cat); // Eyes & blush px_rect(ctx, origin, p, 2.4, 6.4, 1.0, 1.2, dark); px_rect(ctx, origin, p, 4.8, 6.4, 1.0, 1.2, dark); px_rect(ctx, origin, p, 1.8, 5.0, 1.0, 0.9, blush); px_rect(ctx, origin, p, 5.4, 5.0, 1.0, 0.9, blush); // Tiny running paws let paw_dx = if alt_step { 0.8 } else { 0.0 }; px_rect(ctx, origin, p, -4.8 + paw_dx, 2.0, 1.5, 1.8, cat); px_rect(ctx, origin, p, -1.8 + paw_dx, 2.0, 1.5, 1.8, cat); px_rect(ctx, origin, p, 1.6 + paw_dx, 2.0, 1.5, 1.8, cat); px_rect(ctx, origin, p, 4.0 + paw_dx, 2.0, 1.5, 1.8, cat); }