$ git show breathe

Breathe bloom

Intermediate/anim breathe

Six petals expand outward and rotate in a slow in-out loop, for a breathing exercise.

Inspired by HeadspaceFrom William Candillon’s “Can it be done in React Native?” series. The code here is a simplified rewrite for Reanimated 4 and 3.
Main · New Architecture only · worklets live in react-native-worklets

This snippet uses APIs that didn’t change between versions, so the same code runs on Reanimated 4 and 3.

withRepeatEasing.inOuttrigonometry
breathe.tsx · reanimated 4
const p = useSharedValue(0);
useEffect(() => {
  p.value = withRepeat(withTiming(1, { duration: 4000, easing: Easing.inOut(Easing.ease) }), -1, true);
}, []);
const container = useAnimatedStyle(() => ({ transform: [{ rotate: p.value * Math.PI + 'rad' }] }));
function Petal({ index, p }) {
  const style = useAnimatedStyle(() => {
    const a = (index / 6) * 2 * Math.PI;
    const d = interpolate(p.value, [0, 1], [0, R / 2]);
    return {
      transform: [
        { translateX: Math.cos(a) * d }, { translateY: Math.sin(a) * d },
        { scale: interpolate(p.value, [0, 1], [0.4, 1]) },
      ],
    };
  });
  return <Animated.View style={[styles.petal, style]} />; // absolute, round, semi-transparent
}