You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.7 KiB
72 lines
1.7 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>PPTK test page</title>
|
|
<script type="module" defer>
|
|
import * as pptk from "../pptk.js";
|
|
|
|
let canvas = document.getElementById("canvas");
|
|
canvas = pptk.canvas(canvas, {
|
|
update: draw
|
|
});
|
|
|
|
let pannable = pptk.pannable(canvas, {
|
|
preventDefault: true,
|
|
dpr: true,
|
|
center: () => [canvas.width / 2, canvas.height / 2],
|
|
update: () => draw(canvas),
|
|
});
|
|
|
|
let ctx = pptk.ctx_2d(canvas.getContext("2d"));
|
|
|
|
function draw(canvas) {
|
|
ctx.fillStyle = "gray";
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
ctx.beginPath();
|
|
ctx.ellipse(
|
|
...pannable.get(0, 0),
|
|
5 * pannable.zoom_factor,
|
|
5 * pannable.zoom_factor,
|
|
0,
|
|
Math.PI * 2,
|
|
0
|
|
);
|
|
ctx.fillStyle = "white";
|
|
ctx.fill();
|
|
}
|
|
</script>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
width: 100vw;
|
|
width: 100dvw;
|
|
|
|
height: 100vh;
|
|
height: 100dvh;
|
|
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.container {
|
|
overflow: hidden;
|
|
|
|
width: 80vw;
|
|
height: 80vh;
|
|
background: black;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<canvas id="canvas">
|
|
This test requires canvas support
|
|
</canvas>
|
|
</div>
|
|
</body>
|
|
</html>
|