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