Skip to main content

BlendMode

Enum BlendMode 

Source
pub enum BlendMode {
Show 28 variants Normal, Multiply, Add, Screen, Subtract, Min, Max, Erase, Overlay, HardLight, SoftLight, PinLight, HardMix, VividLight, LinearLight, ColorBurn, ColorDodge, LinearBurn, LinearDodge, Darken, Lighten, Difference, Exclusion, Negation, Divide, Saturation, Color, Luminosity,
}
Expand description

Blend mode for compositing a renderable onto its target.

Mirrors the PixiJS v8 catalog. See the module docs for the standard-vs-advanced distinction.

Variants§

§

Normal

Source-over alpha blending. src.a * src + (1 - src.a) * dst.

§

Multiply

dst * src + (1 - src.a) * dst — darkens.

§

Add

src + (1 - src.a) * dst — additive.

§

Screen

1 - (1 - src) * (1 - dst) — softer additive.

§

Subtract

dst - src clamped to [0, 1].

§

Min

min(src, dst) per channel.

§

Max

max(src, dst) per channel.

§

Erase

dst * (1 - src.a) — erases dst proportional to src alpha.

§

Overlay

(base < 0.5) ? 2·base·blend : 1 - 2·(1-base)·(1-blend).

§

HardLight

Overlay with the roles swapped — (blend < 0.5) ? ….

§

SoftLight

Photoshop’s W3C-defined soft-light formula.

§

PinLight

Pixel-wise pin: (blend < 0.5) ? min(base, 2·blend) : max(base, 2·blend - 1).

§

HardMix

VividLight thresholded to {0, 1} per channel.

§

VividLight

(blend < 0.5) ? color-burn(base, 2·blend) : color-dodge(base, 2·(blend - 0.5)).

§

LinearLight

base + 2·blend - 1 clamped.

§

ColorBurn

(blend == 0) ? 0 : 1 - min(1, (1-base) / blend).

§

ColorDodge

(blend == 1) ? 1 : min(1, base / (1-blend)).

§

LinearBurn

base + blend - 1 clamped.

§

LinearDodge

base + blend clamped (a.k.a. linear-dodge / additive).

§

Darken

min(base, blend).

§

Lighten

max(base, blend).

§

Difference

abs(base - blend).

§

Exclusion

base + blend - 2·base·blend.

§

Negation

1 - abs(1 - base - blend).

§

Divide

base / blend. Not GPU-native (needs read-modify-write on dst).

§

Saturation

HSL: keep saturation of foreground, hue+lum of backdrop.

§

Color

HSL: keep hue+saturation of foreground, lum of backdrop.

§

Luminosity

HSL: keep lum of foreground, hue+saturation of backdrop.

Implementations§

Source§

impl BlendMode

Source

pub const fn is_advanced(self) -> bool

Whether this mode requires the offscreen filter path (Tier C). Modes that don’t require it return Some(BlendState) from Self::native_blend_state.

Source

pub const fn native_blend_state(self) -> Option<BlendState>

The wgpu blend state for this mode, if it can be expressed as a single GPU blend equation. Returns None for advanced modes.

Source

pub const fn css_name(self) -> &'static str

CSS-style kebab-case identifier — matches PixiJS v8’s Container.blendMode string values.

Source

pub fn all() -> impl ExactSizeIterator<Item = BlendMode> + DoubleEndedIterator

Iterate every variant. Useful for table-driven tests + the blend-modes storybook gallery.

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 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 Hash for BlendMode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BlendMode

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for BlendMode

Source§

impl Eq for BlendMode

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<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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

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

§

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

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

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

§

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

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

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

§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Upcast<T> for T

§

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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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