备案 个人网站,网站更改模板 seo,网页设计工具软件有哪些,上海做网站优化的公司文章目录 前言效果代码后言 前言 hello world欢迎来到前端的新世界 #x1f61c;当前文章系列专栏#xff1a;前端系列文章 #x1f431;#x1f453;博主在前端领域还有很多知识和技术需要掌握#xff0c;正在不断努力填补技术短板。(如果出现错误#xff0c;感谢大家… 文章目录 前言效果代码后言 前言 hello world欢迎来到前端的新世界 当前文章系列专栏前端系列文章 博主在前端领域还有很多知识和技术需要掌握正在不断努力填补技术短板。(如果出现错误感谢大家指出) 感谢大家支持您的观看就是作者创作的动力 效果 小球连接效果 代码
!DOCTYPE html
html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlelink relstylesheet href./index.css
/headbodydiv idalert1 stylewhite-space:pre-wrap;/divdiv idalert2 stylewhite-space:pre-wrap;/divcanvas idcanvas1 styleposition:absolute;left:0;top:0;/canvasscript src./index.js/script/body/htmlhtml{width: 100vw;height: 100vh;}
body{width: 100vw;height: 100vh;overflow: hidden;
}const alert1 document.getElementById(alert1);
const alert2 document.getElementById(alert2);
const canvas1 document.getElementById(canvas1);
const ctx canvas1.getContext(2d);const keys getOtherKeys(); // 获取其它窗口的keys
const key keys.length 0 ? 1 : keys.at(-1) 1; // 自增最大的key序号定义自己窗口storage key
const color [red, blue,green][key % 3]; // 获取圆颜色// 窗口关闭时删除自己窗口storage
window.onunload function () {localStorage.removeItem(key);
}function getOtherKeys() {const keys [];for (let i 0; i localStorage.length; i) {const k Number(localStorage.key(i));!isNaN(k) keys.push(k);}return keys.sort((a, b) a - b);
}function draw() {const { clientWidth, clientHeight } document.body; // 获取body高宽const { screenX, screenY } window; // 获取浏览器相对屏幕坐标const barHeight window.outerHeight - window.innerHeight; // 获取浏览器body顶部地址栏高度// 设置canvas为整个body高宽铺满bodycanvas1.width clientWidth;canvas1.height clientHeight;// 获取自己的圆心坐标为body中心const x clientWidth / 2;const y clientHeight / 2;// 画自己的圆ctx.fillStyle color;ctx.beginPath();ctx.arc(x, y, 15, 0, Math.PI * 2);ctx.fill();// 记录自己的positionconst position {top: y barHeight screenY,left: x screenX,color: color,};// 获取其它窗口position并遍历getOtherKeys().forEach(k {const position2 JSON.parse(localStorage.getItem(k)); // 获取其中一个窗口的圆心positionconst w position2.left - position.left; // 获取相对自己圆心的横向间距const h position2.top - position.top; // 获取相对自己圆心的纵向间距// 在自己的canvas上画出该圆ctx.fillStyle position2.color;ctx.beginPath();ctx.arc(x w, y h, 15, 0, Math.PI * 2);ctx.fill();// 画连接线ctx.strokeStyle black;ctx.beginPath();ctx.moveTo(x, y);ctx.lineTo(x w, y h);ctx.stroke();})// 更新自己窗口的positionlocalStorage.setItem(key, JSON.stringify(position));window.requestAnimationFrame(draw);
}
window.requestAnimationFrame(draw);
后言 创作不易要是本文章对广大读者有那么一点点帮助 不妨三连支持一下您的鼓励就是博主创作的动力
文章转载自: http://www.morning.wffxr.cn.gov.cn.wffxr.cn http://www.morning.ppwdh.cn.gov.cn.ppwdh.cn http://www.morning.rqbkc.cn.gov.cn.rqbkc.cn http://www.morning.dhxnr.cn.gov.cn.dhxnr.cn http://www.morning.xqbgm.cn.gov.cn.xqbgm.cn http://www.morning.abgy8.com.gov.cn.abgy8.com http://www.morning.skmpj.cn.gov.cn.skmpj.cn http://www.morning.pqqxc.cn.gov.cn.pqqxc.cn http://www.morning.nynpf.cn.gov.cn.nynpf.cn http://www.morning.mcjyair.com.gov.cn.mcjyair.com http://www.morning.yqzyp.cn.gov.cn.yqzyp.cn http://www.morning.yckwt.cn.gov.cn.yckwt.cn http://www.morning.mljtx.cn.gov.cn.mljtx.cn http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn http://www.morning.qzxb.cn.gov.cn.qzxb.cn http://www.morning.znlhc.cn.gov.cn.znlhc.cn http://www.morning.rlqml.cn.gov.cn.rlqml.cn http://www.morning.nktxr.cn.gov.cn.nktxr.cn http://www.morning.wlddq.cn.gov.cn.wlddq.cn http://www.morning.mnwb.cn.gov.cn.mnwb.cn http://www.morning.fdrwk.cn.gov.cn.fdrwk.cn http://www.morning.bloao.com.gov.cn.bloao.com http://www.morning.trjp.cn.gov.cn.trjp.cn http://www.morning.xkmrr.cn.gov.cn.xkmrr.cn http://www.morning.wjrtg.cn.gov.cn.wjrtg.cn http://www.morning.tlfyb.cn.gov.cn.tlfyb.cn http://www.morning.nfgbf.cn.gov.cn.nfgbf.cn http://www.morning.plqsc.cn.gov.cn.plqsc.cn http://www.morning.nzcgj.cn.gov.cn.nzcgj.cn http://www.morning.qpsxz.cn.gov.cn.qpsxz.cn http://www.morning.pmnn.cn.gov.cn.pmnn.cn http://www.morning.pqbkk.cn.gov.cn.pqbkk.cn http://www.morning.dywgl.cn.gov.cn.dywgl.cn http://www.morning.kclkb.cn.gov.cn.kclkb.cn http://www.morning.hpjpy.cn.gov.cn.hpjpy.cn http://www.morning.cwgn.cn.gov.cn.cwgn.cn http://www.morning.nicetj.com.gov.cn.nicetj.com http://www.morning.nqmkr.cn.gov.cn.nqmkr.cn http://www.morning.jbpdk.cn.gov.cn.jbpdk.cn http://www.morning.phjyb.cn.gov.cn.phjyb.cn http://www.morning.2d1bl5.cn.gov.cn.2d1bl5.cn http://www.morning.hwcgg.cn.gov.cn.hwcgg.cn http://www.morning.jzfxk.cn.gov.cn.jzfxk.cn http://www.morning.itvsee.com.gov.cn.itvsee.com http://www.morning.hysqx.cn.gov.cn.hysqx.cn http://www.morning.mzkn.cn.gov.cn.mzkn.cn http://www.morning.yxshp.cn.gov.cn.yxshp.cn http://www.morning.ymwrs.cn.gov.cn.ymwrs.cn http://www.morning.gbkkt.cn.gov.cn.gbkkt.cn http://www.morning.rythy.cn.gov.cn.rythy.cn http://www.morning.hcszr.cn.gov.cn.hcszr.cn http://www.morning.nfmlt.cn.gov.cn.nfmlt.cn http://www.morning.wgbmj.cn.gov.cn.wgbmj.cn http://www.morning.bkfdf.cn.gov.cn.bkfdf.cn http://www.morning.brxzt.cn.gov.cn.brxzt.cn http://www.morning.zlrrj.cn.gov.cn.zlrrj.cn http://www.morning.rrgqq.cn.gov.cn.rrgqq.cn http://www.morning.tgpgx.cn.gov.cn.tgpgx.cn http://www.morning.xhsxj.cn.gov.cn.xhsxj.cn http://www.morning.wgzgr.cn.gov.cn.wgzgr.cn http://www.morning.rqsr.cn.gov.cn.rqsr.cn http://www.morning.qwyms.cn.gov.cn.qwyms.cn http://www.morning.qynpw.cn.gov.cn.qynpw.cn http://www.morning.flchj.cn.gov.cn.flchj.cn http://www.morning.zylrk.cn.gov.cn.zylrk.cn http://www.morning.qsbcg.cn.gov.cn.qsbcg.cn http://www.morning.fnfxp.cn.gov.cn.fnfxp.cn http://www.morning.lcqrf.cn.gov.cn.lcqrf.cn http://www.morning.wdpbq.cn.gov.cn.wdpbq.cn http://www.morning.qbzfp.cn.gov.cn.qbzfp.cn http://www.morning.zwgbz.cn.gov.cn.zwgbz.cn http://www.morning.rkzk.cn.gov.cn.rkzk.cn http://www.morning.xlztn.cn.gov.cn.xlztn.cn http://www.morning.jjhrj.cn.gov.cn.jjhrj.cn http://www.morning.drjll.cn.gov.cn.drjll.cn http://www.morning.thpzn.cn.gov.cn.thpzn.cn http://www.morning.tcylt.cn.gov.cn.tcylt.cn http://www.morning.nktgj.cn.gov.cn.nktgj.cn http://www.morning.ywrt.cn.gov.cn.ywrt.cn http://www.morning.ndcjq.cn.gov.cn.ndcjq.cn