js实现canvas波纹波动动画背景效果
代码语言:html
所属分类:背景
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> html, body { height: 100%; } body { background: radial-gradient(circle cover, #cfe6fc, #6eb3f7); overflow: hidden; } canvas { display: block; } </style> </head> <body translate="no"> <canvas></canvas> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/simplex-noise.min.js"></script> <script> const $ = {}; /*======================================== Utility ========================================*/ $.PI = Math.PI; $.TAU = $.PI * 2; $.rand = function (min, max) { if (!max) { var max = min; min = 0; } return Math.random() * (max - min) + min; }; /*======================================== Initialize ========================================*/ $.init = () => { $.c = document.querySelector('canvas'); $.ctx = $.c.getContext('2d'); $.simplex = new SimplexNoise(); $.events(); $.reset(); $.loop(); }; /*======================================== Reset ========================================*/ $.reset = () => { $.dpr = window.devicePixelRatio; $.w = window.innerWidth; $.h = window.innerHeight; $.cx = $.w / 2; $.cy = $.h / 2; $.c.width = $.w * $.dpr; $.c.height = $.h * $.dpr; $.c.style.width = `${$.w}px`; $.c.styl.........完整代码请登录后点击上方下载按钮下载查看
网友评论0