You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.6 KiB
HTML
105 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>大屏展示</title>
|
|
<script type="module" crossorigin src="./assets/index.9a11bb42.js"></script>
|
|
<link rel="stylesheet" href="./assets/index.5a4ba67a.css">
|
|
</head>
|
|
<body>
|
|
<canvas style="position:absolute;z-index:-2;" id="starBg"></canvas>
|
|
<div style=" position:relative;" id="app"></div>
|
|
</body>
|
|
</html>
|
|
|
|
<script src="/src/assets/JS/Star.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
let stars = [];
|
|
const maxStars = 1000; // 星星数量
|
|
function initCanvas() {
|
|
const canvas = document.getElementById("starBg");
|
|
const ctx = canvas.getContext("2d");
|
|
const w = (canvas.width = window.innerWidth);
|
|
const h = (canvas.height = window.innerHeight);
|
|
|
|
const canvas2 = document.createElement("canvas");
|
|
const ctx2 = canvas2.getContext("2d");
|
|
canvas2.width = 100;
|
|
canvas2.height = 100;
|
|
const half = canvas2.width / 2;
|
|
const gradient2 = ctx2.createRadialGradient(half, half, 0, half, half, half);
|
|
gradient2.addColorStop(0.025, "#CCC");
|
|
gradient2.addColorStop(0.1, "hsl(217, 61%, 33%)");
|
|
gradient2.addColorStop(0.25, "hsl(217, 64%, 6%)");
|
|
gradient2.addColorStop(1, "transparent");
|
|
|
|
ctx2.fillStyle = gradient2;
|
|
ctx2.beginPath();
|
|
ctx2.arc(half, half, half, 0, Math.PI * 2);
|
|
ctx2.fill();
|
|
|
|
for (var i = 1; i < maxStars; i++) {
|
|
const star = new Star({w, h}, ctx, canvas2);
|
|
stars[i] = star;
|
|
}
|
|
function animation() {
|
|
ctx.globalCompositeOperation = "source-over";
|
|
ctx.globalAlpha = 0.8; //尾巴
|
|
ctx.fillStyle = "hsla(217, 64%, 6%, 2)";
|
|
ctx.fillRect(0, 0, w, h);
|
|
|
|
ctx.globalCompositeOperation = "lighter";
|
|
for (let i = 1; i < stars.length; i++) {
|
|
stars[i].draw();
|
|
}
|
|
|
|
window.requestAnimationFrame(animation);
|
|
}
|
|
animation();
|
|
}
|
|
initCanvas();
|
|
</script>
|
|
<style>
|
|
/* html,body{
|
|
margin:0;
|
|
background-image:url(/src/assets/bj2.png);
|
|
background-size: cover;
|
|
width:100%;
|
|
height:100%;
|
|
}
|
|
#app{
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
} */
|
|
|
|
html,body{
|
|
margin:0;
|
|
/* background-image:url(/src/assets/btl.jpg); */
|
|
width:100%;
|
|
height:100%;
|
|
|
|
}
|
|
|
|
#starBg {
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
position: absolute;
|
|
z-index: 2;
|
|
|
|
}
|
|
#app{
|
|
overflow-y:hidden;
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|