pub struct Expr<T> where
T: ?Sized, { /* private fields */ }
Expand description
Expression representation.
An expression is anything that carries a (typed) value and that can be combined in various ways with other
expressions. A literal, a constant or a variable are all expressions. The sum (as in a + b
) of two expressions is
also an expression. A function call returning an expression is also an expression, as in a * sin(b)
. Accessing an
element in an array (which is an expression as it carries items) via an index (an expression) is also an
expression — e.g. levels[y * HEIGHT + x] * size
. The same thing applies to field access, swizzling, etc. etc.
On a general note, expressions are pretty central to the EDSL, as they are the lower level concept you will be
able to manipulate. Expressions are side effect free, so a variable, for instance, can either be considered as an
expression or not. If x
is a variable (see Var
), then x * 10
is an expression, but using x
to mutate its
content does not make a use of x
as an expression. It means that expressions are read-only and even though you
can go from higher constructs (like variables) to expressions, the opposite direction is forbidden.
Literals
The most obvious kind of expression is a literal — e.g. 1
, false
, 3.14
, etc. Any type T
that defines an
implementor From<T> for Expr<T>
can be used as literal. You can then use, for instance, 1.into()
,
Expr::from(1)
, etc.
That is a concern of yours only if you do not use shades-edsl.
Expressions from side-effects
Some side-effects will create expressions, such as creating a variable or a constant. Most of the time, you shouldn’t have to worry about the type of the expression as it should be inferred based on the side-effect.
Expression macros
Some macros will create expressions for you, such as vec2!
, vec3!
and vec4!
or the
sw!
macros.
Implementations
sourceimpl<T> Expr<T> where
T: ?Sized,
impl<T> Expr<T> where
T: ?Sized,
sourcepub const fn new(erased: ErasedExpr) -> Self
pub const fn new(erased: ErasedExpr) -> Self
Type an ErasedExpr
and return it wrapped in Expr<T>
.
sourcepub const fn new_input(handle: u16) -> Self
pub const fn new_input(handle: u16) -> Self
Create a new input.
You should use this function when implementing [Inputs::input()
].
sourcepub fn new_output(handle: u16) -> Self
pub fn new_output(handle: u16) -> Self
Create a new output.
You should use this function when implementing [Outputs::output()
].
sourcepub fn new_env(name: impl Into<String>) -> Self
pub fn new_env(name: impl Into<String>) -> Self
Create a new environment variable.
You should use this function when implementing [Environment::env()
].
sourcepub const fn new_fun_arg(handle: u16) -> Self
pub const fn new_fun_arg(handle: u16) -> Self
Create a new function argument.
You shouldn’t have to use that function, as its main purpose is to be used by shades-edsl.
sourceimpl<T> Expr<T> where
T: PartialOrd,
impl<T> Expr<T> where
T: PartialOrd,
sourcepub fn lt(&self, rhs: impl Into<Expr<T>>) -> Expr<bool>
pub fn lt(&self, rhs: impl Into<Expr<T>>) -> Expr<bool>
Less-than expression.
This method builds an expression representing the binary operation a < b
.
Return
An Expr<bool>
representing a < b
.
sourcepub fn lte(&self, rhs: impl Into<Expr<T>>) -> Expr<bool>
pub fn lte(&self, rhs: impl Into<Expr<T>>) -> Expr<bool>
Less-than-or-equal expression.
This method builds an expression representing the binary operation a <= b
.
Return
An Expr<bool>
representing a <= b
.
sourceimpl Expr<bool>
impl Expr<bool>
sourcepub fn and(&self, rhs: impl Into<Expr<bool>>) -> Expr<bool>
pub fn and(&self, rhs: impl Into<Expr<bool>>) -> Expr<bool>
Logical and expression.
This method builds an expression representing the logical operation a AND b
.
Return
An Expr<bool>
representing a AND b
.
sourceimpl Expr<TessEvaluationPerVertexIn>
impl Expr<TessEvaluationPerVertexIn>
sourcepub fn point_size(&self) -> Expr<f32>
pub fn point_size(&self) -> Expr<f32>
Point size of the vertex.
sourcepub fn clip_distance(&self) -> Expr<[f32]>
pub fn clip_distance(&self) -> Expr<[f32]>
Clip distances to user-defined planes.
sourcepub fn cull_distance(&self) -> Expr<[f32]>
pub fn cull_distance(&self) -> Expr<[f32]>
Cull distances to user-defined planes.
sourceimpl Expr<GeometryPerVertexIn>
impl Expr<GeometryPerVertexIn>
sourcepub fn point_size(&self) -> Expr<f32>
pub fn point_size(&self) -> Expr<f32>
Provides the size point of the vertex if it’s currently being rendered in point mode.
sourcepub fn clip_distance(&self) -> Expr<[f32]>
pub fn clip_distance(&self) -> Expr<[f32]>
Clip distances to user planes of the vertex.
sourcepub fn cull_distance(&self) -> Expr<[f32]>
pub fn cull_distance(&self) -> Expr<[f32]>
Cull distances to user planes of the vertex.
sourceimpl Expr<TessControlPerVertexOut>
impl Expr<TessControlPerVertexOut>
sourcepub fn point_size(&self) -> Var<f32>
pub fn point_size(&self) -> Var<f32>
Point size of the vertex.
sourcepub fn clip_distance(&self) -> Var<[f32]>
pub fn clip_distance(&self) -> Var<[f32]>
Clip distances to user-defined planes.
sourcepub fn cull_distance(&self) -> Var<[f32]>
pub fn cull_distance(&self) -> Var<[f32]>
Cull distances to user-defined planes.
Trait Implementations
sourceimpl<T> Erased for Expr<T>
impl<T> Erased for Expr<T>
type Erased = ErasedExpr
type Erased = ErasedExpr
Erased version.
sourcefn erased_mut(&mut self) -> &mut Self::Erased
fn erased_mut(&mut self) -> &mut Self::Erased
Mutable access to the erased version.
sourceimpl Exponential for Expr<V2<f32>>
impl Exponential for Expr<V2<f32>>
sourceimpl Exponential for Expr<V3<f32>>
impl Exponential for Expr<V3<f32>>
sourceimpl Exponential for Expr<V4<f32>>
impl Exponential for Expr<V4<f32>>
sourceimpl Exponential for Expr<f32>
impl Exponential for Expr<f32>
sourceimpl FloatingExt for Expr<V2<f32>>
impl FloatingExt for Expr<V2<f32>>
sourceimpl FloatingExt for Expr<V3<f32>>
impl FloatingExt for Expr<V3<f32>>
sourceimpl FloatingExt for Expr<V4<f32>>
impl FloatingExt for Expr<V4<f32>>
sourceimpl FloatingExt for Expr<f32>
impl FloatingExt for Expr<f32>
sourceimpl<'a, T, const N: usize> From<&'a [Expr<T>; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: ToType,
impl<'a, T, const N: usize> From<&'a [Expr<T>; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: ToType,
sourceimpl<'a, T, const N: usize> From<&'a [T; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: Clone + ToType,
impl<'a, T, const N: usize> From<&'a [T; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: Clone + ToType,
sourceimpl<T, const N: usize> From<[Expr<T>; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: ToType,
impl<T, const N: usize> From<[Expr<T>; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: ToType,
sourceimpl<T, const N: usize> From<[T; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: Clone + ToType,
impl<T, const N: usize> From<[T; N]> for Expr<[T; N]> where
Expr<T>: From<T>,
T: Clone + ToType,
sourceimpl Geometry for Expr<V2<f32>>
impl Geometry for Expr<V2<f32>>
type LengthExpr = Expr<f32>
fn length(self) -> Self::LengthExpr
fn distance(self, other: Self) -> Self::LengthExpr
fn dot(self, other: Self) -> Self::LengthExpr
fn cross(self, other: Self) -> Self
fn normalize(self) -> Self
fn face_forward(self, normal: Self, reference: Self) -> Self
fn reflect(self, normal: Self) -> Self
fn refract(self, normal: Self, eta: Expr<f32>) -> Self
sourceimpl Geometry for Expr<V3<f32>>
impl Geometry for Expr<V3<f32>>
type LengthExpr = Expr<f32>
fn length(self) -> Self::LengthExpr
fn distance(self, other: Self) -> Self::LengthExpr
fn dot(self, other: Self) -> Self::LengthExpr
fn cross(self, other: Self) -> Self
fn normalize(self) -> Self
fn face_forward(self, normal: Self, reference: Self) -> Self
fn reflect(self, normal: Self) -> Self
fn refract(self, normal: Self, eta: Expr<f32>) -> Self
sourceimpl Geometry for Expr<V4<f32>>
impl Geometry for Expr<V4<f32>>
type LengthExpr = Expr<f32>
fn length(self) -> Self::LengthExpr
fn distance(self, other: Self) -> Self::LengthExpr
fn dot(self, other: Self) -> Self::LengthExpr
fn cross(self, other: Self) -> Self
fn normalize(self) -> Self
fn face_forward(self, normal: Self, reference: Self) -> Self
fn reflect(self, normal: Self) -> Self
fn refract(self, normal: Self, eta: Expr<f32>) -> Self
sourceimpl<T> Swizzlable<[SwizzleSelector; 2]> for Expr<V2<T>>
impl<T> Swizzlable<[SwizzleSelector; 2]> for Expr<V2<T>>
sourceimpl<T> Swizzlable<[SwizzleSelector; 2]> for Expr<V3<T>>
impl<T> Swizzlable<[SwizzleSelector; 2]> for Expr<V3<T>>
sourceimpl<T> Swizzlable<[SwizzleSelector; 2]> for Expr<V4<T>>
impl<T> Swizzlable<[SwizzleSelector; 2]> for Expr<V4<T>>
sourceimpl<T> Swizzlable<[SwizzleSelector; 3]> for Expr<V3<T>>
impl<T> Swizzlable<[SwizzleSelector; 3]> for Expr<V3<T>>
sourceimpl<T> Swizzlable<[SwizzleSelector; 3]> for Expr<V4<T>>
impl<T> Swizzlable<[SwizzleSelector; 3]> for Expr<V4<T>>
sourceimpl<T> Swizzlable<[SwizzleSelector; 4]> for Expr<V4<T>>
impl<T> Swizzlable<[SwizzleSelector; 4]> for Expr<V4<T>>
sourceimpl<T> Swizzlable<SwizzleSelector> for Expr<V2<T>>
impl<T> Swizzlable<SwizzleSelector> for Expr<V2<T>>
sourceimpl<T> Swizzlable<SwizzleSelector> for Expr<V3<T>>
impl<T> Swizzlable<SwizzleSelector> for Expr<V3<T>>
sourceimpl<T> Swizzlable<SwizzleSelector> for Expr<V4<T>>
impl<T> Swizzlable<SwizzleSelector> for Expr<V4<T>>
sourceimpl<T> ToPrimType for Expr<T> where
T: ToPrimType,
impl<T> ToPrimType for Expr<T> where
T: ToPrimType,
sourceimpl Trigonometry for Expr<V2<f32>>
impl Trigonometry for Expr<V2<f32>>
fn radians(&self) -> Self
fn degrees(&self) -> Self
fn sin(&self) -> Self
fn cos(&self) -> Self
fn tan(&self) -> Self
fn asin(&self) -> Self
fn acos(&self) -> Self
fn atan(&self) -> Self
fn sinh(&self) -> Self
fn cosh(&self) -> Self
fn tanh(&self) -> Self
fn asinh(&self) -> Self
fn acosh(&self) -> Self
fn atanh(&self) -> Self
sourceimpl Trigonometry for Expr<V3<f32>>
impl Trigonometry for Expr<V3<f32>>
fn radians(&self) -> Self
fn degrees(&self) -> Self
fn sin(&self) -> Self
fn cos(&self) -> Self
fn tan(&self) -> Self
fn asin(&self) -> Self
fn acos(&self) -> Self
fn atan(&self) -> Self
fn sinh(&self) -> Self
fn cosh(&self) -> Self
fn tanh(&self) -> Self
fn asinh(&self) -> Self
fn acosh(&self) -> Self
fn atanh(&self) -> Self
sourceimpl Trigonometry for Expr<V4<f32>>
impl Trigonometry for Expr<V4<f32>>
fn radians(&self) -> Self
fn degrees(&self) -> Self
fn sin(&self) -> Self
fn cos(&self) -> Self
fn tan(&self) -> Self
fn asin(&self) -> Self
fn acos(&self) -> Self
fn atan(&self) -> Self
fn sinh(&self) -> Self
fn cosh(&self) -> Self
fn tanh(&self) -> Self
fn asinh(&self) -> Self
fn acosh(&self) -> Self
fn atanh(&self) -> Self
sourceimpl Trigonometry for Expr<f32>
impl Trigonometry for Expr<f32>
fn radians(&self) -> Self
fn degrees(&self) -> Self
fn sin(&self) -> Self
fn cos(&self) -> Self
fn tan(&self) -> Self
fn asin(&self) -> Self
fn acos(&self) -> Self
fn atan(&self) -> Self
fn sinh(&self) -> Self
fn cosh(&self) -> Self
fn tanh(&self) -> Self
fn asinh(&self) -> Self
fn acosh(&self) -> Self
fn atanh(&self) -> Self
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for Expr<T> where
T: RefUnwindSafe,
impl<T: ?Sized> Send for Expr<T> where
T: Send,
impl<T: ?Sized> Sync for Expr<T> where
T: Sync,
impl<T: ?Sized> Unpin for Expr<T> where
T: Unpin,
impl<T: ?Sized> UnwindSafe for Expr<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more