diff --git a/Cargo.toml b/Cargo.toml index 98e5e8e..38608bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "cowgen", diff --git a/cowgen/Cargo.toml b/cowgen/Cargo.toml index 463069b..92fbccf 100644 --- a/cowgen/Cargo.toml +++ b/cowgen/Cargo.toml @@ -8,4 +8,4 @@ edition = "2021" [dependencies] ril = { version = "0", features = ["all"] } -magick_rust = { version = "0.16" } + diff --git a/cowgen/src/lib.rs b/cowgen/src/lib.rs index 4e69c86..e439e37 100644 --- a/cowgen/src/lib.rs +++ b/cowgen/src/lib.rs @@ -1,11 +1,5 @@ -use magick_rust::{magick_wand_genesis, MagickError, MagickWand}; use ril::prelude::*; -use std::sync::Once; -use std::{fs::File, path::Path}; - -// Used to make sure MagickWand is initialized exactly once. Note that we -// do not bother shutting down, we simply exit when we're done. -static START: Once = Once::new(); +use std::path::Path; pub struct Generate, V: AsRef> { elements: Vec>, @@ -15,19 +9,7 @@ pub struct Generate, V: AsRef> { impl, V: AsRef> Generate { pub fn new(base: Vec, elements: Vec>) -> Result { Ok(Self { - base: match Image::::from_bytes_inferred(&base) { - Ok(img) => img, - _ => { - START.call_once(|| { - magick_wand_genesis(); - }); - let mut wand = MagickWand::new(); - wand.read_image_blob(&base)?; - wand.set_format("png32")?; - let base = wand.write_image_blob("png")?; - Image::from_bytes_inferred(base)? - } - }, + base: Image::::from_bytes_inferred(&base)?, elements, }) } @@ -47,7 +29,7 @@ impl, V: AsRef> Generate { pos.1 = 0; } - base_image.draw(&Paste::new(img.convert()).with_position(pos.0 as u32, pos.1 as u32)); + base_image.draw(&Paste::new(&img.convert()).with_position(pos.0 as u32, pos.1 as u32)); } let mut buf = Vec::::new(); base_image.encode(ImageFormat::Png, &mut buf).unwrap(); @@ -134,9 +116,3 @@ impl From for CowError { CowError::Other(r.to_string()) } } - -impl From for CowError { - fn from(m: MagickError) -> Self { - CowError::Magick(m.0.to_owned()) - } -} diff --git a/cowmic/Cargo.toml b/cowmic/Cargo.toml index e04ed0c..efe2972 100644 --- a/cowmic/Cargo.toml +++ b/cowmic/Cargo.toml @@ -8,4 +8,4 @@ edition = "2021" [dependencies] cowgen = { path = "../cowgen" } -iced = { git = "https://github.com/iced-rs/iced", branch = "master" } +iced = "0.6" diff --git a/cowmic/src/main.rs b/cowmic/src/main.rs index b264597..2e6431c 100644 --- a/cowmic/src/main.rs +++ b/cowmic/src/main.rs @@ -1,105 +1,3 @@ -use std::path::Path; -use std::{fs::File, io::Write}; - -use cowgen::{CowError, Text}; -use iced::Sandbox; -use iced::Settings; - -fn main() -> Result<(), CowError> { - Cowmic::run(Settings::default()) -} - -struct Element { - position: (i32, i32), - dimensions: (i32, i32), - media: Media, -} - -struct Text {} - -struct Image {} - -enum Media { - Image(Path), - Text(Text), -} - -struct Template { - image_path: String, - elements: Vec -} - -struct Cowmic { - templates: Vec