b0VIM 8.1 2��]L� �A guyl guyl-HP-EliteBook-840-G1 ~guyl/Desktop/rust_things/metropolis/src/lib.rs utf-8
3210 #"! U tp
f ; g c � y � s f e � ] >
l � o 5 v ad � f � : � � J �
)
� � � r Z B ( � � � n \ ? & �
W
<
� � ] I D = � } v Y 6 ( � � � { L � � � � � n b 9 ' � � � � � � ~ n � � � � � � � : / � � � � \ = � � � � � k K > $ � � � Some(vec1) => { } TEXT_VEC = Some(vec![pusher]); None => { match &TEXT_VEC { unsafe { fn add_to_text(pusher: Stext) { use winit::ModifiersState; pub use winit::MouseButton; pub use winit::VirtualKeyCode as keyCode; use image::*; use vulkano::image::Dimensions; pub static mut WIDTH:u16 = 0u16; pub static mut HEIGHT:u16 = 0u16; pub static mut FPS:f32 = 0f32; use math::{bezier_points, catmull_rom_chain}; use color::*; pub mod math; ///Will be much expanded upon in the near future. ///a module to provide some mathematical help functions from the crate. pub mod color; ///future. ///a module used for coloring in this crate, will be adding more functions and easier set in the use canvas_glob::*; mod canvas_glob; mod compute; mod text; pub use canvas::*; pub mod canvas; ///safe canvases ///the canvas mod contains the canvas and image structs used to create multiple and multithreading use mapping::*; mod shaders; mod setup; mod mapping; use vertex::*; mod vertex; //!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::*; //!``` //!the public canvas struct(there is actually an inner one for the static functions). it is //!or you can do something similar only with a safe canvas struct(take your pick for your use case: //!``` //!} //! //show(draw); //! //it's commented because it loopes over with no timeout //! //finally I send the draw function into show like that(should be used without the commenting, //! }; //! circle(400,posy,100); //! fill(rgb(255,0,100)); //! //radius of 100. //! // and circle which draws a circle with a center in 400(in x) and posy(changing y), with a //! // and those are the library functions fill-which makes the filled color be pinkish //! } //! posy+=spd; //! if posy+50< height{ //! spd+=1; //! //inside the draw function I create the accelaration to simulate gravity //! let draw =move || { //! background(grayscale(100)); //! let mut posy = 0; //! let mut spd = 0; //! size(width,height); //! let width = 1200; //! let height = 900; //! //here I set up the background, height, width,spd,and the position on y //!fn main() { //!use metropolis::color::*; //!use metropolis::*; //!``` //!like this (grvaity example): //!and finally send it to the show function(designed to loop over the draw function). //!animation/game/test/simulation you want to run, then you create a closure and save it to a variable, //!size(width,height), afterwards, you create some setup variable and setup the background for the //!the way to use the library is to use the size function to create a canvas with a fixed //!under development(for now it's just 2D functions). //!you to make sveral canvases and display them as you wish. 3D is also coming and is currently //!javascript. Working with it utilizes high level function like arc,line,rect and such that are //!this crate is a high level easy to use graphics renderer inspired by processing in java and p5 in ad w g 5 � ~ % � � � k I < �
�
j
I
� � � n M � � � z �
m
� � � j I � [ O 2 � � � t W � � ; / � q k i g }}}}}}}}}}}}}}}} } } TEXTURE = Some((self.image_data,self.dimensions)); println!("pos:{:?}\ntex:{:?}",FILL_VERTECIES.clone().unwrap()[0].position,FILL_VERTECIES.clone().unwrap()[0].tex_coords); }); tex_coords: map([x,(y+(self.dimensions.height() as u16))], scale), //tex_coords: map_tex(map([x,(y+(self.dimensions.height() as u16))], scale),imsize), color: CANVAS.color, position: map([x,y+(self.dimensions.height() as u16)], scale), add_to_fill(Vertex { }); tex_coords: map([x,y], scale), //tex_coords: map_tex(map([x,y], scale),imsize), color: CANVAS.color, position: map([x,y], scale), add_to_fill(Vertex { }); tex_coords: map([x+(self.dimensions.width() as u16),y+(self.dimensions.height() as u16)], scale), //tex_coords: map_tex(map([x+(self.dimensions.width() as u16),y+(self.dimensions.height() as u16)], scale),imsize), color: CANVAS.color, position: map([x+(self.dimensions.width() as u16),y+(self.dimensions.height() as u16)], scale), add_to_fill(Vertex { }); tex_coords: map([x+(self.dimensions.width() as u16),y+(self.dimensions.height() as u16)], scale), //tex_coords: map_tex(map([x+(self.dimensions.width() as u16),y+(self.dimensions.height() as u16)], scale),imsize), color: CANVAS.color, position: map([x+(self.dimensions.width() as u16),y+(self.dimensions.height() as u16)], scale), add_to_fill(Vertex { }); tex_coords: map([x+(self.dimensions.width() as u16),y], scale), //tex_coords: map_tex(map([x+(self.dimensions.width() as u16),y], scale),imsize), color: CANVAS.color, position: map([x+(self.dimensions.width() as u16),y], scale), add_to_fill(Vertex { }); tex_coords: map([x,y], scale), //tex_coords: map_tex(map([x,y], scale),imsize), color: CANVAS.color, position: map([x,y], scale), add_to_fill(Vertex { let _imsize = [self.dimensions.width() as u16,self.dimensions.height() as u16]; let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn display(self,x:u16,y:u16){ ///simply displays a loaded image ///this function shoould be used inside the draw loop, because it does not load an image, it impl Image{ } 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); ad � c � � � � � � ~ W > ( � � � � � [ U S ' �
�
�
�
�
}
w
u
G
� � � � � z m G A ?
� � � � � � � � = 3 �
�
�
�
^
0
� � � } f > .
� � � � ~ _ H � � � � � ` A * � � � � s c Y > � � � color, position: t_l, add_to_stroke(Vertex { let color = CANVAS.color; if CANVAS.stroke { } }); tex_coords:[0f32,0f32], color, position: b_r, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: b_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_r, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: b_r, add_to_fill(Vertex { let color = CANVAS.fill_color; if CANVAS.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 = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn rect(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 } } CANVAS.show(draw_fn); unsafe { { F: FnMut() + 'static, where pub fn show<F>(draw_fn: F) ///this is the function used to run the animation } } CANVAS.text_size = sz as f32; unsafe { pub fn textSize(sz:u8) { #[allow(non_snake_case)] ///recieves f32 ext size and sets the canvases text_size to that size } } CANVAS.key.get_mod() unsafe{ pub fn get_modifiers()->ModifiersState{ ///returns the current state of the modifiers } } } None=> {return keyCode::Power;} Some(key)=> {return key;}, match CANVAS.key.keycode{ unsafe{ pub fn keyPressed()->keyCode{ #[allow(non_snake_case)] ///returns the current key that is pressed. } } CANVAS.size = (width, height); unsafe { pub fn size(width: u16, height: u16) { ///creates the canvas with the width and height sent to this function } } CANVAS.cursor_pos.1 unsafe{ pub fn mouseY()->u16{ #[allow(non_snake_case)] ///returns the y position of the mouse } } CANVAS.cursor_pos.0 unsafe{ pub fn mouseX()->u16{ #[allow(non_snake_case)] ///returns the x position of the mouse ad u }
; � � � { p j h G : � � � x U ( �
�
�
�
h
Z
>
� � � � � � s Z > 2
� � � � z t r 9 �
�
�
�
�
�
}
d
E
!
� � � � � � J 1 � � � � � � p n a C = ; � � � � Y 3 � � � � [ : � � � � u M = � � � � � n W / � � � � � o P 9 � � � � t ] \ color, position: t_l, add_to_stroke(Vertex { let color = CANVAS.color; if CANVAS.stroke { } }); tex_coords:[0f32,0f32], color, position: b_r, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: b_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_r, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: b_r, add_to_fill(Vertex { let color = CANVAS.fill_color; if CANVAS.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 = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn rect(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 } } CANVAS.show(draw_fn); unsafe { { F: FnMut() + 'static, where pub fn show<F>(draw_fn: F) ///this is the function used to run the animation } } CANVAS.text_size = sz as f32; unsafe { pub fn textSize(sz:u8) { #[allow(non_snake_case)] ///recieves f32 ext size and sets the canvases text_size to that size } } CANVAS.key.get_mod() unsafe{ pub fn get_modifiers()->ModifiersState{ ///returns the current state of the modifiers } } } None=> {return keyCode::Power;} Some(key)=> {return key;}, match C} }}}}}}}}}}} } } None=> {return MouseButton::Other(99);} Some(btn)=> {return btn;}, match CANVAS.mouse.btn{ unsafe{ pub fn mouseClick()->MouseButton{ #[allow(non_snake_case)] ///returns the current key that is pressed on the mouse. } } CANVAS.mouse_scroll.delta_y() unsafe{ pub fn mouseScrollY()->i64{ #[allow(non_snake_case)] ///returns the y scroll delta of the mouse } } CANVAS.mouse_scroll.delta_x() unsafe{ pub fn mouseScrollX()->i64{ #[allow(non_snake_case)] ///returns the x scroll delta of the mouse } } }; } STROKE_VERTECIES = Some(vec2); vec2.push(pusher); let mut vec2 = vec1.clone(); Some(vec1) => { } STROKE_VERTECIES = Some(vec![pusher]); None => { match &STROKE_VERTECIES { unsafe { fn add_to_stroke(pusher: Vertex) { } } }; } FILL_VERTECIES = Some(vec2); vec2.push(pusher); let mut vec2 = vec1.clone(); Some(vec1) => { } FILL_VERTECIES = Some(vec![pusher]); None => { match &FILL_VERTECIES { unsafe { fn add_to_fill(pusher: Vertex) { } } }; } TEXT_VEC = Some(vec2); vec2.push(pusher); let mut vec2 = vec1.clone(); ad O O y � � � � o G 7 � � � � � d M % �
�
�
�
�
a
B
+
� � � � r b ? � � � � � f : - �
�
�
o
A
(
� � � � ~ n M . � � � � � ` P / � � � � � j B 2 � � � � � ~ X 5 � � � � � n F 6 � � � � � c L $ � � � � � ` A * � � � � q a W Q O N } } } }); tex_coords:[0f32,0f32], color, position: t_l, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: b_l, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: b_l, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: b_r, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: t_r, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: t_r, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: t_l, add_to_stroke(Vertex { let color = CANVAS.color; if CANVAS.stroke { } }); tex_coords:[0f32,0f32], color, position: b_r, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: b_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_l, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: t_r, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: b_r, add_to_fill(Vertex { let color = CANVAS.fill_color; if CANVAS.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 = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn square(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, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: b_l, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: b_l, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: b_r, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: b_r, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: t_r, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: t_r, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], ad � s � � V I � � � � k X 0 $ �
�
�
�
�
�
F
� � � � m E , � � � � r Q 2 �
�
�
�
�
d
T
J
/
� � � � x U 6 � � � � � f V 3 � � � � � l D 4 � � � � � � � @ � � � � Y 1 � � � � n F 6 � � � � � g P ( � � � � � d > � � position: pt1, add_to_stroke(Vertex { let color = CANVAS.color; if CANVAS.stroke { } }); tex_coords:[0f32,0f32], color, position: pt4, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: pt3, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: pt2, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: pt1, add_to_fill(Vertex { let color = CANVAS.fill_color; if CANVAS.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 = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn quad(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, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt3, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt3, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt2, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt2, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt1, add_to_stroke(Vertex { let color = CANVAS.color; if CANVAS.stroke { } }); tex_coords:[0f32,0f32], color, position: pt3, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: pt2, add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color, position: pt1, add_to_fill(Vertex { let color = CANVAS.fill_color; if CANVAS.fill { let pt3 = map([x3, y3], scale); let pt2 = map([x2, y2], scale); let pt1 = map([x1, y1], scale); let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn triangle(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, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: srt, add_to_stroke(Vertex { let color = CANVAS.color; let fin = map([x2, y2], scale); let srt = map([x, y], scale); let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn line(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 ad � e � � � � o X 0 � � � � � l M 6 �
�
�
�
}
m
J
+
� � � � � [ K ( � � � � � � G ) �
�
�
e
5
� � < � � � s L � � � � t f C
� � � \ 9 � � � � � P + � � W 2 � � � � f + � � � � W ) � � � � pt_y = pty; pt_x = ptx; }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([x as f32, y as f32], scale), add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([ptx, pty], scale), add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([pt_x, pt_y], scale), add_to_fill(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 CANVAS.fill { } }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([pt_x, pt_y], scale), add_to_stroke(Vertex { pt_y = y as f32 + 0.5; pt_x = x as f32 + a as f32 + 0.5; }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([pt_x, pt_y], scale), add_to_stroke(Vertex { } pt_y = pty; pt_x = ptx; }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([ptx, pty], scale), add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([pt_x, pt_y], scale), add_to_stroke(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 CANVAS.stroke && !(CANVAS.fill && CANVAS.color == CANVAS.fill_color) { let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn ellipse(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, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt4, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt4, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt3, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt3, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt2, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, position: pt2, add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color, ad � ] � � � n F 6 � � � a 9 ) �
�
u
e
[
U
S
� � � � : � � c �
�
�
U
A
� � � v Z > 0
� � � w G $ � � { k a H � � q � � � ` L ' � � � ~ Y � � � � n ` ? � � � t Q 0 � � � � � }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([pt_x, pt_y], scale), add_to_fill(Vertex { pt_y = y as f32 + 0.5; pt_x = x as f32 + rad as f32 + 0.5; }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([pt_x, pt_y], scale), add_to_fill(Vertex { } pt_y = pty; pt_x = ptx; }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([x as f32, y as f32], scale), add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([ptx, pty], scale), add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([pt_x, pt_y], scale), add_to_fill(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 CANVAS.fill { } }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([pt_x, pt_y], scale), add_to_stroke(Vertex { pt_y = y as f32 + 0.5; pt_x = x as f32 + rad as f32 + 0.5; }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([pt_x, pt_y], scale), add_to_stroke(Vertex { } pt_y = pty; pt_x = ptx; }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([ptx, pty], scale), add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([pt_x, pt_y], scale), add_to_stroke(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 CANVAS.stroke && !(CANVAS.fill && CANVAS.color == CANVAS.fill_color) { let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn circle(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: CANVAS.fill_color, position: map_circ([x as f32, y as f32], scale), add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([pt_x, pt_y], scale), add_to_fill(Vertex { pt_y = y as f32 + 0.5; pt_x = x as f32 + a as f32 + 0.5; }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([pt_x, pt_y], scale), add_to_fill(Vertex { } ad � l � � t L < 2 , * � � � | ] > " �
�
�
�
�
K
=
!
� � � � � M G E � � � � z _ D 7 �
�
�
�
d
I
.
� � � � h F 9
� � � � � � � k R > 1
� p ? 2 � � z U & � | U � � � � M $ � � � � � � { I $ � � K & � � position: map_circ([pt_x, pt_y], scale), add_to_fill(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 CANVAS.fill { } } pt_y = pty; pt_x = ptx; }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([ptx, pty], scale), add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.color, position: map_circ([pt_x, pt_y], scale), add_to_stroke(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 CANVAS.stroke && !(CANVAS.fill && CANVAS.color == CANVAS.fill_color) { let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { pub fn arc(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 } } CANVAS.stroke = false; unsafe { pub fn noStroke() { #[allow(non_snake_case)] ///disables stroke on the canvas. } } CANVAS.fill = false; unsafe { pub fn noFill() { #[allow(non_snake_case)] ///disables fill on the canvas. } } CANVAS.stroke_weight = weight; unsafe { pub fn strokeWeight(weight: u8) { #[allow(non_snake_case)] ///sets the stroke weight(the width of lines and points } } CANVAS.background_color = mapping::map_colors([r, g, b, a]); unsafe { let a = color.get_a(); let b = color.get_b(); let g = color.get_g(); let r = color.get_r(); pub fn background(color: Color) { ///sets the background color(using the color struct). } } CANVAS.color = mapping::map_colors([r, g, b, a]); CANVAS.stroke = true; unsafe { let a = color.get_a(); let b = color.get_b(); let g = color.get_g(); let r = color.get_r(); pub fn stroke(color: Color) { ///the color. ///enables stroke and receives the color of the stroke(the struct color) and sets the stroke color to be } } CANVAS.fill_color = mapping::map_colors([r, g, b, a]); CANVAS.fill = true; unsafe { let a = color.get_a(); let b = color.get_b(); let g = color.get_g(); let r = color.get_r(); pub fn fill(color: Color) { ///the color. ///enables fill and receives the color of the fill(the struct color) and sets the fill color to be } } CANVAS.fill = fil; CANVAS.stroke = stro; circle(x, y, CANVAS.stroke_weight as u16); CANVAS.fill = true; CANVAS.stroke = false; let fil = CANVAS.fill; let stro = CANVAS.stroke; unsafe { pub fn point(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: CANVAS.fill_color, position: map_circ([x as f32, y as f32], scale), add_to_fill(Vertex { ad 6 o � � � m 2 � � � Z , �
�
�
�
�
�
�
M
4
� � � � d C " � � � � � } + �
�
�
�
~
a
D
'
� � � � � ~ ! � � � � a 5 � � � � � � i � � � l O , � � � � ~ R - � � � � � � ` T 9 � � � � � b E 4 " � � � s Z <
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 } 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 } } }); text: text, color: CANVAS.color, position: [x as f32,y as f32], add_to_text(Stext{ unsafe{ pub fn text(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: CANVAS.color, position: mapf(*pt, scale), add_to_stroke(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.color, position: mapf(ptnxt, scale), add_to_stroke(Vertex { for pt in c.iter() { let mut ptnxt = c[0]; let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { let c = bezier_points(x1, y1, x2, y2, x3, y3, x4, y4); pub fn bezierCurveVertex(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: CANVAS.color, position: mapf(*pt, scale), add_to_stroke(Vertex { for pt in c.iter() { let scale = [CANVAS.size.0, CANVAS.size.1]; unsafe { let c = catmull_rom_chain(x1, y1, x2, y2, x3, y3, x4, y4); pub fn curveVertex(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], curveVertex( for i in 0..(ptvec.len() - 3) { pub fn curve(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], ptvec[i][0], bezierCurveVertex( if (i + 1) % 4 == 0 || i == 0 { for i in 0..(ptvec.len() - 3) { pub fn bezierCurve(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: CANVAS.fill_color, position: map_circ([x as f32, y as f32], scale), add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.fill_color, position: map_circ([ptx, pty], scale), add_to_fill(Vertex { }); tex_coords:[0f32,0f32], color: CANVAS.fill_color,