1import { useState } from 'react'
2import {
3 AppBar, Box, Container, createTheme, CssBaseline, Link, Paper, Tab, Tabs,
4 ThemeProvider, Toolbar, Typography,
5} from '@mui/material'
6import { Delaunay2D } from './components/Delaunay2D'
7import { Hull3D } from './components/Hull3D'
8import { Benchmarks } from './components/Benchmarks'
10const theme = createTheme({
11 palette: { mode: 'light', primary: { main: '#1565c0' } },
12})
14function App() {
15 const [tab, setTab] = useState(0)
16 return (
17 <ThemeProvider theme={theme}>
18 <CssBaseline />
19 <AppBar position="static" elevation={0}>
20 <Toolbar>
21 <Box component="img" src="/qhull-wasm-demo/qhull-logo.svg" alt="" sx={{ width: 32, height: 32, mr: 1.5 }} />
22 <Typography variant="h6" sx={{ flexGrow: 1 }}>qhull-wasm</Typography>
23 <Link href="https://github.com/magland/qhull-wasm" target="_blank" rel="noreferrer" color="inherit" underline="hover">
24 GitHub
25 </Link>
26 </Toolbar>
27 </AppBar>
29 <Container maxWidth="md" sx={{ py: 3 }}>
30 <Typography variant="body1" sx={{ mb: 2 }}>
31 <Link href="https://github.com/magland/qhull-wasm" target="_blank" rel="noreferrer">qhull-wasm</Link>{' '}
32 is <Link href="http://www.qhull.org" target="_blank" rel="noreferrer">Qhull</Link> (the reentrant
33 {' '}<code>libqhull_r</code>) compiled to WebAssembly, with a small JS API for convex hulls and
34 Delaunay triangulations — the same engine MATLAB and Octave use, now running in the browser.
35 It was built for <Link href="https://numbl.org" target="_blank" rel="noreferrer">numbl</Link>,
36 which uses it to power <code>delaunayn</code> and <code>convhulln</code>.
37 </Typography>
39 <Paper variant="outlined" sx={{ mb: 2 }}>
40 <Tabs value={tab} onChange={(_, v) => setTab(v)} variant="scrollable" scrollButtons="auto">
41 <Tab label="2D Triangulation" />
42 <Tab label="3D Convex Hull" />
43 <Tab label="Benchmarks" />
44 </Tabs>
45 </Paper>
47 <Box sx={{ pb: 4 }}>
48 {tab === 0 && <Delaunay2D />}
49 {tab === 1 && <Hull3D />}
50 {tab === 2 && <Benchmarks />}
51 </Box>
53 <Typography variant="caption" color="text.secondary" component="div" sx={{ mt: 4 }}>
54 qhull-wasm is MIT-licensed; it bundles Qhull (Qhull license). Part of the{' '}
55 <Link href="https://github.com/concept-collection" target="_blank" rel="noreferrer">concept-collection</Link>.
56 </Typography>
57 </Container>
58 </ThemeProvider>
59 )
60}
62export default App