js+svg实现彩色折叠纸条绘制代码
代码语言:html
所属分类:其他
代码描述:js+svg实现彩色折叠纸条绘制代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background: #535455; } .content { max-width: 800px; margin: 0 auto; padding: 30px; } svg { overflow: visible; } button { display: block; margin: 40px auto 0; } </style> </head> <body > <div class="content"> <svg viewBox="0 0 500 200"> </svg> <button>Redraw</button> </div> <script > "use strict"; const svg = document.querySelector("svg"); const button = document.querySelector("button"); const width = 500; const height = 200; const numberOfDataPoints = 20; const xStep = width / numberOfDataPoints; const yMin = Math.round(height * 0.1); const yMax = height - yMin; function addVectors(v1, v2) { return { x: v1.x + v2.x, y: v1.y + v2.y }; } function drawRibbon() { const data = []; for (let i = 0; i <= numberOfDataPoints; i++) { data.push({ x: xStep * i, y: yMin + Math.round(Math.random() * (yMax - yM.........完整代码请登录后点击上方下载按钮下载查看
网友评论0