Skip to main content

Blending and Colors

Blend Shader

Returns a shader that combines the given shaders with a BlendMode.

NameTypeDescription
modeBlendModesee blend modes.
childrenReactNodeShaders to blend

Example

tsx
import React from "react";
import {
Canvas,
Rect,
Turbulence,
Skia,
Shader,
Fill,
RadialGradient,
Blend,
vec
} from "@shopify/react-native-skia";
 
export const BlendDemo = () => {
return (
<Canvas style={{ flex: 1 }}>
<Rect x={0} y={0} width={256} height={256}>
<Blend mode="difference">
<RadialGradient
r={128}
c={vec(128, 128)}
colors={["blue", "yellow"]}
/>
<Turbulence freqX={0.05} freqY={0.05} octaves={4} />
</Blend>
</Rect>
</Canvas>
);
};
tsx
import React from "react";
import {
Canvas,
Rect,
Turbulence,
Skia,
Shader,
Fill,
RadialGradient,
Blend,
vec
} from "@shopify/react-native-skia";
 
export const BlendDemo = () => {
return (
<Canvas style={{ flex: 1 }}>
<Rect x={0} y={0} width={256} height={256}>
<Blend mode="difference">
<RadialGradient
r={128}
c={vec(128, 128)}
colors={["blue", "yellow"]}
/>
<Turbulence freqX={0.05} freqY={0.05} octaves={4} />
</Blend>
</Rect>
</Canvas>
);
};

Result

Blend

Color Shader

Returns a shader with a given color.

NameTypeDescription
colorstringColor

Example

tsx
import React from "react";
import {
Canvas,
Skia,
Fill,
ColorShader
} from "@shopify/react-native-skia";
 
export const BlendDemo = () => {
return (
<Canvas style={{ flex: 1 }}>
<Fill>
<ColorShader color="lightBlue" />
</Fill>
</Canvas>
);
};
tsx
import React from "react";
import {
Canvas,
Skia,
Fill,
ColorShader
} from "@shopify/react-native-skia";
 
export const BlendDemo = () => {
return (
<Canvas style={{ flex: 1 }}>
<Fill>
<ColorShader color="lightBlue" />
</Fill>
</Canvas>
);
};

Result