32 lines
1.1 KiB
HTML
32 lines
1.1 KiB
HTML
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Document</title>
|
|
</head>
|
|
|
|
<body>
|
|
<div>Original array: <span id="src">Loading...</span></div>
|
|
<div>Simplified array: <span id="dest">Loading...</span></div>
|
|
|
|
<script type="module">
|
|
import moduleFactory from './simplify.js'
|
|
import { storeCoords, loadResultAndFreeMemory } from '../wasm-util/coordinates.js'
|
|
|
|
const module = moduleFactory()
|
|
const data = [[0, 0], [1, 1], [1, 2], [2, 2], [5, 5], [5, 0], [6, 10], [10, 10]]
|
|
document.getElementById('src').innerText = JSON.stringify(data)
|
|
|
|
module.onRuntimeInitialized = async _ => {
|
|
const buffer = storeCoords(module, data)
|
|
const result = module._simplify(buffer, data.length * 2, 2, true)
|
|
module._free(buffer)
|
|
const simplified = loadResultAndFreeMemory(module, result)
|
|
document.getElementById('dest').innerText = JSON.stringify(simplified)
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html> |