点击摇摆摇晃效果

代码语言:html

所属分类:动画

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

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
html,
body {
	width: 100%;
	height: 100%;
	overflow: hidden;
}

body {
	margin: 0;
	padding: 0;
	color: #fff;
	background-color: #000;
}

canvas {
	-webkit-tap-highlight-color: transparent;
	tap-highlight-color: transparent;
	-webkit-user-select: none;
	user-select: none;
	cursor: pointer;
}
</style>

</head>
<body translate="no">
<canvas></canvas>

<script >
// Wobble by @neave

window.requestAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) {
  setTimeout(callback, 1000 / 60);
};

Array.prototype.shuffle = function () {
  var j, temp;
  for (var i = this.length - 1; i > 0; i--) {
    j = Math.floor(Math.random() * (i + 1));
    temp = this[i];
    this[i] = this[j];
    this[j] = temp;
  }
  return this;
};

Math.clamp = function (n, min, max) {
  return Math.max(min, Math.min(n, max));
};

var get = document.querySelector.bind(document),
on = document.addEventListener.bind(document),
mouseOff = -1000,
mouseX,
mouseY,
viscosity = 25,
damping = 0.1,
totalPoints,
dist,
scale,
canvas,
context,
surfaces,
palleteNum = 0,
palleteFirst = ['0cf', '0fc', 'ff0', 'f0c', 'c0f'],
palletes = [
['000', 'ff0', 'f0f', '0ff', 'fff'],
['000', 'fff', '000', '.........完整代码请登录后点击上方下载按钮下载查看

网友评论0