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