mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Anime gifs
This commit is contained in:
@@ -19,4 +19,5 @@ yansi-term = "^0.1"
|
||||
[dev-dependencies]
|
||||
tinybmp = "^0.2.3"
|
||||
glam = "*"
|
||||
rog_dbus = { path = "../rog-dbus" }
|
||||
rog_dbus = { path = "../rog-dbus" }
|
||||
gif = "^0.11.2"
|
||||
41
asusctl/examples/animatrix-diag-png.rs
Normal file
41
asusctl/examples/animatrix-diag-png.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use std::{env, error::Error, path::Path, process::exit};
|
||||
|
||||
use rog_anime::{
|
||||
AniMeDataBuffer, {AniMeDiagonal, Vec2},
|
||||
};
|
||||
use rog_dbus::AuraDbusClient;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let (client, _) = AuraDbusClient::new().unwrap();
|
||||
|
||||
let args: Vec<String> = env::args().into_iter().collect();
|
||||
if args.len() != 7 {
|
||||
println!(
|
||||
"Usage: <filepath> <x scale> <y scale> <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");
|
||||
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(),
|
||||
)?;
|
||||
|
||||
client
|
||||
.proxies()
|
||||
.anime()
|
||||
.write(<AniMeDataBuffer>::from(&matrix))
|
||||
.unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
33
asusctl/examples/animatrix-diag.rs
Normal file
33
asusctl/examples/animatrix-diag.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use std::{thread::sleep, time::Duration};
|
||||
|
||||
use rog_anime::{AniMeDataBuffer, AniMeDiagonal};
|
||||
use rog_dbus::AuraDbusClient;
|
||||
|
||||
// In usable data:
|
||||
// Top row start at 1, ends at 32
|
||||
|
||||
// 74w x 36h diagonal used by the windows app
|
||||
|
||||
fn main() {
|
||||
let (client, _) = AuraDbusClient::new().unwrap();
|
||||
|
||||
|
||||
for step in (2..50).rev() {
|
||||
let mut matrix = AniMeDiagonal::new();
|
||||
for c in (0..60).into_iter().step_by(step) {
|
||||
for i in matrix.get_mut().iter_mut() {
|
||||
i[c] = 50;
|
||||
}
|
||||
}
|
||||
|
||||
for c in (0..35).into_iter().step_by(step) {
|
||||
for i in matrix.get_mut()[c].iter_mut() {
|
||||
*i = 50;
|
||||
}
|
||||
}
|
||||
|
||||
let m = <AniMeDataBuffer>::from(&matrix);
|
||||
client.proxies().anime().write(m).unwrap();
|
||||
sleep(Duration::from_millis(300));
|
||||
}
|
||||
}
|
||||
60
asusctl/examples/animatrix-gif.rs
Normal file
60
asusctl/examples/animatrix-gif.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use std::{env, fs::File, path::Path, thread::sleep, time::Duration};
|
||||
|
||||
use rog_anime::{AniMeDataBuffer, AniMeDiagonal};
|
||||
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));
|
||||
}
|
||||
|
||||
loop {
|
||||
for frame in frames.iter() {
|
||||
client.proxies().anime().write(frame.data.clone()).unwrap();
|
||||
sleep(frame.delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let args: Vec<String> = env::args().into_iter().collect();
|
||||
if args.len() != 8 {
|
||||
println!(
|
||||
"Usage: <filepath> <x scale> <y scale> <angle> <x pos> <y pos> <fineness> <brightness>"
|
||||
"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");
|
||||
|
||||
BIN
asusctl/examples/controller.gif
Normal file
BIN
asusctl/examples/controller.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
asusctl/examples/controller.png
Normal file
BIN
asusctl/examples/controller.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
BIN
asusctl/examples/diag_sq.png
Normal file
BIN
asusctl/examples/diag_sq.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
BIN
asusctl/examples/levelup.png
Normal file
BIN
asusctl/examples/levelup.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
BIN
asusctl/examples/sunset.gif
Normal file
BIN
asusctl/examples/sunset.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Reference in New Issue
Block a user