Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
f0f3be5c
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f0f3be5c
编写于
10月 28, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
02fa3606
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
56 addition
and
2 deletion
+56
-2
common/color_utils.py
common/color_utils.py
+52
-0
sim_scenes/solar_system/halley_comet_sim.py
sim_scenes/solar_system/halley_comet_sim.py
+2
-1
sim_scenes/solar_system/halley_comet_sim_02.py
sim_scenes/solar_system/halley_comet_sim_02.py
+2
-1
未找到文件。
common/color_utils.py
浏览文件 @
f0f3be5c
...
@@ -34,6 +34,54 @@ def conv_to_vec4_color(colour: tuple, alpha=1):
...
@@ -34,6 +34,54 @@ def conv_to_vec4_color(colour: tuple, alpha=1):
# color = ursina_color.rgba(r, g, b, a)
# color = ursina_color.rgba(r, g, b, a)
# def brightest(color):
# if isinstance(color, tuple):
# r, g, b = color
# elif isinstance(color, list):
# r, g, b = color
#
# brightest_color 等于的值就是 r g b 同时按照比例增加,直到 r g b 其中一个值达到 255 为止,
# 比如: r=127 g=20 b=40,则 brightest_color=127*2 约等于 255, g=20*2=40 b=40*2=80
# brightest_color的 r g b 就等于 255 40 80
# 请实现以下代码:
# TODO:
#
#
# return brightest_color
def
brightest
(
color
):
if
isinstance
(
color
,
tuple
):
r
,
g
,
b
=
color
elif
isinstance
(
color
,
list
):
r
,
g
,
b
=
color
b_color
=
[
r
,
g
,
b
]
max_value
=
max
(
r
,
g
,
b
)
if
max_value
<
255
:
multiplier
=
255
/
max_value
b_color
=
[
value
*
multiplier
if
value
*
multiplier
<=
255
else
255
for
value
in
b_color
]
r
,
g
,
b
=
int
(
b_color
[
0
]),
int
(
b_color
[
1
]),
int
(
b_color
[
2
])
if
isinstance
(
color
,
tuple
):
return
r
,
g
,
b
elif
isinstance
(
color
,
list
):
return
[
r
,
g
,
b
]
def
trail_color_brightest
(
bodies
):
"""
天体尾巴最亮
@param bodies:
@return:
"""
for
body
in
bodies
:
c
=
body
.
trail_color
if
c
is
None
:
c
=
body
.
color
if
c
is
None
:
c
=
(
255
,
255
,
255
)
bc
=
brightest
(
c
)
body
.
trail_color
=
bc
def
adjust_brightness
(
color
,
target_brightness
:
float
=
0.6
):
def
adjust_brightness
(
color
,
target_brightness
:
float
=
0.6
):
"""
"""
调整颜色的亮度到目标 target_brightness(确保亮度不超过 1.0)
调整颜色的亮度到目标 target_brightness(确保亮度不超过 1.0)
...
@@ -68,3 +116,7 @@ def get_inverse_color(color):
...
@@ -68,3 +116,7 @@ def get_inverse_color(color):
inverse_g
=
255
-
g
inverse_g
=
255
-
g
inverse_b
=
255
-
b
inverse_b
=
255
-
b
return
inverse_r
,
inverse_g
,
inverse_b
return
inverse_r
,
inverse_g
,
inverse_b
if
__name__
==
'__main__'
:
print
(
brightest
((
100
,
20
,
50
)))
sim_scenes/solar_system/halley_comet_sim.py
浏览文件 @
f0f3be5c
...
@@ -12,6 +12,7 @@ from ursina import camera, application
...
@@ -12,6 +12,7 @@ from ursina import camera, application
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
common.celestial_data_service
import
get_init_pos_vels
,
init_bodies_pos_vels
from
common.celestial_data_service
import
get_init_pos_vels
,
init_bodies_pos_vels
from
common.color_utils
import
brightest
,
trail_color_brightest
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.func
import
calculate_distance
from
common.func
import
calculate_distance
from
objs
import
HalleComet
,
Obj
from
objs
import
HalleComet
,
Obj
...
@@ -55,7 +56,7 @@ class HalleyCometSim:
...
@@ -55,7 +56,7 @@ class HalleyCometSim:
self
.
pluto
,
# 冥王星
self
.
pluto
,
# 冥王星
]
]
# endregion
# endregion
trail_color_brightest
(
self
.
bodies
)
init_bodies_pos_vels
(
self
.
bodies
)
init_bodies_pos_vels
(
self
.
bodies
)
def
build_halley_comet
(
self
):
def
build_halley_comet
(
self
):
...
...
sim_scenes/solar_system/halley_comet_sim_02.py
浏览文件 @
f0f3be5c
...
@@ -12,6 +12,7 @@ from ursina import camera, application
...
@@ -12,6 +12,7 @@ from ursina import camera, application
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
common.celestial_data_service
import
get_init_pos_vels
,
init_bodies_reality_pos_vels
from
common.celestial_data_service
import
get_init_pos_vels
,
init_bodies_reality_pos_vels
from
common.color_utils
import
trail_color_brightest
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.func
import
calculate_distance
from
common.func
import
calculate_distance
from
objs
import
HalleComet
,
Obj
from
objs
import
HalleComet
,
Obj
...
@@ -62,7 +63,7 @@ class HalleyCometSim:
...
@@ -62,7 +63,7 @@ class HalleyCometSim:
self
.
neptune
,
# 海王星
self
.
neptune
,
# 海王星
]
]
# endregion
# endregion
trail_color_brightest
(
self
.
bodies
)
init_bodies_reality_pos_vels
(
self
.
bodies
)
init_bodies_reality_pos_vels
(
self
.
bodies
)
def
build_halley_comet
(
self
):
def
build_halley_comet
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录