图示

直接干代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body{
overflow: hidden;
}
</style>
</head>
<body>
<canvas id="galaxy" width="1500" height="1000" ></canvas>
<script type="text/javascript">
const galaxy = document.querySelector("#galaxy");
const ct = galaxy.getContext("2d");
const colors = ct.createLinearGradient(0,200,200,0);
colors.addColorStop(0,"#000");
colors.addColorStop(0.5,"#111111");
colors.addColorStop(1.0,"#000");
var rcolors = null;
var n = 1;
const w = 1390;
const h = 680;
const rx = Math.floor(w/2);
const ry = Math.floor(h/2);
ct.translate(rx,ry);
function drawGalaxy(){
ct.clearRect(-rx,-ry,w,h);
ct.fillStyle = colors;
ct.beginPath();
ct.fillRect(-rx,-ry,w,h);
ct.closePath()
for (var i = 0; i < 150; i++) {
ct.beginPath()
ct.strokeStyle = 'white';
ct.arc(getRandom(-rx,rx),getRandom(-ry,ry),1,0, getRandom(90,360) ,false);
ct.stroke();
}
if(n++ == 360){
n = 1
}
rcolors = ct.createRadialGradient(0,0,1,0,0,50);
rcolors.addColorStop(0,'#ec1221');
rcolors.addColorStop(0.5,'#ec2427');
rcolors.addColorStop(1.0,'#ec283c');
ct.save()
ct.beginPath()
ct.fillStyle = rcolors;
ct.arc(0,0,50,0,360,false);
ct.fill();
ct.restore()
rcolors = ct.createRadialGradient(0,0,1,0,0,10);
rcolors.addColorStop(0,'#0c40ff')
rcolors.addColorStop(0.5,'#2063ff')
rcolors.addColorStop(1.0,'#3575ff')
ct.beginPath();
ct.strokeStyle = "#03A9F4"
ct.arc(0,0,70,0,360,false);
ct.stroke();
ct.closePath()
ct.save()
ct.beginPath()
ct.rotate(n*3*Math.PI/180);
ct.fillStyle = rcolors;
ct.arc(0,-70,10,0,360,false);
ct.fill();
ct.closePath()
ct.restore()
rcolors = ct.createRadialGradient(0,0,1,0,0,15);
rcolors.addColorStop(0,'#ff4c06')
rcolors.addColorStop(0.5,'#ff7818')
rcolors.addColorStop(1.0,'#ffb726')
ct.beginPath();
ct.strokeStyle = "#03A9F4"
ct.arc(0,0,100,0,360,false);
ct.stroke();
ct.closePath()
ct.save()
ct.beginPath()
ct.rotate(n*4*Math.PI/180);
ct.fillStyle = rcolors;
ct.arc(0,-100,15,0,360,false);
ct.fill();
ct.closePath()
ct.restore()
rcolors = ct.createRadialGradient(0,0,1,0,0,18);
rcolors.addColorStop(0,'#0caaff')
rcolors.addColorStop(0.5,'#78beff')
rcolors.addColorStop(1.0,'#92c7ff')
ct.beginPath();
ct.strokeStyle = "#03A9F4"
ct.arc(0,0,140,0,360,false);
ct.stroke();
ct.closePath()
ct.save()
ct.beginPath()
ct.rotate(n*2*Math.PI/180);
ct.fillStyle = rcolors;
ct.arc(0,-140,18,0,360,false);
ct.fill();
ct.closePath()
ct.restore()
rcolors = ct.createRadialGradient(0,0,1,0,0,16);
rcolors.addColorStop(0.2,'#ff5500')
ct.beginPath();
ct.strokeStyle = "#03A9F4"
ct.arc(0,0,180,0,360,false);
ct.stroke();
ct.closePath()
ct.save()
ct.beginPath()
ct.rotate(n*7*Math.PI/180);
ct.fillStyle = rcolors;
ct.arc(0,-180,16,0,360,false);
ct.fill();
ct.closePath()
ct.restore()
}
drawGalaxy()
setInterval(drawGalaxy,60);
function getRandom(min,max){
const choose = max - min +1;
return Math.floor(Math.random()*choose +min);
}
</script>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现