绿叶清舟 发表于 2023-3-9 20:15

横空出世


<style>
#papa { left: -250px; width: 1100px; height: 700px; display: grid; place-items: center; background: #000 url('https://pic.imgdb.cn/item/6409cc8cf144a01007e20707.jpg') no-repeat center/cover; box-shadow: 3px 3px 30px #000; position: relative; }
#canv { position: relative; top: 220px; left: -30px; opacity: .65; mix-blend-mode: screen;}
#disc { position: absolute; width: 40px; height: 40px; left: 10px; top: 610px; background: conic-gradient(red,orange,yellow,green,teal,blue,purple); mask: radial-gradient(transparent 4px,red 0); -webkit-mask: radial-gradient(transparent 4px,red 0); border-radius: 50%; cursor: pointer; z-index: 10; animation: rot 2s linear infinite; }
#lrcbox { position: absolute; left: 60px; top: 10px;font: bold 22px / 40px sans-serif; color: lightblue; text-shadow: 2px 2px 4px #222; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
</head>
<body>

<div id="papa">
      <span id="disc"></span>
      
      <canvas id="canv" width="600" height="320"></canvas>
</div>

<script>
let ctx = canv.getContext('2d');
let w = canv.width,
      h = canv.height,
      tick = 0,
      particles = [];
let opts = {
      baseBaseSize: 15,
      addedBaseSize: 5,
      baseVel: 2,
      addedVel: 1,
      baseTime: 60,
      addedTime: 20,
      overTime: 5,
      sliding: .99,
      particleChance: .9,
      particles: 100,
      templateParticleColor: 'hsla(hue,80%,50%,alp)',
      repaintAlpha: 'rgba(0,0,0,.1)',
      startColor: .2,
      fullColor: .5,
      stopColor: .6,
      timeToColorChange: 3
};
let aud = new Audio();
aud.src = 'https://music.163.com/song/media/outer/url?id=2022139876.mp3';
aud.loop = true;
aud.autoplay = true;
disc.style.animationPlayState = aud.paused ? 'paused' : 'running';
disc.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('playing', () => disc.style.animationPlayState = 'running');
aud.addEventListener('pause', () => disc.style.animationPlayState = 'paused');

function Particle() {
      this.reset();
}
Particle.prototype.reset = function() {
      this.x = Math.pow(Math.random(), 1 / 4);
      this.y = h / 2;
      var color = opts.templateParticleColor.replace('hue', this.x * 360 * 2 + tick * opts.timeToColorChange);
      this.baseSize = (Math.random() + this.x) / 2 * (opts.baseBaseSize + opts.addedBaseSize * Math.random());
      this.gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, this.baseSize / 2);
      this.gradient.addColorStop(opts.startColor, color.replace('alp', 0));
      this.gradient.addColorStop(opts.fullColor, color.replace('alp', 1));
      this.gradient.addColorStop(opts.stopColor, color.replace('alp', 1));
      this.gradient.addColorStop(1, color.replace('alp', 0));
      this.vx = -(1 + Math.random() / 10 - this.x) * (opts.baseVel + Math.random() * opts.addedVel);
      this.vy = Math.pow(this.x, 4) * (opts.baseVel + Math.random() * opts.addedVel) * (Math.random() < .5 ? -1 : 1);
      this.x *= w / 2;
      if (Math.random() < .5) {
                this.x = w - this.x;
                this.vx *= -1;
      }
      this.time = opts.baseTime + opts.addedTime * Math.random();
      this.tick = this.time + opts.overTime;
};
Particle.prototype.step = function() {
      var size;
      if (this.tick <= this.time) {
                this.x += this.vx *= opts.sliding;
                this.y += this.vy *= opts.sliding;
                size = Math.pow(this.tick / this.time, 1 / 2)
      } else size = 1 - ((this.tick - this.time) / opts.overTime) + .000001;
      --this.tick;
      ctx.translate(this.x, this.y);
      ctx.scale(size, size);
      ctx.fillStyle = this.gradient;
      ctx.fillRect(-this.baseSize / 2, -this.baseSize / 2, this.baseSize, this.baseSize);
      ctx.scale(1 / size, 1 / size);
      ctx.translate(-this.x, -this.y);
      if (this.tick <= 0) this.reset();
};
(function anim() {
      window.requestAnimationFrame(anim);
      ctx.globalCompositeOperation = 'source-over';
      ctx.fillStyle = opts.repaintAlpha;
      ctx.fillRect(0, 0, w, h);
      ctx.globalCompositeOperation = 'lighter';
      ++tick;
      if (particles.length < opts.particles && Math.random() < opts.particleChance) particles.push(new Particle);
      particles.map(function(particle) {
                particle.step();
      });
})();
</script>

马黑黑 发表于 2023-3-9 20:26

蹦出来的?

梦油 发表于 2023-3-9 20:31

清舟朋友的礼花好漂亮哎!

绿叶清舟 发表于 2023-3-9 20:36

梦油 发表于 2023-3-9 20:31
清舟朋友的礼花好漂亮哎!

那是悟空带出来的{:4_173:}

绿叶清舟 发表于 2023-3-9 20:36

马黑黑 发表于 2023-3-9 20:26
蹦出来的?

肯定不是生出来的

梦油 发表于 2023-3-9 20:54

绿叶清舟 发表于 2023-3-9 20:36
那是悟空带出来的

好嘛,悟空还会放花呐。

绿叶清舟 发表于 2023-3-9 21:02

梦油 发表于 2023-3-9 20:54
好嘛,悟空还会放花呐。

是啊,现在流行的了{:4_173:}

梦油 发表于 2023-3-9 21:12

绿叶清舟 发表于 2023-3-9 21:02
是啊,现在流行的了

俺太闭塞啦。{:4_189:}

绿叶清舟 发表于 2023-3-9 21:14

梦油 发表于 2023-3-9 21:12
俺太闭塞啦。

都怪悟空没告诉你了{:4_173:}

马黑黑 发表于 2023-3-9 21:22

绿叶清舟 发表于 2023-3-9 20:36
肯定不是生出来的

基因鉴定不好做

小辣椒 发表于 2023-3-9 21:55

清舟这个特效好棒,以前冬天做过的{:4_178:}

小辣椒 发表于 2023-3-9 21:58

清舟图片直接加代码出来了,冬雨是做H5播放器背景里面的

小辣椒 发表于 2023-3-9 21:58

清舟图片直接加代码出来了,冬雨是做H5播放器背景里面的

红影 发表于 2023-3-9 22:30

小辣椒 发表于 2023-3-9 21:58
清舟图片直接加代码出来了,冬雨是做H5播放器背景里面的

这个效果应该是挺早以前的吧,清舟去前面的帖子里寻宝,让这些漂亮的效果又出现了呢。
而且这个制图好棒,文字正好在效果上,效果正好和文字内容相符,这么多的正好,都是精心构思的结果{:4_199:}

小辣椒 发表于 2023-3-9 22:33

红影 发表于 2023-3-9 22:30
这个效果应该是挺早以前的吧,清舟去前面的帖子里寻宝,让这些漂亮的效果又出现了呢。
而且这个制图好棒 ...

是的,这些特效网络很多的,要花时间做的

庶民 发表于 2023-3-10 05:32

很大气的。

樵歌 发表于 2023-3-10 10:34

建议:文化部研究下一部西游记重拍时应用此创作!***圈阅//20230310

梦油 发表于 2023-3-10 11:16

绿叶清舟 发表于 2023-3-9 21:14
都怪悟空没告诉你了

有你来告诉俺一声就可以了

绿叶清舟 发表于 2023-3-10 18:43

马黑黑 发表于 2023-3-9 21:22
基因鉴定不好做

这个现在不难啊

绿叶清舟 发表于 2023-3-10 18:44

小辣椒 发表于 2023-3-9 21:55
清舟这个特效好棒,以前冬天做过的

谢谢辣椒,冬雨做过啊
页: [1] 2 3
查看完整版本: 横空出世