aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-03-17 12:22:40 +0000
committerAkshay <[email protected]>2021-03-17 12:22:40 +0000
commit7615546fb0157c3ec9d2f25ec9837ee0b6cb7e9a (patch)
treeb197326f7812ec20e2207b0e444f2a50569c5b74 /src/main.rs
parent83732aed1a41a713cd8790fcebae90aabe78b789 (diff)
feat: basic command mode, add text box primitives
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 14f4cf5..ebdf793 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,6 @@
1mod app; 1mod app;
2mod bitmap; 2mod bitmap;
3mod command;
3mod consts; 4mod consts;
4mod dither; 5mod dither;
5mod symmetry; 6mod symmetry;
@@ -8,8 +9,41 @@ mod utils;
8 9
9use app::AppState; 10use app::AppState;
10 11
12use std::{
13 env,
14 fs::OpenOptions,
15 io::{Cursor, Read},
16};
17
18use obi::Image;
19
11pub fn main() { 20pub fn main() {
12 let sdl_context = sdl2::init().unwrap(); 21 let sdl_context = sdl2::init().unwrap();
13 let ttf_context = sdl2::ttf::init().unwrap(); 22 let ttf_context = sdl2::ttf::init().unwrap();
14 AppState::init(200, 200, &sdl_context, &ttf_context).run(); 23 let args: Vec<_> = env::args().collect();
24 if args.len() < 2 {
25 AppState::init(200, 200, &sdl_context, &ttf_context, None).run();
26 return;
27 } else {
28 let path = args.get(1).unwrap();
29 let image_src = OpenOptions::new()
30 .read(true)
31 .write(false)
32 .create(false)
33 .open(path);
34 if let Ok(mut image) = image_src {
35 let mut buf = Vec::new();
36 image.read_to_end(&mut buf).unwrap();
37 let decoded = Image::decode(&mut (Cursor::new(buf))).unwrap();
38 let (width, height) = (decoded.width(), decoded.height());
39 AppState::init(
40 width,
41 height,
42 &sdl_context,
43 &ttf_context,
44 Some(decoded.data),
45 )
46 .run();
47 }
48 }
15} 49}