BlendMode
Mojo struct 🡭
BlendMode
@memory_only
struct BlendModeHow a drawn color combines with the pixel underneath.
SOURCE_OVER, the default, is ordinary alpha compositing: the source covers the backdrop in proportion to its alpha. The rest are the other twelve Porter-Duff operators, the eleven separable blend modes and the four non-separable ones; see this module’s docstring for the formula each one applies.
Aliases
SOURCE_OVER = BlendMode(Int(0))SOURCE = BlendMode(Int(1))DESTINATION_IN = BlendMode(Int(2))DESTINATION_OUT = BlendMode(Int(3))XOR = BlendMode(Int(4))CLEAR = BlendMode(Int(5))DESTINATION = BlendMode(Int(6))DESTINATION_OVER = BlendMode(Int(7))SOURCE_IN = BlendMode(Int(8))SOURCE_OUT = BlendMode(Int(9))SOURCE_ATOP = BlendMode(Int(10))DESTINATION_ATOP = BlendMode(Int(11))ADD = BlendMode(Int(12))MULTIPLY = BlendMode(Int(13))SCREEN = BlendMode(Int(14))OVERLAY = BlendMode(Int(15))DARKEN = BlendMode(Int(16))LIGHTEN = BlendMode(Int(17))DIFFERENCE = BlendMode(Int(18))EXCLUSION = BlendMode(Int(19))COLOR_DODGE = BlendMode(Int(20))COLOR_BURN = BlendMode(Int(21))HARD_LIGHT = BlendMode(Int(22))SOFT_LIGHT = BlendMode(Int(23))HUE = BlendMode(Int(24))SATURATION = BlendMode(Int(25))COLOR = BlendMode(Int(26))LUMINOSITY = BlendMode(Int(27))
Implemented traits
AnyType, Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, Writable
Methods
__init__
fn def __init__(out self, value: Int)Prefer the comptime constants over constructing one directly.
Args:
- value (
Int): 0 SOURCE_OVER, 1 SOURCE, 2 DESTINATION_IN, 3 DESTINATION_OUT, 4 XOR, 5 CLEAR, 6 DESTINATION, 7 DESTINATION_OVER, 8 SOURCE_IN, 9 SOURCE_OUT, 10 SOURCE_ATOP, 11 DESTINATION_ATOP, 12 ADD, 13 MULTIPLY, 14 SCREEN, 15 OVERLAY, 16 DARKEN, 17 LIGHTEN, 18 DIFFERENCE, 19 EXCLUSION, 20 COLOR_DODGE, 21 COLOR_BURN, 22 HARD_LIGHT, 23 SOFT_LIGHT, 24 HUE, 25 SATURATION, 26 COLOR, 27 LUMINOSITY. - self (
Self)
Returns:
Self
__eq__
fn def __eq__(self, other: Self) -> BoolArgs:
- self (
Self) - other (
Self)
Returns:
Bool
__ne__
fn def __ne__(self, other: Self) -> BoolArgs:
- self (
Self) - other (
Self)
Returns:
Bool
write_to
fn def write_to[W: Writer](self, mut writer: W)Parameters:
- W (
Writer)
Args:
- self (
Self) - writer (
W)
__str__
fn def __str__(self) -> StringArgs:
- self (
Self)
Returns:
String
is_source_over
fn def is_source_over(self) -> BoolWhether this is the default mode.
write_pixel and _fill_region ask this once per call before
anything else, since it is what decides between the blend paths
that were always there and the general one.
Args:
- self (
Self)
Returns:
Bool: True for SOURCE_OVER.
is_separable
fn def is_separable(self) -> BoolWhether this is one of the eleven separable blend modes, MULTIPLY through SOFT_LIGHT: a B applied to each channel on its own.
Args:
- self (
Self)
Returns:
Bool: True for the separable blend modes, False for the
Porter-Duff operators and the non-separable modes.
is_non_separable
fn def is_non_separable(self) -> BoolWhether this is one of the four non-separable blend modes, HUE, SATURATION, COLOR and LUMINOSITY: a B that needs the whole RGB triple.
Args:
- self (
Self)
Returns:
Bool: True for the four non-separable modes.