diff --git a/src/image.rs b/src/image.rs index 3b24363..071daa9 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1,5 +1,4 @@ use std::fs::File; -use std::path::Path; use crate::vec2::Vec2; //todo: make dynamically different bitdepths @@ -48,11 +47,11 @@ impl Image { pub fn draw_image(&mut self, pos: Vec2, image: &Image) { //todo: write proper implementation later - for y in 0..image.size.y as i32 { - for x in 0..image.size.x as i32 { + for y in 0..image.size.y { + for x in 0..image.size.x { //todo: implement better(very stupid to do per pixel) - if x + pos.x >= 0 && y + pos.y >= 0 && x + pos.x < self.size.x as i32 && y + pos.y < self.size.y as i32 { - let p = image.get_pixel(Vec2 { x, y: y }); + if x + pos.x >= 0 && y + pos.y >= 0 && x + pos.x < self.size.x && y + pos.y < self.size.y { + let p = image.get_pixel(Vec2 { x, y }); if p > 0 { self.set_pixel(Vec2 { x: x + pos.x, y: y + pos.y }, p); } @@ -75,7 +74,7 @@ impl Image { }; let xs = xdiff / step; let ys = ydiff / step; - for i in 1..=(step as i32) { + for _ in 1..=(step as i32) { self.set_pixel(Vec2 { x: x as i32, y: y as i32 }, color); x += xs; y += ys; diff --git a/src/rect.rs b/src/rect.rs index 87d441e..2487df8 100644 --- a/src/rect.rs +++ b/src/rect.rs @@ -9,9 +9,9 @@ pub struct Rect { impl Rect { pub fn new(x: T, y: T, w: T, h: T) -> Rect { - return Rect { + Rect { pos: Vec2{x, y}, size: Vec2{x: w, y: h}, - }; + } } } diff --git a/src/window.rs b/src/window.rs index ad785d2..b1902c7 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,6 +1,6 @@ use pixels::{Pixels, SurfaceTexture}; use winit::dpi::LogicalSize; -use winit::event::{ElementState, Event as WinitEvent, VirtualKeyCode, WindowEvent, MouseButton as WinitMouseButton}; +use winit::event::{ElementState, Event as WinitEvent, WindowEvent, MouseButton as WinitMouseButton}; use winit::event_loop::{ControlFlow, EventLoop}; use winit::window::{WindowBuilder}; use crate::image::Image; @@ -77,7 +77,7 @@ pub fn run(width: i32, height: i32) { event_loop.run(move |event, _, control_flow| { match event { WinitEvent::NewEvents(_) => {} - WinitEvent::WindowEvent { window_id, event: window_event } => { + WinitEvent::WindowEvent { event: window_event, .. } => { match window_event { WindowEvent::Resized(_) => {} WindowEvent::Moved(_) => {}