silphius/app/react/context/radians.js
2024-09-22 02:16:32 -05:00

15 lines
376 B
JavaScript

import {useCallback, useState} from 'react';
import useAnimationFrame from '@/react/hooks/use-animation-frame.js';
import {TAU} from '@/util/math.js';
export function useRadians() {
const [radians, setRadians] = useState(0);
useAnimationFrame(
useCallback((elapsed) => {
setRadians((radians) => radians + (elapsed * TAU));
}, []),
);
return radians;
}