键盘控制的烟花效果

键盘控制的烟花效果

添加时间:2021-02-19 14:13:29
站长推荐丨赞助论坛,可获取海量资源终身免费下载权限奥!
举报 举报
收藏
预览
附件 附件
  • 模板类型模板类型:图形
  • 模板颜色模板颜色:初级
  • 下载积分下载积分:28 米粒
  • 下载权限下载权限:

    赞助会员

一款键盘控制的烟花效果,可以通过键盘来控制烟花的发射位置和发射个数等等,整体的城市效果还是挺不错的,喜欢的童鞋请收下吧。
键盘控制的烟花效果
分类:html/css > 图形 难易:初级

页面的head部分,仅需引入一个CSS样式文件即可,代码如下:

<link type="text/css" rel="stylesheet" href="css/style.css">

页面的body部分,虽然代码较多,但不难看出用了canvas和svg来绘制整个图形,代码如下:

<div class="gradient"></div>
<div class="scene-wrapper">
	<canvas></canvas>
	<?xml version="1.0" encoding="utf-8"?>
    <!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
	<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 494.5 559.4" style="enable-background:new 0 0 494.5 559.4;" xml:space="preserve">
			<!--省略部分代码-->
			<g id="city-hall">
				<rect x="316.3" y="351.4" class="st7" width="22.3" height="27.2"/>
				<rect x="334.6" y="323.6" class="st7" width="29" height="55"/>
				<rect x="290.3" y="329.6" class="st7" width="28" height="48.9"/>
				<rect x="290.3" y="329.6" class="st8" width="11.4" height="48.9"/>
				<rect x="352.3" y="323.6" class="st8" width="11.4" height="55"/>
				<line class="st18" x1="294.1" y1="333.1" x2="294.1" y2="378.1"/>
				<line class="st18" x1="298.1" y1="333.1" x2="298.1" y2="378.1"/>
				<line class="st18" x1="356.1" y1="327.4" x2="356.1" y2="378"/>
				<line class="st18" x1="360.1" y1="327.4" x2="360.1" y2="378"/>
				<g id="windows_right_1_">
					<rect x="347.6" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="326.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="326.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="326.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="326.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="329.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="329.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="329.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="329.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="368.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="368.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="368.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="341.4" y="374.6" class="st10" width="1.5" height="1.5"/>
					<rect x="338.2" y="374.6" class="st10" width="1.5" height="1.5"/>
					<rect x="344.5" y="374.6" class="st10" width="1.5" height="1.5"/>
					<rect x="347.6" y="374.6" class="st10" width="1.5" height="1.5"/>
				</g>
				<g id="windows_left">
					<rect x="314.3" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="332.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="335.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="338.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="341.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="344.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="347.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="350.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="353.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="368.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="356.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="359.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="362.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="365.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="368.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="368.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="371.6" class="st10" width="1.5" height="1.5"/>
					<rect x="308" y="374.6" class="st10" width="1.5" height="1.5"/>
					<rect x="304.9" y="374.6" class="st10" width="1.5" height="1.5"/>
					<rect x="311.1" y="374.6" class="st10" width="1.5" height="1.5"/>
					<rect x="314.3" y="374.6" class="st10" width="1.5" height="1.5"/>
				</g>
				<polygon class="st19" points="313.1,378.6 313.1,372.4 340.2,372.4 340.2,378.6 		"/>
				<polygon class="st20" points="343.4,369.4 340.2,374.2 313.1,374.2 310,369.4 		"/>
				<path class="st21" d="M342.9,369.5c0.4,0,0.4-0.2,0.1-0.4c-1.8-1.1-7.7-4.1-16.2-4.1c-10.3,0-16.8,4.5-16.8,4.5H342.9z"/>
			</g>
			<line id="city-line" class="st9" x1="0" y1="378.6" x2="494.5" y2="378.6"/>
		</g>
		<g id="clouds">
			<path id="cloud-2" class="st22" d="M135.1,235.1c0,0-0.6-5.7-7.4-5.7s-7.7,6.4-7.7,6.4s-0.9-0.4-2.5-0.4c-1.6,0.1-6.4,2-5.7,7
				c0,0-3.7,1-3.7,3.8c0,2.9,3.1,3.3,3.1,3.3h48.9c0,0,1.6-0.3,1.6-2.5s-3-2.3-3-2.3l-5,0.1c0,0-0.1-6.1-7-6.1c0,0-3.1,0.1-3.8,1.3
				c0,0,1-4.8-5.3-4.8c0,0-2-0.1-2.8,0.8C135,236.1,135.3,236,135.1,235.1z"/>
			<path id="cloud-1" class="st22" d="M359.3,261c0,0-1.1-0.8-3-0.8s-4.1,1.4-4.1,2.8c0,0-1.1-0.6-3.4-0.6s-5.2,2.5-5.2,4.9h-6.2
				c0,0-2.5,0.4-2.5,2.5s0.6,2.8,2.4,2.8s36,0,36,0s4.2-0.8,4.2-5.5s-5.2-5.5-5.2-5.5s-1.4-5-6.6-5S359.3,261,359.3,261z"/>
		</g>
		<g id="triggers">
			<circle id="trigger-middle-left" class="st23" cx="229.6" cy="142.3" r="0.8"/>
			<circle id="trigger-middle-right" class="st23" cx="265.9" cy="142.3" r="0.8"/>
			<circle id="trigger-top-right" class="st23" cx="261.3" cy="135" r="0.8"/>
			<circle id="trigger-hat-right" class="st23" cx="254.3" cy="80.2" r="0.8"/>
			<circle id="trigger-hat-left" class="st23" cx="241.1" cy="80.2" r="0.8"/>
			<circle id="trigger-top-left" class="st23" cx="234" cy="135" r="0.8"/>
			<circle id="trigger-bottom-left" class="st23" cx="230.7" cy="149.1" r="0.8"/>
			<circle id="trigger-bottom-right" class="st23" cx="264.7" cy="149.1" r="0.8"/>
		</g>
	</svg>
	<div class="instructions">按键 <span>A</span>, <span>S</span>, <span>D</span>, <span>F</span> 可控制焰火。</div>
</div>

页面的底部,需远程调用多个JS文件,并引入一个本地JS文件,代码如下:

<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.2/plugins/CSSPlugin.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.2/TimelineLite.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.2/TweenMax.min.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/49240/vector2D.js'></script>
<script type="text/javascript" src="js/index.js"></script>
相关内容推荐
资源求助发帖
查看更多发帖

*

回帖描述:

*

链接类型:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
热点内容推荐
标题:键盘控制的烟花效果

*

描述:
平均回复时间:3-10分钟
规则介绍:悬赏寻求论坛网友分享资源,站点对分享内容的准确性,合法性,版权等没有足够的监管能力。如果您发现资源不正确,无法使用,不符合法律法律等情况,您可以直接举报资源。站长将尽快核实您的举报,并根据情况,采取封号,退换米粒等处理。

*

回帖描述:

*

链接类型:

*

阅读权限:

*

下载链接:

密码:
发帖规则:回帖内容为会员之间的私信,普通网友无法查看。
免责声明:回帖中提供的链接内容仅供会员之间学习参考使用,获取内容后请在法律法规范围内使用。回帖提供的内容应符合法律法规要求,不得违反法律法律的要求。
站点权责:回帖内容如违反法律法规,站点有权封停账号使用权利。对用户举报的内容,站点有责任及时删除违规内容。
  • 背景波浪
  • 背景波浪
  • 波浪
  • 波浪
客服
在线咨询
周一 至 周日 9:00 ~ 22:00
QQ:1326974360
微信:juyoubuluo6688
客服热线
18205485173
工作日 9:00 ~ 18:00
微信扫码咨询
客户服务
欢迎咨询服务
咨询量较多时,请耐心等待
社群

关注公众号

获取更多资讯

扫码进群(QQ)

与更多大牛交流沟通

0.214060s