svg对角线动画艺术效果
代码语言:html
所属分类:悬停
代码描述:svg对角线动画艺术效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { background: #000; margin: 0; } svg { display: block; width: 100vw; height: 100vh; } </style> </head> <body translate="no"> <svg> </svg> <script> const svgNS = 'http://www.w3.org/2000/svg'; const $ = document.querySelector.bind(document); const svg = $('svg'); const rand = (min, max) => min + Math.floor(Math.random() * (max - min + 1)); const palette = [ '#f07', '#0cf', '#0f7', '#fff']; function setSize() { svg.setAttributeNS(svgNS, 'viewBox', [0, 0, innerWidth, innerHeight].join(' ')); }; function create(tag, attrs) { const el = document.createElementNS(svgNS, tag); if (attrs) { Object.entries(attrs).map(([key, value]) => { el.setAttribute(key, value); }); } svg.appendChild(el); return el; } class GenerativePattern { constructor(color = '#fff') { this.pathStyle = { fill: 'none', 'stroke': color }; this.pathDef = ''; this.setRandomPosition(); this.set.........完整代码请登录后点击上方下载按钮下载查看
网友评论0