import Animated from "react-native-reanimated" ; import type { Vector } from "./Vectors" ; import { vec } from "./Vectors" ; import type { Transforms2d } from "./Matrix3" ; const { divide , sub , multiply , add , cos , sin } = Animated ; export const translateZ = ( perspective , z ) => ( { scale : divide ( perspective , sub ( perspective , z ) ) } ) ; export const translate = ( { x : translateX , y : translateY } ) => [ { translateX } , { translateY } , ] ; export const transformOrigin = ( { x , y } , ... transformations ) : Transforms2d => [ { translateX : x } , { translateY : y } , ... transformations , { translateX : multiply ( x , - 1 ) } , { translateY : multiply ( y , - 1 ) } , ] ; export const rotateTranslation = ( tr , rotate ) => ( { x : sub ( multiply ( tr . x , cos ( rotate ) ) , multiply ( tr . y , sin ( rotate ) ) ) , y : add ( multiply ( tr . x , sin ( rotate ) ) , multiply ( tr . y , cos ( rotate ) ) ) , } ) ; export const scaleTranslation = ( tr , scale ) => vec . multiply ( tr , scale ) ;