飞机步道(plane trails)

  • 示例
  • HTML
  • CSS
  • JS

更多有趣示例 尽在 小红砖社区

示例

HTML

<svg id="patternSVG" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="sqrs" width="20" height="20" patternUnits="userSpaceOnUse" id="pulseBg" viewBox="0 0 20 20" ><rect class="gridRect" x="0" y="0" width="20" height="20"  fill="none"/>       </pattern></defs><rect id="grid"  class="grid" y="-100" fill="url(#sqrs)" width="100%" height="200%" stroke="none"/></svg><svg id="mainSVG" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600"><defs><filter id="glow" x="-100%" y="-100%" width="250%" height="250%"><feGaussianBlur stdDeviation="8" result="coloredBlur" /><feOffset dx="0" dy="0" result="offsetblur"></feOffset><feFlood id="glowAlpha" flood-color="#FFF" flood-opacity="1"></feFlood><feComposite in2="offsetblur" operator="in"></feComposite><feMerge><feMergeNode/>          <feMergeNode in="SourceGraphic"></feMergeNode></feMerge></filter>
</defs><g ><polyline class="trailLine"/><polyline class="trailLine"/><polyline class="trailLine"/><polyline class="trailLine"/><polyline class="trailLine"/><polyline class="trailLine"/><path class="plane" d="M20,13.7v-1.4l-8.6-5.1V3.5c0-1-0.6-3.5-1.4-3.5S8.6,2.4,8.6,3.5v3.7L0,12.2v1.4l8.6-1.8l0.5,5l-2.5,1.9V20l3.5-0.8l3.5,0.8v-1.2L11,16.9l0.5-5L20,13.7z" /><path class="plane" d="M20,13.7v-1.4l-8.6-5.1V3.5c0-1-0.6-3.5-1.4-3.5S8.6,2.4,8.6,3.5v3.7L0,12.2v1.4l8.6-1.8l0.5,5l-2.5,1.9V20l3.5-0.8l3.5,0.8v-1.2L11,16.9l0.5-5L20,13.7z" /><path class="plane" d="M20,13.7v-1.4l-8.6-5.1V3.5c0-1-0.6-3.5-1.4-3.5S8.6,2.4,8.6,3.5v3.7L0,12.2v1.4l8.6-1.8l0.5,5l-2.5,1.9V20l3.5-0.8l3.5,0.8v-1.2L11,16.9l0.5-5L20,13.7z" /><path class="plane" d="M20,13.7v-1.4l-8.6-5.1V3.5c0-1-0.6-3.5-1.4-3.5S8.6,2.4,8.6,3.5v3.7L0,12.2v1.4l8.6-1.8l0.5,5l-2.5,1.9V20l3.5-0.8l3.5,0.8v-1.2L11,16.9l0.5-5L20,13.7z" /><path class="plane" d="M20,13.7v-1.4l-8.6-5.1V3.5c0-1-0.6-3.5-1.4-3.5S8.6,2.4,8.6,3.5v3.7L0,12.2v1.4l8.6-1.8l0.5,5l-2.5,1.9V20l3.5-0.8l3.5,0.8v-1.2L11,16.9l0.5-5L20,13.7z" /><path class="plane" d="M20,13.7v-1.4l-8.6-5.1V3.5c0-1-0.6-3.5-1.4-3.5S8.6,2.4,8.6,3.5v3.7L0,12.2v1.4l8.6-1.8l0.5,5l-2.5,1.9V20l3.5-0.8l3.5,0.8v-1.2L11,16.9l0.5-5L20,13.7z" /></g></svg>

CSS

body {background-color: #141723 ;
/* background-color: #FFF ; */overflow: hidden;text-align:center;display: flex;align-items: center;justify-content: center;}body,
html {height: 100%;width: 100%;margin: 0;padding: 0;
}
:root {--line-stroke: #0074b3;/* --grid-stroke: #00adef; */--line-stroke-width: 1.5;--circle-fill: #00adef;--circle-stroke: #0074b3;
}svg {position: absolute;width: 100%;height: 100%;visibility: hidden;}
.trailLine {stroke:var(--line-stroke);stroke-width: var(--line-stroke-width);fill: none;stroke-linecap: round;stroke-linejoin: round;stroke-dasharray: 4 10
}
.gridRect {stroke:var(--circle-stroke);}
#grid {opacity: 0.085;}
#glowAlpha {flood-color: var(--circle-stroke)
}
.plane {fill:#CCC;
}

JS

let select = s => document.querySelector(s),selectAll = s =>  document.querySelectorAll(s),mainSVG = select('#mainSVG'),trailLine = select('#trailLine'),numPoints = 300,svgHeight = 600,height = svgHeight,allPlanes = gsap.utils.toArray('.plane'),allTrailLines = selectAll('.trailLine'),allTrailPoints = [],planeColorArray = ['#04BCE8', '#EA6360', '#4EBE92', '#A83395', '#4A52A6', '#F2CD5D'],planeWidth = allPlanes[0].getBBox().width;gsap.defaults({lazy:true}) gsap.set('svg', {visibility: 'visible'
})
gsap.set(allPlanes, {transformOrigin: '50% 100%',yPercent: -20
})
let p = CustomEase.create('trail', 'M0,0 C0,0 0.08957,0.04997 0.14563,0.07332 0.17361,0.08497 0.19406,0.08816 0.22447,0.09346 0.25234,0.09831 0.27245,0.10281 0.29876,0.1 0.3304,0.09662 0.3574,0.09206 0.38526,0.07627 0.46146,0.0331 0.50906,-0.01658 0.58698,-0.06332 0.61735,-0.08154 0.64322,-0.09168 0.67604,-0.09815 0.70315,-0.10349 0.72556,-0.09999 0.75503,-0.09644 0.7862,-0.09269 0.8064,-0.0881 0.83671,-0.07879 0.87049,-0.06842 0.89148,-0.06013 0.92338,-0.04473 0.95378,-0.03007 1,0 1,0 ');const swayPlane = (_id) => {gsap.set(allPlanes[_id], {x: allTrailPoints[_id][0].x - (planeWidth/2),y: allTrailPoints[_id][0].y - planeWidth})gsap.to(allPlanes[_id], {duration: 0.1,rotation: ((planeInitArray[_id].x - (allTrailPoints[_id][50].x)) * 0.72),ease: 'sine.inOut'})
}let planeInitArray = []
let duration = gsap.utils.random(5, 20);
for(var j = 0; j < allPlanes.length; j++) {let trailLine = allTrailLines[j];let pointX = gsap.utils.random(250, 350);let pointArray = [];let heightMultiplier = gsap.utils.random(0.11, 0.8);gsap.set(allTrailLines[j], {stroke: planeColorArray[j]})for(let i = 0; i < numPoints; i++) {let point = trailLine.points.appendItem(mainSVG.createSVGPoint());pointArray.push(point)point.x = pointX;gsap.set(point, {y:(height * heightMultiplier) + (i * ((height ) / numPoints))})           }
allTrailPoints.push(pointArray)planeInitArray.push({x: pointArray[0].x, y: pointArray[0].y} );let tl = gsap.timeline();tl.to(allTrailPoints[j], {duration: gsap.utils.random(7, 14),x: '-=' + gsap.utils.random(-600, 600),stagger: {each: duration / 1000,repeat: -1},onUpdate: swayPlane,onUpdateParams:[j],ease: 'trail'}).seek(gsap.utils.random(300, 1000));}let extraTl = gsap.timeline();
extraTl.to(allTrailLines, {strokeDashoffset:-(14 * 4),repeat: -1,ease: 'none'
}).to('#grid', {duration: 1,y: '+=40',ease: 'none',repeat: -1
}, 0)

飞机步道(plane trails)相关推荐

  1. Problem N: 设计飞机类Plane及其派生类

    Problem Description 设计一个飞机Plane类,由它派生出歼击机Fighter类和轰炸机Bomber类,歼击机Fighter类和轰炸机Bomber类又共同派生出歼轰机(多用途战斗机) ...

  2. PHP3d地球,three.js绘制地球、飞机与轨迹的效果示例

    对于three.js不太熟悉的朋友们可以参考这篇文章,threejs官网:https://threejs.org/ 首先我们来看下要实现的效果 这个缩小后的图片,下面我们来看下近距离的动态效果.. 效 ...

  3. Python基础-Pygame游戏框架之飞机大战

    Pygame游戏框架 Pygame Pygame是一套跨平台的Python模块,专为编写游戏而设计. 它包括计算机图形和声音库,旨在与Python编程语言一起使用. 展示窗体 引入pygame模块 i ...

  4. python飞机大战源码素材包_python(pygame)滑稽大战(类似飞机大战) 教程

    成品已录制视频投稿B站(本文目前实现了基础的游戏功能),点击观看 本帖曾在百度贴吧直播,但由于人气低反响差已停更. 项目稽忽悠不(github)地址(目前只上传了素材,代码还在整理中): https: ...

  5. C#飞机大战案例详细教程

    飞机大战游戏开发稳定版 实现效果如下 子弹碰撞敌机 己方碰撞敌机 己方飞机碰撞补给 飞机跟随鼠标移动 爆炸动画 爆炸音效 需要拓展的请自行拓展,欢迎大佬点评! 运行界面截图 运行界面截图 实现功能:1 ...

  6. 飞机大战小游戏(超详细)

    偷学Python之最后的项目二:飞机大战小游戏(超详细) 古之立大事者,不惟有超世之才,亦必有坚忍不拔之志.--苏轼 甜甜先说 这次用Python中的pygame模块来完成一个飞机大战的小游戏:基本思 ...

  7. Python+Pgzrun制作打飞机游戏(附源码)

    目录 基本框架 创建滚动背景 创建飞机 让plane移动 发射子弹 创建敌机 敌机移动 金币制度 关卡制度 设置 创建更高级飞机(SRplane和SSRplane ) 开始 炸弹 介绍 源码 基本框架 ...

  8. 树莓派基于PS2操纵杆的飞机大战小游戏

    击中病毒LED灯闪烁 PS2操纵杆.PCF8591 PCF8591: SDA - SDA SCL - SCL VCC - 5V GND - GND AIN1.AIN2.AIN3找空插即可 PS2操纵杆 ...

  9. 飞机大战--java

    菜鸟日记-2月10日 案例 : 飞机大战 要求: 玩家可控制飞机躲避炮弹,界面显示玩家游玩时间 效果: 1.游戏物体根类 (飞机,炮弹等类都继承于此类) import java.awt.*;/* * ...

最新文章

  1. C++模式学习------策略模式
  2. Java知识系列 -- 反射
  3. PHp批量推送数据太慢,PHP非阻塞批量推送数据-php教程
  4. 树的特征能否复用问题
  5. C++ 实现布隆过滤器(BloomFilter)
  6. 【渝粤教育】广东开放大学 知识产权法 形成性考核 (34)
  7. 读中文_挑战来了!康辉喊你读中文十级绕口令!
  8. HDU6092——Rikka with Subset 【dp】
  9. zabbix监控mysql死锁
  10. pca百分比取多少比较好_防晒霜指数多少比较好?防晒霜SPF多少够用
  11. 个位百位AS3实现经典算法(二) 水仙花数
  12. 网件R8000路由器怎么云存储_给大姐姐换个“控制中心”——NETGEAR 网件 R7800 AC2600M 路由器 简晒_路由器...
  13. 计算机系统结构cache,大连理工大学计算机系统结构实验 实验四
  14. python3中expected an indented block(缩进问题)
  15. impala hive随机抽样方法
  16. Pocket PC访问PC上的Webservice
  17. Base64解密转图片
  18. c语言 for循环说课,《程序的循环结构-For循环语句》教学设计
  19. 从0到1400star,从阮一峰周刊到尤雨溪推荐,小透明开源项目的2021年总结
  20. 【论文导读】- Link Weight Prediction Using Supervised Learning Methods(使用监督学习方法的链路权重预测及其在Yelp网络中的应用)

热门文章

  1. C++语言判断一个数是否为素数1/2
  2. linux-文件系统
  3. python中列表(list)的基本定义和用法
  4. Python-列表切片list[-1]、list[-1:]、list[:-1]、list[::1]、list[::-1]的区别
  5. 友盟推送集成的常见问题
  6. 如何更有效地发现用户痛点?
  7. 使用vue-lunar-full-calendar插件展示带有农历和节假日的日历
  8. 简单明了强烈推荐办公神器
  9. 台式计算机一小时功率,电脑电源功率如何选?电脑1小时能耗多少电?
  10. ASPX和Razor