fade to red
This commit is contained in:
parent
2aba7e33c1
commit
1e6b95e21b
1 changed files with 15 additions and 11 deletions
26
src/main.rs
26
src/main.rs
|
@ -1,5 +1,3 @@
|
||||||
use std::io::Cursor;
|
|
||||||
|
|
||||||
use mpris::PlayerFinder;
|
use mpris::PlayerFinder;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tray_item::IconSource;
|
use tray_item::IconSource;
|
||||||
|
@ -10,26 +8,32 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
let mut tracker = players[0].track_progress(500)?;
|
let mut tracker = players[0].track_progress(500)?;
|
||||||
|
|
||||||
let icon = IconSource::Data{data: gen_icon(), height: 32, width: 32};
|
let icon = IconSource::Data{data: gen_icon(0), height: 32, width: 32};
|
||||||
|
|
||||||
let mut tray = TrayItem::new("funring", icon);
|
let mut tray = TrayItem::new("funring", icon)?;
|
||||||
|
|
||||||
println!("Hello, {}!", players[0].identity());
|
println!("Hello, {}!", players[0].identity());
|
||||||
loop {
|
loop {
|
||||||
let player = &players[0];
|
let tick = tracker.tick();
|
||||||
let elapsed = player.get_position().unwrap().as_secs();
|
let elapsed = tick.progress.position().as_secs();
|
||||||
let total = player.get_metadata().unwrap().length().unwrap().as_secs();
|
let total = tick.progress.length().unwrap().as_secs();
|
||||||
println!("{elapsed}s/{total}s!");
|
println!("{elapsed}s/{total}s!");
|
||||||
|
let prog = elapsed as f32 / total as f32 * 256.0;
|
||||||
|
println!("{prog}");
|
||||||
|
|
||||||
|
tray.set_icon(
|
||||||
|
IconSource::Data{data: gen_icon(prog as u8), height: 32, width: 32}
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_icon() -> Vec<u8> {
|
fn gen_icon(red: u8) -> Vec<u8> {
|
||||||
let mut icon = Vec::new();
|
let mut icon = Vec::new();
|
||||||
for pix in 0..(32*32) {
|
for pix in 0..(32*32) {
|
||||||
icon.push(0);
|
|
||||||
icon.push(0);
|
|
||||||
icon.push(255);
|
|
||||||
icon.push(1);
|
icon.push(1);
|
||||||
|
icon.push(red);
|
||||||
|
icon.push(0);
|
||||||
|
icon.push(0);
|
||||||
}
|
}
|
||||||
icon
|
icon
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue