blendMode property on paint components.
What are Blend Modes?
Blend modes are operators that take two colors (source and destination) and return a new color. They allow you to create various visual effects by controlling how new content blends with existing content on the canvas.Setting Blend Modes
You can set blend modes as a property on shapes, groups, or paint components:Available Blend Modes
React Native Skia supports all standard Skia blend modes. The documentation below uses these abbreviations:s: source colord: destination colorsa: source alphada: destination alphar: result (when all components computed the same way)
Porter-Duff Modes
These are the classic compositing modes:| Mode | Formula | Description |
|---|---|---|
clear | r = 0 | Clears to transparent |
src | r = s | Shows only source |
dst | r = d | Shows only destination |
srcOver | r = s + (1-sa)*d | Source over destination (default) |
dstOver | r = d + (1-da)*s | Destination over source |
srcIn | r = s * da | Source inside destination |
dstIn | r = d * sa | Destination inside source |
srcOut | r = s * (1-da) | Source outside destination |
dstOut | r = d * (1-sa) | Destination outside source |
srcATop | r = s*da + d*(1-sa) | Source atop destination |
dstATop | r = d*sa + s*(1-da) | Destination atop source |
xor | r = s*(1-da) + d*(1-sa) | XOR mode |
plus | r = min(s + d, 1) | Add colors |
Separable Blend Modes
These modes work on color components:| Mode | Description |
|---|---|
modulate | Multiply source and destination |
screen | Invert, multiply, invert again |
overlay | Multiply or screen depending on destination |
darken | Keep darker color |
lighten | Keep lighter color |
colorDodge | Brighten destination to reflect source |
colorBurn | Darken destination to reflect source |
hardLight | Multiply or screen depending on source |
softLight | Lighten or darken depending on source |
difference | Absolute difference |
exclusion | Similar to difference but softer |
multiply | Multiply colors together |
Non-Separable Blend Modes
These modes work on hue, saturation, and luminosity:| Mode | Description |
|---|---|
hue | Hue of source with saturation and luminosity of destination |
saturation | Saturation of source with hue and luminosity of destination |
color | Hue and saturation of source with luminosity of destination |
luminosity | Luminosity of source with hue and saturation of destination |
Custom Blend Modes
React Native Skia also provides custom blend modes:| Mode | Description |
|---|---|
plusDarker | Similar to iOS kCGBlendModePlusDarker |
plusLighter | Similar to iOS kCGBlendModePlusLighter |
Examples
Multiply Effect
Difference Effect
Using with Shaders
You can combine blend modes with shaders for creative effects:Blend Component
For more complex scenarios, use theBlend component to explicitly blend multiple shaders:
Performance Considerations
- Some blend modes are more computationally expensive than others
srcOver(the default) is the fastest- Non-separable modes (
hue,saturation,color,luminosity) can be slower - Use blend modes sparingly for complex scenes with many layers