aboutsummaryrefslogtreecommitdiff
path: root/src/camera/filter
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-01-28 23:53:56 +0100
committerJulian T <julian@jtle.dk>2021-01-28 23:53:56 +0100
commitf467334b26f31b19ebbd222de2b4167b1538ccee (patch)
treef58839dde3f299a7c67aa37f9c86bcf36aa4186e /src/camera/filter
parent33a35c50c20e863123642c8c9ea31dfc006945f6 (diff)
Unfinished film
Diffstat (limited to 'src/camera/filter')
-rw-r--r--src/camera/filter/mod.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/camera/filter/mod.rs b/src/camera/filter/mod.rs
index 93c6fc5..bfa17bb 100644
--- a/src/camera/filter/mod.rs
+++ b/src/camera/filter/mod.rs
@@ -1,22 +1,32 @@
use crate::vector::Vector2f;
use crate::Float;
-pub trait Filter {
+trait Eval {
fn eval(&self, point: &Vector2f) -> Float;
- fn radius(&self) -> Vector2f;
}
-pub struct BoxFilter {
- radius: Vector2f,
+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 Filter for BoxFilter {
+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)
+ }
+}
- fn radius(&self) -> Vector2f {
- self.radius
+impl Filter {
+ fn new_box(radius: &Vector2f) -> Filter {
+ Filter { radius: radius.clone(), eval: Box::new(BoxFilter {}) }
}
}