|
@@ -0,0 +1,43 @@
|
|
|
|
+extern crate piston_window;
|
|
|
|
+
|
|
|
|
+use clap;
|
|
|
|
+use clap::{App, Arg, SubCommand};
|
|
|
|
+use piston_window::*;
|
|
|
|
+
|
|
|
|
+fn main() {
|
|
|
|
+ let matches = App::new("Oculante")
|
|
|
|
+ .arg(
|
|
|
|
+ Arg::with_name("INPUT")
|
|
|
|
+ .help("Display this image")
|
|
|
|
+ .required(true)
|
|
|
|
+ .index(1),
|
|
|
|
+ )
|
|
|
|
+ .get_matches();
|
|
|
|
+
|
|
|
|
+ let img = matches.value_of("INPUT").unwrap();
|
|
|
|
+
|
|
|
|
+ let opengl = OpenGL::V3_2;
|
|
|
|
+ let mut window: PistonWindow = WindowSettings::new("Oculante", [300, 300])
|
|
|
|
+ .exit_on_esc(true)
|
|
|
|
+ .graphics_api(opengl)
|
|
|
|
+ .build()
|
|
|
|
+ .unwrap();
|
|
|
|
+
|
|
|
|
+ match Texture::from_path(
|
|
|
|
+ &mut window.create_texture_context(),
|
|
|
|
+ &img,
|
|
|
|
+ Flip::None,
|
|
|
|
+ &TextureSettings::new(),
|
|
|
|
+ ) {
|
|
|
|
+ Ok(texture) => {
|
|
|
|
+ window.set_lazy(true);
|
|
|
|
+ while let Some(e) = window.next() {
|
|
|
|
+ window.draw_2d(&e, |c, g, _| {
|
|
|
|
+ clear([1.0; 4], g);
|
|
|
|
+ image(&texture, c.transform, g);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Err(e) => println!("Could not create texture. {}", e),
|
|
|
|
+ }
|
|
|
|
+}
|