Trait zng_color::MixAdjust

source ·
pub trait MixAdjust {
Show 21 methods // Required methods fn mix_normal(self, background: Self) -> Self; fn mix_multiply(self, background: Self) -> Self; fn mix_screen(self, background: Self) -> Self; fn mix_overlay(self, background: Self) -> Self; fn mix_darken(self, background: Self) -> Self; fn mix_lighten(self, background: Self) -> Self; fn mix_colordodge(self, background: Self) -> Self; fn mix_colorburn(self, background: Self) -> Self; fn mix_hardlight(self, background: Self) -> Self; fn mix_softlight(self, background: Self) -> Self; fn mix_difference(self, background: Self) -> Self; fn mix_exclusion(self, background: Self) -> Self; fn mix_hue(self, background: Self) -> Self; fn mix_saturation(self, background: Self) -> Self; fn mix_color(self, background: Self) -> Self; fn mix_luminosity(self, background: Self) -> Self; fn lighten<A: Into<Factor>>(self, amount: A) -> Self; fn darken<A: Into<Factor>>(self, amount: A) -> Self; fn desaturate<A: Into<Factor>>(self, amount: A) -> Self; fn with_lightness<L: Into<Factor>>(self, lightness: L) -> Self; // Provided method fn mix(self, mode: MixBlendMode, background: Self) -> Self where Self: Sized { ... }
}
Expand description

Color mix and adjustment methods.

Required Methods§

source

fn mix_normal(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Normal.

Normal alpha blend of the foreground color over the background.

source

fn mix_multiply(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Multiply.

Multiply the colors.

The resultant color is always at least as dark as either color. Multiplying any color with black results in black. Multiplying any color with white preserves the original color.

source

fn mix_screen(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Screen.

Multiply the colors, then complements the result.

The result color is always at least as light as either of the two constituent colors. Screening any color with white produces white; screening with black leaves the original color unchanged. The effect is similar to projecting multiple photographic slides simultaneously onto a single screen.

source

fn mix_overlay(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Overlay.

Multiplies or screens the colors, depending on the background color value.

Foreground color overlays the background while preserving its highlights and shadows. The background color is not replaced but is mixed with the foreground color to reflect the lightness or darkness of the background.

This is the inverse of hardlight.

source

fn mix_darken(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Darken.

Selects the darker of the colors.

The background color is replaced with the foreground where the background is darker; otherwise, it is left unchanged.

source

fn mix_lighten(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Lighten.

Selects the lighter of the colors.

The background color is replaced with the foreground where the background is lighter; otherwise, it is left unchanged.

source

fn mix_colordodge(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::ColorDodge.

Brightens the background color to reflect the foreground color. Painting with black produces no changes.

source

fn mix_colorburn(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::ColorBurn.

Darkens the background color to reflect the foreground color. Painting with white produces no change.

source

fn mix_hardlight(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::HardLight.

Multiplies or screens the colors, depending on the foreground color value.

The effect is similar to shining a harsh spotlight on the background color.

source

fn mix_softlight(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::SoftLight.

Darkens or lightens the colors, depending on the foreground color value.

The effect is similar to shining a diffused spotlight on the background color.

source

fn mix_difference(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Difference.

Subtracts the darker of the two constituent colors from the lighter color.

Painting with white inverts the background color; painting with black produces no change.

source

fn mix_exclusion(self, background: Self) -> Self

MixAdjust background over self using the MixBlendMode::Exclusion.

Produces an effect similar to that of the difference mode but lower in contrast.

Painting with white inverts the background color; painting with black produces no change.

source

fn mix_hue(self, background: Self) -> Self

MixAdjust self over background using the MixBlendMode::Hue`.

Creates a color with the hue of the foreground color and the saturation and luminosity of the background color.

This method converts both inputs to Hsla and the result back to Rgba.

source

fn mix_saturation(self, background: Self) -> Self

MixAdjust self over background using the MixBlendMode::Saturation`.

Creates a color with the saturation of the foreground color and the hue and luminosity of the background color.

This method converts both inputs to Hsla and the result back to Rgba.

source

fn mix_color(self, background: Self) -> Self

MixAdjust self over background using the MixBlendMode::Color`.

Creates a color with the hue and saturation of the foreground color and the luminosity of the background color.

This method converts both inputs to Hsla and the result back to Rgba.

source

fn mix_luminosity(self, background: Self) -> Self

MixAdjust self over background using the MixBlendMode::Luminosity`.

Creates a color with the luminosity of the foreground color and the hue and saturation of the background color.

This method converts both inputs to Hsla and the result back to Rgba.

source

fn lighten<A: Into<Factor>>(self, amount: A) -> Self

Adds the amount to the color lightness.

§Examples

Add 10% of the current lightness to the DARK_RED color:

web_colors::DARK_RED.lighten(10.pct())
source

fn darken<A: Into<Factor>>(self, amount: A) -> Self

Subtracts the amount from the color lightness.

§Examples

Removes 10% of the current lightness from the DARK_RED color:

web_colors::DARK_RED.darken(10.pct())
source

fn desaturate<A: Into<Factor>>(self, amount: A) -> Self

Subtracts the amount from the color saturation.

§Examples

Removes 10% of the current saturation from the RED color:

colors::RED.desaturate(10.pct())
source

fn with_lightness<L: Into<Factor>>(self, lightness: L) -> Self

Returns a copy of this color with a new lightness.

Provided Methods§

source

fn mix(self, mode: MixBlendMode, background: Self) -> Self
where Self: Sized,

MixAdjust background over self using the mode.

Object Safety§

This trait is not object safe.

Implementors§