2024-12-01 21:57:10 -05:00
|
|
|
import React, {useContext, useEffect} from "react";
|
2024-12-08 16:17:21 -05:00
|
|
|
import {xforms as transforms, xformFinal as final} from "../src/params";
|
2024-12-01 18:17:36 -05:00
|
|
|
import {PainterContext} from "../src/Canvas";
|
2024-12-08 15:35:27 -05:00
|
|
|
import {chaosGameHistogram} from "./chaosGameHistogram";
|
2024-12-01 15:16:30 -05:00
|
|
|
|
2024-12-01 21:57:10 -05:00
|
|
|
type Props = {
|
|
|
|
quality?: number;
|
2024-12-08 16:17:21 -05:00
|
|
|
paint: (width: number, histogram: Uint32Array) => ImageData;
|
2024-12-01 21:57:10 -05:00
|
|
|
children?: React.ReactElement;
|
2024-12-01 18:17:36 -05:00
|
|
|
}
|
2024-12-08 16:17:21 -05:00
|
|
|
export default function FlameHistogram({quality, paint, children}: Props) {
|
2024-12-01 18:17:36 -05:00
|
|
|
const {width, height, setPainter} = useContext(PainterContext);
|
|
|
|
|
2024-12-01 21:57:10 -05:00
|
|
|
useEffect(() => {
|
|
|
|
const gameParams = {
|
|
|
|
width,
|
|
|
|
height,
|
2024-12-08 16:17:21 -05:00
|
|
|
transforms,
|
|
|
|
final,
|
2024-12-01 21:57:10 -05:00
|
|
|
quality,
|
2024-12-08 16:17:21 -05:00
|
|
|
paint
|
2024-12-01 21:57:10 -05:00
|
|
|
}
|
|
|
|
setPainter(chaosGameHistogram(gameParams));
|
|
|
|
}, []);
|
2024-12-01 18:17:36 -05:00
|
|
|
|
2024-12-01 21:57:10 -05:00
|
|
|
return children;
|
2024-12-01 15:16:30 -05:00
|
|
|
}
|