Skip to main content

CompositeOperation

Enum CompositeOperation 

Source
pub enum CompositeOperation {
Show 26 variants SourceOver, SourceIn, SourceOut, SourceAtop, DestinationOver, DestinationIn, DestinationOut, DestinationAtop, Lighter, Copy, Xor, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity,
}
Expand description

The type of compositing operation to apply when drawing new shapes

(JavaScript docs)

Variants§

§

SourceOver

Draws new shapes over existing canvas content

§

SourceIn

Draws new shapes over existing canvas content, but only where existing canvas content overlaps. Anything not in that area becomes transparent.

§

SourceOut

New shapes are drawn where there is no existing canvas content. Everything else (including old canvas content) is made transparent.

§

SourceAtop

Draws new shapes only where there is existing canvas content, over existing canvas content

§

DestinationOver

Draws new shapes behind existing canvas content

§

DestinationIn

Keeps existing canvas content where it overlaps with the new shape. Everything outside the overlap is made transparent.

§

DestinationOut

The existing content is kept where it doesn’t overlap with the new shape. Everything else, including the new shape area, is made transparent.

§

DestinationAtop

Existing content is kept only where it overlaps with the new shape. The new shape is drawn behind the existing content.

§

Lighter

Where both shapes overlap, the new color is determined by adding color values

§

Copy

Only the new shape is shown

§

Xor

Where both shapes overlap, make it transparent

§

Multiply

The pixels of the new and old layer are multiplied. (Pixel values are in the range of [0,1], so this makes a darker picture)

§

Screen

Pixels from both new and old are inverted, multiplied together, then inverted again. (Pixel values are in the range of [0,1], so this makes a lighter picture)

§

Overlay

Applies Multiply to dark colors in the existing content, and Screen to bright colors in the existing content

§

Darken

Retains the darkest pixels

§

Lighten

Retains the lighest pixels

§

ColorDodge

Divides the bottom layer by the inverted top layer.

§

ColorBurn

Divides the inverted bottom layer by the top layer, and then inverts the result.

§

HardLight

A combination of multiply and screen like overlay, but with top and bottom layer swapped.

§

SoftLight

A softer version of hard-light. Pure black or white does not result in pure black or white.

§

Difference

Subtracts the bottom layer from the top layer or the other way round to always get a positive value.

§

Exclusion

Like difference, but with lower contrast.

§

Hue

Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer.

§

Saturation

Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer.

§

Color

Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer.

§

Luminosity

Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer.

Trait Implementations§

Source§

impl Clone for CompositeOperation

Source§

fn clone(&self) -> CompositeOperation

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 CompositeOperation

Source§

impl Debug for CompositeOperation

Source§

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

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

impl Eq for CompositeOperation

Source§

impl PartialEq for CompositeOperation

Source§

fn eq(&self, other: &CompositeOperation) -> 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 StructuralPartialEq for CompositeOperation

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