use crate::{
    components::{CodeType, Snippet},
    errors::*,
};

use super::Transform;

pub struct Polar {
    snippet: Snippet,
    origin: f32,
}

impl Polar {
    pub fn new() -> Result<Self> {
        let snippets = Snippet::new(
            "polar",
            CodeType::<&'static str>::Path("transform/polar.glsl".into()),
            true,
            Some("forward".to_string()),
        )?;

        Ok(Self {
            snippet: snippets,
            origin: 0.0,
        })
    }
}

impl Transform for Polar {
    fn snippet(&self) -> &Snippet {
        &self.snippet
    }

    fn chain(mut self, other: impl Transform) -> Self {
        let new_snippet = self.snippet.chain(other.snippet().to_owned());
        self.snippet = new_snippet;
        self
    }
}

mod test {
    use super::*;

    #[test]
    fn test_polar() {
        let polar = Polar::new().unwrap();

        println!("{}", polar.snippet);
    }
}
