aboutsummaryrefslogtreecommitdiff
path: root/src/camera/film.rs
blob: e31b760aa92c3787a872afa91a4a2c35d98fa217 (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
52
53
54
55
use crate::vector::{Vector2, Vector2f};
use crate::Float;
use crate::bound;
use bound::{Bound2i, Bound2f};
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 Filter,
}

pub struct FilmTile {
    
}

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

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

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



        //let tilebound = bound::intersect(bound, 
    }

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

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