import { useMemo, useState } from "react" import { useTranslation } from "react-i18next" import { Button } from "@/components/ui/button" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { useColorGrading } from "../../services/color-grading-provider" import { CurveEditor, CurvePoint } from "./curve-editor" // Цвета для разных типов кривых const CURVE_COLORS = { master: "#ffffff", red: "#ef4444", green: "#22c55e", blue: "#3b82f6", } // Начальные точки для кривой (прямая линия) const DEFAULT_CURVE_POINTS: CurvePoint[] = [ { x: 0, y: 256, id: "start" }, { x: 256, y: 0, id: "end" }, ] export function CurvesSection() { const { t } = useTranslation() const { state, dispatch } = useColorGrading() const [activeCurve, setActiveCurve] = useState<"master" | "red" | "green" | "blue">("master") // Получаем точки для активной кривой const activeCurvePoints = useMemo(() => { switch (activeCurve) { case "master": return state.curves.master || DEFAULT_CURVE_POINTS case "red": return state.curves.red || DEFAULT_CURVE_POINTS case "green": return state.curves.green || DEFAULT_CURVE_POINTS case "blue": return state.curves.blue || DEFAULT_CURVE_POINTS default: return state.curves.master || DEFAULT_CURVE_POINTS } }, [activeCurve, state.curves]) // Обработчик изменения точек кривой const handlePointsChange = (points: CurvePoint[]) => { dispatch({ type: "UPDATE_CURVE", curve: activeCurve, points, }) } // Сброс кривой к исходному состоянию const handleReset = () => { dispatch({ type: "UPDATE_CURVE", curve: activeCurve, points: DEFAULT_CURVE_POINTS, }) } // Автоматическая коррекция (простая S-кривая для контраста) const handleAuto = () => { const autoCurve: CurvePoint[] = [ { x: 0, y: 256, id: "start" }, { x: 64, y: 176, id: "shadows" }, { x: 192, y: 80, id: "highlights" }, { x: 256, y: 0, id: "end" }, ] dispatch({ type: "UPDATE_CURVE", curve: activeCurve, points: autoCurve, }) } return (
{/* Заголовок секции */}
{t("colorGrading.curves.description", "Fine-tune tonal response with interactive curves")}
{/* Переключатель типа кривой */} setActiveCurve(value as typeof activeCurve)} className="w-full" > {t("colorGrading.curves.master", "Master")} {t("colorGrading.curves.red", "Red")} {t("colorGrading.curves.green", "Green")} {t("colorGrading.curves.blue", "Blue")}
{/* Интерактивный редактор кривой */} {/* Кнопки управления */}
{t("colorGrading.curves.hint", "Click to add points, drag to adjust")}
) }