尽梨了,谁能告诉我剩下的那 0.2 差在哪?
```
function sleep(time = 100) {
return new Promise((reslove) => {
setTimeout(() => {
reslove();
}, time)
})
}
async function drawCircleByMouse(canvasEl, centerX, centerY, radius = 200) {
let radian = 0;
const pointers = [];
while (radian < Math.PI * 2) {
const x = centerX + Math.cos(radian) * radius
const y = centerY + Math.sin(radian) * radius
pointers.push({ x, y });
radian += 0.1;
}
const startPoint = pointers[0];
const mousedownEnt = new MouseEvent("mousedown", { clientX: startPoint.x, clientY: startPoint.y, bubbles: true });
canvasEl.dispatchEvent(mousedownEnt);
for (let point of pointers) {
await sleep();
const mousemoveEnt = new MouseEvent("mousemove", { clientX: point.x, clientY: point.y, bubbles: true });
canvasEl.dispatchEvent(mousemoveEnt);
radian += 0.01;
}
const mousemoveEnt = new MouseEvent("mousemove", { clientX: startPoint.x, clientY: startPoint.y, bubbles: true });
canvasEl.dispatchEvent(mousemoveEnt);
const endPoint = pointers[pointers.length - 1];
const mouseupEnt = new MouseEvent("mouseup", { clientX: endPoint.x, clientY: endPoint.y, bubbles: true });
canvasEl.dispatchEvent(mouseupEnt);
}
document.querySelector('a').click();
setTimeout(async () => {
const el = document.querySelector('div');
const rect = el.getBoundingClientRect();
const rem = window.innerHeight / 100 * 9;
const centerX = window.innerWidth / 2;
const centerY = window.innerHeight / 2 - 20;
await drawCircleByMouse(el, centerX, centerY);
}, 2000);
```