SkBlendMode Reference === # Blend Mode ## Overview
Topic | Description |
---|---|
Constants | enum and enum class, and their const values |
Functions | global and class member functions |
Related Functions | similar member functions grouped together |
Topic | Description |
---|---|
SkBlendMode Name | returns mode as C string |
enum
, enum class
, #define
, const
, and constexpr
.
Topic | Description |
---|---|
SkBlendMode | algorithm combining source and destination pixels |
SkBlendMode::kClear | replaces destination with zero: fully transparent |
SkBlendMode::kColor | hue and saturation of source with luminosity of destination |
SkBlendMode::kColorBurn | darken destination to reflect source |
SkBlendMode::kColorDodge | brighten destination to reflect source |
SkBlendMode::kDarken | darker of source and destination |
SkBlendMode::kDifference | subtract darker from lighter with higher contrast |
SkBlendMode::kDst | preserves destination |
SkBlendMode::kDstATop | destination inside source blended with source |
SkBlendMode::kDstIn | destination trimmed by source |
SkBlendMode::kDstOut | destination trimmed outside source |
SkBlendMode::kDstOver | destination over source |
SkBlendMode::kExclusion | subtract darker from lighter with lower contrast |
SkBlendMode::kHardLight | multiply or screen, depending on source |
SkBlendMode::kHue | hue of source with saturation and luminosity of destination |
SkBlendMode::kLastCoeffMode | last Porter Duff blend mode |
SkBlendMode::kLastMode | last valid value |
SkBlendMode::kLastSeparableMode | last blend mode operating separately on components |
SkBlendMode::kLighten | lighter of source and destination |
SkBlendMode::kLuminosity | luminosity of source with hue and saturation of destination |
SkBlendMode::kModulate | product of Premultiplied colors; darkens destination |
SkBlendMode::kMultiply | multiply source with destination, darkening image |
SkBlendMode::kOverlay | multiply or screen, depending on destination |
SkBlendMode::kPlus | sum of colors |
SkBlendMode::kSaturation | saturation of source with hue and luminosity of destination |
SkBlendMode::kScreen | multiply inverse of pixels, inverting result; brightens destination |
SkBlendMode::kSoftLight | lighten or darken, depending on source |
SkBlendMode::kSrc | replaces destination |
SkBlendMode::kSrcATop | source inside destination blended with destination |
SkBlendMode::kSrcIn | source trimmed inside destination |
SkBlendMode::kSrcOut | source trimmed outside destination |
SkBlendMode::kSrcOver | source over destination |
SkBlendMode::kXor | each of source and destination trimmed outside the other |
enum class SkBlendMode { kClear, kSrc, kDst, kSrcOver, kDstOver, kSrcIn, kDstIn, kSrcOut, kDstOut, kSrcATop, kDstATop, kXor, kPlus, kModulate, kScreen, kLastCoeffMode = kScreen, kOverlay, kDarken, kLighten, kColorDodge, kColorBurn, kHardLight, kSoftLight, kDifference, kExclusion, kMultiply, kLastSeparableMode = kMultiply, kHue, kSaturation, kColor, kLuminosity, kLastMode = kLuminosity, };### Constants
Const | Value | Details | Description |
---|---|---|---|
SkBlendMode::kClear |
0 | Clear | Replaces destination with Alpha and Color components set to zero; a fully transparent pixel. |
SkBlendMode::kSrc |
1 | Src | Replaces destination with source. Destination alpha and color component values are ignored. |
SkBlendMode::kDst |
2 | Dst | Preserves destination, ignoring source. Drawing with Paint set to kDst has no effect. |
SkBlendMode::kSrcOver |
3 | Src Over | Replaces destination with source blended with destination. If source is opaque, replaces destination with source. Used as the default Blend Mode for SkPaint. |
SkBlendMode::kDstOver |
4 | Dst Over | Replaces destination with destination blended with source. If destination is opaque, has no effect. |
SkBlendMode::kSrcIn |
5 | Src In | Replaces destination with source using destination opacity. |
SkBlendMode::kDstIn |
6 | Dst In | Scales destination opacity by source opacity. |
SkBlendMode::kSrcOut |
7 | Src Out | Replaces destination with source using the inverse of destination opacity, drawing source fully where destination opacity is zero. |
SkBlendMode::kDstOut |
8 | Dst Out | Replaces destination opacity with inverse of source opacity. If source is transparent, has no effect. |
SkBlendMode::kSrcATop |
9 | Src Atop | Blends destination with source using read destination opacity. |
SkBlendMode::kDstATop |
10 | Dst Atop | Blends destination with source using source opacity. |
SkBlendMode::kXor |
11 | Xor | Blends destination by exchanging transparency of the source and destination. |
SkBlendMode::kPlus |
12 | Plus | Replaces destination with source and destination added together. |
SkBlendMode::kModulate |
13 | Modulate | Replaces destination with source and destination multiplied together. |
SkBlendMode::kScreen |
14 | Screen | Replaces destination with inverted source and destination multiplied together. |
SkBlendMode::kLastCoeffMode |
14 | last Porter_Duff blend mode | |
SkBlendMode::kOverlay |
15 | Overlay | Replaces destination with multiply or screen, depending on destination. |
SkBlendMode::kDarken |
16 | Darken | Replaces destination with darker of source and destination. |
SkBlendMode::kLighten |
17 | Lighten | Replaces destination with lighter of source and destination. |
SkBlendMode::kColorDodge |
18 | Color Dodge | Makes destination brighter to reflect source. |
SkBlendMode::kColorBurn |
19 | Color Burn | Makes destination darker to reflect source. |
SkBlendMode::kHardLight |
20 | Hard Light | Makes destination lighter or darker, depending on source. |
SkBlendMode::kSoftLight |
21 | Soft Light | Makes destination lighter or darker, depending on source. |
SkBlendMode::kDifference |
22 | Difference | Subtracts darker from lighter with higher contrast. |
SkBlendMode::kExclusion |
23 | Exclusion | Subtracts darker from lighter with lower contrast. |
SkBlendMode::kMultiply |
24 | Multiply | Multiplies source with destination, darkening image. |
SkBlendMode::kLastSeparableMode |
24 | Last blend mode operating separately on components. | |
SkBlendMode::kHue |
25 | Hue | Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged. |
SkBlendMode::kSaturation |
26 | Saturation | Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged. |
SkBlendMode::kColor |
27 | Color | Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged. |
SkBlendMode::kLuminosity |
28 | Luminosity | Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged. |
SkBlendMode::kLastMode |
28 | Used by tests to iterate through all valid values. |
\[0, 0\]
.
Use SkBlendMode::kClear to initialize a buffer to fully transparent pixels when
creating a mask with irregular edges.
### Example
Sa
as source Alpha, Sc
as source Color component;
SkBlendMode::kSrc sets destination to: \[Sa, Sc\]
.
Use SkBlendMode::kSrc to copy one buffer to another. All pixels are copied,
regardless of source and destination Alpha values. As a parameter to
SkCanvas::drawAtlas, selects sprites and ignores colors.
### Example
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kDst preserves destination set to: \[Da, Dc\]
.
Setting Paint Blend Mode to SkBlendMode::kDst causes drawing with
Paint to have no effect. As a parameter to SkCanvas::drawAtlas,
selects colors and ignores sprites.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kSrcOver replaces destination with: \[Sa \+ Da \* \(1 \- Sa\), Sc \+ Dc \* \(1 \- Sa\)\]
,
drawing source over destination. SkBlendMode::kSrcOver is the default for Paint.
SkBlendMode::kSrcOver cannot make destination more transparent; the result will
be at least as opaque as the less transparent of source and original destination.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kDstOver replaces destination with: \[Da \+ Sa \* \(1 \- Da\), Dc \+ Sc \* \(1 \- Da\)\]
,
drawing destination over source. Has no effect destination if is opaque.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha;
SkBlendMode::kSrcIn replaces destination with: \[Sa \* Da, Sc \* Da\]
,
drawing source with destination opacity.
### Example
Sa
as source Alpha,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kDstIn replaces destination with: \[Da \* Sa, Dc \* Sa\]
,
scaling destination Alpha by source Alpha. Resulting
destination is visible where source is visible.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha;
SkBlendMode::kSrcOut replaces destination with: \[Sa \* \(1 \- Da\), Sc \* \(1 \- Da\)\]
,
drawing source fully where destination Alpha is zero. Is destination
is opaque, has no effect.
### Example
Sa
as source Alpha,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kDstOut replaces destination with: \[Da \* \(1 \- Sa\), Dc \* \(1 \- Sa\)\]
,
scaling destination Alpha by source transparency. Resulting
destination is visible where source is transparent. If source is transparent,
has no effect.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kSrcATop replaces destination with: \[Da, Sc \* Da \+ Dc \* \(1 \- Sa\)\]
,
replacing opaque destination with opaque source. If source or destination
is transparent, has no effect.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kDstATop replaces destination with: \[Sa, Dc \* Sa \+ Sc \* \(1 \- Da\)\]
,
making destination transparent where source is transparent.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kXor replaces destination with:
\[Sa \+ Da \- 2 \* Sa \* Da, Sc \* \(1 \- Da\) \+ Dc \* \(1 \- Sa\)\]
,
exchanging the transparency of the source and destination.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kPlus replaces destination with: \[Sa \+ Da, Sc \+ Dc\]
,
summing the Alpha and Color components.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kModulate replaces destination with: \[Sa \* Da, Sc \* Dc\]
,
scaling Alpha and Color components by the lesser of the values.
SkBlendMode::kModulate differs from SkBlendMode::kMultiply in two ways.
SkBlendMode::kModulate like SkBlendMode::kSrcATop alters the destination inside
the destination area, as if the destination Alpha defined the boundaries of a
soft clip. SkBlendMode::kMultiply like SkBlendMode::kSrcOver can alter the
destination where the destination is transparent.
SkBlendMode::kModulate computes the product of the source and destination using
Premultiplied component values. SkBlendMode::kMultiply the product of the source
and destination using Unpremultiplied component values.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kScreen replaces destination with: \[Sa \+ Da \- Sa \* Da, Sc \+ Dc \- Sc \* Dc\]
.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kOverlay replaces destination with:
\[Sa \+ Da \- Sa \* Da, Sc \* \(1 \- Da\) \+ Dc \* \(1 \- Sa\) \+
\(2 \* Dc <= Da ? 2 \* Sc \* Dc : Sa \* Da \- 2 \* \(Da \- Dc\) \* \(Sa \- Sc\)\)\]
.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kDarken replaces destination with:
\[Sa \+ Da \- Sa \* Da, Sc \+ Dc \- max\(Sc \* Da, Dc \* Sa\)\]
.
SkBlendMode::kDarken does not make an image darker; it replaces the destination
component with source if source is darker.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kLighten replaces destination with:
\[Sa \+ Da \- Sa \* Da, Sc \+ Dc \- min\(Sc \* Da, Dc \* Sa\)\]
.
SkBlendMode::kDarken does not make an image lighter; it replaces the destination
component with source if source is lighter.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kColorDodge replaces destination with:
\[Sa \+ Da \- Sa \* Da, Dc == 0 ? Sc \* \(1 \- Da\) : Sc == Sa ? Sc \+ Da \* \(1 \- Sa\) :
Sa \* min\(Da, Dc \* Sa / \(Sa \- Sc\)\) \+ Sc \* \(1 \- Da\) \+ Da \* \(1 \- Sa\)\]
,
making destination brighter to reflect source.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kColorBurn replaces destination with:
\[Sa \+ Da \- Sa \* Da, Dc == Da ? Dc \+ Sc \* \(1 \- Da\) : Sc == 0 ? Da \* \(1 \- Sa\) :
Sa \* \(Da \- min\(Da, \(Da \- Dc\) \* Sa / Sc\)\) \+ Sc \* \(1 \- Da\) \+ Da \* \(1 \- Sa\)\]
,
making destination darker to reflect source.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kHardLight replaces destination with:
\[Sa \+ Da \- Sa \* Da, Sc \* \(1 \- Da\) \+ Dc \* \(1 \- Sa\) \+
2 \* Sc <= Sa ? 2 \* Sc \* Dc : Sa \* Da \- 2 \* \(Da \- Dc\) \* \(Sa \- Sc\)\]
,
making destination lighter or darker, depending on source.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
where m = Da > 0 ? Dc / Da : 0
;
SkBlendMode::kSoftLight replaces destination with: \[Sa \+ Da \- Sa \* Da, Sc / Da \+ Dc / Sa \+
\(2 \* Sc <= Sa ? Dc \* \(Sa \+ \(2 \* Sc \- Sa\) \* \(1 \- m\)\) : Dc \* Sa \+ Da \* \(2 \* Sc \- Sa\) \*
\(4 \* Dc <= Da ? \(16 \* m \* m \+ 4 \* m\) \* \(m \- 1\) \+ 7 \* m : sqrt(m) \- m\)\)\]
,
making destination lighter or darker, depending on source.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kDifference replaces destination with:
\[Sa \+ Da \- Sa \* Da, Sc \+ Dc \- 2 \* min\(Sc \* Da, Dc \* Sa\)\]
,
replacing destination with lighter less darker.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kExclusion replaces destination with:
\[Sa \+ Da \- Sa \* Da, Sc \+ Dc \- 2 \* Sc \* Dc\]
,
replacing destination with lighter less darker, ignoring Alpha.
### Example
Sa
as source Alpha, Sc
as source Color component,
Da
as destination Alpha, Dc
as destination Color component;
SkBlendMode::kMultiply replaces destination with:
\[Sa \+ Da \- Sa \* Da, Sc \* \(1 \- Da\) \+ Dc \* \(1 \- Sa\) \+ Sc \* Dc\]
,
the product of Unpremultiplied source and destination.
SkBlendMode::kMultiply makes the image darker.
### Example
Sa
as source Alpha, S
as source Color,
Da
as destination Alpha, D
as destination Color;
SkBlendMode::kHue replaces destination with:
\[Sa \+ Da \- Sa \* Da, SetLuminosity(SetSaturation(S, Saturation(D)\), Luminosity(D)\)\]
,
source hue, leaving destination luminosity and saturation unchanged.
### Example
Sa
as source Alpha, S
as source Color,
Da
as destination Alpha, D
as destination Color;
SkBlendMode::kHue replaces destination with:
\[Sa \+ Da \- Sa \* Da, SetLuminosity(SetSaturation(D, Saturation(S)\), Luminosity(D)\)\]
,
source hue, leaving destination luminosity and saturation unchanged.
### Example
Sa
as source Alpha, S
as source Color,
Da
as destination Alpha, D
as destination Color;
SkBlendMode::kColor replaces destination with:
\[Sa \+ Da \- Sa \* Da, SetLuminosity(S, Luminosity(D)\)\]
,
source hue and saturation, leaving destination luminosity unchanged.
### Example
Sa
as source Alpha, S
as source Color,
Da
as destination Alpha, D
as destination Color;
SkBlendMode::kLuminosity replaces destination with:
\[Sa \+ Da \- Sa \* Da, SetLuminosity(D, Luminosity(S)\)\]
,
source luminosity, leaving destination hue and saturation unchanged.
### Example
SK_API const char* SkBlendMode Name(SkBlendMode blendMode)Returns name of blendMode as null-terminated C string. ### Parameters