欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用JavaScript實(shí)現(xiàn)繪制2023新年煙花的示例代碼

 更新時(shí)間:2023年01月21日 09:42:54   作者:橙 子_  
大家過(guò)年好!新春佳節(jié),在這個(gè)充滿喜悅的日子里,愿新年的鐘聲帶給你一份希望和期待。在這喜慶的日子里,小編和大家分享一個(gè)煙花代碼,希望大家能夠喜歡

前言

大家過(guò)年好!新春佳節(jié),在這個(gè)充滿喜悅的日子里,愿新年的鐘聲帶給你一份希望和期待,我相信,時(shí)空的距離不能阻隔你我,我的祝福永遠(yuǎn)在你身邊。

祝愿朋友,財(cái)源滾滾,吉祥高照,鴻運(yùn)當(dāng)頭,幸福環(huán)繞,萬(wàn)事順心,笑口常開。

在這喜慶的日子里,我給大家分享一個(gè)煙花代碼,代碼下載在使用教程部分,希望大家都能開開心心過(guò)大年!

煙花效果展示

煙花樣式可以自定義選擇,背景音樂(lè)選擇十分真實(shí)的仿煙花聲。當(dāng)你把代碼打包發(fā)給朋友打開時(shí),新年的氛圍在此刻達(dá)到了頂峰。也許你在這一年里背井離鄉(xiāng)忙于工作,學(xué)習(xí),也許你在這一年里過(guò)得風(fēng)生水起,做著喜歡的工作,又或是這一年里,你過(guò)的不盡人意,新年到來(lái)之時(shí),忘記所有煩惱,在家多陪陪父母,出門和朋友聚會(huì),2023 年我們重頭再來(lái)!

使用教程

無(wú)論是你想自己下載研究代碼,還是你是小白想發(fā)給朋友欣賞,都十分推薦。下面是手把手教學(xué),帶你零基礎(chǔ)看一場(chǎng)代碼帶來(lái)的浪漫煙花。

第一步:下載代碼壓縮包文件,解壓。

第二步:打開解壓好的文件夾,此時(shí)可以看到三個(gè)文件,如果你想試試效果,雙擊 .html 后綴的文件在瀏覽器打開運(yùn)行即可。

第三步:如果想研究前端代碼,我們可以看一下,文件夾中一共存放了三個(gè)文件,分別是:

  • HTML文件
  • CSS文件
  • JavaScript文件

這三個(gè)部分便是我們常說(shuō)的前端三劍客,是前端的基礎(chǔ)內(nèi)容,構(gòu)成了前端技術(shù)棧。其中,HTML負(fù)責(zé)結(jié)構(gòu)部分,他就像是骨架一樣,CSS 又叫層疊樣式表,負(fù)責(zé)頁(yè)面的美化,還有負(fù)責(zé)交互邏輯的 JavaScript 。

對(duì)于小白來(lái)說(shuō),網(wǎng)上有很多的教程,可以說(shuō)是眼花繚亂。這樣的方式是不是方便很多呢?不用你新建一個(gè)記事本文件。哈哈,重點(diǎn)還是能在代碼里學(xué)到東西哦,煙花只是為了新年的氛圍??!

查看源碼

HTML代碼

由于文章的篇幅原因,代碼只展示一部分示例。HTML 撐起了整個(gè)頁(yè)面的大致框架,不如你想給頁(yè)面加上一個(gè)按鈕,一個(gè)輸入框等等。他是頁(yè)面的骨架,負(fù)責(zé)頁(yè)面的結(jié)構(gòu)部分。

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>HTML5 Canvas超逼真煙花綻放動(dòng)畫</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#000000">
<link rel="shortcut icon" type="image/png"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >
<link rel="icon" type="image/png"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >
<link rel="apple-touch-icon-precomposed"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >
<meta name="msapplication-TileColor" content="#000000">
<meta name="msapplication-TileImage" content="https://s3-us-west-2.amazonaws.com/s.cdpn.io/329180/firework-burst-icon-v2.png">
<link  rel="external nofollow"  rel="stylesheet"><link rel="stylesheet"  rel="external nofollow" >
<link rel="stylesheet" href="./style.css" rel="external nofollow" >

</head>
<body>

<!-- App -->
<div class="container">
	<div class="loading-init">
		<div class="loading-init__header">Loading</div>
		<div class="loading-init__status">Assembling Shells</div>
	</div>
	<div class="stage-container remove">
		<div class="canvas-container">
			<canvas id="trails-canvas"></canvas>
			<canvas id="main-canvas"></canvas>
		</div>
		<div class="controls">
			<div class="btn pause-btn">
				<svg fill="white" width="24" height="24"><use href="#icon-pause" rel="external nofollow"  rel="external nofollow"  xlink:href="#icon-pause" rel="external nofollow"  rel="external nofollow" ></use></svg>
			</div>
			<div class="btn sound-btn">
				<svg fill="white" width="24" height="24"><use href="#icon-sound-off" rel="external nofollow"  rel="external nofollow"  xlink:href="#icon-sound-off" rel="external nofollow"  rel="external nofollow" ></use></svg>
			</div>
			<div class="btn settings-btn">
				<svg fill="white" width="24" height="24"><use href="#icon-settings" rel="external nofollow"  rel="external nofollow"  xlink:href="#icon-settings" rel="external nofollow"  rel="external nofollow" ></use></svg>
			</div>
		</div>
		<div class="menu hide">
			<div class="menu__inner-wrap">
				<div class="btn btn--bright close-menu-btn">
					<svg fill="white" width="24" height="24"><use href="#icon-close" rel="external nofollow"  rel="external nofollow"  xlink:href="#icon-close" rel="external nofollow"  rel="external nofollow" ></use></svg>
				</div>
				<div class="menu__header">Settings</div>
				<div class="menu__subheader">For more info, click any label.</div>
				<form>
					<div class="form-option form-option--select">
						<label class="shell-type-label">Shell Type</label>
						<select class="shell-type"></select>
					</div>
					<div class="form-option form-option--select">
						<label class="shell-size-label">Shell Size</label>
						<select class="shell-size"></select>
					</div>
					<div class="form-option form-option--select">
						<label class="quality-ui-label">Quality</label>
						<select class="quality-ui"></select>
					</div>
					<div class="form-option form-option--select">
						<label class="sky-lighting-label">Sky Lighting</label>
						<select class="sky-lighting"></select>
					</div>
					<div class="form-option form-option--select">
						<label class="scaleFactor-label">Scale</label>
						<select class="scaleFactor"></select>
					</div>
					<div class="form-option form-option--checkbox">
						<label class="auto-launch-label">Auto Fire</label>
						<input class="auto-launch" type="checkbox" />
					</div>
					<div class="form-option form-option--checkbox form-option--finale-mode">
						<label class="finale-mode-label">Finale Mode</label>
						<input class="finale-mode" type="checkbox" />
					</div>
					<div class="form-option form-option--checkbox">
						<label class="hide-controls-label">Hide Controls</label>
						<input class="hide-controls" type="checkbox" />
					</div>
					<div class="form-option form-option--checkbox form-option--fullscreen">
						<label class="fullscreen-label">Fullscreen</label>
						<input class="fullscreen" type="checkbox" />
					</div>
					<div class="form-option form-option--checkbox">
						<label class="long-exposure-label">Open Shutter</label>
						<input class="long-exposure" type="checkbox" />
					</div>
				</form>
				<div class="credits">
					Passionately built by <a  rel="external nofollow"  target="_blank">Caleb Miller</a>.
				</div>
			</div>
		</div>
	</div>
</div>
<!-- partial -->
  <script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/329180/fscreen%401.0.1.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/329180/Stage%400.1.4.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/329180/MyMath.js'></script><script  src="./script.js"></script>

</body>
</html>

CSS代碼

當(dāng)然,只使用 HTML 的頁(yè)面是十分單調(diào)的,我們還需要對(duì)頁(yè)面進(jìn)行美化,此時(shí)需要加入 CSS 代碼。

.help-modal__overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  opacity: 0;
  transition-property: opacity;
  transition-timing-function: ease-in;
  transition-duration: 0.25s;
}
.help-modal__dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 400px;
  max-height: calc(100vh - 100px);
  margin: 10px;
  padding: 20px;
  border-radius: 0.3em;
  background-color: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: scale(0.9, 0.9);
  transition-property: opacity, transform;
  transition-timing-function: ease-in;
  transition-duration: 0.25s;
}

JavaScript

JavaScript 處理代碼的交互邏輯,是十分重要的一部分,也是比較難的一部分。

function toggleSound(toggle) {
	if (typeof toggle === 'boolean') {
		store.setState({ soundEnabled: toggle });
	} else {
		store.setState({ soundEnabled: !store.state.soundEnabled });
	}
}

function toggleMenu(toggle) {
	if (typeof toggle === 'boolean') {
		store.setState({ menuOpen: toggle });
	} else {
		store.setState({ menuOpen: !store.state.menuOpen });
	}
}

function updateConfig(nextConfig) {
	nextConfig = nextConfig || getConfigFromDOM();
	store.setState({
		config: Object.assign({}, store.state.config, nextConfig)
	});
	
	configDidUpdate();
}

// Map config to various properties & apply side effects
function configDidUpdate() {
	const config = store.state.config;
	
	quality = qualitySelector();
	isLowQuality = quality === QUALITY_LOW;
	isNormalQuality = quality === QUALITY_NORMAL;
	isHighQuality = quality === QUALITY_HIGH;
	
	if (skyLightingSelector() === SKY_LIGHT_NONE) {
		appNodes.canvasContainer.style.backgroundColor = '#000';
	}
	
	Spark.drawWidth = quality === QUALITY_HIGH ? 0.75 : 1;
}

新年祝福

兔年是歲月輪回中美麗的風(fēng)景,洋溢燦爛;兔年是季節(jié)變遷中幸福的旋律,飄蕩快樂(lè);兔年是人生歲月中溫暖的記憶,灑滿祝福。愿你兔年大吉大利,萬(wàn)事如意!

以上就是利用JavaScript實(shí)現(xiàn)繪制2023新年煙花的示例代碼的詳細(xì)內(nèi)容,更多關(guān)于JavaScript新年煙花的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論