2024-12-15 21:19:09 -05:00
|
|
|
import { useContext, useEffect, useState } from "react";
|
|
|
|
import { Coefs } from "../src/transform";
|
2024-12-01 21:57:10 -05:00
|
|
|
import * as params from "../src/params";
|
2024-12-15 21:19:09 -05:00
|
|
|
import { PainterContext } from "../src/Canvas";
|
|
|
|
import { buildBlend } from "./buildBlend";
|
|
|
|
import { chaosGameFinal } from "./chaosGameFinal";
|
|
|
|
import { VariationEditor, VariationProps } from "./VariationEditor";
|
|
|
|
import { CoefEditor } from "./CoefEditor";
|
|
|
|
import { applyPost, applyTransform } from "../src/applyTransform";
|
2024-12-01 18:17:36 -05:00
|
|
|
|
2024-11-30 17:35:42 -05:00
|
|
|
export default function FlameFinal() {
|
2024-12-15 21:19:09 -05:00
|
|
|
const { width, height, setPainter } = useContext(PainterContext);
|
2024-11-30 17:35:42 -05:00
|
|
|
|
2024-12-15 21:19:09 -05:00
|
|
|
const [xformFinalCoefs, setXformFinalCoefs] = useState<Coefs>(params.xformFinalCoefs);
|
|
|
|
const resetXformFinalCoefs = () => setXformFinalCoefs(params.xformFinalCoefs);
|
2024-11-30 17:35:42 -05:00
|
|
|
|
2024-12-15 21:19:09 -05:00
|
|
|
const xformFinalVariationsDefault: VariationProps = {
|
|
|
|
linear: 0,
|
|
|
|
julia: 1,
|
|
|
|
popcorn: 0,
|
|
|
|
pdj: 0
|
|
|
|
};
|
|
|
|
const [xformFinalVariations, setXformFinalVariations] = useState<VariationProps>(xformFinalVariationsDefault);
|
|
|
|
const resetXformFinalVariations = () => setXformFinalVariations(xformFinalVariationsDefault);
|
2024-11-30 17:35:42 -05:00
|
|
|
|
2024-12-15 21:19:09 -05:00
|
|
|
const [xformFinalCoefsPost, setXformFinalCoefsPost] = useState<Coefs>(params.xformFinalCoefsPost);
|
|
|
|
const resetXformFinalCoefsPost = () => setXformFinalCoefsPost(params.xformFinalCoefsPost);
|
2024-11-30 17:35:42 -05:00
|
|
|
|
2024-12-15 21:19:09 -05:00
|
|
|
useEffect(() => {
|
|
|
|
const finalBlend = buildBlend(xformFinalCoefs, xformFinalVariations);
|
|
|
|
const finalXform = applyPost(xformFinalCoefsPost, applyTransform(xformFinalCoefs, finalBlend));
|
2024-11-30 17:35:42 -05:00
|
|
|
|
2024-12-15 21:19:09 -05:00
|
|
|
setPainter(chaosGameFinal({ width, height, transforms: params.xforms, final: finalXform }));
|
|
|
|
}, [xformFinalCoefs, xformFinalVariations, xformFinalCoefsPost]);
|
2024-11-30 17:35:42 -05:00
|
|
|
|
2024-12-15 21:19:09 -05:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<CoefEditor title={"Final Transform"} isPost={false} coefs={xformFinalCoefs} setCoefs={setXformFinalCoefs}
|
|
|
|
resetCoefs={resetXformFinalCoefs} />
|
|
|
|
<VariationEditor title={"Final Transform Variations"} variations={xformFinalVariations}
|
|
|
|
setVariations={setXformFinalVariations} resetVariations={resetXformFinalVariations} />
|
|
|
|
<CoefEditor title={"Final Transform Post"} isPost={true} coefs={xformFinalCoefsPost}
|
|
|
|
setCoefs={setXformFinalCoefsPost} resetCoefs={resetXformFinalCoefsPost} />
|
|
|
|
</>
|
|
|
|
);
|
2024-11-30 17:35:42 -05:00
|
|
|
}
|