import React from 'react'; import logo from './logo.svg'; import './App.css'; import { render } from './component'; import * as blobs2 from 'blobs/v2'; import { annotatedEquation, testComponent, testRow, annotatedDiagram, testCol, testArrow, annotatedEquationRef, blobPaperJSTest, } from './testComponents'; import * as _ from 'lodash'; import { bertinHotel } from './examples/bertinHotel'; // import { blob as test_blob } from './examples/paperjs-test'; import { SVG } from './components/SVG'; import { Col } from './components/Col'; import { Row } from './components/Row'; import { Rect } from './components/Rect'; import { Text } from './components/Text'; import { Char, Peritext } from './examples/peritext'; import { Bluefish } from './components/Bluefish'; // import { Child, Parent } from './components/TestingRefs'; import { Child, Parent } from './components/TestingContext'; import { Align } from './components/Align'; import { GoGTest } from './examples/grammars/gog/examples/test'; import { rasterize } from './rasterize'; import { Label, LabelTest } from './examples/label'; import { Group } from './components/Group'; import labelLayout, { Anchors } from './components/Label/LabelLayout'; import { PointLabel } from './components/Label/PointLabel'; import { Circle, Ref } from './main'; import { GoTree } from './examples/gotree'; import { driving } from './examples/grammars/gog/examples/driving'; import { Plot2 as Plot } from './examples/grammars/gog/Plot'; import { scaleLinear } from 'd3-scale'; import { GlobalFrame } from './python-tutor'; const blob = (blobOptions: blobs2.BlobOptions, svgOptions?: blobs2.SvgOptions | undefined): JSX.Element => { return ; }; function App() { const [startOpId, setStartOpId] = React.useState('5@B'); const [rangeval, setRangeval] = React.useState(undefined); const [circle, setCircle] = React.useState(null); const [pngUrl, setPngUrl] = React.useState(null); const [text1, setText1] = React.useState(null); const [text2, setText2] = React.useState(null); const [text3, setText3] = React.useState(null); const [circle1, setCircle1] = React.useState(null); const [circle2, setCircle2] = React.useState(null); const [circle3, setCircle3] = React.useState(null); // React.useEffect(() => { // if ( // text1 === null || // text2 === null || // text3 === null || // circle1 === null || // circle2 === null || // circle3 === null // ) { // return; // } // console.log('layout', text1); // labelLayout({ // // labels and anchor points // texts: [ // { label: text1, ref: circle1 }, // { label: text2, ref: circle2 }, // { label: text3, ref: circle3 }, // ], // // canvas size (provided by parent in Bluefish) // size: [500, 500], // // optional sorting function to determine label layout priority order // compare: undefined, // // label offset from anchor point // offset: [1], // // offset orientation (e.g. 'top-left') // anchor: Anchors, // // optional list of elements to avoid (like a line mark) // avoidElements: [], // // whether or not we should avoid the anchor points (circle1, circle2, circle3) // avoidRefElements: true, // // padding around canvas to allow labels to be partially offscreen // padding: 0, // }); // }, [text1, text2, text3, circle1, circle2, circle3]); // use canvg to convert circle to png React.useEffect(() => { async function convert() { if (circle !== null) { const canvas = await rasterize(circle, { width: 100, height: 100 }); const blob = await canvas.convertToBlob(); const pngUrl = URL.createObjectURL(blob); setPngUrl(pngUrl); } } convert(); }, [circle]); return (
{/* scaleLinear([0, _.max(driving.map((d) => +d.miles))!], [0, width])} y={({ height }) => scaleLinear([0, _.max(driving.map((d) => +d.gas))!], [height, 0])} color={() => () => 'black'} >
scaleLinear([0, _.max(driving.map((d) => +d.miles))!], [0, width])} y={({ height }) => scaleLinear([0, _.max(driving.map((d) => +d.gas))!], [height, 0])} color={() => () => 'black'} >
scaleLinear([0, _.max(driving.map((d) => +d.miles))!], [0, width])} y={({ height }) => scaleLinear([0, _.max(driving.map((d) => +d.gas))!], [height, 0])} color={() => () => 'black'} >
*/} {/* scaleLinear([0, _.max(driving.map((d) => +d.miles))!], [0, width])} y={({ height }) => scaleLinear([0, _.max(driving.map((d) => +d.gas))!], [height, 0])} color={() => () => 'black'} > */}



{/* {{ the: 'center', of: , to: , }} , to: { the: 'topCenter', of: , }, }} /> */}
{/* , ref: 'rect1' }, { label: ( */} {/* */} {/* ), ref: 'rect2', }, { label: , ref: 'rect3' }, ]} compare={undefined} offset={[1]} anchor={Anchors} avoidElements={[]} avoidRefElements padding={0} /> */}
{/* */} {/* */} {/* , ref: 'rect1' }, { label: , ref: 'rect2' }, { label: , ref: 'rect3' }, ]} compare={undefined} offset={[1]} anchor={Anchors} avoidElements={[]} avoidRefElements padding={0} /> */}
{ setText1(node as any); }} x={25} y={25} > text1 { setCircle1(node as any); }} cx={25} cy={25} fill={'black'} r={5} /> { setText2(node as any); }} x={40} y={25} > text2 { setCircle2(node as any); }} cx={40} cy={25} fill={'black'} r={5} /> { setText3(node as any); }} x={50} y={50} > text3 { setCircle3(node as any); }} cx={50} cy={50} fill={'black'} r={5} /> {/* */} { setCircle(node as any); }} cx="50" cy="50" r="40" stroke="green" strokeWidth="4" fill="yellow" />
{`${circle?.outerHTML}`}
{''}
setRangeval(event.target.value as any)} />

The range value is {rangeval}


"OP ID": {startOpId}
{/* */}
{/* */} {/* */} {/* { } */} {/* { } */} {/* { } */} {/* { } { }
{ } { } { } { } */} {/* */} {/*
{render(blobPaperJSTest)}

{render(bertinHotel)}

{render(annotatedDiagram)}

{render(annotatedEquationRef)}

{render(testArrow)}
{render(annotatedDiagram)}
{render(testRow)} {render(testCol)} {render(testComponent)}

{render(annotatedEquation)}
{blob( { seed: Math.random(), extraPoints: 8, randomness: 4, size: 256, }, { fill: 'white', // 🚨 NOT SANITIZED stroke: 'black', // 🚨 NOT SANITIZED strokeWidth: 4, }, )}
*/}
); } export default App;