Skip to content

Instantly share code, notes, and snippets.

/main.rs
Created Nov 1, 2016

Embed
What would you like to do?
Piston - Nearest point interpolation
extern crate piston_window;
extern crate find_folder;
extern crate graphics;
use piston_window::*;
use graphics::rectangle::square;
use std::default::Default;
fn main() {
println!("Hello, world!");
let assets = find_folder::Search::ParentsThenKids(3, 3)
.for_folder("assets").unwrap();
let mut window: PistonWindow =
WindowSettings::new("Hello Piston!", [64, 48])
.exit_on_esc(true)
.build()
.unwrap();
let texture_settings = TextureSettings::new()
.filter(piston_window::texture::Filter::Nearest);
let texture = Texture::from_path(
&mut window.factory,
&(assets.join("sprite.png")),
Flip::None,
&texture_settings
).unwrap_or_else(|e| { panic!("Failed to load assets: {}", e) });
let image= Image::new()
.rect(square(0.0, 0.0, 40.0));
let mut events = window.events();
while let Some(e) = events.next(&mut window) {
if let Some(_r) = e.render_args() {
window.draw_2d(&e, |c, g| {
clear([0.75; 4], g);
image.draw(&texture, &Default::default(), c.zoom(4.).transform, g);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.