graphics_style/styles/texture/
transform.rs

1use super::*;
2
3/// ```rust
4/// text.transform(|t| t.scale(0.5, 0.5)).transform(|t| t.translate(0.5, 0.5)).finish();
5/// ```
6#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7pub struct TextureTransform {
8    raw: Texture,
9    wrap: TextureWrap,
10    filter: TextureFilter,
11}
12
13impl Texture {
14    pub fn transform(&self) -> TextureTransform {
15        TextureTransform { raw: self.clone(), wrap: Default::default(), filter: Default::default() }
16    }
17}
18
19impl TextureTransform {
20    pub fn finish(self) -> Texture {
21        todo!()
22    }
23    pub fn with_wrap(self, wrap: TextureWrap) -> Self {
24        Self { wrap, ..self }
25    }
26    pub fn with_filter(self, filter: TextureFilter) -> Self {
27        Self { filter, ..self }
28    }
29}
30#[derive(Debug, Clone, PartialEq, Eq, Hash)]
31
32pub enum TextureWrap {
33    Repeat,
34    Clamp,
35}
36#[derive(Debug, Clone, PartialEq, Eq, Hash)]
37
38pub enum TextureFilter {
39    Nearest,
40    Linear,
41}
42
43impl Default for TextureWrap {
44    fn default() -> Self {
45        Self::Repeat
46    }
47}
48
49impl Default for TextureFilter {
50    fn default() -> Self {
51        Self::Nearest
52    }
53}