mirror of
https://github.com/bspeice/speice.io
synced 2024-12-23 00:58:09 -05:00
30 lines
739 B
TypeScript
30 lines
739 B
TypeScript
import React, {useContext, useEffect} from "react";
|
|
import randomBiUnit from './biunit';
|
|
import plot from './plot';
|
|
import randomInteger from './randint';
|
|
import Canvas, {ImageContext} from "../src/Canvas";
|
|
|
|
interface Props {
|
|
renderFn: (image: ImageData) => void;
|
|
}
|
|
function Render({renderFn}: Props) {
|
|
const {width, height, setImage} = useContext(ImageContext);
|
|
const image = new ImageData(width, height);
|
|
|
|
useEffect(() => {
|
|
renderFn(image);
|
|
setImage(image);
|
|
}, []);
|
|
|
|
return <></>;
|
|
}
|
|
|
|
const Scope = {
|
|
plot,
|
|
randomBiUnit,
|
|
randomInteger,
|
|
Canvas,
|
|
Gasket: ({renderFn}: Props) =>
|
|
<Canvas width={600} height={600}><Render renderFn={renderFn}/></Canvas>
|
|
}
|
|
export default Scope; |