<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      canvas 鼠標(biāo)與點(diǎn)之間連線


      <!DOCTYPE html>
      <html lang="en">
        <head>
          <meta charset="UTF-8" />
          <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
          <title>Document</title>
          <style>
            .canvas {
              width: 100%;
              height: calc(100vh - 24px);
              border: 1px solid black;
              box-sizing: border-box;
            }
          </style>
        </head>
        <body>
          <canvas class="canvas"></canvas>
      
          <script>
            /** @type {HTMLCanvasElement} */
            const canvas = document.querySelector('.canvas');
            const ctx = canvas.getContext('2d');
      
            const pointMap = new Map();
      
            canvas.width = canvas.clientWidth * window.devicePixelRatio;
            canvas.height = canvas.clientHeight * window.devicePixelRatio;
      
            canvas.addEventListener('mousemove', (e) => {
              const rect = canvas.getBoundingClientRect();
              let x = e.clientX - rect.left,
                y = e.clientY - rect.top;
              x = (x * window.devicePixelRatio).toFixed(2);
              y = (y * window.devicePixelRatio).toFixed(2);
      
              ctx.clearRect(0, 0, canvas.width, canvas.height);
              renderPoints();
              computedPosition(x, y);
            });
      
            randomPoints(canvas.clientWidth, canvas.clientHeight, 20);
            renderPoints();
      
            // 計算鼠標(biāo)與每個點(diǎn)(圓)的距離
            function computedPosition(x, y) {
              // console.log('x, y => ', x, y);
              for (const [key, { x: pointX, y: pointY, color }] of pointMap) {
                const distance = Math.sqrt((x - pointX) ** 2 + (y - pointY) ** 2);
                if (distance < 200) {
                  // 點(diǎn)與鼠標(biāo)的距離小于200,則連線
                  ctx.beginPath();
                  ctx.moveTo(x, y);
                  ctx.lineTo(pointX, pointY);
                  ctx.strokeStyle = color;
                  ctx.stroke();
                }
              }
            }
      
            // 渲染點(diǎn)
            function renderPoints() {
              for (const { x, y, color } of pointMap.values()) {
                // console.log("point => ", point)
                drawCircle(x, y, color);
              }
            }
      
            // 生成隨機(jī)點(diǎn)
            function randomPoints(boundWidth, boundHeight, count = 0) {
              if (!count) return;
      
              count = parseInt(count);
      
              const minWidth = 0,
                minHeight = 0,
                maxWidth = boundWidth,
                maxHeight = boundHeight;
      
              for (let i = 0; i < count; i++) {
                let x = randomPoint(minWidth, maxWidth),
                  y = randomPoint(minHeight, maxHeight);
      
                x = Math.floor(x / 10) * 10;
                y = Math.floor(y / 10) * 10;
      
                pointMap.set(i, { x, y, color: randomColor() });
              }
            }
      
            // 生成隨機(jī)點(diǎn)的坐標(biāo)
            function randomPoint(min, max) {
              return Math.floor(Math.random() * (max - min + 1)) + min;
            }
      
            // 生成隨機(jī)顏色
            function randomColor() {
              const letters = '0123456789ABCDEF';
              let color = '#';
              for (let i = 0; i < 6; i++) {
                color += letters[Math.floor(Math.random() * 16)];
              }
              return color;
            }
      
            // 繪制點(diǎn)(圓)
            function drawCircle(x, y, color = 'black') {
              ctx.beginPath();
              ctx.arc(x, y, 10, 0, 2 * Math.PI);
              ctx.fillStyle = color;
              ctx.fill();
            }
          </script>
        </body>
      </html>
      
      posted @ 2024-06-02 19:09  _clai  閱讀(49)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 精品国产福利一区二区在线| 久久久久国产一级毛片高清版A| 国产午夜A理论毛片| 国产av一区二区午夜福利| 中文字幕日韩有码av| 麻阳| 精品国产中文字幕在线| 欧美嫩交一区二区三区| 中文字幕少妇人妻精品| 国产老头多毛Gay老年男| 无码免费大香伊蕉在人线国产| 77777亚洲午夜久久多人| 久久综合开心激情五月天| 亚洲AV午夜成人无码电影| 午夜国产精品福利一二| 国产一区二区亚洲精品| 国产sm重味一区二区三区| 中文字幕久久精品波多野结| 国产剧情视频一区二区麻豆| 久久久亚洲欧洲日产国码αv| 国内自产少妇自拍区免费| 亚洲成在人线在线播放无码| 国产愉拍精品手机| 亚洲日本乱码熟妇色精品| 国产又爽又黄又爽又刺激| 日韩精品无码一区二区视频| 国产亚洲精品福利在线无卡一 | 色就色中文字幕在线视频| 99在线精品国自产拍中文字幕| 亚洲美女厕所偷拍美女尿尿 | 亚洲中文久久久精品无码| 国产边打电话边被躁视频| 精品偷拍被偷拍在线观看| 亚洲精品久荜中文字幕| 四虎库影成人在线播放| 久久成人国产精品免费软件| 国产精品国产精品国产精品| 国产日韩一区二区在线| 精品久久久久中文字幕日本| 97色伦97色伦国产| 日本久久久免费高清|