From e4ec4d2a8081595d6412acd60c2448d37a1614f4 Mon Sep 17 00:00:00 2001 From: Isabelle L Date: Fri, 19 Jun 2020 01:25:16 -0500 Subject: [PATCH] scaling --- src/lib.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 86abefc..14ccbf1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,16 +74,24 @@ pub struct Context { pixel_buffer: PixelBuffer, height: usize, width: usize, + scale: usize, window: Window, } impl Context { /// create a new context - pub fn new(width: usize, height: usize, title: String) -> Result { - let pixel_buffer = PixelBuffer::new(height, width); - let mut window = Window::new(&title, width, height, WindowOptions::default())?; + pub fn new( + width: usize, + height: usize, + title: String, + scale: Option, + ) -> Result { + let scale = scale.unwrap_or(1); + let pixel_buffer = PixelBuffer::new(width, height); + let mut window = Window::new(&title, width * scale, height * scale, WindowOptions::default())?; window.limit_update_rate(Some(std::time::Duration::from_micros(16600))); - Ok(Context { pixel_buffer, window, height, width }) + + Ok(Context { pixel_buffer, window, height, width, scale }) } /// render the internal buffer to the screen