pub struct ImageSampler {
pub x_extend: Extend,
pub y_extend: Extend,
pub quality: ImageQuality,
pub alpha: f32,
}Expand description
Parameters which specify how to sample an image during rendering.
When a renderer is drawing an image, they will (in most cases) not directly copy the bytes from the source image to their render target; instead, they will sample from the image. This involves determining from which part of the source image to read, and how to handle cases where the source image’s pixels are not aligned with the render target exactly, in any combination of scale, position or rotation. They might also perform an alpha multiplication, as done here. This struct contains the parameters used by sampling.
Fields§
§x_extend: ExtendExtend mode in the horizontal direction.
y_extend: ExtendExtend mode in the vertical direction.
quality: ImageQualityHint for desired rendering quality.
alpha: f32An additional alpha multiplier to use with the image.
Implementations§
Source§impl ImageSampler
impl ImageSampler
Sourcepub fn new() -> ImageSampler
pub fn new() -> ImageSampler
Creates a new ImageSampler with default values
Sourcepub fn with_extend(self, mode: Extend) -> ImageSampler
pub fn with_extend(self, mode: Extend) -> ImageSampler
Builder method for setting the image extend mode in both directions.
Sourcepub fn with_x_extend(self, mode: Extend) -> ImageSampler
pub fn with_x_extend(self, mode: Extend) -> ImageSampler
Builder method for setting the image extend mode in the horizontal direction.
Sourcepub fn with_y_extend(self, mode: Extend) -> ImageSampler
pub fn with_y_extend(self, mode: Extend) -> ImageSampler
Builder method for setting the image extend mode in the vertical direction.
Sourcepub fn with_quality(self, quality: ImageQuality) -> ImageSampler
pub fn with_quality(self, quality: ImageQuality) -> ImageSampler
Builder method for setting a hint for the desired image quality when rendering.
Sourcepub fn with_alpha(self, alpha: f32) -> ImageSampler
pub fn with_alpha(self, alpha: f32) -> ImageSampler
Returns the image with the alpha multiplier set to alpha.
Sourcepub fn multiply_alpha(self, alpha: f32) -> ImageSampler
pub fn multiply_alpha(self, alpha: f32) -> ImageSampler
Returns the image with the alpha multiplier multiplied again by alpha.
The behaviour of this transformation is undefined if alpha is negative.
Trait Implementations§
Source§impl Clone for ImageSampler
impl Clone for ImageSampler
Source§fn clone(&self) -> ImageSampler
fn clone(&self) -> ImageSampler
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImageSampler
impl Debug for ImageSampler
Source§impl Default for ImageSampler
impl Default for ImageSampler
Source§fn default() -> ImageSampler
fn default() -> ImageSampler
Source§impl PartialEq for ImageSampler
impl PartialEq for ImageSampler
impl Copy for ImageSampler
impl StructuralPartialEq for ImageSampler
Auto Trait Implementations§
impl Freeze for ImageSampler
impl RefUnwindSafe for ImageSampler
impl Send for ImageSampler
impl Sync for ImageSampler
impl Unpin for ImageSampler
impl UnwindSafe for ImageSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.