import React, { useEffect, useRef, useState } from 'react';
import { useFaceTracking } from '../hooks/useFaceTracking';
import { AvatarConfig, Rect } from '../types';
interface StudioProps {
avatar: AvatarConfig;
onBack: () => void;
}
/**
* Sprite Component
* Renders a specific crop of the source image into a target container.
*/
const Sprite: React.FC<{
imageSrc: string;
sourceRect: Rect;
style?: React.CSSProperties;
className?: string;
}> = ({ imageSrc, sourceRect, style, className }) => {
// To display a cropped region (sourceRect) of the image, we use an inner
// positioned negatively and scaled up.
// Example: If sourceRect.w is 0.1 (10%), the image must be scaled to 10x (1000%) size.
const widthScale = 100 / (sourceRect.w * 100);
const heightScale = 100 / (sourceRect.h * 100);
return (