pub struct Params { /* private fields */ }Expand description
The values one draw gives to the parameters of its material, by name.
A parameter that is not set is zero. Setting a name the material does not declare, or a value of another type, makes the draw fail with a diagnostic and use its fallback; non-finite floats become zero.
use zaxis::{Color, Params, vec2};
let params = Params::new().f32("hover", 0.5).vec2("pointer", vec2(0.25, 0.75)).color("tint", Color::WHITE);
assert_eq!(params.len(), 3);Implementations§
Source§impl Params
impl Params
pub fn new() -> Self
Sourcepub fn set(self, name: &'static str, value: ParamValue) -> Self
pub fn set(self, name: &'static str, value: ParamValue) -> Self
Set name to value, replacing an earlier value of the same name.
pub fn f32(self, name: &'static str, value: f32) -> Self
pub fn i32(self, name: &'static str, value: i32) -> Self
pub fn u32(self, name: &'static str, value: u32) -> Self
pub fn vec3(self, name: &'static str, value: [f32; 3]) -> Self
pub fn vec4(self, name: &'static str, value: [f32; 4]) -> Self
pub fn vec2(self, name: &'static str, value: Vec2) -> Self
Sourcepub fn color(self, name: &'static str, value: Color) -> Self
pub fn color(self, name: &'static str, value: Color) -> Self
A color as the linear, straight-alpha vec4<f32> the renderer blends with.
Sourcepub fn array(self, name: &'static str, values: &[[f32; 4]]) -> Self
pub fn array(self, name: &'static str, values: &[[f32; 4]]) -> Self
At most as many elements as the declared array has; the rest stay zero.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn pack(&self, layout: &ParamLayout) -> Result<Vec<u8>, MaterialError>
pub fn pack(&self, layout: &ParamLayout) -> Result<Vec<u8>, MaterialError>
The bytes of the parameters laid out as layout says, layout.size() long.
Trait Implementations§
impl StructuralPartialEq for Params
Auto Trait Implementations§
impl Freeze for Params
impl RefUnwindSafe for Params
impl Send for Params
impl Sync for Params
impl Unpin for Params
impl UnsafeUnpin for Params
impl UnwindSafe for Params
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.