canvas 星空特效
阿里云图标 首页背景–星空特效 效果 代码 <html> <canvas id="_bgcanvas" style="position: fixed;z-index:-1"></canvas> <script> /** * * @param {string} element canvas 元素 * @param {int} width 宽 * @param {int} height 高 */ function xingkong (element, width, height) { var canvas = document.querySelector(element); var w = width ||document.documentElement.clientWidth; var h = height || document.documentElement.clientHeight; canvas.width = w, canvas.height = h; var context = canvas.getContext("2d"); // 背景 context.fillStyle = "#090723"; context.fillRect(0, 0, w, h); for (var l = [], r = 0; r < h; r += 4){ l.push(new t({ x: