$ git show wave-fill
Liquid fill progress
A round progress gauge filled with liquid: the surface waves continuously while the level rises to the value.
// Unchanged in Reanimated 4: the wave is a computed path, so it stays on animated props
import Svg, { Path, ClipPath, Circle, Defs, G } from 'react-native-svg';
const AnimatedPath = Animated.createAnimatedComponent(Path);
const S = 120; // size
const AMP = 6; // wave height
const phase = useSharedValue(0);
const level = useSharedValue(0);
useEffect(() => {
phase.value = withRepeat(withTiming(2 * Math.PI, { duration: 1800, easing: Easing.linear }), -1);
}, []);
useEffect(() => {
level.value = withTiming(progress, { duration: 900, easing: Easing.out(Easing.cubic) });
}, [progress]);
const wave = useAnimatedProps(() => {
const top = S * (1 - level.value);
let d = 'M 0 ' + top;
for (let x = 0; x <= S; x += 4) {
d += ' L ' + x + ' ' + (top + AMP * Math.sin((x / S) * 2 * Math.PI + phase.value));
}
return { d: d + ' L ' + S + ' ' + S + ' L 0 ' + S + ' Z' };
});
<Svg width={S} height={S}>
<Defs>
<ClipPath id="bubble"><Circle cx={S / 2} cy={S / 2} r={S / 2 - 3} /></ClipPath>
</Defs>
<Circle cx={S / 2} cy={S / 2} r={S / 2 - 1.5} stroke="#2F54EB" strokeWidth={3} fill="#EEF2FF" />
<G clipPath="url(#bubble)">
<AnimatedPath animatedProps={wave} fill="#2F54EB" />
</G>
</Svg>