html--月食

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <style>
  *, *:before, *:after {
  margin:0;
  padding:0;
  -webkit-box-sizing:border-box;
          box-sizing:border-box;
}
html,
body {
  width:100%;
  height:100%;
}
body {
  position:relative;
  background-color:#011111;
  background-image:radial-gradient(#0d292a 0%, #011111 70%);
  background-size:100% 600px;
  background-repeat:no-repeat;
}
.moon {
  position:absolute;
  top:200px;
  left:50%;
  width:8rem;
  height:8rem;
  overflow:hidden;
  border-radius:50%;
  -webkit-transform:translateX(-50%);
          transform:translateX(-50%);
  -webkit-box-shadow:0 0 400px 100px #123839;
          box-shadow:0 0 400px 100px #123839;
  -webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
}
.moon:after {
  content:'';
  position:absolute;
  top:1px;
  right:1px;
  bottom:1px;
  left:1px;
  z-index:-1;
  border-radius:50%;
  background-color:#fff5bb;
  background-image:
    radial-gradient(#f2e594 0%, #f2e594 70%, transparent 70%, transparent 100%),
    radial-gradient(#f2e594 0%, #f2e594 70%, transparent 70%, transparent 100%),
    radial-gradient(#f2e594 0%, #f2e594 70%, transparent 70%, transparent 100%),
    radial-gradient(#f2e594 0%, #f2e594 70%, transparent 70%, transparent 100%),
    radial-gradient(#f2e594 0%, #f2e594 70%, transparent 70%, transparent 100%);
  background-size:10px 10px, 5px 5px, 15px 15px, 10px 10px, 7px 7px;
  background-repeat:no-repeat;
  background-position:10% 20%, 70% 15%, 35% 70%, 80% 50%, 70% 75%;
    -webkit-box-shadow:inset -15px -15px 0 #f2e594;
            box-shadow:inset -15px -15px 0 #f2e594;
}
.moon:before {
  content:'';
  position:absolute;
  top:0;
  right:0;
  bottom:0;
  left:0;
  z-index:222;
  background:#0b2526;
  border-radius:50%;
  -webkit-transform:translateX(-100%);
          transform:translateX(-100%);
  -webkit-animation:phase 20s infinite linear;
          animation:phase 20s infinite linear;
}
@-webkit-keyframes phase {
  0%, 100% {-webkit-transform:translateX(-100%);transform:translateX(-100%);}
  10% {-webkit-transform:translateX(-100%);transform:translateX(-100%);}
  99.999% {-webkit-transform:translateX(100%);transform:translateX(100%);}
}
@keyframes phase {
  0%, 100% {-webkit-transform:translateX(-100%);transform:translateX(-100%);}
  10% {-webkit-transform:translateX(-100%);transform:translateX(-100%);}
  99.999% {-webkit-transform:translateX(100%);transform:translateX(100%);}
}
  </style>
 </HEAD>

 <BODY>
  <div class="moon"></div>
 </BODY>
</HTML>


在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

  • 30
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在 Matlab 中生成日食月食动画,可以利用 Matlab 自带的绘图功能和一些简单的计算。以下是一个示例代码,可以生成一段时间内的日食月食动画: ```matlab % 设置参数 R_earth = 6378.1; % 地球半径 R_moon = 1737.4; % 月球半径 d_moon_earth = 384400; % 地月距离 d_sun_earth = 149.6e6; % 地日距离 theta = linspace(0, 2*pi, 1000); % 绘图用的角度数组 % 设置时间步长 dt = 0.1; % 秒 % 设置模拟时间 t_start = 0; % 开始时间 t_end = 3600*24*30; % 结束时间,这里模拟了一个月 % 初始化绘图窗口 figure('Position', [100, 100, 800, 600]); % 进行模拟 for t = t_start:dt:t_end % 计算位置 theta_moon = mod(t / (27.3 * 24 * 3600) * 2 * pi, 2*pi); % 月球的角度 theta_sun = mod(t / (365.25 * 24 * 3600) * 2 * pi, 2*pi); % 太阳的角度 x_moon = d_moon_earth * cos(theta_moon); % 月球的 x 坐标 y_moon = d_moon_earth * sin(theta_moon); % 月球的 y 坐标 x_sun = d_sun_earth * cos(theta_sun); % 太阳的 x 坐标 y_sun = d_sun_earth * sin(theta_sun); % 太阳的 y 坐标 % 计算月食和日食 d_moon_sun = sqrt((x_moon - x_sun)^2 + (y_moon - y_sun)^2); % 月球和太阳的距离 d_earth_sun = sqrt(x_sun^2 + y_sun^2); % 地球和太阳的距离 d_earth_moon = sqrt((x_moon - R_earth)^2 + y_moon^2); % 地球和月球的距离 if d_moon_sun < R_moon % 月球在太阳前面,发生日食 if d_earth_sun < d_moon_earth % 日全食 % 绘制地球 fill(R_earth * cos(theta), R_earth * sin(theta), [0.1, 0.1, 0.1]); hold on; % 绘制太阳和月球 fill(x_sun + R_sun * cos(theta), y_sun + R_sun * sin(theta), 'y'); fill(x_moon + R_moon * cos(theta), y_moon + R_moon * sin(theta), 'k'); hold off; axis equal; xlim([-d_sun_earth, d_sun_earth]); ylim([-d_sun_earth, d_sun_earth]); title('Total Solar Eclipse'); else % 日偏食 % 绘制地球和太阳 fill(R_earth * cos(theta), R_earth * sin(theta), [0.1, 0.1, 0.1]); hold on; fill(x_sun + R_sun * cos(theta), y_sun + R_sun * sin(theta), 'y'); % 绘制月球的阴影 fill(x_moon + R_moon * cos(theta), y_moon + R_moon * sin(theta), [0.1, 0.1, 0.1]); fill(x_moon + d_moon_sun * cos(theta), y_moon + d_moon_sun * sin(theta), [0.9, 0.9, 0.9]); hold off; axis equal; xlim([-d_sun_earth, d_sun_earth]); ylim([-d_sun_earth, d_sun_earth]); title('Partial Solar Eclipse'); end else % 月球在太阳后面,发生月食 if d_earth_sun < d_moon_earth % 月全食 % 绘制地球 fill(R_earth * cos(theta), R_earth * sin(theta), [0.1, 0.1, 0.1]); hold on; % 绘制太阳和月球 fill(x_sun + R_sun * cos(theta), y_sun + R_sun * sin(theta), 'y'); fill(x_moon + R_moon * cos(theta), y_moon + R_moon * sin(theta), 'k'); % 绘制月球的阴影 fill(x_moon + d_earth_moon * cos(theta), y_moon + d_earth_moon * sin(theta), [0.9, 0.9, 0.9]); hold off; axis equal; xlim([-d_sun_earth, d_sun_earth]); ylim([-d_sun_earth, d_sun_earth]); title('Total Lunar Eclipse'); else % 月偏食 % 绘制地球和月球 fill(R_earth * cos(theta), R_earth * sin(theta), [0.1, 0.1, 0.1]); hold on; fill(x_moon + R_moon * cos(theta), y_moon + R_moon * sin(theta), 'k'); % 绘制太阳的阴影 fill(x_sun + d_earth_moon * cos(theta), y_sun + d_earth_moon * sin(theta), [0.9, 0.9, 0.9]); hold off; axis equal; xlim([-d_sun_earth, d_sun_earth]); ylim([-d_sun_earth, d_sun_earth]); title('Partial Lunar Eclipse'); end end % 暂停一段时间,使动画更流畅 pause(0.01); end ``` 这个程序模拟了一个月内的日食月食情况。在程序中,我们设置了太阳、地球和月球的半径和距离,并使用时间步长进行模拟。在每个时间步长中,我们计算太阳、地球和月球的位置,并根据它们的相对位置,判断是否发生了日食或月食,并绘制相应的图形。我们使用 `fill` 函数绘制圆形图形,并在每个时间步长中暂停一段时间,使得动画更流畅。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fo安方

觉得俺的文章还行,感谢打赏,爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值