diff options
author | Julian T <julian@jtle.dk> | 2021-01-25 14:43:46 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-01-25 14:43:46 +0100 |
commit | 33a35c50c20e863123642c8c9ea31dfc006945f6 (patch) | |
tree | 6bbdd9f0f5d4deddec50fca1c3dbff3f2878ffac /src/camera/film.rs | |
parent | 41ea2d8f94043d49fc26aaaa8030a73dcfdc2da9 (diff) |
Started work on implementing vectors bounding and film
Diffstat (limited to 'src/camera/film.rs')
-rw-r--r-- | src/camera/film.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/camera/film.rs b/src/camera/film.rs new file mode 100644 index 0000000..c4a65ce --- /dev/null +++ b/src/camera/film.rs @@ -0,0 +1,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(); + } +} + |