Skip to main content

BlendMode

Enum BlendMode 

Source
#[repr(u32)]
pub enum BlendMode {
Show 44 variants Normal = 0, Multiply = 1, Screen = 2, Overlay = 3, SoftLight = 4, HardLight = 5, ColorDodge = 6, ColorBurn = 7, Difference = 8, Exclusion = 9, Add = 10, Subtract = 11, Darken = 12, Lighten = 13, Hue = 14, Saturation = 15, Color = 16, Luminosity = 17, And = 18, Average = 19, Bleach = 20, Divide = 21, Extremity = 22, Freeze = 23, Geometric = 24, Glow = 25, GrainExtract = 26, GrainMerge = 27, HardMix = 28, HardOverlay = 29, Harmonic = 30, Heat = 31, Interpolate = 32, LinearLight = 33, Multiply128 = 34, Negation = 35, Or = 36, Phoenix = 37, PinLight = 38, Reflect = 39, SoftDifference = 40, Stain = 41, VividLight = 42, Xor = 43,
}
Expand description

Pixel-value blend modes.

The discriminant is the value written into the shader’s mode uniform, so variants are only ever appended, never renumbered. Each doc comment gives the normalised formula in terms of base and overlay (see the module docs for how those map onto FFmpeg’s A and B).

Variants§

§

Normal = 0

Overlay replaces base.

§

Multiply = 1

base × overlay.

§

Screen = 2

1 − (1−base)(1−overlay).

§

Overlay = 3

Multiply below 50% grey, Screen above.

§

SoftLight = 4

base² + 2·overlay·base·(1−base).

§

HardLight = 5

Hard light — Overlay with base/overlay swapped.

§

ColorDodge = 6

base ≥ 1 ? base : min(1, overlay/(1−base)).

§

ColorBurn = 7

base ≤ 0 ? base : max(0, 1−(1−overlay)/base).

§

Difference = 8

|base − overlay|.

§

Exclusion = 9

base + overlay − 2·base·overlay.

§

Add = 10

clamp(base + overlay, 0, 1).

§

Subtract = 11

clamp(base − overlay, 0, 1).

§

Darken = 12

min(base, overlay).

§

Lighten = 13

max(base, overlay).

§

Hue = 14

Overlay hue + base saturation + base lightness.

§

Saturation = 15

Base hue + overlay saturation + base lightness.

§

Color = 16

Overlay hue + overlay saturation + base lightness.

§

Luminosity = 17

Base hue + base saturation + overlay lightness.

§

And = 18

Bitwise and of the two 8-bit samples.

§

Average = 19

(base + overlay)/2.

§

Bleach = 20

1 − base − overlay.

§

Divide = 21

overlay == 0 ? 1 : base/overlay.

§

Extremity = 22

|1 − base − overlay|.

§

Freeze = 23

overlay == 0 ? 0 : 1 − min((1−base)²/overlay, 1).

§

Geometric = 24

sqrt(max(base,0)·max(overlay,0)).

§

Glow = 25

base ≥ 1 ? base : min(1, overlay²/(1−base)).

§

GrainExtract = 26

0.5 + base − overlay (FFmpeg’s difference128).

§

GrainMerge = 27

base + overlay − 0.5 (FFmpeg’s addition128).

§

HardMix = 28

base < 1 − overlay ? 0 : 1.

§

HardOverlay = 29

base ≥ 1 ? 1 : min(1, base > 0.5 ? overlay/(2−2·base) : 2·base·overlay).

§

Harmonic = 30

base + overlay == 0 ? 0 : 2·base·overlay/(base + overlay).

§

Heat = 31

base == 0 ? 0 : 1 − min((1−overlay)²/base, 1).

§

Interpolate = 32

(2 − cos(base·π) − cos(overlay·π))/4.

§

LinearLight = 33

overlay + 2·base − 1.

The C branches on overlay < 0.5, but both arms collapse to the same expression once MAX == 2·HALF, which holds in the DEPTH == 32 branch. The 8-bit path differs by one LSB.

§

Multiply128 = 34

8·(base−0.5)·overlay + 0.5.

§

Negation = 35

1 − |1 − base − overlay|.

§

Or = 36

Bitwise or of the two 8-bit samples.

§

Phoenix = 37

min(base, overlay) − max(base, overlay) + 1.

§

PinLight = 38

overlay < 0.5 ? min(base, 2·overlay) : max(base, 2·overlay − 1).

§

Reflect = 39

overlay ≥ 1 ? overlay : min(1, base²/(1−overlay)).

§

SoftDifference = 40

base > overlay ? (overlay ≥ 1 ? 0 : (base−overlay)/(1−overlay)) : (overlay ≤ 0 ? 0 : (overlay−base)/overlay).

§

Stain = 41

2 − base − overlay.

§

VividLight = 42

base < 0.5 ? burn(2·base, overlay) : dodge(2·base − 1, overlay).

§

Xor = 43

Bitwise xor of the two 8-bit samples.

Trait Implementations§

Source§

impl Clone for BlendMode

Source§

fn clone(&self) -> BlendMode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BlendMode

Source§

impl Debug for BlendMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BlendMode

Source§

fn default() -> BlendMode

Returns the “default value” for a type. Read more
Source§

impl Eq for BlendMode

Source§

impl PartialEq for BlendMode

Source§

fn eq(&self, other: &BlendMode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BlendMode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,