use crate::asset::Handle as AssetHandle; use crate::image::Image; use crate::builder; #[derive(Debug, Clone)] #[non_exhaustive] pub struct Texture { pub asset_handle: AssetHandle, pub properties: Properties, } impl Texture { pub fn new(asset_handle: AssetHandle) -> Self { Self { asset_handle, properties: Properties::default(), } } pub fn with_properties( asset_handle: AssetHandle, properties: Properties, ) -> Self { Self { asset_handle, properties } } } builder! { /// Texture properties #[builder(name = PropertiesBuilder, derives=(Debug, Clone))] #[derive(Debug, Clone)] #[non_exhaustive] pub struct Properties { pub wrap: Wrapping, pub magnifying_filter: Filtering, pub minifying_filter: Filtering, } } impl Properties { pub fn builder() -> PropertiesBuilder { PropertiesBuilder::default() } } impl Default for Properties { fn default() -> Self { Self { wrap: Wrapping::Repeat, magnifying_filter: Filtering::Linear, minifying_filter: Filtering::Nearest, } } } impl Default for PropertiesBuilder { fn default() -> Self { Properties::default().into() } } #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Filtering { Nearest, Linear, } /// Texture wrapping. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Wrapping { Repeat, MirroredRepeat, ClampToEdge, ClampToBorder, }