canvas实现彩色圆点气球泡泡飘起来上升浮动粒子动画效果代码
代码语言:html
所属分类:粒子
代码描述:canvas实现彩色圆点气球泡泡飘起来上升浮动粒子动画效果代码
代码标签: canvas 彩色 圆点 气球 泡泡 飘起来 上升 浮动 粒子 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; background-color: #000000; } canvas { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style> </head> <body> <canvas id="bubbleCanvas"></canvas> <script> const canvas = document.getElementById('bubbleCanvas'); const ctx = canvas.getContext('2d'); // Resize the canvas to full screen function resizeCanvas() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; } window.addEventListener('resize', resizeCanvas); resizeCanvas(); const bubbles = []; function randomNeonColor() { const colors = ['#1c9cbd', '#8abe56','#f7ce46','#4256a1','#3c57a6','#da3832','#ec248f','#bd6700','#a29e5e','#ebf2dd','#ffffff','#cd760c','#efeed4','#e3e1bf','#69ccff']; return colors[Math.floor(Math.random() * colors.length)]; } function createBubble() { const bubble = { x: Math.random(.........完整代码请登录后点击上方下载按钮下载查看
网友评论0