def _draw_celestial_bodies(self, context): for planet in self.sun.planets: if not planet.visible: continue radius = get_planet_scale_radius(self.width, self.height, planet, self.zoom) if self.big_planets: radius = min(10 * radius, 35) x = self.x + planet.x + self.width / 2.0 y = self.y + planet.y + self.height / 2.0 context.set_source_rgb(*planet.color) context.arc(x, y, radius, 0, 2 * math.pi) context.fill() if self.show_orbits: radius = au_to_pixels(self.width, self.height, planet.orbital_radius, self.zoom) + get_sun_scale_radius( self.width, self.height, self.zoom) context.set_source_rgb(*planet.color) context.arc(self.x + self.width / 2, self.y + self.height / 2, radius, 0, 2 * math.pi) context.stroke() for satellite in planet.natural_satellites: if not satellite.visible: continue radius = get_planet_scale_radius(self.width, self.height, satellite, self.zoom) if radius >= 1: context.set_source_rgb(*satellite.color) context.arc(x + satellite.x, y + satellite.y, radius, 0, 2 * math.pi) context.fill() for body in self.get_all_bodies(): if not body.preselected or not body.visible: continue x = self.x + body.x + self.width / 2.0 y = self.y + body.y + self.height / 2.0 if self.big_planets: radius = min(10 * radius, 35) context.set_source_rgb(*Color.SELECTED) context.arc(x, y, self.get_body_radius(body), 0, 2 * math.pi) context.stroke() break radius = get_sun_scale_radius(self.width, self.height, self.zoom) context.set_source_rgb(*self.sun.color) context.arc(self.x + self.width / 2, self.y + self.height / 2, radius, 0, 2 * math.pi) context.fill()
def get_body_radius(self, body): if body.name == BodyName.SUN: return get_sun_scale_radius(self.width, self.height, self.zoom) else: return get_planet_scale_radius(self.width, self.height, body, self.zoom)
def calculate_position(self, width, height, zoom): radius = km_to_pixels(width, height, self.radius, zoom) distance = au_to_pixels(width, height, self.orbital_radius, zoom) distance += get_planet_scale_radius(width, height, self.around_the, zoom) distance += radius * 2 + zoom self.x = distance * math.sin(self.angle * math.pi / 180.0) self.y = distance * math.cos(self.angle * math.pi / 180.0)