pub enum BlendMode {
Multiply,
Screen,
Overlay,
Darken,
Lighten,
ColorDodge,
ColorBurn,
HardLight,
SoftLight,
Difference,
Exclusion,
PlusLighter,
}Variants§
Multiply
Screen
Overlay
Darken
Lighten
ColorDodge
ColorBurn
HardLight
SoftLight
Difference
Exclusion
PlusLighter
Trait Implementations§
impl Copy for BlendMode
impl Eq for BlendMode
Source§impl ShaderEffect for BlendMode
impl ShaderEffect for BlendMode
const WGSL: &'static str = fn dodge(b: vec3<f32>, s: vec3<f32>) -> vec3<f32> { let lit = min(vec3<f32>(1.0), b / max(vec3<f32>(1.0) - s, vec3<f32>(1e-5))); return select(lit, vec3<f32>(0.0), b <= vec3<f32>(0.0)); } fn burn(b: vec3<f32>, s: vec3<f32>) -> vec3<f32> { let dark = vec3<f32>(1.0) - min(vec3<f32>(1.0), (vec3<f32>(1.0) - b) / max(s, vec3<f32>(1e-5))); return select(dark, vec3<f32>(1.0), b >= vec3<f32>(1.0)); } fn hard_light(b: vec3<f32>, s: vec3<f32>) -> vec3<f32> { let multiply = 2.0 * b * s; let screen = vec3<f32>(1.0) - 2.0 * (vec3<f32>(1.0) - b) * (vec3<f32>(1.0) - s); return select(screen, multiply, s <= vec3<f32>(0.5)); } fn soft_light(b: vec3<f32>, s: vec3<f32>) -> vec3<f32> { let curve = select(sqrt(b), ((16.0 * b - 12.0) * b + 4.0) * b, b <= vec3<f32>(0.25)); let dark = b - (vec3<f32>(1.0) - 2.0 * s) * b * (vec3<f32>(1.0) - b); let light = b + (2.0 * s - vec3<f32>(1.0)) * (curve - b); return select(light, dark, s <= vec3<f32>(0.5)); } fn mix_colors(mode: i32, b: vec3<f32>, s: vec3<f32>) -> vec3<f32> { switch mode { case 0 { return b * s; } case 1 { return b + s - b * s; } case 2 { return hard_light(s, b); } case 3 { return min(b, s); } case 4 { return max(b, s); } case 5 { return dodge(b, s); } case 6 { return burn(b, s); } case 7 { return hard_light(b, s); } case 8 { return soft_light(b, s); } case 9 { return abs(b - s); } case 10 { return b + s - 2.0 * b * s; } default { return s; } } } fn effect(in: EffectInput) -> vec4<f32> { let source = sample_content(in.local); if (source.a <= 0.0) { return vec4<f32>(0.0); } let behind = sample_backdrop(in.local); let mode = i32(param(0).x); if (mode == 11) { return vec4<f32>(source.rgb + behind.rgb * source.a, source.a); } let b = behind.rgb / max(behind.a, 1e-5); let s = source.rgb / source.a; let mixed = clamp(mix_colors(mode, b, s), vec3<f32>(0.0), vec3<f32>(1.0)); return vec4<f32>(source.rgb * (1.0 - behind.a) + mixed * source.a * behind.a, source.a); }
const INPUTS: Inputs = Inputs::BOTH
fn uniforms(&self, uniforms: &mut [f32; 16])
const CLOCK: Option<usize> = None
fn margin(&self) -> f32
fn content_blur(&self) -> f32
fn backdrop_blur(&self) -> f32
fn backdrop_reach(&self) -> Option<f32>
impl StructuralPartialEq for BlendMode
Auto Trait Implementations§
impl Forget for BlendMode
impl Freeze for BlendMode
impl Move for BlendMode
impl RefUnwindSafe for BlendMode
impl Send for BlendMode
impl Sync for BlendMode
impl Unpin for BlendMode
impl UnsafeUnpin for BlendMode
impl UnwindSafe for BlendMode
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.