Add additional anime cli commands for image types

This commit is contained in:
Luke D. Jones
2021-10-28 23:43:50 +13:00
parent a925cbaed5
commit 678505811d
8 changed files with 194 additions and 104 deletions

View File

@@ -88,7 +88,7 @@ pub struct AnimeGif(Vec<AnimeFrame>, AnimTime);
impl AnimeGif {
/// Create an animation using the 74x36 ASUS gif format
#[inline]
pub fn create_diagonal_gif(
pub fn from_diagonal_gif(
file_name: &Path,
duration: AnimTime,
brightness: f32,
@@ -130,7 +130,7 @@ impl AnimeGif {
/// Create an animation using the 74x36 ASUS gif format from a png
#[inline]
pub fn create_diagonal_png(
pub fn from_diagonal_png(
file_name: &Path,
duration: AnimTime,
brightness: f32,
@@ -159,7 +159,7 @@ impl AnimeGif {
/// Create an animation using a gif of any size. This method must precompute the
/// result.
#[inline]
pub fn create_png_gif(
pub fn from_gif(
file_name: &Path,
scale: f32,
angle: f32,
@@ -231,7 +231,7 @@ impl AnimeGif {
/// will be 1 second long. If `AnimTime::Cycles` is specified for `duration` then this can
/// be considered how many seconds the image will show for.
#[inline]
pub fn create_png_static(
pub fn from_png(
file_name: &Path,
scale: f32,
angle: f32,

View File

@@ -69,7 +69,7 @@ impl ActionData {
file,
time,
brightness,
} => ActionData::Animation(AnimeGif::create_diagonal_gif(file, *time, *brightness)?),
} => ActionData::Animation(AnimeGif::from_diagonal_gif(file, *time, *brightness)?),
ActionLoader::AsusImage {
file,
time,
@@ -80,9 +80,7 @@ impl ActionData {
let data = <AnimeDataBuffer>::from(&image);
ActionData::Image(Box::new(data))
}
_ => {
ActionData::Animation(AnimeGif::create_diagonal_png(file, *time, *brightness)?)
}
_ => ActionData::Animation(AnimeGif::from_diagonal_png(file, *time, *brightness)?),
},
ActionLoader::ImageAnimation {
file,
@@ -94,7 +92,7 @@ impl ActionData {
} => {
if let Some(ext) = file.extension() {
if ext.to_string_lossy().to_lowercase() == "png" {
return Ok(ActionData::Animation(AnimeGif::create_png_static(
return Ok(ActionData::Animation(AnimeGif::from_png(
file,
*scale,
*angle,
@@ -104,7 +102,7 @@ impl ActionData {
)?));
}
}
ActionData::Animation(AnimeGif::create_png_gif(
ActionData::Animation(AnimeGif::from_gif(
file,
*scale,
*angle,
@@ -129,7 +127,7 @@ impl ActionData {
let data = <AnimeDataBuffer>::from(&image);
ActionData::Image(Box::new(data))
}
_ => ActionData::Animation(AnimeGif::create_png_static(
_ => ActionData::Animation(AnimeGif::from_png(
file,
*scale,
*angle,