MCPcopy Create free account
hub / github.com/FedeCarollo/jukebox-cli / update_notes

Method update_notes

src/canvas_state.rs:102–125  ·  view source on GitHub ↗
(&mut self, width: u16, height: u16, is_playing: bool)

Source from the content-addressed store, hash-verified

100 }
101
102 pub fn update_notes(&mut self, width: u16, height: u16, is_playing: bool) {
103 if !is_playing {
104 return;
105 }
106
107 let mut rng = rand::rng();
108
109 self.floating_notes.retain(|note| !note.is_expired());
110
111 // Add a note with 50% probability
112 if rng.random_bool(0.5) && self.floating_notes.len() < 6 {
113 let actual_width = width.saturating_sub(2);
114 let actual_height = height.saturating_sub(2);
115
116 if actual_width > 0 && actual_height > 0 {
117 let x = rng.random_range(0..actual_width);
118 let y = rng.random_range(0..actual_height);
119
120 if let Some(note) = FloatingNote::new(x, y, &self.note_images) {
121 self.floating_notes.push(note);
122 }
123 }
124 }
125 }
126
127 pub fn get_canvas(&mut self, width: u16, height: u16) -> Vec<Vec<Span<'static>>> {
128 // Only the right border in jukebox_side, so subtract only 1 from width

Callers 1

render_jukebox_matrixFunction · 0.80

Calls 1

is_expiredMethod · 0.80

Tested by

no test coverage detected