lemon_engine/shapes/
triangle.rs

1use super::vector2::{Vector2, Vertex};
2
3/// A Triangle Struct 
4pub struct Triangle {
5    pub vertex1: Vector2,
6    pub vertex2: Vector2,
7    pub vertex3: Vector2
8}
9
10impl Triangle {
11    /// Creates a new Triangle from 3 [i32, i32]'s
12    pub fn new(vertex1: Vec<i32>, vertex2: Vec<i32>, vertex3: Vec<i32>) -> Triangle {
13        return Triangle { 
14            vertex1: Vector2::new(vertex1[0] as f32 / 100f32, vertex1[1] as f32 / 100f32),
15            vertex2: Vector2::new(vertex2[0] as f32 / 100f32, vertex2[1] as f32 / 100f32),
16            vertex3: Vector2::new(vertex3[0] as f32 / 100f32, vertex3[1] as f32 / 100f32),
17        }
18    }
19    /// Converts the Struct to Vertices instead of Vector2's
20    pub fn to_vertices(self) -> Vec<Vertex> {
21        return vec![
22            self.vertex1.to_vertices(),
23            self.vertex2.to_vertices(),
24            self.vertex3.to_vertices()
25        ]
26    }
27}