cleanup and update dependencies
This commit is contained in:
		
							parent
							
								
									4cfd912ebe
								
							
						
					
					
						commit
						5d54a56e56
					
				| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
[workspace]
 | 
			
		||||
resolver = "2"
 | 
			
		||||
 | 
			
		||||
members = [
 | 
			
		||||
    "cowgen",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,4 +8,4 @@ edition = "2021"
 | 
			
		|||
 | 
			
		||||
[dependencies]
 | 
			
		||||
ril = { version = "0", features = ["all"] }
 | 
			
		||||
magick_rust = { version = "0.16" }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<T: AsRef<str>, V: AsRef<Path>> {
 | 
			
		||||
    elements: Vec<Element<T, V>>,
 | 
			
		||||
| 
						 | 
				
			
			@ -15,19 +9,7 @@ pub struct Generate<T: AsRef<str>, V: AsRef<Path>> {
 | 
			
		|||
impl<T: AsRef<str>, V: AsRef<Path>> Generate<T, V> {
 | 
			
		||||
    pub fn new(base: Vec<u8>, elements: Vec<Element<T, V>>) -> Result<Self, CowError> {
 | 
			
		||||
        Ok(Self {
 | 
			
		||||
            base: match Image::<Rgba>::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::<Rgba>::from_bytes_inferred(&base)?,
 | 
			
		||||
            elements,
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +29,7 @@ impl<T: AsRef<str>, V: AsRef<Path>> Generate<T, V> {
 | 
			
		|||
                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::<u8>::new();
 | 
			
		||||
        base_image.encode(ImageFormat::Png, &mut buf).unwrap();
 | 
			
		||||
| 
						 | 
				
			
			@ -134,9 +116,3 @@ impl From<ril::Error> for CowError {
 | 
			
		|||
        CowError::Other(r.to_string())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl From<MagickError> for CowError {
 | 
			
		||||
    fn from(m: MagickError) -> Self {
 | 
			
		||||
        CowError::Magick(m.0.to_owned())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,4 +8,4 @@ edition = "2021"
 | 
			
		|||
 | 
			
		||||
[dependencies]
 | 
			
		||||
cowgen = { path = "../cowgen" }
 | 
			
		||||
iced = { git = "https://github.com/iced-rs/iced", branch = "master" }
 | 
			
		||||
iced = "0.6"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<Element>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct Cowmic {
 | 
			
		||||
    templates: Vec<Template>,
 | 
			
		||||
    view: View,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum Message {}
 | 
			
		||||
 | 
			
		||||
impl Sandbox for Cowmic {
 | 
			
		||||
    type Message = Message;
 | 
			
		||||
 | 
			
		||||
    fn new() -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            view: View::Library(Library::View::new()),
 | 
			
		||||
			templates: vec![],
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn title(&self) -> String {
 | 
			
		||||
        "Cowmic".to_string()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn update(&mut self, message: Self::Message) {
 | 
			
		||||
        todo!()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn view(&self) -> iced::Element<'_, Self::Message> {
 | 
			
		||||
        todo!()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// library -> view template -> create image (fill out template) -> save to filesystem
 | 
			
		||||
//          \-> new template
 | 
			
		||||
enum View {
 | 
			
		||||
    Library(Library::View),
 | 
			
		||||
    // Template(Template),
 | 
			
		||||
    // Generate(Generate),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// features:
 | 
			
		||||
// import template
 | 
			
		||||
// delete template
 | 
			
		||||
// rename template
 | 
			
		||||
// autosave all templates
 | 
			
		||||
mod Library {
 | 
			
		||||
    use super::Template;
 | 
			
		||||
 | 
			
		||||
    pub struct View;
 | 
			
		||||
 | 
			
		||||
	impl View {
 | 
			
		||||
		pub fn new(templates: Vec<Template>) -> Self {
 | 
			
		||||
			Self
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		fn update(&mut self, message: Message) {
 | 
			
		||||
			todo!()
 | 
			
		||||
		}
 | 
			
		||||
	
 | 
			
		||||
		fn view(&self) -> iced::Element<'_, Message> {
 | 
			
		||||
			todo!()
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
    enum Message {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mod NewTemplate {
 | 
			
		||||
    struct View {
 | 
			
		||||
        image: Image
 | 
			
		||||
    };
 | 
			
		||||
    enum Message {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mod Generate {
 | 
			
		||||
    enum Message {}
 | 
			
		||||
fn main() {
 | 
			
		||||
    println!("hello, world");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,106 @@
 | 
			
		|||
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<Element>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct Cowmic {
 | 
			
		||||
    templates: Vec<Template>,
 | 
			
		||||
    view: View,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum Message {}
 | 
			
		||||
 | 
			
		||||
impl Sandbox for Cowmic {
 | 
			
		||||
    type Message = Message;
 | 
			
		||||
 | 
			
		||||
    fn new() -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            view: View::Library(Library::View::new()),
 | 
			
		||||
            templates: vec![],
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn title(&self) -> String {
 | 
			
		||||
        "Cowmic".to_string()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn update(&mut self, message: Self::Message) {
 | 
			
		||||
        todo!()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn view(&self) -> iced::Element<'_, Self::Message> {
 | 
			
		||||
        todo!()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// library -> view template -> create image (fill out template) -> save to filesystem
 | 
			
		||||
//          \-> new template
 | 
			
		||||
enum View {
 | 
			
		||||
    Library(Library::View),
 | 
			
		||||
    // Templatep(Template),
 | 
			
		||||
    // Generate(Generate),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// features:
 | 
			
		||||
// import template
 | 
			
		||||
// delete template
 | 
			
		||||
// rename template
 | 
			
		||||
// autosave all templates
 | 
			
		||||
mod Library {
 | 
			
		||||
    use super::Template;
 | 
			
		||||
 | 
			
		||||
    pub struct View;
 | 
			
		||||
 | 
			
		||||
    impl View {
 | 
			
		||||
        pub fn new(templates: Vec<Template>) -> Self {
 | 
			
		||||
            Self
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fn update(&mut self, message: Message) {
 | 
			
		||||
            todo!()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fn view(&self) -> iced::Element<'_, Message> {
 | 
			
		||||
            todo!()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    enum Message {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mod NewTemplate {
 | 
			
		||||
    struct View {
 | 
			
		||||
        image: Image,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    enum Message {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mod Generate {
 | 
			
		||||
    enum Message {}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue