use nalgebra_glm::Vec2;

#[derive(Debug, Clone)]
pub struct Sprite {
    pub position: Vec2,
    pub size: Vec2,
    pub color: [f32; 4],
    pub texture_index: u32,
    pub texture_index2: u32,
    pub blend_factor: f32,
    pub uv_min: Vec2,
    pub uv_max: Vec2,
    pub rotation: f32,
    pub depth: f32,
    pub scale: Vec2,
}

impl Default for Sprite {
    fn default() -> Self {
        Self {
            position: Vec2::new(0.0, 0.0),
            size: Vec2::new(100.0, 100.0),
            color: [1.0, 1.0, 1.0, 1.0],
            texture_index: 0,
            texture_index2: 0,
            blend_factor: 0.0,
            uv_min: Vec2::new(0.0, 0.0),
            uv_max: Vec2::new(1.0, 1.0),
            rotation: 0.0,
            depth: 0.0,
            scale: Vec2::new(1.0, 1.0),
        }
    }
}

impl Sprite {
    pub fn new(position: Vec2, size: Vec2) -> Self {
        Self {
            position,
            size,
            ..Default::default()
        }
    }

    pub fn with_texture(mut self, texture_index: u32) -> Self {
        self.texture_index = texture_index;
        self.texture_index2 = texture_index;
        self
    }

    pub fn with_multitexture(
        mut self,
        texture_index: u32,
        texture_index2: u32,
        blend_factor: f32,
    ) -> Self {
        self.texture_index = texture_index;
        self.texture_index2 = texture_index2;
        self.blend_factor = blend_factor;
        self
    }

    pub fn with_color(mut self, color: [f32; 4]) -> Self {
        self.color = color;
        self
    }

    pub fn with_rotation(mut self, rotation: f32) -> Self {
        self.rotation = rotation;
        self
    }

    pub fn with_scale(mut self, scale: Vec2) -> Self {
        self.scale = scale;
        self
    }

    pub fn with_depth(mut self, depth: f32) -> Self {
        self.depth = depth;
        self
    }
}
