metropolis 0.9.1

A high level easy to use graphics renderer
b0VIM 8.1V��]��Aguylguyl-HP-EliteBook-840-G1~guyl/Desktop/rust_things/metropolis/src/canvas.rsutf-8
U3210#"! Utpoo5qE�
i�N:xc�
=(Q	tgp�eKY�]	Qfad
�o����/���v6#�
�
�
i
L
 
���?"	����qU5	�
�
p
C
B
$

�	�	�	l	k	`	P	9	#	����i-"��vdH)'���fC5���Y*�����{oF4+����s^G7������b8+��#[deri    mouse_scroll:MouseScroll,    mouse:Mouse,    cursor_pos:(u16,u16),    key:Key,    texture:Option<(Vec<u8>,Dimensions)>,    stroke_vec: Vec<Vertex>,         text_vec: Vec<Stext>,       fill_vec: Vec<Vertex>,         text_size: f32,    resizeable: bool,    pub fps: f32,    background_color: [f32; 4],    fill_color: [f32; 4],    fill: bool,    stroke_weight: u8,    color: [f32; 4],    stroke: bool,    size: (u16, u16),pub struct Canvas {#[derive(Clone, PartialEq)]///as you may see the draw loop is designed a bit different.///```///}///   canv.show(draw);///   };///        canvas///       canvas.bezierCurve(curve_vec);///      ];///          [250, 050],///           [150, 150],///           [80, 240],///           [75, 257],///           [50, 300],///           [30, 370],///           [0, 400],///       let curve_vec: Vec<[i64; 2]> = vec![///   let draw = |mut canvas:Canvas|->Canvas {///   canv.background(grayscale(100));///   let mut canv:Canvas= Canvas::new(width,height);///   //size(width, height);///   let width = 800;///       let height = 600;///fn main(){///use metropolis::canvas::Canvas;///use metropolis::color::*;///```///mutithreading safe but needs a slightly different way to use:///the public canvas struct(there is actually an inner one for the static functions). it is}    pub dimensions:Dimensions,    pub image_data:Vec<u8>,pub struct Image{#[derive(Clone)]///framerate in aout 12 fps.///This struct is meant for loading and saving the image once and not every frame, it improves}        .collect::<Vec<_>>()        })            ) as Arc<dyn FramebufferAbstract + Send + Sync>                    .unwrap(),                    .build()                    .unwrap()                    .add(image.clone())                Framebuffer::start(render_pass.clone())            Arc::new(        .map(|image| {        .iter()    images    dynamic_state.viewports = Some(vec![viewport]);    };        depth_range: 0.0..1.0,        dimensions: [dimensions[0] as f32, dimensions[1] as f32],        origin: [0.0, 0.0],    let viewport = Viewport {    let dimensions = images[0].dimensions();) -> Vec<Arc<dyn FramebufferAbstract + Send + Sync>> {    dynamic_state: &mut DynamicState,    render_pass: Arc<dyn RenderPassAbstract + Send + Sync>,    images: &[Arc<SwapchainImage<Window>>],fn window_size_dependent_setup(pub use winit::MouseButton;pub use winit::VirtualKeyCode as keyCode;use crate::math::{bezier_points, catmull_rom_chain};use image::*;use crate::mapping::*;use crate::mapping;use crate::color::Color;use vulkano::format::Format;use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;use vulkano::sampler::{Sampler, SamplerAddressMode, Filter, MipmapMode};use vulkano::image::{ImmutableImage, Dimensions};use std::time::{Duration, Instant};use crate::text::{DrawText, DrawTextTrait};use winit::MouseScrollDelta;use winit::dpi::LogicalPosition;use winit::{ModifiersState,KeyboardInput,ElementState,Event, WindowEvent,VirtualKeyCode};use winit::Window;use vulkano::sync::{FlushError, GpuFuture};use vulkano::sync;use vulkano::swapchain::{AcquireError, SwapchainCreationError};use vulkano::swapchain;use vulkano::pipeline::viewport::Viewport;use vulkano::image::SwapchainImage;use vulkano::framebuffer::{Framebuffer, FramebufferAbstract, RenderPassAbstract};use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState,AutoCommandBuffer};use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};use std::sync::Arc;use crate::vertex::*;use crate::setup::*;ad�WQ����_>���{W=$�
�
�
�
z
]
R
L
J

��HC���}UE;9�
�
o
4
/
�	�	�	�	l	I	!		���p`G=;����uV>20����Z��[YWV}}        Image{image_data,dimensions}        let dimensions = Dimensions::Dim2d { width: img.width(), height: img.height() };        let image_data = img.raw_pixels();        img.resize(img.width() , img.height() ,image::imageops::FilterType::Nearest);        let img = image::open(path).unwrap();pub fn img(path:&str)->Image{#[allow(non_snake_case)]///should strictly be used outside the draw loop!///takes a path to the image and loads it into an Image struct}        });            text: text,            color: self.color,            position: [x as f32,y as f32],        self.text_vec.push(Stext{    pub fn text(&mut self,x:u16,y:u16,text:&'static str){///drawes a text of a certain color and locaion on the canvas}        }            ptnxt = *pt;            });                tex_coords:[0f32,0f32],                color: self.color,                position: mapf(*pt, scale),            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color: self.color,                position: mapf(ptnxt, scale),            self.stroke_vec.push(Vertex {        for pt in c.iter() {        let mut ptnxt = c[0];        let scale = [self.size.0, self.size.1];        let c = bezier_points(x1, y1, x2, y2, x3, y3, x4, y4);pub fn bezierCurveVertex(&mut self,x1: i64, y1: i64, x2: i64, y2: i64, x3: i64, y3: i64, x4: i64, y4: i64) {#[allow(non_snake_case)]///uses the cubic bezier curve algorithm in order to create a curve}        }            });                tex_coords:[0f32,0f32],                color: self.color,                position: mapf(*pt, scale),            self.stroke_vec.push(Vertex {        for pt in c.iter() {        let scale = [self.size.0, self.size.1];        let c = catmull_rom_chain(x1, y1, x2, y2, x3, y3, x4, y4);pub fn curveVertex(&mut self,x1: i64, y1: i64, x2: i64, y2: i64, x3: i64, y3: i64, x4: i64, y4: i64) {#[allow(non_snake_case)]///uses the catmull rom chain algorithm in order to create a curve}    }        );            ptvec[i + 3][1],            ptvec[i + 3][0],            ptvec[i + 2][1],            ptvec[i + 2][0],            ptvec[i + 1][1],            ptvec[i + 1][0],            ptvec[i][1],            ptvec[i][0],        self.curveVertex(    for i in 0..(ptvec.len() - 3) {pub fn curve(&mut self,ptvec: Vec<[i64; 2]>) {///loopes over the array and uses curveVertex to create a catmull rom chain curve}    }        }            );                ptvec[i + 3][1],                ptvec[i + 3][0],                ptvec[i + 2][1],                ptvec[i + 2][0],                ptvec[i + 1][1],                ptvec[i + 1][0],                ptvec[i][1],adS	C
5������7�������i�
�
�
�
�
�
�
�
G
*
�����zJ-����yJ-�
�
�
�
m
I
C
)


�	�	�	�	m	g	-	�����@:�����	����cG	����rQ?9����K�����ysO2���yO0��        let b = color.get_b();        let g = color.get_g();        let r = color.get_r();    pub fn fill(&mut self, color:Color) {    ///the color.    ///enables fill and receives the color of the fill(the struct color) and sets the fill color to be    }        self.fill = false;    pub fn noFill(&mut self) {    #[allow(non_snake_case)]    ///disables fill on the canvas.    }        self.stroke = false;    pub fn noStroke(&mut self){    #[allow(non_snake_case)]    ///disables stroke on the canvas.    }        self.stroke = stroke;    pub fn set_stroke(&mut self,stroke:bool){    ///only sets stroke on, no need to send in color, last stroke color will e used    }        self.fill = fill;    pub fn set_fill(&mut self,fill:bool){    ///only sets fill on, no need to send in color, last fill color will e used    }        self.fill    pub fn get_fill(self)->bool{    ///retruns the fill state of the canvas    }        self.stroke    pub fn get_stroke(self)->bool{    ///retruns the stroke state of the canvas    }        self.color = mapping::map_colors([r, g, b, a]);        self.stroke = true;        let a = color.get_a();        let b = color.get_b();        let g = color.get_g();        let r = color.get_r();    pub fn stroke(&mut self,color:Color){    ///the color.    ///enables stroke and receives the color of the stroke(the struct color) and sets the stroke color to be    }        self.stroke_weight = weight;    pub fn strokeWeight(&mut self,weight:u8){    #[allow(non_snake_case)]    ///sets the stroke weight(the width of lines and points    }        self.background_color = mapping::map_colors([r, g, b, a]);        let a = color.get_a();        let b = color.get_b();        let g = color.get_g();        let r = color.get_r();    pub fn background(&mut self,color:Color){    ///sets the background color(using the color struct).    }        self.key.get_mod()    pub fn get_modifiers(self)->ModifiersState{    ///returns the current state of the modifiers    }        self.cursor_pos.1    pub fn mouseY(&self)->u16{    #[allow(non_snake_case    }        self.mouse_scroll.delta_y()    pub fn mouseScrollY(&self)->i64{    #[allow(non_snake_case)]    ///returns the y scroll delta of the mouse    }        self.mouse_scroll.delta_x()    pub fn mouseScrollX(&self)->i64{    #[allow(non_snake_case)]    ///returns the x scroll delta of the mouse    }        }        None=> {return VirtualKeyCode::Power;}        Some(key)=> {return key;},        match self.key.keycode{    pub fn keyPressed(&mut self)->VirtualKeyCode{    #[allow(non_snake_case)]    ///returns the current key that is pressed.    }        }        None=> {return MouseButton::Other(99);}        Some(btn)=> {return btn;},        match self.mouse.btn{    pub fn mouseClick(&mut self)->MouseButton{    #[allow(non_snake_case)]    ///returns the current key that is pressed on the mouse.impl Canvas {}    }        self.moder    pub fn get_mod(self)->ModifiersState{    }        Key{keycode,moder}        let keycode = None;        let moder = ModifiersState{shift:false,ctrl:false,alt:false,logo:false};        pub fn new()->Key{impl Key{}    pub moder:ModifiersState,    pub keycode:Option<VirtualKeyCode>,struct Key{#[derive(Copy,Clone,PartialEq)]}    }        Mouse{btn,moder}        let btn = None;        let moder = ModifiersState{shift:false,ctrl:false,alt:false,logo:false};        pub fn new()->Mouse{impl Mouse{}    pub moder:ModifiersState,    pub btn:Option<MouseButton>,struct Mouse{ad�p���h@0������(�
�
�
}
U
5

�����lY1%#�|wG�
�
�
�
g
H
1
	
�	�	�	�	s	c	;			�����\=&�����fV,
����u^6&�����dE.����94���dM$�����fG0��            });                tex_coords:[0f32,0f32],                color,                position: pt2,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt1,            self.fill_vec.push(Vertex {            let color = self.fill_color;        if self.fill {        let pt4 = map([x4, y4], scale);        let pt3 = map([x3, y3], scale);        let pt2 = map([x2, y2], scale);        let pt1 = map([x1, y1], scale);        let scale = [self.size.0, self.size.1];    pub fn quad(&mut self,x1: u16, y1: u16, x2: u16, y2: u16, x3: u16, y3: u16, x4: u16, y4: u16) {///recieves the x and y of the 4 points of the quad and creates it based on them}        }            });                tex_coords:[0f32,0f32],                color,                position: pt1,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt3,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt3,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt2,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt2,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt1,            self.stroke_vec.push(Vertex {            let color = self.color;        if self.stroke {        }            });                tex_coords:[0f32,0f32],                color,                position: pt3,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt2,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt1,            self.fill_vec.push(Vertex {            let color = self.fill_color;        if self.fill {        let pt3 = map([x3, y3], scale);        let pt2 = map([x2, y2], scale);        let pt1 = map([x1, y1], scale);        let scale = [self.size.0, self.size.1];    pub fn triangle(&mut self,x1: u16, y1: u16, x2: u16, y2: u16, x3: u16, y3: u16) {///recieves the x and y of the 3 points of the triangle and creates it based on them}        });                tex_coords:[0f32,0f32],            color,            position: fin,        self.stroke_vec.push(Vertex {        });                tex_coords:[0f32,0f32],            color,            position: srt,        self.stroke_vec.push(Vertex {        let color = self.color;        let fin = map([x2, y2], scale);        let srt = map([x, y], scale);        let scale = [self.size.0, self.size.1];    pub fn line(&mut self,x: u16, y: u16, x2: u16, y2: u16) {///line between them.///recieves the x and y of the top point and then the x and the y of the bottom point and creates a}        }            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_l,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],ad#�e���zjB#�����cD-�
�
�
�
m
]
3

����|e=-����kL5
�
�
�
�
u
e
;


�	�	�	�	`	B			��X3�_1����c(����U����pF
�����a<�h<���                    color: self.fill_color,                    position: map_circ([pt_x, pt_y], scale),                self.fill_vec.push(Vertex {                let pty = y as f32 + ((an as f32 / 360.0) * 6.28).sin() * b as f32;                let ptx = x as f32 + ((an as f32 / 360.0) * 6.28).cos() * a as f32;            for an in (0..360).step_by(6) {            let mut pt_y = y as f32;            let mut pt_x = x as f32 + a as f32;        if self.fill {        }            });                tex_coords:[0f32,0f32],                color: self.color,                position: map_circ([pt_x, pt_y], scale),            self.stroke_vec.push(Vertex {            pt_y = y as f32 + 0.5;            pt_x = x as f32 + a as f32 + 0.5;            });                tex_coords:[0f32,0f32],                color: self.color,                position: map_circ([pt_x, pt_y], scale),            self.stroke_vec.push(Vertex {            }                pt_y = pty;                pt_x = ptx;                });                tex_coords:[0f32,0f32],                    color: self.color,                    position: map_circ([ptx, pty], scale),                self.stroke_vec.push(Vertex {                });                tex_coords:[0f32,0f32],                    color: self.color,                    position: map_circ([pt_x, pt_y], scale),                self.stroke_vec.push(Vertex {                let pty = y as f32 + ((an as f32 / 360.0) * 6.28).sin() * b as f32;                let ptx = x as f32 + ((an as f32 / 360.0) * 6.28).cos() * a as f32;            for an in (0..360).step_by(6) {            let mut pt_y = y as f32;            let mut pt_x = x as f32 + a as f32;        if self.stroke && !(self.fill && self.color == self.fill_color) {        let scale = [self.size.0, self.size.1];    pub fn ellipse(&mut self,x: u16, y: u16, a: u16, b: u16) {///and creates it accordingly///recieves the x and the y of the center of the ellipse and the width and height of the ellipse}        }            });                tex_coords:[0f32,0f32],                color,                position: pt1,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt4,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt4,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt3,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt3,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt2,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt2,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt1,            self.stroke_vec.push(Vertex {            let color = self.color;        if self.stroke {        }            });                tex_coords:[0f32,0f32],                color,                position: pt4,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: pt3,            self.fill_vec.push(Vertex {ad*�Y���]1	���X0�
�
�
u
M
%

���c;��rJ:0.�
�
�
i

�	�	�	H	���a5!���eQ5���]M���tL<2���D���Z.���[G���                    color: self.fill_color,                    position: map_circ([x as f32, y as f32], scale),                self.fill_vec.push(Vertex {                });                    tex_coords:[0f32,0f32],                    color: self.fill_color,                    position: map_circ([ptx, pty], scale),                self.fill_vec.push(Vertex {                });                    tex_coords:[0f32,0f32],                    color: self.fill_color,                    position: map_circ([pt_x, pt_y], scale),                self.fill_vec.push(Vertex {                let pty = y as f32 + ((a as f32 / 360.0) * 6.28).sin() * rad as f32;                let ptx = x as f32 + ((a as f32 / 360.0) * 6.28).cos() * rad as f32;            for a in (0..360).step_by(6) {            let mut pt_y = y as f32;            let mut pt_x = x as f32 + rad as f32;        if self.fill {        }            });                tex_coords:[0f32,0f32],                color: self.color,                position: map_circ([pt_x, pt_y], scale),            self.stroke_vec.push(Vertex {            pt_y = y as f32 + 0.5;            pt_x = x as f32 + rad as f32 + 0.5;            });                tex_coords:[0f32,0f32],                color: self.color,                position: map_circ([pt_x, pt_y], scale),            self.stroke_vec.push(Vertex {            }                pt_y = pty;                pt_x = ptx;                });                    tex_coords:[0f32,0f32],                    color: self.color,                    position: map_circ([ptx, pty], scale),                self.stroke_vec.push(Vertex {                });                    tex_coords:[0f32,0f32],                    color: self.color,                    position: map_circ([pt_x, pt_y], scale),                self.stroke_vec.push(Vertex {                let pty = y as f32 + ((a as f32 / 360.0) * 6.28).sin() * rad as f32;                let ptx = x as f32 + ((a as f32 / 360.0) * 6.28).cos() * rad as f32;            for a in (0..360).step_by(6) {            let mut pt_y = y as f32;            let mut pt_x = x as f32 + rad as f32;        if self.stroke && !(self.fill && self.color == self.fill_color) {        let scale = [self.size.0, self.size.1];    pub fn circle(&mut self,x: u16, y: u16, rad: u16) {///recieves the x and y of the center of the circle and the radius and builds it with them.}        }            });                tex_coords:[0f32,0f32],                color: self.fill_color,                position: map_circ([x as f32, y as f32], scale),            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color: self.fill_color,                position: map_circ([pt_x, pt_y], scale),            self.fill_vec.push(Vertex {            pt_y = y as f32 + 0.5;            pt_x = x as f32 + a as f32 + 0.5;            });                tex_coords:[0f32,0f32],                color: self.fill_color,                position: map_circ([pt_x, pt_y], scale),            self.fill_vec.push(Vertex {            }                pt_y = pty;                pt_x = ptx;                });                tex_coords:[0f32,0f32],                    color: self.fill_color,                    position: map_circ([x as f32, y as f32], scale),                self.fill_vec.push(Vertex {                });                tex_coords:[0f32,0f32],                    color: self.fill_color,                    position: map_circ([ptx, pty], scale),                self.fill_vec.push(Vertex {                });                tex_coords:[0f32,0f32],ad�]����zR����f>�
�
�
}
<

����pGB"���|ca�
�
�
W

�	�	�	2	��rK��{O;����}N��x;���h<���_3�����m8����                ptvec[i][0],            self.bezierCurveVertex(        if (i + 1) % 4 == 0 || i == 0 {    for i in 0..(ptvec.len() - 3) {pub fn bezierCurve(&mut self,ptvec: Vec<[i64; 2]>) {#[allow(non_snake_case)]///loopes over the array and uses curveVertex to create a bezier curve}        }            }                pt_y = pty;                pt_x = ptx;                });                    tex_coords:[0f32,0f32],                    color: self.fill_color,                    position: map_circ([x as f32, y as f32], scale),                self.fill_vec.push(Vertex {                });                    tex_coords:[0f32,0f32],                    color: self.fill_color,                    position: map_circ([ptx, pty], scale),                self.fill_vec.push(Vertex {                });                    tex_coords:[0f32,0f32],                    color: self.fill_color,                    position: map_circ([pt_x, pt_y], scale),                self.fill_vec.push(Vertex {                let pty = y as f32 + ((a as f32 / 360.0) * 6.28).sin() * rad as f32;                let ptx = x as f32 + ((a as f32 / 360.0) * 6.28).cos() * rad as f32;            for a in (0..deg + 6).step_by(6) {            let mut pt_y = y as f32;            let mut pt_x = x as f32 + rad as f32;        if self.fill {        }            }                pt_y = pty;                pt_x = ptx;                });                    tex_coords:[0f32,0f32],                    color: self.color,                    position: map_circ([ptx, pty], scale),                self.stroke_vec.push(Vertex {                });                    tex_coords:[0f32,0f32],                    color: self.color,                    position: map_circ([pt_x, pt_y], scale),                self.stroke_vec.push(Vertex {                let pty = y as f32 + ((a as f32 / 360.0) * 6.28).sin() * rad as f32;                let ptx = x as f32 + ((a as f32 / 360.0) * 6.28).cos() * rad as f32;            for a in (0..deg + 6).step_by(6) {            let mut pt_y = y as f32;            let mut pt_x = x as f32 + rad as f32;        if self.stroke && !(self.fill && self.color == self.fill_color) {        let scale = [self.size.0, self.size.1];    pub fn arc(&mut self,x: u16, y: u16, rad: u16, deg: u16) {///covered by the arc (360 degree arc is a full circle).///create an arc from a circle, recieves the center of the circle and the radius and the degrees}        self.fill = fil;        self.stroke = stro;        self.circle(x, y, self.stroke_weight as u16);        self.fill = true;        self.stroke = false;        let fil = self.fill;        let stro = self.stroke;    pub fn point(&mut self,x: u16, y: u16) {///recieves the x and the y and makes a small circle in the spot(size depends on strokeWeight).}        }            });                tex_coords:[0f32,0f32],                color: self.fill_color,                position: map_circ([x as f32, y as f32], scale),            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color: self.fill_color,                position: map_circ([pt_x, pt_y], scale),            self.fill_vec.push(Vertex {            pt_y = y as f32 + 0.5;            pt_x = x as f32 + rad as f32 + 0.5;            });                tex_coords:[0f32,0f32],                color: self.fill_color,                position: map_circ([pt_x, pt_y], scale),            self.fill_vec.push(Vertex {            }                pt_y = pty;                pt_x = ptx;                });                    tex_coords:[0f32,0f32],ad$t���zj`G#�����aB+�
�
�
�
k
[
1

����zc;+����iJ3�
�
�
�
s
c
Y
W
�	�	�	�	m	7			���sT=���oG(����{SC�����fO'
����pH8����vW@����pF'                color,                position: b_l,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_r,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_r,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.stroke_vec.push(Vertex {            let color = self.color;        if self.stroke {        }            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_r,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.fill_vec.push(Vertex {            let color = self.fill_color;        if self.fill {        let b_l = map([x, y + width], scale);        let t_r = map([x + width, y], scale);        let b_r = map([x + width, y + width], scale);        let t_l = map([x, y], scale);        let scale = [self.size.0, self.size.1];    pub fn square(&mut self,x: u16, y: u16, width: u16) {///recieves the x and y of the top spot and then the width of the sqaure you want built.}        }            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_l,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_l,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_r,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_r,            self.stroke_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.stroke_vec.push(Vertex {            let color = self.color;        if self.stroke {        }            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.fill_vec.push(Vertex {ad��=��w]F����w]F�
�
�
�
s
Y
6


����uK��S4�
�
}
I

�	�	�	d	7	
	���qC�����^=�����x���r;
���vW@����rJ+����~VF����            });                tex_coords:[0f32,0f32],                color,                position: b_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_r,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.fill_vec.push(Vertex {            let color = self.fill_color;        if self.fill {        let b_l = map([x, y + height], scale);        let t_r = map([x + width, y], scale);        let b_r = map([x + width, y + height], scale);        let t_l = map([x, y], scale);        let scale = [self.size.0, self.size.1];    pub fn rect(&mut self,x: u16, y: u16, width: u16, height: u16) {///built.///recieves the x and y of the top spot and then the width and height of the rectangle you want        }        //});        }            self.mouse_scroll.delta = (0,0);            self.mouse.btn = Some(MouseButton::Other(99));            self.key.keycode = Some(VirtualKeyCode::Power);            self= draw_fn(self);            //draw_fn(self.clone());            self.stroke_vec = vec![];            self.fill_vec = vec![];            self.text_vec = vec![];            }            self.fps =counter1 as f32/(end-start).as_secs() as f32;            if end- start>Duration::new(1,0){            end = Instant::now();                }                    }                            Box::new(sync::now(env.device.clone())) as Box<_>;                        previous_frame_end =                        println!("{:?}", e);                    Err(e) => {                    }                            Box::new(sync::now(env.device.clone())) as Box<_>;                        previous_frame_end =                        recreate_swapchain = true;                    Err(FlushError::OutOfDate) => {                    }                        previous_frame_end = Box::new(future) as Box<_>;                        future.wait(None).unwrap();                    Ok(future) => {                match future {                    .then_signal_fence_and_flush();                    .then_swapchain_present(env.queue.clone(), env.swapchain.clone(), image_num)                    .unwrap()                    .then_execute(env.queue.clone(), command_buffer)                    .join(acquire_future)                let future = previous_frame_end                    }                        };                }                .unwrap();                .build()                .unwrap()                .end_render_pass()                .unwrap()                )                    (),                    (),                    vec![stroke_vertex_buffer.clone()],                    &env.dynamic_state,                    env.stroke_pipeline.clone(),                .draw(                .unwrap()                )                    (),                    (),                    vec![fill_vertex_buffer.clone()],                    &env.dynamic_state,                    env.fill_pipeline.clone(),                .draw(                .unwrap()                .begin_render_pass(env.framebuffers[image_num].clone(), false, clear_values)                .unwrap()                )ad�c�tI ��|jP�
�
�
�
l
6

�����a)�����_F+�
�
x
P
>
$
�	�	�	g	?			�����e=�����l;"����j����5��xW?-���kS;)����_���                    env.queue.family(),                    env.device.clone(),                    command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(                        None=>{                            },                .unwrap();                .build()                .unwrap()                .end_render_pass()                .unwrap()                )                    (),                    (),                    vec![stroke_vertex_buffer.clone()],                    &env.dynamic_state,                    env.stroke_pipeline.clone(),                .draw(                .unwrap()                )                    (),                    set.clone(),                    vec![fill_vertex_buffer.clone()],                    &env.dynamic_state,                    env.tex_pipeline.clone(),                .draw(                .unwrap()                .begin_render_pass(env.framebuffers[image_num].clone(), false, clear_values)                .unwrap()                )                    env.queue.family(),                    env.device.clone(),                        command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(                            Some(set)=>{                        match set.clone(){                    }else{                        };                },                .unwrap();                .build()                .draw_text(&mut text, image_num)                .unwrap()                .end_render_pass()                .unwrap()                )                    (),                    (),                    vec![stroke_vertex_buffer.clone()],                    &env.dynamic_state,                    env.stroke_pipeline.clone(),                .draw(                .unwrap()                )                    (),                    (),                    vec![fill_vertex_buffer.clone()],                    &env.dynamic_state,                    env.fill_pipeline.clone(),                .draw(                .unwrap()                .begin_render_pass(env.framebuffers[image_num].clone(), false, clear_values)                .unwrap()                )                    env.queue.family(),                    env.device.clone(),                command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(                None=>{                            },                .unwrap();                .build()                .draw_text(&mut text, image_num)                .unwrap()                .end_render_pass()                .unwrap()                )                    (),                    (),                    vec![stroke_vertex_buffer.clone()],                    &env.dynamic_state,                    env.stroke_pipeline.clone(),                .draw(                .unwrap()                )                    (),                    set.clone(),                    vec![fill_vertex_buffer.clone()],                    &env.dynamic_state,                    env.tex_pipeline.clone(),                .draw(                .unwrap()                .begin_render_pass(env.framebuffers[image_num].clone(), false, clear_values)                .unwrap()                )                    env.queue.family(),                    env.device.clone(),                command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(                            Some(set)=>{                        match set.clone(){                        }                            text.queue_text(txt.position[0],txt.position[0], self.text_size, txt.color,txt.text);ad!
�
��gH-���}6#�
�
�
S
&
���yb��jK4�
�
�
�
�
�
f
)

�	�	�	c	(		���y=���K4���(���Y4��G�|X���nW��~                        for txt in self.text_vec{                if self.text_vec.len()>0{                let command_buffer:AutoCommandBuffer;                let clear_values = vec![self.background_color.into()];                    };                        Err(err) => panic!("{:?}", err),                        }                            continue;                            recreate_swapchain = true;                        Err(AcquireError::OutOfDate) => {                        Ok(r) => r,                    match swapchain::acquire_next_image(env.swapchain.clone(), None) {                let (image_num, acquire_future) =                }                    recreate_swapchain = false;                    text = DrawText::new(env.device.clone(), env.queue.clone(), env.swapchain.clone(), &new_images);                    );                        &mut env.dynamic_state,                        env.render_pass.clone(),                        &new_images,                    env.framebuffers = window_size_dependent_setup(                    env.swapchain = new_swapchain;                        };                            Err(err) => panic!("{:?}", err),                            Err(SwapchainCreationError::UnsupportedDimensions) => continue,                            Ok(r) => r,                        match env.swapchain.recreate_with_dimension(dimensions) {                    let (new_swapchain, new_images) =                    };                        [dimensions.0, dimensions.1]                            .into();                            .to_physical(window.get_hidpi_factor())                            .unwrap()                            .get_inner_size()                        let dimensions: (u32, u32) = window                    let dimensions = {                if recreate_swapchain {                let window = env.surface.window();                .unwrap();                )                    self.fill_vec.clone().iter().cloned(),                    BufferUsage::all(),                    env.device.clone(),                let fill_vertex_buffer = CpuAccessibleBuffer::from_iter(                .unwrap();                )                    self.stroke_vec.clone().iter().cl                },                    self.mouse_scroll = MouseScroll{de                },                },                    self.mouse_scroll = MouseScroll{delta:(pos.x as i64,pos.y as i64),moder:modifiers};                } => {                            ..                            modifiers,                            delta: MouseScrollDelta::PixelDelta(pos),                    WindowEvent::MouseWheel{                },                    self.mouse = Mouse{btn:Some(button1),moder:modifiers};                } => {                            ..                            modifiers,                            button: button1,                            state: ElementState::Pressed,                    WindowEvent::MouseInput{                   }=>{self.cursor_pos = (posx as u16,posy as u16);},                        ..                        position:LogicalPosition{x:posx,y:posy},                    WindowEvent::CursorMoved{                },                    self.key = Key{keycode:Some(key),moder:modifiers};                    }                        done = true;                    if key == VirtualKeyCode::W && modifiers.ctrl{                } => {                        ..                        },                            ..                            modifiers,                            virtual_keycode: Some(key),                            state: ElementState::Pressed,ad�i����:����M("�
�
�
�
�
w
b
\
5


����r`?)�����u_G5!�
�
�
�
�
[
Q
'
!

�	�	�	p	L	+	����]A����/��\C����l^S����NM>���T=���{L/��                        input:KeyboardInput{                    WindowEvent::KeyboardInput{                match event{                Event::WindowEvent{event,..}=>                } => recreate_swapchain = true,                    ..                    event: WindowEvent::Resized(_),                Event::WindowEvent {                } => done = true,                    ..                    event: WindowEvent::CloseRequested,                Event::WindowEvent {            events_loop.poll_events(|ev| match ev {                previous_frame_end.cleanup_finished();            let mut done = false;        loop {        let mut recreate_swapchain = env.recreate_swapchain;        let mut end;        let start = Instant::now();        let mut counter1 = 0;        let mut text = DrawText::new(env.device.clone(), env.queue.clone(), env.swapchain.clone(), &env.images);        };            }                previous_frame_end =Box::new(env.previous_frame_end.unwrap());                set =None;            None =>{            },        previous_frame_end = Box::new(tex_future) as Box<dyn GpuFuture>;    .build().unwrap()));    .add_sampled_image(texture.clone(), sampler.clone()).unwrap()    set = Some(Arc::new(PersistentDescriptorSet::start(env.tex_pipeline.clone(),0)    SamplerAddressMode::Repeat, 0.0, 1.0, 0.0, 0.0).unwrap();    MipmapMode::Nearest, SamplerAddressMode::Repeat, SamplerAddressMode::Repeat,    let sampler = Sampler::new(env.device.clone(), Filter::Linear, Filter::Linear,        };                ).unwrap()                env.queue.clone()                Format::R8G8B8A8Srgb,                dimensions,                vec_tex.iter().cloned(),                ImmutableImage::from_iter(        let (texture, tex_future) = {                let dimensions = dim1;                let vec_tex = vec1.to_vec();            Some((vec1,dim1))=>{        match self.texture.clone(){        //draw_fn();        self = draw_fn(self);        let (mut env, mut events_loop) = init(self.size.0, self.size.1);        let mut previous_frame_end;        let set;    {        F: FnMut(Self)->Canvas + 'static,    where    pub fn show<F>(mut self, mut draw_fn: F)    ///this is the function used to run the animation    }        }    mouse_scroll:MouseScroll::new(),    mouse:Mouse::new(),    cursor_pos:(0,0),    key:Key::new(),    texture:None,    stroke_vec: vec![],    fill_vec: vec![],    text_vec: vec![],    text_size: 18.0,    resizeable: false,    fps: 60.0,    background_color: [1.0, 1.0, 1.0, 1.0],    fill_color: [1.0, 1.0, 1.0, 1.0],    fill: false,    stroke_weight: 8,    color: [0.0, 0.0, 0.0, 1.0],    stroke: true,    size: (width, height),        Canvas{    pub fn new(width:u16,height:u16)->Canvas{    ///creates a new canvas surface for rendering    }        self.size.1     pub fn width(self)->u16{    ///returns the width of the canvas    }        self.size.1     pub fn height(self)->u16{    ///returns the height of the canvas    }        self.size    pub fn get_size(self)->(u16,u16) {    ///returns the size of the canvas    }        self.size = (width, height);    pub fn size(&mut self,width: u16, height: u16) {    ///creates the canvas with the width and height sent to this function    }        self.text_size = sz as f32;    pub fn textSize(&mut self,sz:u8) {    #[allow(non_snake_case)]    ///recieves f32 ext size and sets the canvases text_size to that size    }        self.fill_color = mapping::map_colors([r, g, b, a]);        self.fill = true;        let a = color.get_a();ad�
�
�����tr`A�����vpQ& �
##########################[derive(Copy,Clone,Part##################[de#[derive##################################################[derive(Copy,Clone,PartialEq)]}    }        self.delta.1//.PixelDelta.y as i64    pub fn delta_y(self)->i64{    }        self.delta.0    pub fn delta_x(self)->i64{    }        MouseScroll{delta,moder}        let delta = (0,0);        let moder = ModifiersState{shift:false,ctrl:false,alt:false,logo:false};        pub fn new()->MouseScroll{impl MouseScroll{}    pub moder:ModifiersState,    pub delta:(i64,i64),struct MouseScroll{#[derive(Copy,Clone,PartialEq)]}    //draw:FnMut() + 'static, adA
�
(����e[���Z+�
�
�
�
e
U
-

����xa9)����kL5
�
            });                tex_coords:[0f32,0f32],                color,                position: b_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_l,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: t_r,            self.fill_vec.push(Vertex {            });                tex_coords:[0f32,0f32],                color,                position: b_r,            self.fill_vec.push(Vertex {            let color = self.fill_color;        if self.fill {        let b_l = map([x, y + height], scale);        let t_r = map([x + width, y], scale);        let b_r = map([x + width, y + height], scale);        let t_l = map([x, y], scale);        let scale = [self.size.0, self.size.1];    pub fn rect(&mut self,x: u16, y: u16, width: u16, height: u16) {///built.///recieves the x and y of the top spot and then the width and height of the rectangle you want        }        //});        }            counter1+=1;ad��:������v*���R@%�
�
�
Q
?
$
���f8��t]'�
�
Q

�	�	�	]	,	��p@.���G����9��                        for txt in self.text_vec{                if self.text_vec.len()>0{                let command_buffer:AutoCommandBuffer;                let clear_values = vec![self.background_color.into()];                    };                        Err(err) => panic!("{:?}", err),                        }                            continue;                            recreate_swapchain = true;                        Err(AcquireError::OutOfDate) => {                        Ok(r) => r,                    match swapchain::acquire_next_image(env.swapchain.clone(), None) {                let (image_num, acquire_future) =                }                    recreate_swapchain = false;                    text = DrawText::new(env.device.clone(), env.queue.clone(), env.swapchain.clone(), &new_images);                    );                        &mut env.dynamic_state,                        env.render_pass.clone(),                        &new_images,                    env.framebuffers = window_size_dependent_setup(                    env.swapchain = new_swapchain;                        };                            Err(err) => panic!("{:?}", err),                            Err(SwapchainCreationError::UnsupportedDimensions) => continue,                            Ok(r) => r,                        match env.swapchain.recreate_with_dimension(dimensions) {                    let (new_swapchain, new_images) =                    };                        [dimensions.0, dimensions.1]                            .into();                            .to_physical(window.get_hidpi_factor())                            .unwrap()                            .get_inner_size()                        let dimensions: (u32, u32) = window                    let dimensions = {                if recreate_swapchain {                let window = env.surface.window();                .unwrap();                )                    self.fill_vec.clone().iter().cloned(),                    BufferUsage::all(),                    env.device.clone(),                let fill_vertex_buffer = CpuAccessibleBuffer::from_iter(                .unwrap();                )                    self.stroke_vec.clone().iter().cloned(),                    BufferUsage::all(),                    env.device.clone(),                let stroke_vertex_buffer = CpuAccessibleBuffer::from_iter(            env.dynamic_state.line_width = Some(self.stroke_weight as f32);            }                return;            if done {            });                _ => (),            }                _=>{},ad��E���yN1����uo5�
�
�
�
H
B

����#����kO�
�
�
�
z
Y
G
A
�	�	�	�	S	%			����{W:���W8�        let b = color.get_b();        let g = color.get_g();        let r = color.get_r();    pub fn fill(&mut self, color:Color) {    ///the color.    ///enables fill and receives the color of the fill(the struct color) and sets the fill color to be    }        self.fill = false;    pub fn noFill(&mut self) {    #[allow(non_snake_case)]    ///disables fill on the canvas.    }        self.stroke = false;    pub fn noStroke(&mut self){    #[allow(non_snake_case)]    ///disables stroke on the canvas.    }        self.stroke = stroke;    pub fn set_stroke(&mut self,stroke:bool){    ///only sets stroke on, no need to send in color, last stroke color will e used    }        self.fill = fill;    pub fn set_fill(&mut self,fill:bool){    ///only sets fill on, no need to send in color, last fill color will e used    }        self.fill    pub fn get_fill(self)->bool{    ///retruns the fill state of the canvas    }        self.stroke    pub fn get_stroke(self)->bool{    ///retruns the stroke state of the canvas    }        self.color = mapping::map_colors([r, g, b, a]);        self.stroke = true;        let a = color.get_a();        let b = color.get_b();        let g = color.get_g();        let r = color.get_r();    pub fn stroke(&mut self,color:Color){    ///the color.    ///enables stroke and receives the color of the stroke(the struct color) and sets the stroke color to be    }        self.stroke_weight = weight;    pub fn strokeWeight(&mut self,weight:u8){    #[allow(non_snake_case)]    ///sets the stroke weight(the width of lines and points    }        self.background_color = mapping::map_colors([r, g, b, a]);        let a = color.get_a();        let b = color.get_b();        let g = color.get_g();        let r = color.get_r();    pub fn background(&mut self,color:Color){    ///sets the background color(using the color struct).    }        self.key.get_mod()    pub fn get_modifiers(self)->ModifiersState{    ///returns the current state of the modifiers    }        self.cursor_pos.1    pub fn mouseY(&self)->u16{    #[allow(non_snake_case)]    ///returns the y position of the mouse    }        self.cursor_pos.0    pub fn mouseX(&self)->u16{    #[allow(non_snake_case)]    ///returns the x position of the mouse