Skip to main content

Morphology

The morphology image filter is identical to its SVG counterpart. It is used to erode or dilate the input image. Its usefulness lies primarily in fattening or thinning effects.

NameTypeDescription
operatorerode or dilatewhether to erode (i.e., thin) or dilate (fatten). Default is dilate
radiusnumber or VectorRadius of the effect.
children?ImageFilterOptional image filter to be applied first.

Example

tsx
import {Canvas, Text, Morphology, useFont} from "@shopify/react-native-skia";
 
export const MorphologyDemo = () => {
const font = useFont(require("./SF-Pro.ttf"), 24);
return (
<Canvas style={{ width: 256, height: 256 }}>
<Text
text="Hello World"
x={32}
y={32}
font={font}
/>
<Text
text="Hello World"
x={32}
y={64}
font={font}
>
<Morphology radius={1} />
</Text>
<Text
text="Hello World"
x={32}
y={96}
font={font}
>
<Morphology radius={0.3} operator="erode" />
</Text>
</Canvas>
);
};
tsx
import {Canvas, Text, Morphology, useFont} from "@shopify/react-native-skia";
 
export const MorphologyDemo = () => {
const font = useFont(require("./SF-Pro.ttf"), 24);
return (
<Canvas style={{ width: 256, height: 256 }}>
<Text
text="Hello World"
x={32}
y={32}
font={font}
/>
<Text
text="Hello World"
x={32}
y={64}
font={font}
>
<Morphology radius={1} />
</Text>
<Text
text="Hello World"
x={32}
y={96}
font={font}
>
<Morphology radius={0.3} operator="erode" />
</Text>
</Canvas>
);
};