[−][src]Struct sfml::graphics::blend_mode::BlendMode
Blending modes for drawing.
BlendMode
is a type that represents a blend mode.
A blend mode determines how the colors of an object you draw are mixed with the colors that are already in the buffer.
The type is composed of 6 components, each of which has its own public field:
- Color Source Factor (
color_src_factor
) - Color Destination Factor (
color_dst_factor
) - Color Blend Equation (
color_equation
) - Alpha Source Factor (
alpha_src_factor
) - Alpha Destination Factor (
alpha_dst_factor
) - Alpha Blend Equation (
alpha_equation
)
The source factor specifies how the pixel you are drawing contributes to the final color. The destination factor specifies how the pixel already drawn in the buffer contributes to the final color.
The color channels RGB (red, green, blue; simply referred to as color) and A (alpha; the transparency) can be treated separately. This separation can be useful for specific blend modes, but most often you won't need it and will simply treat the color as a single unit.
The blend factors and equations correspond to their OpenGL equivalents. In general, the color of the resulting pixel is calculated according to the following formula (src is the color of the source pixel, dst the color of the destination pixel, the other variables correspond to the public members, with the equations being + or - operators):
dst.rgb = color_src_factor * src.rgb (color_equation) color_dst_factor * dst.rgb dst.a = alpha_src_factor * src.a (alpha_equation) alpha_dst_factor * dst.a
All factors and colors are represented as floating point numbers between 0 and 1. Where necessary, the result is clamped to fit in that range.
In SFML, a blend mode can be specified every time you draw a Drawable
object to
a render target. It is part of the RenderStates
compound that is passed to
RenderTarget::draw
.
Fields
color_src_factor: Factor
Source blending factor for the color channels.
color_dst_factor: Factor
Destination blending factor for the color channels.
color_equation: Equation
Blending equation for the color channels.
alpha_src_factor: Factor
Source blending factor for the alpha channel.
alpha_dst_factor: Factor
Destination blending factor for the alpha channel.
alpha_equation: Equation
Blending equation for the alpha channel.
Methods
impl BlendMode
[src]
pub fn new(
col_src: Factor,
col_dst: Factor,
col_equ: Equation,
alpha_src: Factor,
alpha_dst: Factor,
alpha_equ: Equation
) -> Self
[src]
col_src: Factor,
col_dst: Factor,
col_equ: Equation,
alpha_src: Factor,
alpha_dst: Factor,
alpha_equ: Equation
) -> Self
Create a new BlendMode
pub const ALPHA: BlendMode
[src]
"Alpha" blend mode
pub const ADD: BlendMode
[src]
"Add" blend mode
pub const MULTIPLY: BlendMode
[src]
"Multiply" blend mode
pub const NONE: BlendMode
[src]
"None" blend mode
Trait Implementations
impl Clone for BlendMode
[src]
impl Copy for BlendMode
[src]
impl Default for BlendMode
[src]
impl Eq for BlendMode
[src]
impl PartialEq<BlendMode> for BlendMode
[src]
impl Debug for BlendMode
[src]
Auto Trait Implementations
impl Send for BlendMode
impl Sync for BlendMode
impl Unpin for BlendMode
impl UnwindSafe for BlendMode
impl RefUnwindSafe for BlendMode
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,