folk-canvas/demo/[tests]distance-field.html

59 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Distance Perf</title>
<style>
html {
height: 100%;
}
body {
min-height: 100%;
position: relative;
margin: 0;
}
folk-shape {
border: 2px solid black;
}
</style>
</head>
<body>
<script type="module">
import '../src/standalone/folk-shape.ts';
import '../src/standalone/folk-distance-field.ts';
const d = document.createElement('folk-distance-field');
const geometries = [];
const now = performance.now();
for (let i = 0; i < 20; i++) {
for (let j = 0; j < 20; j++) {
const geo = document.createElement('folk-shape');
geo.x = 100 * i + Math.floor(Math.random() * 45);
geo.y = 100 * j + Math.floor(Math.random() * 45);
geo.width = geo.height = 45;
geometries.push(geo);
d.appendChild(geo);
}
}
console.log(performance.now() - now);
document.body.appendChild(d);
// function tick() {
// window.requestAnimationFrame(tick);
// for (let i = 0; i < 10; i++) {
// const g = geometries[Math.floor(Math.random() * geometries.length)];
// const max = 50;
// g.x += Math.floor(Math.random() * max - max / 2);
// g.y += Math.floor(Math.random() * max - max / 2);
// }
// }
// tick();
</script>
</body>
</html>