anime: CLI and user-daemon work

This commit is contained in:
Luke D Jones
2021-04-07 22:20:29 +12:00
parent 8010da0891
commit 7d0f15d738
65 changed files with 721 additions and 188 deletions

View File

@@ -1,8 +1,6 @@
use std::{env, error::Error, path::Path, process::exit};
use rog_anime::{
AniMeDataBuffer, {AniMeDiagonal, Vec2},
};
use rog_anime::{AniMeDataBuffer, AniMeDiagonal};
use rog_dbus::AuraDbusClient;
fn main() -> Result<(), Box<dyn Error>> {
@@ -15,7 +13,8 @@ fn main() -> Result<(), Box<dyn Error>> {
exit(-1);
}
let matrix = AniMeDiagonal::from_png(Path::new(&args[1]), args[2].parse::<f32>().unwrap())?;
let matrix =
AniMeDiagonal::from_png(Path::new(&args[1]), None, args[2].parse::<f32>().unwrap())?;
client
.proxies()

View File

@@ -12,7 +12,7 @@ fn main() {
let (client, _) = AuraDbusClient::new().unwrap();
for step in (2..50).rev() {
let mut matrix = AniMeDiagonal::new();
let mut matrix = AniMeDiagonal::new(None);
for c in (0..60).into_iter().step_by(step) {
for i in matrix.get_mut().iter_mut() {
i[c] = 50;

View File

@@ -1,6 +1,6 @@
use std::{env, path::Path, thread::sleep};
use rog_anime::AniMeBlock;
use rog_anime::{Action, Sequences};
use rog_dbus::AuraDbusClient;
fn main() {
@@ -14,16 +14,21 @@ fn main() {
let path = Path::new(&args[1]);
let brightness = args[2].parse::<f32>().unwrap();
let gif = AniMeBlock::asus_gif(path, brightness).unwrap();
let mut seq = Sequences::new();
seq.add_asus_gif(path, None, brightness).unwrap();
loop {
for frame in gif.get_animation().unwrap().frames() {
client
.proxies()
.anime()
.write(frame.frame().clone())
.unwrap();
sleep(frame.delay());
for action in seq.iter() {
if let Action::Animation(frames) = action {
for frame in frames.frames() {
client
.proxies()
.anime()
.write(frame.frame().clone())
.unwrap();
sleep(frame.delay());
}
}
}
}
}

View File

@@ -8,7 +8,7 @@ use rog_dbus::AuraDbusClient;
fn main() {
let (client, _) = AuraDbusClient::new().unwrap();
let mut matrix = AniMeGrid::new();
let mut matrix = AniMeGrid::new(None);
let tmp = matrix.get_mut();
let mut i = 0;

View File

@@ -1,20 +1,28 @@
use std::{env, path::Path, thread::sleep};
use std::{
env,
path::Path,
thread::sleep,
time::{Duration, Instant},
};
use glam::Vec2;
use rog_anime::AniMeBlock;
use rog_anime::{Action, Sequences};
use rog_dbus::AuraDbusClient;
fn main() {
let (client, _) = AuraDbusClient::new().unwrap();
let args: Vec<String> = env::args().into_iter().collect();
if args.len() != 7 {
println!("Usage: <filepath> <scale> <angle> <x pos> <y pos> <brightness>");
println!("e.g, asusctl/examples/file.gif 0.9 0.4 0.0 0.0 0.8");
if args.len() < 7 {
println!(
"Usage: <filepath> <scale> <angle> <x pos> <y pos> <brightness> <duration> <filepath>"
);
println!("e.g, asusctl/examples/file.gif 0.9 0.4 0.0 0.0 0.8 0");
return;
}
let gif = AniMeBlock::image_gif(
let mut seq = Sequences::new();
seq.add_image_gif(
Path::new(&args[1]),
args[2].parse::<f32>().unwrap(),
args[3].parse::<f32>().unwrap(),
@@ -22,18 +30,62 @@ fn main() {
args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap(),
),
if let Ok(time) = args[7].parse::<u64>() {
if time != 0 {
Some(Duration::from_secs(time))
} else {
None
}
} else {
None
},
args[6].parse::<f32>().unwrap(),
)
.unwrap();
if args.len() == 9 {
seq.add_image_gif(
Path::new(&args[8]),
args[2].parse::<f32>().unwrap(),
args[3].parse::<f32>().unwrap(),
Vec2::new(
args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap(),
),
if let Ok(time) = args[7].parse::<u64>() {
if time != 0 {
Some(Duration::from_secs(time))
} else {
None
}
} else {
None
},
args[6].parse::<f32>().unwrap(),
)
.unwrap();
}
loop {
for frame in gif.get_animation().unwrap().frames() {
client
.proxies()
.anime()
.write(frame.frame().clone())
.unwrap();
sleep(frame.delay());
for action in seq.iter() {
if let Action::Animation(frames) = action {
let start = Instant::now();
'outer: loop {
for frame in frames.frames() {
client
.proxies()
.anime()
.write(frame.frame().clone())
.unwrap();
if let Some(time) = frames.duration() {
if Instant::now().duration_since(start) > time {
break 'outer;
}
}
sleep(frame.delay());
}
}
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB