Johann Woelper 6 gadi atpakaļ
revīzija
71180f5ce5
5 mainītis faili ar 1614 papildinājumiem un 0 dzēšanām
  1. 3 0
      .gitignore
  2. 1558 0
      Cargo.lock
  3. 10 0
      Cargo.toml
  4. BIN
      rust.png
  5. 43 0
      src/main.rs

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+/target
+**/*.rs.bk
+.history

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1558 - 0
Cargo.lock


+ 10 - 0
Cargo.toml

@@ -0,0 +1,10 @@
+[package]
+name = "oculante"
+version = "0.1.1"
+authors = ["Johann Woelper <woelper@gmail.com>"]
+edition = "2018"
+
+[dependencies]
+piston_window = "*"
+clap = "*"
+image = "*"

BIN
rust.png


+ 43 - 0
src/main.rs

@@ -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),
+    }
+}