From c973384b5caf2cb258bca557e75545a126d31fde Mon Sep 17 00:00:00 2001 From: march3 Date: Wed, 5 Apr 2023 09:47:15 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bodies/color_body.py | 3 ++- sim_scenes/funny/utils/body_utils.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bodies/color_body.py b/bodies/color_body.py index 131ec70..088b3d8 100644 --- a/bodies/color_body.py +++ b/bodies/color_body.py @@ -29,7 +29,8 @@ class ColorBody(Body): self.color = color texture = self.gen_texture(texture, texture_bright, texture_contrast) if rotation_speed is None: - rotation_speed = random.randint(10, 100) / 50 + # 旋转方向随机 + rotation_speed = random.randint(10, 100) / 50 - 1 params = { "name": name, "mass": mass, diff --git a/sim_scenes/funny/utils/body_utils.py b/sim_scenes/funny/utils/body_utils.py index 27f6ccc..caceae2 100644 --- a/sim_scenes/funny/utils/body_utils.py +++ b/sim_scenes/funny/utils/body_utils.py @@ -83,7 +83,7 @@ def gen_bodies_from_image(pixel_image, params, texture="color_body.png"): # 获取像素的颜色 pixel = img.getpixel((w, h)) # 对于纯白色的颜色,就忽略,不生成星球(这样图片中,纯白色越多,对电脑的压力就越小) - if pixel[0] >= 255 and pixel[1] >= 255 and pixel[1] >= 255: + if pixel[0] >= 220 and pixel[1] >= 220 and pixel[1] >= 220: continue body_str = body_template % (f"星球{w}:{h}", pixel[0], pixel[1], pixel[2], scale * 10, (width - w) * interval_factor, (height - h) * interval_factor, scale) -- GitLab