diff --git a/apps/paper/package.json b/apps/paper/package.json index 77226ab3f8..0bf42d9ada 100644 --- a/apps/paper/package.json +++ b/apps/paper/package.json @@ -31,7 +31,7 @@ "react-native-reanimated": "^3.16.5", "react-native-safe-area-context": "^4.10.9", "react-native-screens": "^4.3.0", - "react-native-svg": "^15.9.0", + "react-native-svg": "^15.10.1", "react-native-wgpu": "0.1.19", "typescript": "^5.2.2" }, diff --git a/apps/paper/src/Examples/Breathe/TestReconciller.tsx b/apps/paper/src/Examples/Breathe/TestReconciller.tsx new file mode 100644 index 0000000000..f117bc037b --- /dev/null +++ b/apps/paper/src/Examples/Breathe/TestReconciller.tsx @@ -0,0 +1,106 @@ +import React, { useCallback, useMemo, useState } from "react"; +import { Button, StyleSheet, useWindowDimensions, View } from "react-native"; +import { + BlurMask, + vec, + Canvas, + Circle, + Fill, + Group, + polar2Canvas, + mix, +} from "@shopify/react-native-skia"; +import type { SharedValue } from "react-native-reanimated"; +import { useDerivedValue } from "react-native-reanimated"; + +import { useLoop } from "../../components/Animations"; + +const c1 = "#61bea2"; +const c2 = "#529ca0"; + +interface RingProps { + index: number; + progress: SharedValue; + total: number; +} + +const Ring = ({ index, progress, total }: RingProps) => { + const { width, height } = useWindowDimensions(); + const R = width / 4; + const center = useMemo( + () => vec(width / 2, height / 2 - 64), + [height, width] + ); + + const theta = (index * (2 * Math.PI)) / total; + const transform = useDerivedValue(() => { + const { x, y } = polar2Canvas( + { theta, radius: progress.value * R }, + { x: 0, y: 0 } + ); + const scale = mix(progress.value, 0.3, 1); + return [{ translateX: x }, { translateY: y }, { scale }]; + }); + + return ( + + ); +}; + +export const Breathe = () => { + const [rings, setRings] = useState(12); + const { width, height } = useWindowDimensions(); + const center = useMemo( + () => vec(width / 2, height / 2 - 64), + [height, width] + ); + + const progress = useLoop({ duration: 3000 }); + + const transform = useDerivedValue(() => [ + { rotate: mix(progress.value, -Math.PI, 0) }, + ]); + + const add = useCallback(() => { + setRings((r) => r + 1); + }, []); + const remove = useCallback(() => { + setRings((r) => Math.max(1, r - 1)); + }, []); + return ( + + +