mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
anime: tweak gif animation time types
This commit is contained in:
@@ -22,16 +22,30 @@ impl AniMeFrame {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
|
||||
pub enum AnimTime {
|
||||
Time(Duration),
|
||||
Cycles(u32),
|
||||
Infinite,
|
||||
}
|
||||
|
||||
impl Default for AnimTime {
|
||||
fn default() -> Self {
|
||||
Self::Infinite
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// A gif animation. This is a collection of frames from the gif, and a duration
|
||||
/// that the animation should be shown for.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct AniMeGif(Vec<AniMeFrame>, Option<Duration>);
|
||||
pub struct AniMeGif(Vec<AniMeFrame>, AnimTime);
|
||||
|
||||
impl AniMeGif {
|
||||
/// Create an animation using the 74x36 ASUS gif format
|
||||
pub fn create_diagonal_gif(
|
||||
file_name: &Path,
|
||||
duration: Option<Duration>,
|
||||
duration: AnimTime,
|
||||
brightness: f32,
|
||||
) -> Result<Self, AnimeError> {
|
||||
let mut matrix = AniMeDiagonal::new(None);
|
||||
@@ -75,7 +89,7 @@ impl AniMeGif {
|
||||
scale: f32,
|
||||
angle: f32,
|
||||
translation: Vec2,
|
||||
duration: Option<Duration>,
|
||||
duration: AnimTime,
|
||||
brightness: f32,
|
||||
) -> Result<Self, AnimeError> {
|
||||
let mut frames = Vec::new();
|
||||
@@ -142,7 +156,7 @@ impl AniMeGif {
|
||||
&self.0
|
||||
}
|
||||
|
||||
pub fn duration(&self) -> Option<Duration> {
|
||||
pub fn duration(&self) -> AnimTime {
|
||||
self.1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{path::Path, time::Duration};
|
||||
use glam::Vec2;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::{error::AnimeError, AniMeDataBuffer, AniMeGif, AniMeImage};
|
||||
use crate::{AniMeDataBuffer, AniMeGif, AniMeImage, AnimTime, error::AnimeError};
|
||||
|
||||
///
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
@@ -36,7 +36,7 @@ impl Sequences {
|
||||
pub fn add_asus_gif(
|
||||
&mut self,
|
||||
file: &Path,
|
||||
duration: Option<Duration>,
|
||||
duration: AnimTime,
|
||||
brightness: f32,
|
||||
) -> Result<(), AnimeError> {
|
||||
let frames = AniMeGif::create_diagonal_gif(file, duration, brightness)?;
|
||||
@@ -64,7 +64,7 @@ impl Sequences {
|
||||
scale: f32,
|
||||
angle: f32,
|
||||
translation: Vec2,
|
||||
duration: Option<Duration>,
|
||||
duration: AnimTime,
|
||||
brightness: f32,
|
||||
) -> Result<(), AnimeError> {
|
||||
let frames =
|
||||
|
||||
Reference in New Issue
Block a user