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>delaunay</code>, <code>delaunayn</code>, <code>convhull</code>,
37 and <code>convhulln</code>.
38 </Typography>
40 <Paper variant="outlined" sx={{ mb: 2 }}>
41 <Tabs value={tab} onChange={(_, v) => setTab(v)} variant="scrollable" scrollButtons="auto">
42 <Tab label="2D Triangulation" />
43 <Tab label="3D Convex Hull" />
44 <Tab label="Benchmarks" />
45 </Tabs>
46 </Paper>
48 <Box sx={{ pb: 4 }}>
49 {tab === 0 && <Delaunay2D />}
50 {tab === 1 && <Hull3D />}
51 {tab === 2 && <Benchmarks />}
52 </Box>
54 <Typography variant="caption" color="text.secondary" component="div" sx={{ mt: 4 }}>
55 qhull-wasm is MIT-licensed; it bundles Qhull (Qhull license). Part of the{' '}
56 <Link href="https://github.com/concept-collection" target="_blank" rel="noreferrer">concept-collection</Link>.
57 </Typography>
58 </Container>
59 </ThemeProvider>
60 )
61}
63export default App