mirror of
https://github.com/bspeice/speice.io
synced 2024-12-23 00:58:09 -05:00
25 lines
715 B
TypeScript
25 lines
715 B
TypeScript
import React, { useContext, useEffect } from "react";
|
|
import { xformFinal as final, xforms as transforms } from "../src/params";
|
|
import { PainterContext } from "../src/Canvas";
|
|
import { chaosGameHistogram } from "./chaosGameHistogram";
|
|
|
|
type Props = {
|
|
paint: (width: number, height: number, histogram: number[]) => ImageData;
|
|
children?: React.ReactElement;
|
|
}
|
|
export default function FlameHistogram({ paint, children }: Props) {
|
|
const { width, height, setPainter } = useContext(PainterContext);
|
|
|
|
useEffect(() => {
|
|
const gameParams = {
|
|
width,
|
|
height,
|
|
transforms,
|
|
final,
|
|
paint
|
|
};
|
|
setPainter(chaosGameHistogram(gameParams));
|
|
}, [width, height]);
|
|
|
|
return children;
|
|
} |