react+svg绘制漂亮的立体山峰山峦效果代码
代码语言:html
所属分类:布局界面
代码描述:react+svg绘制漂亮的立体山峰山峦效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { width: 100vw; height: 100vh; position: relative; font-family: "Montserrat", sans-serif; } .mountains { width: 100%; height: 100%; } button { position: absolute; bottom: 20px; right: 20px; background: #46b799; padding: 0.5rem 0.5rem; border: none; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); cursor: pointer; font-weight: bold; } button:hover { background: #5cebc5; } </style> </head> <body> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.17.1.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.17.1.js"></script> <script> const { useEffect, useRef, useState} = window.React; const { render } = window.ReactDOM; const LAYERS = 10; const X_VARIANCE = 500; const Y_VARIANCE = 400; const HUE_VARIANCE = 80; const random = (min, max) => Math.round(Math.random() * (max - min) + min); const rd = (num, deviation) => random(num - deviation, num + deviation); const randomize = (d) => d.replace(/(\-?[\d]+)/g, v => { const i = parseInt(v); const n = rd(i, 20); if (Math.sign(i) === -1 && Math.sign(n) !== -1) { return ' ' + n; } return n; }); const Mountain = ({ index, hue: _hue }) => { const i = index / (LAYERS - 1); // Normalized to 0-1 const hue = _hue + i * HUE_VARIANCE; return /*#__PURE__*/( React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("defs", null, /*#__PURE__*/ React.createElement("linearGradient", { id: .........完整代码请登录后点击上方下载按钮下载查看
网友评论0