Fix initial posts to use the new painter API

This commit is contained in:
Bradlee Speice 2024-11-29 23:19:19 -05:00
parent 112470ce5a
commit f327b53863
4 changed files with 19 additions and 14 deletions

View File

@ -0,0 +1,16 @@
import Canvas, {PainterContext} from "../src/Canvas";
import {useContext} from "react";
export function Render({f}) {
const {setPainter} = useContext(PainterContext);
setPainter(f);
return <></>;
}
export default function Gasket({f}) {
return (
<Canvas width={500} height={500}>
<Render f={f}/>
</Canvas>
)
}

View File

@ -27,10 +27,4 @@ function* chaosGame() {
}
// Wiring so the code above displays properly
function Gasket() {
const {setPainter} = useContext(PainterContext);
setPainter(chaosGame());
return (<></>)
}
render(<Gasket/>)
render(<Gasket f={chaosGame()}/>)

View File

@ -177,9 +177,7 @@ import Scope from './scope'
import chaosGameSource from '!!raw-loader!./chaosGame'
<!--
<Playground scope={Scope} noInline={true}>{chaosGameSource}</Playground>
-->
<hr/>

View File

@ -1,15 +1,12 @@
import {useContext} from "react";
import Gasket from "./Gasket";
import { plot } from './plot';
import { randomBiUnit } from '../src/randomBiUnit';
import { randomInteger } from '../src/randomInteger';
import Canvas, {PainterContext} from "../src/Canvas";
const Scope = {
Canvas,
PainterContext,
Gasket,
plot,
randomBiUnit,
randomInteger,
useContext,
}
export default Scope;