html--瀑布效果


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>瀑布效果</title>

<style>
body {
  background: #222;
  color: white;
  overflow:hidden;
}

#container {
  box-shadow: inset 0 1px 0 #444, 0 -1px 0 #000;
  height: 100vh;
  width: 100vw;
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  will-change: transform;
  -webkit-transform: translateZ(0);
          transform: translateZ(0);
}

canvas#waterfall {
  display: block;
  margin: 0 auto;
  width: 30%;
  height: 55%;
  will-change: transform;
  -webkit-transform: translateZ(0);
          transform: translateZ(0);
}

.emma {
  height: 100vh;
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
}

h1 {
  color: #0af;
  font-size: 30vw;
}

canvas#surface {
  -webkit-animation: fade-in 3000ms forwards;
          animation: fade-in 3000ms forwards;
  display: block;
  left: 0;
  position: absolute;
  top: 0;
  z-index: -1;
}

@-webkit-keyframes fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
</style>

</head>
<body>

<div id="container">

	<canvas id="waterfall"></canvas>
	
    <div class="emma flex">
        <div> </div>
    </div>
	
</div>

<script type="text/javascript" src="js/pixi.min.js"></script>
<script type="text/javascript" src="js/tinycolor.min.js"></script>

<script type="text/javascript">
+!~-(function(PIXI, window, document, undefined) {
  var waterfallCanvas = function(c, cw, ch) {
    var _this = this;
    this.c = c;
    this.ctx = c.getContext('2d');
    this.cw = cw;
    this.ch = ch;
    this.particles = [];
    this.particleRate = 6;
    this.gravity = 0.15;
    this.init = function() {
      this.loop();
    };
    this.reset = function() {
      this.ctx.clearRect(0, 0, this.cw, this.ch);
      this.particles = [];
    };
    this.rand = function(rMi, rMa) {
      return ~~((Math.random() * (rMa - rMi + 1)) + rMi);
    };
    this.Particle = function() {
      var newWidth = _this.rand(1, 20);
      var newHeight = _this.rand(1, 45);
      this.x = _this.rand(10 + (newWidth / 2), _this.cw - 10 - (newWidth / 2));
      this.y = -newHeight;
      this.vx = 0;
      this.vy = 0;
      this.width = newWidth;
      this.height = newHeight;
      this.hue = _this.rand(200, 220);
      this.saturation = _this.rand(30, 60);
      this.lightness = _this.rand(30, 60);
    };
    this.Particle.prototype.update = function(i) {
      this.vx += this.vx;
      this.vy += _this.gravity;
      this.x += this.vx;
      this.y += this.vy;
    };
    this.Particle.prototype.render = function() {
      _this.ctx.strokeStyle = 'hsla(' + this.hue + ', ' + this.saturation + '%, ' + this.lightness + '%, .05)';
      _this.ctx.beginPath();
      _this.ctx.moveTo(this.x, this.y);
      _this.ctx.lineTo(this.x, this.y + this.height);
      _this.ctx.lineWidth = this.width / 2;
      _this.ctx.lineCap = 'round';
      _this.ctx.stroke();
    };
    this.Particle.prototype.renderBubble = function() {
      _this.ctx.fillStyle = 'hsla(' + this.hue + ', 40%, 40%, 1)';
      _this.ctx.fillStyle = 'hsla(' + this.hue + ', ' + this.saturation + '%, ' + this.lightness + '%, .3)';
      _this.ctx.beginPath();
      _this.ctx.arc(this.x + this.width / 2, _this.ch - 20 - _this.rand(0, 10), _this.rand(1, 8), 0, Math.PI * 2, false);
      _this.ctx.fill();
    };
    this.createParticles = function() {
      var i = this.particleRate;
      while (i--) {
        this.particles.push(new this.Particle());
      }
    };
    this.removeParticles = function() {
      var i = this.particleRate;
      while (i--) {
        var p = this.particles[i];
        if (p.y > _this.ch - 20 - p.height) {
          p.renderBubble();
          _this.particles.splice(i, 1);
        }
      }
    };
    this.updateParticles = function() {
      var i = this.particles.length;
      while (i--) {
        var p = this.particles[i];
        p.update(i);
      }
    };
    this.renderParticles = function() {
      var i = this.particles.length;
      while (i--) {
        var p = this.particles[i];
        p.render();
      }
    };
    this.clearCanvas = function() {
      this.ctx.globalCompositeOperation = 'destination-out';
      this.ctx.fillStyle = 'rgba(255,255,255,.06)';
      this.ctx.fillRect(0, 0, this.cw, this.ch);
      this.ctx.globalCompositeOperation = 'lighter';
    };
    this.loop = function() {
      var loopIt = function() {
        requestAnimationFrame(loopIt, _this.c);
        _this.clearCanvas();
        _this.createParticles();
        _this.updateParticles();
        _this.renderParticles();
        _this.removeParticles();
      };
      loopIt();
    };
  };
  var isCanvasSupported = function() {
    var elem = document.createElement('canvas');
    return !!(elem.getContext && elem.getContext('2d'));
  };
  var setupRAF = function() {
    var lastTime = 0;
    var vendors = ['ms', 'moz', 'webkit', 'o'];
    for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
      window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
      window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
    }
    if (!window.requestAnimationFrame) {
      window.requestAnimationFrame = function(callback, element) {
        var currTime = new Date().getTime();
        var timeToCall = Math.max(0, 16 - (currTime - lastTime));
        var id = window.setTimeout(function() {
          callback(currTime + timeToCall);
        }, timeToCall);
        lastTime = currTime + timeToCall;
        return id;
      };
    }
    if (!window.cancelAnimationFrame) {
      window.cancelAnimationFrame = function(id) {
        clearTimeout(id);
      };
    }
  };
  if (isCanvasSupported()) {
    var c = document.getElementById('waterfall');
    var cw = c.width = Math.max(document.getElementById('waterfall').scrollWidth, document.getElementById('waterfall').offsetWidth, document.getElementById('waterfall').clientWidth, document.getElementById('waterfall').scrollWidth, document.getElementById('waterfall').offsetWidth);
    var ch = c.height = Math.max(document.getElementById('waterfall').scrollHeight, document.getElementById('waterfall').offsetHeight, document.getElementById('waterfall').clientHeight, document.getElementById('waterfall').scrollHeight, document.getElementById('waterfall').offsetHeight);
    var waterfall = new waterfallCanvas(c, cw, ch);
    setupRAF();
    waterfall.init();
  } /* Second plugin */
  var w, h, renderer, stage, waveGraphics, partGraphics, waveTexture, partTexture, waveCount, partCount, waves, parts;

  function init() {
    renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight / 2, {
      backgroundColor: '0x' + tinycolor('hsl(200, 50%, 10%)').toHex()
    });
    stage = new PIXI.Container();
    waveCount = 2000;
    partCount = 1000;
    waves = [];
    parts = [];
    document.body.appendChild(renderer.view);
    reset();
    for (var i = 0; i < 300; i++) {
      step();
    }
    loop();
  }

  function reset() {
    w = window.innerWidth;
    h = window.innerHeight;
    renderer.resize(w, h);
    waveGraphics = null;
    waveTexture = null;
    partGraphics = null;
    partTexture = null;
    waveGraphics = new PIXI.Graphics();
    waveGraphics.cacheAsBitmap = true;
    waveGraphics.beginFill('0x' + tinycolor('hsl(200, 74%, 40%)').toHex(), 0.15);
    waveGraphics.drawCircle(0, 0, 20);
    waveGraphics.endFill();
    waveTexture = waveGraphics.generateTexture();
    partGraphics = new PIXI.Graphics();
    partGraphics.cacheAsBitmap = true;
    partGraphics.beginFill('0x' + tinycolor('hsl(200, 70%, 40%)').toHex(), 0.2);
    partGraphics.drawCircle(0, 0, 15);
    partGraphics.endFill();
    partTexture = partGraphics.generateTexture();
  }

  function step() {
    if (waves.length < waveCount) {
      for (var i = 0; i < 10; i++) {
        var wave = new PIXI.Sprite(waveTexture),
          scale = 0.2 + Math.random() * 0.8;
        wave.position.x = w / 2;
        wave.position.y = h / 2;
        wave.anchor.x = 0.5;
        wave.anchor.y = 0.5;
        wave.scale.x = scale * 10;
        wave.scale.y = scale * 0.5;
        wave.blendMode = PIXI.BLEND_MODES.SCREEN;
        waves.push({
          sprite: wave,
          x: wave.position.x,
          y: wave.position.y,
          vx: 0,
          vy: 0,
          angle: Math.PI / 2 + Math.random() * Math.PI + Math.PI * 1.5,
          speed: 0.01 + Math.random() / 10
        });
        stage.addChild(wave);
      }
    }
    for (var i = 0, length = waves.length; i < length; i++) {
      var wave = waves[i];
      wave.sprite.position.x = wave.x;
      wave.sprite.position.y = wave.y;
      wave.vx = Math.cos(wave.angle) * wave.speed;
      wave.vy = Math.sin(wave.angle) * wave.speed;
      wave.x += wave.vx;
      wave.y += wave.vy;
      wave.speed *= 1.01;
      if (wave.x > w + 200 || wave.x < -200 || wave.y > h + 200) {
        wave.x = w / 2;
        wave.y = h / 2;
        wave.speed = 0.01 + Math.random() / 10;
      }
    }
    if (parts.length < partCount) {
      var part = new PIXI.Sprite(partTexture),
        scale = 0.2 + Math.random() * 0.8,
        type = Math.random() > 0.5 ? 1 : 0;
      part.position.x = w / 2 + Math.random() * 380 - 190;
      part.position.y = h / 2 + 0;
      part.anchor.x = 0.5;
      part.anchor.y = 0.5;
      part.scale.x = type ? scale : scale * 0.5;
      part.scale.y = type ? scale : scale * 15;
      part.blendMode = PIXI.BLEND_MODES.SCREEN;
      parts.push({
        sprite: part,
        ox: part.position.x,
        oy: part.position.y,
        x: part.position.x,
        y: part.position.y,
        vx: 0,
        vy: 0,
        angle: (-Math.PI * 0.5) + (w / 2 - part.position.x) / 750,
        speed: 0.0001 + Math.random() / 50
      });
      stage.addChild(part);
    }
    for (var i = 0, length = parts.length; i < length; i++) {
      var part = parts[i];
      part.sprite.position.x = part.x;
      part.sprite.position.y = part.y;
      part.vx = Math.cos(part.angle) * part.speed;
      part.vy = Math.sin(part.angle) * part.speed;
      part.x += part.vx;
      part.y += part.vy;
      part.speed *= 1.01;
      if (part.x > w + 50 || part.x < -50 || part.y < -50) {
        part.x = part.ox;
        part.y = part.oy;
        part.speed = 0.01 + Math.random() / 50;
      }
    }
    renderer.render(stage);
  }

  function loop() {
    step();
    requestAnimationFrame(loop);
  }
  window.addEventListener('resize', reset);
  init();
})(PIXI, this, document);
</script>

</body>
</html>

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/607022.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【Qt 学习笔记】Qt常用控件 | 输入类控件 | Slider的使用及说明

博客主页&#xff1a;Duck Bro 博客主页系列专栏&#xff1a;Qt 专栏关注博主&#xff0c;后期持续更新系列文章如果有错误感谢请大家批评指出&#xff0c;及时修改感谢大家点赞&#x1f44d;收藏⭐评论✍ Qt常用控件 | 输入类控件 | Slider的使用及说明 文章编号&#xff1a;…

已经有 Prometheus 了,还需要夜莺?

谈起当下监控&#xff0c;Prometheus 无疑是最火的项目&#xff0c;如果只是监控机器、网络设备&#xff0c;Zabbix 尚可一战&#xff0c;如果既要监控设备又要监控应用程序、Kubernetes 等基础设施&#xff0c;Prometheus 就是最佳选择。甚至有些开源项目&#xff0c;已经内置…

QGraphicsView实现简易地图12『平移与偏移』

前文链接&#xff1a;QGraphicsView实现简易地图11『指定层级-定位坐标』 提供地图平移与偏移功能。地图平移是指将地图的中心点更改为给定的点&#xff0c;即移动地图到指定位置。地图偏移是指将当前视口内的地图向上/下/左/右/进行微调&#xff0c;这里偏移视口宽/高的四分之…

压缩机继电器EOCRDS-30NY7Q升级后型号:EOCRDS3-30S

EOCR-DS3系列型号&#xff1a; EOCRDS3-05S EOCRDS-05S EOCRDS1-05S EOCRDS3-30S EOCRDS-30S EOCRDS1-30S EOCRDS3-60S EOCRDS-60S EOCRDS1-60S EOCRDS3-05W EOCRDS-05W EOCRDS1-05W EOCRDS3-30W EOCRDS-30W EOCRDS1-30W EOCRDS3-60W EOCRDS-60W EOCRDS1-60W EOCR-DS3T-…

extern关键字的使用。keil中编译时,出现error:identifier xxx is undefined

问题 编译时&#xff0c;出现error&#xff1a; identifier “Reg_Flag” is undefined extern Reg_Flag reg_flag; 很奇怪&#xff0c;我明明已经定义了。无非就是定义是在extern的下面&#xff0c;会不会是这个原因&#xff1f; 解决 果然&#xff0c;把extern的部分放到…

3D模型如何实现拖拽打开?---模大狮模型网

在当今数字化时代&#xff0c;3D技术的应用已经深入到各行各业&#xff0c;为用户带来了更加丰富、生动的体验。然而&#xff0c;对于一些用户来说&#xff0c;打开和查看3D模型可能会面临一些困难&#xff0c;特别是在无法拖拽打开时。本文将为您揭示解决这一问题的方法&#…

智能商品计划系统:引领未来零售业的革新之路

随着科技的飞速发展&#xff0c;人工智能&#xff08;AI&#xff09;和大数据技术已成为推动各行业革新的关键动力。在零售行业中&#xff0c;智能商品计划系统的出现&#xff0c;正逐步改变着传统的商品规划与管理方式&#xff0c;为品牌注入新的活力与竞争力。本文将对智能商…

TMS320F280049 CLB模块--总览(0)

CLB模块是可配置的逻辑块&#xff0c;和FPGA的CLB有些不同。 下图是CLB模块在系统中的交互&#xff0c;图中CLB XBAR和TILE是CLB。从049中有4个CLB&#xff0c;也就是TILE1-4。 下图是CPU和CLB交互的示意图。 下图是CLB的时钟。 参考文档&#xff1a; TMS320F28004x Real-Tim…

欢乐钓鱼大师内置辅助,游戏脚本!自动操作!

在《欢乐钓鱼大师》游戏中&#xff0c;探索珍稀鱼类成为钓鱼大师的过程充满了乐趣和挑战。下面是一些特殊鱼类的钓鱼技巧和详细攻略&#xff0c;助你在游戏中获得更好的成绩和丰厚的奖励。 一、碘化之齿 碘化之齿是游戏中一种珍稀的鱼类&#xff0c;它的出现需要一定的条件和技…

STC8增强型单片机开发 【GPIO的理解⭐⭐】

目录 一、引言 二、GPIO概述 三、GPIO的功能 1. 输入功能&#xff1a; 2. 输出功能 四、GPIO的配置方法 1. 选择GPIO端口和引脚&#xff1a; 2. 设置GPIO模式&#xff1a; 3. 配置GPIO参数&#xff1a; 五、GPIO应用实例 1. 硬件连接&#xff1a; 2. 编程实现&…

探索精酿啤酒:从经典到创新

Fendi club啤酒一直以来都以其卓着的品质和与众不同的口感深受消费者喜爱。而随着时代的变迁和消费者口味的不断变化&#xff0c;Fendi club啤酒也在不断地探索和创新&#xff0c;以满足市场的多样化需求。 在经典的口感和风味基础上&#xff0c;Fendi club啤酒不断地尝试新的原…

sql Server2015安装——参考的教程

1.sql Server安装包来自&#xff1a;https://mp.weixin.qq.com/s/Pe_YbWw_MgwjzzZhQWIYfA 2.需要的替换文件和补丁&#xff1a;https://blog.csdn.net/Auspicious_air/article/details/108315154 https://blog.csdn.net/m0_60477996/article/details/126748477 3.安装manger…

MybatisPlus 构造器wrapper的使用与原理

系列文章目录 MyBatis缓存原理 Mybatis plugin 的使用及原理 MyBatisSpringboot 启动到SQL执行全流程 数据库操作不再困难&#xff0c;MyBatis动态Sql标签解析 Mybatis的CachingExecutor与二级缓存 使用MybatisPlus还是MyBaits &#xff0c;开发者应该如何选择&#xff1f; My…

极简—springMVC工作流程

1、流程图 2、流程 发起请求&#xff1a;客户端通过 HTTP 协议向服务器发起请求。前端控制器&#xff1a;这个请求会先到前端控制器 DispatcherServlet&#xff0c;它是整个流程的入口点&#xff0c;负责接收请求并将其分发给相应的处理器。处理器映射&#xff1a;DispatcherS…

SDN和SD-WAN的对比

在数字化浪潮的推动下&#xff0c;SDN&#xff08;软件定义网络&#xff09;和SD-WAN&#xff08;软件定义广域网&#xff09;作为企业网络技术的两大支柱&#xff0c;正逐步引领网络架构的革新。尽管两者在理念和基础上有所共通&#xff0c;但在实际应用、功能特性和部署策略上…

视频号小店不直播怎么出单?这里面的秘密,一篇文章全曝光!

大家好&#xff0c;我是电商糖果 这两年关于视频号搞电商的话题度非常高&#xff0c;也吸引了很多商家入驻。 视频号因为背后巨大的私域流量池扶持&#xff0c;所以它的转化率非常高。 根据官方发出来的战报&#xff0c;我们也可以看出它的数据是翻倍增长。 在2024微信公开…

52. 【Android教程】网页视图:WebView

在前面的章节我们所围绕的全部都是纯客户端开发&#xff0c;我们叫 Native 开发。这样的好处就是体验和性能会非常好&#xff0c;但是在实际的使用中我们会发现存在大量的 H5 页面。这样就可以结合 Native / H5 双端的优势完成一个混合开发&#xff0c;而在这种开发模式中首当其…

Photoshop 2022 for Mac/win:释放创意,打造专业级的图像编辑体验

在数字图像编辑的世界里&#xff0c;Adobe Photoshop 2022无疑是那颗璀璨的明星。这款专为Mac和Windows用户设计的图像处理软件&#xff0c;以其卓越的性能和丰富的功能&#xff0c;赢得了全球数百万创作者的青睐。 Photoshop 2022在继承前代版本强大功能的基础上&#xff0c;…

QGraphicsView实现简易地图11『指定层级-定位坐标』

前文链接&#xff1a;QGraphicsView实现简易地图10『自适应窗口大小』 提供一个地图初始化函数&#xff0c;指定地图显示的中心点和地图缩放层级 能够让地图显示某一层级的瓦片&#xff0c;并将中心点坐标显示在视图中心。 1、动态演示效果 7级地图-大连-老虎滩 定位到 8级地图…

ChatGLM3大模型本地化部署、应用开发与微调

文章目录 写在前面ChatGLM3推荐图书作者简介推荐理由粉丝福利写在后面 写在前面 本期博主给大家推荐一本初学者学习并部署大模型的入门书籍&#xff0c;一起来看看吧&#xff01; ChatGLM3 ChatGLM3是继一系列先进语言模型之后的又一力作&#xff0c;专为追求高精度和广泛适…
最新文章