gsap实现流星 滑过帆布磨砂动画透明效果代码
代码语言:html
所属分类:动画
代码描述:gsap实现流星 滑过帆布磨砂动画透明效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> *, *:after, *:before { box-sizing: border-box; } body { display: grid; place-items: center; min-height: 100vh; font-family: "SF Pro Text", "SF Pro Icons", "AOS Icons", "Helvetica Neue", Helvetica, Arial, sans-serif, system-ui; background: linear-gradient(50deg, hsl(0 0% 50% / 0.25), transparent), hsl(0 0% 0%); overflow: hidden; } .meteor { aspect-ratio: 1; width: 200px; filter: drop-shadow(0 0 25px orange); background: radial-gradient(hsl(30 80% 50% / 0.05), transparent 50%); /* outline: 2px dashed hsl(0 0% 50% / 0.15);*/ position: absolute; left: 50%; bottom: 100%; translate: -50% -50%; -webkit-animation: scale var(--speed) calc(var(--speed) * -0.5) infinite linear ; animation: scale var(--speed) calc(var(--speed) * -0.5) infinite linear ; } @-webkit-keyframes scale { to { transform: translateY(calc(100cqh + 200%)); } } @keyframes scale { to { transform: translateY(calc(100cqh + 200%)); } } .line { --speed: 6s; width: 2px; position: relative; height: 150vmax; background: hsl(0 0% 40% / 0.15); rotate: 50deg; position: fixed; top: 10%; left: 50%; translate: 0 -50%; container-type: size; } .line:nth-of-type(2) { --speed: 10s; top: 40%; } .line:nth-of-type(3) { --speed: 8s; top: 90%; } .line:nth-of-type(4) { --speed: 12s; top: 60%; } article { width: 40vmin; aspect-ratio: 4 / 3; background: hsl(0 0% 25% / 0.25); border: 1px solid hsl(0 0% 40%); border-radius: 12px; z-index: 2; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); } </style> </head> <body translate="no"> <div class="line"> <canvas class="meteor"></canvas> </div> <div class="line"> <canvas class="meteor"></canvas> </div> <div class="line"> <canvas class="meteor"></canvas> </div> <div class="line"> <canvas class="meteor"></canvas> </div> <article></article> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.10.4.js"></script> <script type="module"> class Meteor { constructor(options) { const that = this this.canvas = options.element this.options = options this.context = this.canvas.getContext('2d') this.canvas.height = this.canvas.offsetHeight * window.devicePixelRatio this.canvas.width = this.canvas.offsetWidth * window.devicePixelRatio // Create a reusable gradient that.gradient = that.context.createLinearGradient(that.canvas.width * 0.5, that.canvas.height * 0.5, that.canvas.width * 0.5, 0) that.gradient.addColorStop(0, 'hsl(30, 100%, 100%)') that.gradient.addColorStop(0.025, 'hsl(30, 100%, 70%)') that.gradient.addColorStop(0.15, 'hsl(30, 100%, 40%)') that.gradient.addColorStop(0.55, 'hsl(30, 100%, 20%)') that.gradient.addColorStop(1, 'transparent') that.sparkGradient = that.context.createLinearGradient.........完整代码请登录后点击上方下载按钮下载查看
网友评论0