js+css实现炫酷黑洞粒子动画效果代码
代码语言:html
所属分类:粒子
代码描述:js+css实现炫酷黑洞粒子动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { width: 100vw; height: 100vh; background: #141414; } a-hole { position: absolute; top: 0; left: 0; margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; } a-hole:before { position: absolute; top: 50%; left: 50%; z-index: 2; display: block; width: 150%; height: 140%; background: radial-gradient(ellipse at 50% 55%, transparent 10%, black 50%); transform: translate3d(-50%, -50%, 0); content: ""; } a-hole:after { position: absolute; top: 50%; left: 50%; z-index: 5; display: block; width: 100%; height: 100%; background: radial-gradient(ellipse at 50% 75%, #a900ff 20%, transparent 75%); mix-blend-mode: overlay; transform: translate3d(-50%, -50%, 0); content: ""; } @-webkit-keyframes aura-glow { 0% { background-position: 0 100%; } 100% { background-position: 0 300%; } } @keyframes aura-glow { 0% { background-position: 0 100%; } 100% { background-position: 0 300%; } } a-hole .aura { position: absolute; top: -71.5%; left: 50%; z-index: 3; width: 30%; height: 140%; background: linear-gradient(20deg, #00f8f1, #ffbd1e20 16.5%, #fe848f 33%, #fe848f20 49.5%, #00f8f1 66%, #00f8f160 85.5%, #ffbd1e 100%) 0 100%/100% 200%; border-radius: 0 0 100% 100%; filter: blur(50px); mix-blend-mode: plus-lighter; opacity: 0.75; transform: translate3d(-50%, 0, 0); -webkit-animation: aura-glow 5s infinite linear; animation: aura-glow 5s infinite linear; } a-hole .overlay { position: absolute; top: 0; left: 0; z-index: 10; width: 100%; height: 100%; background: repeating-linear-gradient(transparent, transparent 1px, white 1px, white 2px); mix-blend-mode: overlay; opacity: 0.5; } a-hole canvas { display: block; width: 100%; height: 100%; } </style> </head> <body> <a-hole> <canvas class="js-canvas"></canvas> <div class="aura"></div> <div class="overlay"></div> </a-hole><!-- .a-hole --> <script type="module"> import easingUtils from "//repo.bfw.wiki/bfwrepo/js/module/easing-utils.mjs"; class AHole extends HTMLElement { /** * Init */ connectedCallback() { // Elements this.canvas = this.querySelector(".js-canvas"); this.ctx = this.canvas.getContext("2d"); this.discs = []; this.lines = []; // Init this.setSize(); this.setDiscs(); this.setLines(); this.setParticles(); this.bindEvents(); // RAF requestAnimationFrame(this.tick.bind(this)); } /** * Bind events */ bindEvents() { window.addEventListener("resize", this.onResize.bind(this)); } /** * Resize handler */ onResize() { this.setSize(); this.setDiscs(); this.setLines(); this.setParticles(); } /** * Set size */ setSize() { this.rect = this.getBoundingClientRect(); this.render = { width: this.rect.width, height: this.rect.height, dpi: window.devicePixelRatio }; this.canvas.width = this.render.width * this.render.dpi; this.canvas.h.........完整代码请登录后点击上方下载按钮下载查看
网友评论0