def draw( self, surface, color=None, line_thickness=-1, pos_delta=None, frame_image_reference_pos=None, scale=1, radius=None, ): """draws a circle on a surface surface: the pygame surface to draw the circle on""" if color == None: color = self.color if radius == None: radius = 0.5 * mathfuncs.distance(self.endPoint1.pos, self.endPoint2.pos) pos = mathfuncs.midpoint(self.endPoint1.pos, self.endPoint2.pos) if frame_image_reference_pos != None: pos = scale_image_point(pos, frame_image_reference_pos, scale) radius = radius * scale if pos_delta != None: pos = move_image_point(pos, pos_delta) if line_thickness == -1: line_thickness = self.thickness if radius < line_thickness: line_thickness = radius pygame.draw.circle(surface, color, (int(pos[0]), int(pos[1])), int(radius)) # , \
def get_top_right_reference_position(self): x_half_length = 0.5 * abs(self.endPoint1.pos[0] - self.endPoint2.pos[0]) y_half_length = 0.5 * abs(self.endPoint1.pos[1] - self.endPoint2.pos[1]) pos = mathfuncs.midpoint(self.endPoint1.pos, self.endPoint2.pos) return (int(pos[0] + x_half_length), int(pos[1] - y_half_length))
def draw_outer_circle(circle, color, surface): radius = (.5 * mathfuncs.distance(circle.endPoint1.pos, \ circle.endPoint2.pos)) pos = mathfuncs.midpoint(circle.endPoint1.pos, circle.endPoint2.pos) pygame.draw.circle(surface, \ color, \ (int(pos[0]), int(pos[1])), \ int(radius))
def get_top_left_and_bottom_right(self): position = mathfuncs.midpoint(self.endPoint1.pos, self.endPoint2.pos) position = (int(position[0]), int(position[1])) radius = int(mathfuncs.distance(self.endPoint1.pos, self.endPoint2.pos) / 2) point_radius = max(self.endPoint1.radius, self.endPoint2.radius) point1_top_left, point1_bottom_right = self.endPoint1.get_top_left_and_bottom_right() point2_top_left, point1_bottom_right = self.endPoint2.get_top_left_and_bottom_right() return ( ( position[0] - radius - self.thickness - point_radius, position[1] - radius - self.thickness - point_radius, ), ( position[0] + radius + self.thickness + point_radius, position[1] + radius + self.thickness + point_radius, ), )
def get_top_right_reference_position(self): radius = 0.5 * mathfuncs.distance(self.endPoint1.pos, self.endPoint2.pos) pos = mathfuncs.midpoint(self.endPoint1.pos, self.endPoint2.pos) return (int(pos[0] + radius), int(pos[1] - radius))
def center(self): return mathfuncs.midpoint(self.endPoint1.pos, self.endPoint2.pos)