canvas彩色气泡漂浮动画效果代码

代码语言:html

所属分类:动画

代码描述:canvas彩色气泡漂浮动画效果代码

代码标签: canvas 彩色 气泡 漂浮 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
<style>
*,
::before,
::after{
  margin:0;
  padding:0;
  box-sizing:border-box;
}

body{
  overflow:hidden;
}

canvas{
  background-color:#121212;
}
</style>

  
  
</head>

<body >
  <canvas id="myCanvas"></canvas>

      <script  >
let canvas = document.getElementById("myCanvas");

let width = window.innerWidth;
let height = window.innerHeight;

canvas.width = width;
canvas.height = height;

let c = canvas.getContext('2d');

let colors = ["#A020F0", "#5CACEE", "#0FDDAF", "#00688B"];

function Circle(x, y, r, color) {
  this.x = x;
  this.y = y;
  this.radius = r;
  this.startX = x - 15;
  this.endX = x + 15;
  this.startY = y - 15;
  this.endY = y + 15;
  this.dx = Math.random() - 0.5;
  this.dy = Math.random() - 0.5;

  this.draw = function () {
    c.beginPath();
    c.arc(this.x,.........完整代码请登录后点击上方下载按钮下载查看

网友评论0