Algorithms to use when painting on the canvas.
When drawing a shape or image onto a canvas, different algorithms can be used to blend the pixels. The image below shows the effects of these modes.
The "src" (source) image is the shape or image being drawn, the "dst" (destination) image is the current contents of the canvas onto which the source is being drawn.
When using saveLayer
and restore
, the blend mode of the Paint given to
the saveLayer
will be applied when restore
is called. Each call to
saveLayer
introduces a new layer onto which shapes and images are painted;
when restore
is called, that layer is then composited onto the parent
layer, with the "src" being the most-recently-drawn shapes and images, and
the "dst" being the parent layer. (For the first saveLayer
call, the
parent layer is the canvas itself.)
See also:
- Paint.blendMode, which uses BlendMode to define the compositing strategy.
Constants
- clear → BlendMode
-
Drop both the source and destination images, leaving nothing.
This corresponds to the "clear" Porter-Duff operator.
const BlendMode(0)
- color → BlendMode
-
const BlendMode(27)
- colorBurn → BlendMode
-
const BlendMode(19)
- colorDodge → BlendMode
-
const BlendMode(18)
- darken → BlendMode
-
const BlendMode(16)
- difference → BlendMode
-
const BlendMode(22)
- dst → BlendMode
-
Drop the source image, only paint the destination image.
Conceptually, the source image is discarded, leaving the destination untouched.
This corresponds to the "Destination" Porter-Duff operator.
const BlendMode(2)
- dstATop → BlendMode
-
Composite the destination image over the source image, but only where it overlaps the source.
This corresponds to the "Destination atop Source" Porter-Duff operator.
const BlendMode(10)
- dstIn → BlendMode
-
Show the destination image, but only where the two images overlap. The source image is not rendered, it is treated merely as a mask.
To show the source image instead, consider srcIn.
To reverse the semantic of the mask (only showing the source where the destination is present, rather than where it is absent), consider srcIn.
This corresponds to the "Destination in Source" Porter-Duff operator.
const BlendMode(6)
- dstOut → BlendMode
-
Show the destination image, but only where the two images do not overlap. The source image is not rendered, it is treated merely as a mask.
To show the source image instead, consider srcOut.
To reverse the semantic of the mask (only showing the destination where the source is present, rather than where it is absent), consider dstIn.
This corresponds to the "Destination out Source" Porter-Duff operator.
const BlendMode(8)
- dstOver → BlendMode
-
Composite the source image under the destination image.
This is the opposite of srcOver.
This corresponds to the "Destination over Source" Porter-Duff operator.
const BlendMode(4)
- exclusion → BlendMode
-
const BlendMode(23)
- hardLight → BlendMode
-
const BlendMode(20)
- hue → BlendMode
-
const BlendMode(25)
- lighten → BlendMode
-
const BlendMode(17)
- luminosity → BlendMode
-
const BlendMode(28)
- modulate → BlendMode
-
const BlendMode(13)
- multiply → BlendMode
-
const BlendMode(24)
- overlay → BlendMode
-
const BlendMode(15)
- plus → BlendMode
-
Composite the source and destination images by summing their components.
This corresponds to the "Source plus Destination" Porter-Duff operator.
const BlendMode(12)
- saturation → BlendMode
-
const BlendMode(26)
- screen → BlendMode
-
const BlendMode(14)
- softLight → BlendMode
-
const BlendMode(21)
- src → BlendMode
-
Drop the destination image, only paint the source image.
Conceptually, the destination is first cleared, then the source image is painted.
This corresponds to the "Copy" Porter-Duff operator.
const BlendMode(1)
- srcATop → BlendMode
-
Composite the source image over the destination image, but only where it overlaps the destination.
This corresponds to the "Source atop Destination" Porter-Duff operator.
const BlendMode(9)
- srcIn → BlendMode
-
Show the source image, but only where the two images overlap. The destination image is not rendered, it is treated merely as a mask.
To show the destination image instead, consider dstIn.
To reverse the semantic of the mask (only showing the source where the destination is absent, rather than where it is present), consider srcOut.
This corresponds to the "Source in Destination" Porter-Duff operator.
const BlendMode(5)
- srcOut → BlendMode
-
Show the source image, but only where the two images do not overlap. The destination image is not rendered, it is treated merely as a mask.
To show the destination image instead, consider dstOut.
To reverse the semantic of the mask (only showing the source where the destination is present, rather than where it is absent), consider srcIn.
This corresponds to the "Source out Destination" Porter-Duff operator.
const BlendMode(7)
- srcOver → BlendMode
-
Composite the source image over the destination image.
This is the default value. It represents the most intuitive case, where shapes are painted on top of what is below, with transparent areas showing the destination layer.
This corresponds to the "Source over Destination" Porter-Duff operator, also known as the Painter's Algorithm.
const BlendMode(3)
- values → List<BlendMode>
-
A constant List of the values in this enum, in order of their declaration.
const List<BlendMode>
- xor → BlendMode
-
Composite the source and destination images, leaving transparency where they would overlap.
This corresponds to the "Source xor Destination" Porter-Duff operator.
const BlendMode(11)
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
other) → bool -
The equality operator. [...]
inherited