GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
scripts/web-probe/demo.html (1.4K)
1 <!doctype html>
2 <meta charset="utf-8">
3 <title>cce-ui</title>
4 <!-- An app on the browser shell: examples/demo_web.rs, or the example the
5 query names (?app=probe3d_web) — any that exports start(canvas, fonts,
6 families, fill), or the entry the query names in its place
7 (&entry=start_traced), and capture(). The page owns the canvas's size (fill =
8 Sizing::Page). window.capture() reads the next frame back from the GPU,
9 base64 RGBA8: a headless Chromium leaves a WebGPU canvas out of its
10 screenshots. -->
11 <style>html,body{margin:0;background:#3f3f3f;overflow:hidden}canvas{display:block;width:100vw;height:100vh}</style>
12 <canvas id="c"></canvas>
13 <script type="module">
14 const app = new URLSearchParams(location.search).get('app') || 'demo_web';
15 const mod = await import(`./${app}.js`);
16 const { default: init, capture } = mod;
17 const start = mod[new URLSearchParams(location.search).get('entry') || 'start'];
18 await init();
19 const { files, families } = await (await fetch('fonts.json')).json();
20 const fonts = [];
21 for (const n of files) fonts.push(new Uint8Array(await (await fetch('fonts/' + n)).arrayBuffer()));
22 await start(document.getElementById('c'), fonts, families, true);
23 window.capture = async () => {
24 const rgba = await capture();
25 let s = '';
26 for (let i = 0; i < rgba.length; i += 0x8000) s += String.fromCharCode.apply(null, rgba.subarray(i, i + 0x8000));
27 return btoa(s);
28 };
29 window.demoReady = true;
30 </script>