use shared::Float;
use shared::core::filter::FilterSampler;
use shared::core::geometry::{Point2f, Vector2f};
use shared::filters::LanczosSincFilter;
use shared::utils::math::windowed_sinc;

pub trait LanczosFilterCreator {
    fn new(radius: Vector2f, tau: Float) -> Self;
}

impl LanczosFilterCreator for LanczosSincFilter {
    fn new(radius: Vector2f, tau: Float) -> Self {
        let sampler = FilterSampler::new(radius, move |p: Point2f| {
            windowed_sinc(p.x(), radius.x(), tau) * windowed_sinc(p.y(), radius.y(), tau)
        });

        Self {
            radius,
            tau,
            sampler,
        }
    }
}
