pub struct MaterialPaint { /* private fields */ }Expand description
One draw of a registered material: where, with which parameters, and over which image.
The shape is a rectangle with optional rounded corners; clip, scroll, visual transforms,
opacity and layer order work as for any other shape, and the mesh is cached like theirs.
Changing params between frames only rewrites the draw’s uniform block.
Hit testing is the caller’s: allocate the rectangle and use Ui::interact.
A draw that cannot use its material (not registered, invalid WGSL, parameters that do
not fit the schema) paints fallback, transparent by default, and
reports the reason once through Context::diagnostics.
Implementations§
Source§impl MaterialPaint
impl MaterialPaint
pub fn params(self, params: Params) -> Self
pub fn corner_radius(self, radius: impl Into<CornerRadius>) -> Self
Sourcepub fn tint(self, tint: Color) -> Self
pub fn tint(self, tint: Color) -> Self
The straight color the shader receives as in.tint. Its alpha is coverage, which the
library applies after the shader.
pub fn opacity(self, opacity: f32) -> Self
Sourcepub fn image(self, source: impl Into<ImageSource>) -> Self
pub fn image(self, source: impl Into<ImageSource>) -> Self
The widget texture the shader samples with widget_color. The material must be
declared reads_texture. Pixels are those of the
image once it is loaded; until then the shader sees the placeholder.
Sourcepub fn fit(self, fit: ImageFit) -> Self
pub fn fit(self, fit: ImageFit) -> Self
How the image fills the shape. Stretch by default; Cover and Contain choose the
part of the texture and the rectangle shown.
pub fn filter(self, filter: TextureFilter) -> Self
Sourcepub fn backdrop_blur(self, sigma: f32) -> Self
pub fn backdrop_blur(self, sigma: f32) -> Self
Sigma, in logical pixels, of the blurred backdrop of a
reads_backdrop material; 4 by default, at most 64.
Sourcepub fn fallback(self, color: Color) -> Self
pub fn fallback(self, color: Color) -> Self
What to paint when the material cannot be used. Transparent by default.
Sourcepub fn animated(self, animated: bool) -> Self
pub fn animated(self, animated: bool) -> Self
Whether this draw reads the clock. Only meaningful for a material declared
animated: false gives in.time and in.delta as zero
and asks for no frames, for a draw that only needs to move while something else
(a hover, a drag) is going on. True by default.
Trait Implementations§
Source§impl Clone for MaterialPaint
impl Clone for MaterialPaint
Auto Trait Implementations§
impl Freeze for MaterialPaint
impl RefUnwindSafe for MaterialPaint
impl Send for MaterialPaint
impl Sync for MaterialPaint
impl Unpin for MaterialPaint
impl UnsafeUnpin for MaterialPaint
impl UnwindSafe for MaterialPaint
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.