Skip to main content

BlendMode

Algorithms used to combine source and destination pixels during painting.

The source is the content being drawn and the destination is the content already present behind it.

Inherits: enum.Enum

Properties

  • CLEAR - Drops both the source and destination, leaving a fully transparent result.
  • COLOR - Takes the hue and saturation from the source and the luminosity from the destination.
  • COLOR_BURN - Darkens the destination by dividing the inverse destination by the source and then inverting the result.
  • COLOR_DODGE - Brightens the destination by dividing it by the inverse of the source.
  • DARKEN - Chooses the darker value from each source and destination color channel.
  • DIFFERENCE - Subtracts the smaller channel value from the larger one.
  • DST - Drops the source and keeps only the destination.
  • DST_A_TOP - Draws the destination over the source, but only where they overlap.
  • DST_IN - Keeps the destination only where the source and destination overlap.
  • DST_OUT - Keeps the destination only where the source and destination do not overlap.
  • DST_OVER - Draws the source underneath the destination.
  • EXCLUSION - Produces an effect similar to DIFFERENCE, but softer.
  • HARD_LIGHT - Combines multiply and screen-style blending while favoring the source image.
  • HUE - Takes the hue from the source and the saturation and luminosity from the destination.
  • LIGHTEN - Chooses the lighter value from each source and destination color channel.
  • LUMINOSITY - Takes the luminosity from the source and the hue and saturation from the destination.
  • MODULATE - Multiplies the source and destination color channels without multiplying alpha.
  • MULTIPLY - Multiplies the source and destination color channels, including alpha.
  • OVERLAY - Combines multiply and screen-style blending while favoring the destination image.
  • PLUS - Adds the source and destination channel values together.
  • SATURATION - Takes the saturation from the source and the hue and luminosity from the destination.
  • SCREEN - Multiplies the inverted source and destination values, then inverts the result.
  • SOFT_LIGHT - Applies a softer lighting effect than OVERLAY.
  • SRC - Drops the destination and keeps only the source.
  • SRC_A_TOP - Draws the source over the destination, but only where they overlap.
  • SRC_IN - Keeps the source only where the source and destination overlap.
  • SRC_OUT - Keeps the source only where the source and destination do not overlap.
  • SRC_OVER - Draws the source over the destination.
  • VALUES - Not a usable blend mode.
  • XOR - Uses an exclusive-or composition so overlapping areas become transparent.

Examples

Blend Mode showcase

play_arrowTry Online
import flet as ft


def showcase_card(blend_mode: ft.BlendMode) -> ft.Container:
return ft.Container(
width=280,
padding=12,
border=ft.Border.all(1, ft.Colors.RED),
border_radius=10,
bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
content=ft.Column(
spacing=8,
controls=[
ft.Text(blend_mode.name, weight=ft.FontWeight.BOLD),
ft.Image(
src="https://picsum.photos/id/237/200/300",
width=240,
height=130,
fit=ft.BoxFit.COVER,
color=ft.Colors.LIGHT_GREEN_200,
color_blend_mode=blend_mode,
border_radius=8,
),
],
),
)


def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

page.appbar = ft.AppBar(title="BlendMode Showcase")
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Text("Compare color blending results for each BlendMode value."),
ft.Row(
wrap=True,
spacing=12,
expand=True,
scroll=ft.ScrollMode.AUTO,
alignment=ft.MainAxisAlignment.CENTER,
controls=[
showcase_card(blend_mode) for blend_mode in ft.BlendMode
],
),
]
)
)
)


if __name__ == "__main__":
ft.run(main)

Properties

CLEARclass-attributeinstance-attribute

Drops both the source and destination, leaving a fully transparent result.

COLORclass-attributeinstance-attribute

Takes the hue and saturation from the source and the luminosity from the destination.

COLOR_BURNclass-attributeinstance-attribute

Darkens the destination by dividing the inverse destination by the source and then inverting the result.

COLOR_DODGEclass-attributeinstance-attribute

Brightens the destination by dividing it by the inverse of the source.

DARKENclass-attributeinstance-attribute

Chooses the darker value from each source and destination color channel.

DIFFERENCEclass-attributeinstance-attribute

Subtracts the smaller channel value from the larger one.

Compositing black has no effect, while compositing white inverts the other image.

DSTclass-attributeinstance-attribute

Drops the source and keeps only the destination.

DST_A_TOPclass-attributeinstance-attribute

Draws the destination over the source, but only where they overlap.

DST_INclass-attributeinstance-attribute

Keeps the destination only where the source and destination overlap.

The source acts as an opacity mask.

DST_OUTclass-attributeinstance-attribute

Keeps the destination only where the source and destination do not overlap.

The source acts as an opacity mask.

DST_OVERclass-attributeinstance-attribute

Draws the source underneath the destination.

EXCLUSIONclass-attributeinstance-attribute

Produces an effect similar to DIFFERENCE, but softer.

HARD_LIGHTclass-attributeinstance-attribute

Combines multiply and screen-style blending while favoring the source image.

HUEclass-attributeinstance-attribute

Takes the hue from the source and the saturation and luminosity from the destination.

LIGHTENclass-attributeinstance-attribute

Chooses the lighter value from each source and destination color channel.

LUMINOSITYclass-attributeinstance-attribute

Takes the luminosity from the source and the hue and saturation from the destination.

MODULATEclass-attributeinstance-attribute

Multiplies the source and destination color channels without multiplying alpha.

MULTIPLYclass-attributeinstance-attribute

Multiplies the source and destination color channels, including alpha.

OVERLAYclass-attributeinstance-attribute

Combines multiply and screen-style blending while favoring the destination image.

PLUSclass-attributeinstance-attribute

Adds the source and destination channel values together.

This is useful for cross-fading between two images.

SATURATIONclass-attributeinstance-attribute

Takes the saturation from the source and the hue and luminosity from the destination.

SCREENclass-attributeinstance-attribute

Multiplies the inverted source and destination values, then inverts the result.

This can only produce the same or lighter colors.

SOFT_LIGHTclass-attributeinstance-attribute

Applies a softer lighting effect than OVERLAY.

SRCclass-attributeinstance-attribute

Drops the destination and keeps only the source.

SRC_A_TOPclass-attributeinstance-attribute

Draws the source over the destination, but only where they overlap.

SRC_INclass-attributeinstance-attribute

Keeps the source only where the source and destination overlap.

The destination acts as an opacity mask.

SRC_OUTclass-attributeinstance-attribute

Keeps the source only where the source and destination do not overlap.

The destination acts as an opacity mask.

SRC_OVERclass-attributeinstance-attribute

Draws the source over the destination.

This is the default painting behavior.

VALUESclass-attributeinstance-attribute

Not a usable blend mode.

Warning

This member exists in the Python enum surface but does not map to a runtime blend mode. Do not use it for painting or image composition.

XORclass-attributeinstance-attribute

Uses an exclusive-or composition so overlapping areas become transparent.