网友回复
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Canvas拖动方块</title>
</head>
<body>
<canvas id="canvas" width="500" height="500" style="border:1px solid red;"></canvas>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
let startX, startY;
let isDrawing = false;
const rects = [];
let selectedSquare = null;
let offsetX, offsetY;
function findSquare(x, y) {
for (let i = rects.length - 1; i >= 0; i--) {
const square = rects[i];
if (x >= square.x && x <= square.x + square.w &&
y >= square.y && y <= square.y + square.h) {
return square;
}
}
return null;
}
canvas.addEventListener('mousedown', (e) => {
const mouseX = e.clientX - canvas.getBoundingClientRect().left;
const mouseY = e.clientY - canvas.getBoundingClientRect().top;
...点击查看剩余70%
go如何写一个类似redis的nosql数据库让python客户端调用?
php7中为啥无法使用$_SERVER['HTTP_RAW_POST_DATA'] ?
chrome插件能否实现2台电脑的远程协助桌面控制?
python如何通过webrtc网页远程协助控制python运行的电脑?
systemd-nspawn与unshare区别?
Firejail、Bubblewrap沙箱与docker、podman容器区别?
如何访问unshare -n -- python3 -m http.server 8000创建的网站url?
linux中如何限制进程执行非法的系统调用命令,例如reboot 删除等等?
pivot_root与chroot有啥区别?
linux中如何限制进程使用cpu、内存、网络的最大值?


