Skip to main content

fret_ui_kit/
image_sampling.rs

1use fret_core::scene::ImageSamplingHint;
2use fret_ui::element::ImageProps;
3
4/// Ecosystem-only helpers for setting image sampling hints.
5///
6/// This keeps `fret-ui` as a mechanism layer while allowing policy layers to opt in to
7/// nearest-neighbor sampling for pixel-art / canvas-style content.
8pub trait ImageSamplingExt {
9    fn sampling_hint(self, hint: ImageSamplingHint) -> Self;
10    fn nearest(self) -> Self;
11    fn linear(self) -> Self;
12}
13
14impl ImageSamplingExt for ImageProps {
15    fn sampling_hint(self, hint: ImageSamplingHint) -> Self {
16        self.sampling(hint)
17    }
18
19    fn nearest(self) -> Self {
20        self.sampling(ImageSamplingHint::Nearest)
21    }
22
23    fn linear(self) -> Self {
24        self.sampling(ImageSamplingHint::Linear)
25    }
26}