aboutsummaryrefslogtreecommitdiff
path: root/src/camera/film.rs
blob: c4a65cef7eddb10c7e553a81c3552679441d2b05 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::vector::{Vector2, Vector2f};
use crate::Float;
use crate::bounding::Bound2i;
use super::filter::Filter;

#[derive(Clone)]
pub struct Pixel {
    pub rgb: [Float; 3],
}

pub struct Film<'a> {
    pub resolution: Vector2<usize>,

    pixels: Vec<Pixel>,
    filter: &'a dyn Filter,
    filter_radius: Vector2f,
}

pub struct FilmTile {
    
}

impl Pixel {
    fn new() -> Pixel {
        Pixel { rgb: [0.0, 0.0, 0.0] }
    }
}

impl Film<'_> {
    fn new(resolution: Vector2<usize>, filter: & dyn Filter) -> Film {
        let area = resolution.x * resolution.y;
        Film {
            resolution,
            pixels: vec![Pixel::new(); area],
            filter,
            filter_radius: filter.radius()
        }
    }

    fn get_tile(bound: &Bound2i) {
        // Used to calculate descrete coordinates into continues
        let halfpixel = Vector2f::from_xy(0.5, 0.5);
    }

    fn splat(&mut self, point: &Vector2<usize>, pixel: &Pixel) {
        let index = point.x + point.y * self.resolution.x;

        self.pixels[index] = pixel.clone();
    }
}