mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Prepare for user saving of anime sequences
This commit is contained in:
@@ -9,26 +9,17 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let (client, _) = AuraDbusClient::new().unwrap();
|
||||
|
||||
let args: Vec<String> = env::args().into_iter().collect();
|
||||
if args.len() != 7 {
|
||||
if args.len() != 3 {
|
||||
println!(
|
||||
"Usage: <filepath> <x scale> <y scale> <x pos> <y pos> <brightness>"
|
||||
"Usage: <filepath> <brightness>"
|
||||
);
|
||||
println!("e.g, asusctl/examples/doom_large.png 0.9 0.9 0.4 0.0 0.0 0.8");
|
||||
println!("All args except path and fineness are floats");
|
||||
println!("e.g, asusctl/examples/doom_large.png 0.8");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
let matrix = AniMeDiagonal::from_png(
|
||||
Path::new(&args[1]),
|
||||
Vec2::new(
|
||||
args[2].parse::<f32>().unwrap(),
|
||||
args[3].parse::<f32>().unwrap(),
|
||||
),
|
||||
Vec2::new(
|
||||
args[4].parse::<f32>().unwrap(),
|
||||
args[5].parse::<f32>().unwrap(),
|
||||
),
|
||||
args[6].parse::<f32>().unwrap(),
|
||||
args[2].parse::<f32>().unwrap(),
|
||||
)?;
|
||||
|
||||
client
|
||||
|
||||
@@ -10,7 +10,6 @@ use rog_dbus::AuraDbusClient;
|
||||
|
||||
fn main() {
|
||||
let (client, _) = AuraDbusClient::new().unwrap();
|
||||
|
||||
|
||||
for step in (2..50).rev() {
|
||||
let mut matrix = AniMeDiagonal::new();
|
||||
|
||||
@@ -1,60 +1,29 @@
|
||||
use std::{env, fs::File, path::Path, thread::sleep, time::Duration};
|
||||
|
||||
use rog_anime::{AniMeDataBuffer, AniMeDiagonal};
|
||||
use rog_anime::AniMeSequence;
|
||||
use rog_dbus::AuraDbusClient;
|
||||
|
||||
struct AniMeFrame {
|
||||
data: AniMeDataBuffer,
|
||||
delay: Duration,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (client, _) = AuraDbusClient::new().unwrap();
|
||||
|
||||
let args: Vec<String> = env::args().into_iter().collect();
|
||||
// if args.len() != 7 {
|
||||
// exit(-1);
|
||||
// }
|
||||
|
||||
let mut frames = Vec::new();
|
||||
let mut matrix = AniMeDiagonal::new();
|
||||
|
||||
let mut decoder = gif::DecodeOptions::new();
|
||||
// Configure the decoder such that it will expand the image to RGBA.
|
||||
decoder.set_color_output(gif::ColorOutput::RGBA);
|
||||
// Read the file header
|
||||
let file = File::open(Path::new(&args[1])).unwrap();
|
||||
let mut decoder = decoder.read_info(file).unwrap();
|
||||
|
||||
while let Some(frame) = decoder.read_next_frame().unwrap() {
|
||||
let wait = frame.delay;
|
||||
for (y, row) in frame.buffer.chunks(frame.width as usize * 4).enumerate() {
|
||||
for (x, px) in row.chunks(4).enumerate() {
|
||||
if px[3] != 255 {
|
||||
// should be t but not in some gifs? What, ASUS, what?
|
||||
continue;
|
||||
}
|
||||
matrix.get_mut()[y + frame.top as usize][x + frame.left as usize] = px[0];
|
||||
}
|
||||
}
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(<AniMeDataBuffer>::from(&matrix))
|
||||
.unwrap();
|
||||
|
||||
frames.push(AniMeFrame {
|
||||
data: <AniMeDataBuffer>::from(&matrix),
|
||||
delay: Duration::from_millis(wait as u64),
|
||||
});
|
||||
|
||||
sleep(Duration::from_millis(wait as u64));
|
||||
if args.len() != 3 {
|
||||
println!("Please supply filepath and brightness");
|
||||
return;
|
||||
}
|
||||
|
||||
let path = Path::new(&args[1]);
|
||||
let brightness = args[2].parse::<f32>().unwrap();
|
||||
let gif = AniMeSequence::gif(path, brightness).unwrap();
|
||||
|
||||
loop {
|
||||
for frame in frames.iter() {
|
||||
client.proxies().anime().write(frame.data.clone()).unwrap();
|
||||
sleep(frame.delay);
|
||||
for frame in gif.get_animation().unwrap().frames() {
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(frame.frame().clone())
|
||||
.unwrap();
|
||||
sleep(frame.delay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{env, error::Error, path::Path, process::exit};
|
||||
|
||||
use rog_anime::{
|
||||
AniMeDataBuffer, {AnimeImage, Vec2},
|
||||
AniMeDataBuffer, {AniMeImage, Vec2},
|
||||
};
|
||||
use rog_dbus::AuraDbusClient;
|
||||
|
||||
@@ -13,12 +13,11 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!(
|
||||
"Usage: <filepath> <x scale> <y scale> <angle> <x pos> <y pos> <brightness>"
|
||||
);
|
||||
println!("e.g, asusctl/examples/doom_large.png 0.9 0.9 0.4 0.0 0.0, 0.8");
|
||||
println!("All args except path and fineness are floats");
|
||||
println!("e.g, asusctl/examples/doom_large.png 0.9 0.9 0.4 0.0 0.0,0.8");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
let matrix = AnimeImage::from_png(
|
||||
let matrix = AniMeImage::from_png(
|
||||
Path::new(&args[1]),
|
||||
Vec2::new(
|
||||
args[2].parse::<f32>().unwrap(),
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{
|
||||
};
|
||||
|
||||
use rog_anime::{
|
||||
AniMeDataBuffer, {AnimeImage, Vec2},
|
||||
AniMeDataBuffer, {AniMeImage, Vec2},
|
||||
};
|
||||
use rog_dbus::AuraDbusClient;
|
||||
|
||||
@@ -18,7 +18,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
let mut matrix = AnimeImage::from_png(
|
||||
let mut matrix = AniMeImage::from_png(
|
||||
Path::new(&args[1]),
|
||||
Vec2::new(
|
||||
args[2].parse::<f32>().unwrap(),
|
||||
|
||||
@@ -10,7 +10,7 @@ use daemon::{
|
||||
use gumdrop::{Opt, Options};
|
||||
use rog_anime::{
|
||||
AniMeDataBuffer, ANIME_DATA_LEN,
|
||||
AnimeImage, Vec2,
|
||||
AniMeImage, Vec2,
|
||||
};
|
||||
use rog_dbus::AuraDbusClient;
|
||||
use rog_types::{
|
||||
@@ -178,7 +178,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let matrix = AnimeImage::from_png(
|
||||
let matrix = AniMeImage::from_png(
|
||||
Path::new(&image.path),
|
||||
Vec2::new(image.scale, image.scale),
|
||||
image.angle,
|
||||
|
||||
Reference in New Issue
Block a user