aboutsummaryrefslogtreecommitdiff
path: root/src/camera/filter/mod.rs
blob: 01d094c9368e8e37e70cb4f8bf1b7cae11310de1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::vector::Vector2f;
use crate::Float;

trait Eval {
    fn eval(&self, point: &Vector2f) -> Float;
}

pub struct Filter {
    eval: Box<dyn Eval>,
    pub radius: Vector2f,
}

struct BoxFilter {}

// The same a no filter, and can give aliasing in final image
impl Eval for BoxFilter {
    fn eval(&self, _: &Vector2f) -> Float {
        1.0
    }
}

impl Eval for Filter {
    fn eval(&self, point: &Vector2f) -> Float {
        self.eval.eval(point)
    }
}

impl Filter {
    pub fn new_box(radius: Vector2f) -> Filter {
        Filter { radius: radius, eval: Box::new(BoxFilter {}) }
    }
}