Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Changes to the "Values" will require a Click on the Canvas to be applied.
css
html, body{ overflow: hidden; background: #000; padding: 0px; margin: 0px; } #menu{ position: absolute; top: 0px; left: 0px; background: rgba(90,90,90,0.8); padding: 5px; border-radius: 0px 0px 10px 0px; color: #fff; max-width: 50%; }
JavaScript
var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); w = ctx.canvas.width = window.innerWidth; h = ctx.canvas.height = window.innerHeight; window.onresize = function() { w = ctx.canvas.width = window.innerWidth; h = ctx.canvas.height = window.innerHeight; }; canvas.onclick = function(){ props = [{}]; genWaves(); } // ctx.globalCompositeOperation = "lighter"; props = [{}]; hueRotate = 240; frames = 0; frequency = 0.01; count = 10; alpha = 0.5; outlineWidth = 8; maxAmp = 100; minAmp = 50; maxGap = 40; minGap = 20; maxSpeed = 1; minSpeed = 0.3; document.body.style.background = "hsl("+hueRotate+", 20%, 15%)"; var controls = new function() { this.hueRotate = hueRotate; this.count = count; this.alpha = alpha; this.outlineWidth = outlineWidth; this.maxAmp = maxAmp; this.minAmp = minAmp; this.maxGap = maxGap; this.minGap = minGap; this.maxSpeed = maxSpeed; this.minSpeed = minSpeed; this.frequency = frequency; this.redraw = function() { hueRotate = controls.hueRotate; count = controls.count; alpha = controls.alpha; outlineWidth = controls.outlineWidth; maxAmp = controls.maxAmp; minAmp = controls.minAmp; maxGap = controls.maxGap; minGap = controls.minGap; maxSpeed = controls.maxSpeed; minSpeed = controls.minSpeed; frequency = controls.frequency; document.body.style.background = "hsl("+hueRotate+", 20%, 15%)"; } } var gui = new dat.GUI({resizable : false}); //gui.add(controls, "count", 1, 10).step(1).onChange(controls.redraw); var f1 = gui.addFolder('Visual'); var f2 = gui.addFolder('Values'); f1.add(controls, "hueRotate", 0, 360).step(1).onChange(controls.redraw); f1.add(controls, "alpha", 0.1, 1).onChange(controls.redraw); f1.add(controls, "outlineWidth", 0, 20).onChange(controls.redraw); f2.add(controls, "maxAmp", 50, 300).step(1).onChange(controls.redraw); f2.add(controls, "minAmp", 10, 100).step(1).onChange(controls.redraw); f2.add(controls, "maxGap", 30, 80).step(1).onChange(controls.redraw); f2.add(controls, "minGap", 10, 30).step(1).onChange(controls.redraw); f2.add(controls, "maxSpeed", 0.5, 2).onChange(controls.redraw); f2.add(controls, "minSpeed", 0.1, 0.5).onChange(controls.redraw); f2.add(controls, "frequency", 0.001, 0.05).onChange(controls.redraw); f1.open(); f2.open(); function genWaves(){ for (i = 0; i < count; i++) { props.push({ rAmp: Math.round(Math.random() * (maxAmp - minAmp) + minAmp), rAmp1: Math.random() * (2 - 1) + 1, rAmp2: Math.random() * (2 - 1) + 1, rTop: Math.round(Math.random() * (maxGap - minGap) + minGap), rFreq: frequency, rSpeed: Math.random() * (-maxSpeed + minSpeed) - minSpeed, rPhi: 0, rFrames: 0, rColOff: Math.round(Math.random() * 80 - 40) }); } } function drawWave() { ctx.filter = "hue-rotate(" + hueRotate + "deg)"; for (j = 0; j < count; j++) { ctx.beginPath(); ctx.moveTo(0, h); ctx.lineWidth = outlineWidth; ctx.strokeStyle = "#fff"; ctx.fillStyle = "hsla(" + props[j].rColOff + ", " + ((j*2)+40) + "%, "+((j*2)+40)+"%, "+alpha+")"; for (var x = 0; x < w; x++) { y = Math.cos(x * props[j].rFreq + props[j].rPhi) * props[j].rAmp / props[j].rAmp1 + props[j].rAmp / props[j].rAmp2; ctx.lineTo(x, y + props[j].rTop * j); } ctx.lineTo(w, h); ctx.stroke(); ctx.fill(); ctx.closePath(); } } function drawFrame() { ctx.clearRect(0, 0, w, h); for (i = 0; i < count; i++) { props[i].rFrames += props[i].rSpeed; props[i].rPhi = props[i].rFrames / 30; } drawWave(); requestId = requestAnimationFrame(drawFrame); } genWaves(); drawFrame();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>彩色波浪-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号