victor实现螺旋口动画效果

代码语言:html

所属分类:动画

代码描述:victor实现螺旋口动画效果

代码标签: 动画 效果

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

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

<style>
body {
  overflow: hidden;
}

canvas {
  width: 100vw;
  height: 100vh;
}
</style>

</head>
<body>
<canvas id="c"></canvas>

<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/victor.min.js"></script>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/chroma.min.js"></script>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/simplex-noise.min.js"></script>
<script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/tweakpane.min.js"></script>
<script i>
console.clear();

class Utils {
  static randomRange(min, max) {
    return Math.random() * (max - min) + min;
  }

  static mapRange(value, inputMin, inputMax, outputMin, outputMax, clamp) {
    if (Math.abs(inputMin - inputMax) < Number.EPSILON) {
      return outputMin;
    } else {
      var outVal = (value - inputMin) / (inputMax - inputMin) * (outputMax - outputMin) + outputMin;
      if (clamp) {
        if (outputMax < outputMin) {
          if (outVal < outputMax) outVal = outputMax;else
          if (outVal > outputMin) outVal = outputMin;
        } else {
          if (outVal > outputMax) outVal = outputMax;else
          if (outVal < outputMin) outVal = outputMin;
        }
      }
      return outVal;
    }
  }}


Utils.simplex = new SimplexNoise('seed');

class App {
  constructor() {
    this.config = {
      bgColor: chroma({ h: 230, s: 0.5, l: 0.1 }).hex() };


    this.canvas = document.getElementById('c');
    this.ctx = this.canvas.getContext('2d');

    this.shadowCanvas = document.createElement('canvas');
    this.shadowCtx = this.shadowCanvas.getContext('2d');

    this.angle = 0;
    this.timestamp = 0;
    this.fpsHistory = [];

    this.setUpVars();
    this.setUpListeners();
    this.setUpGui();
    this.update();
  }

  setUpGui() {
    const pane = new Tweakpane();
    const folder = pane.addFolder({
      expanded: false,
      title: 'Settings' });

    folder.addInput(this.config, 'bgColor');
  }

  setUpVars() {
    this.canvas.width = this.shadowCanvas.width = this.wWidth.........完整代码请登录后点击上方下载按钮下载查看

网友评论0