aboutsummaryrefslogtreecommitdiff
path: root/evc/src/refsampler.rs
blob: b27ceae1aa5f55148100231a2fd0c1dc32f35b43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::{
    frame::Frame,
    helpers::{matrix::Mat2, pixel::Pixel, vector::Vec2},
};

pub struct Sampler<'a> {
    frame: &'a Frame,

    translation: Vec2<f32>,
    transform: Mat2<f32>,

    value_scale: f32,
}

impl Sampler<'_> {
    #[inline]
    pub fn sample(&self, p: Vec2<f32>) -> Pixel {
        self.frame
            .sample(self.translation + self.transform.transform(p))
            .scale(self.value_scale)
    }
}