def Shape_Circle(DISPLAY, X, Y, Radius, Color, Width=0, draw_top_right=False, draw_top_left=False, draw_bottom_left=False, draw_bottom_right=False): """ Draw a Circle :param DISPLAY:Surface to draw :param X:Circle X :param Y:Circle Y :param Radius:Circle Radius :param Color:Color (RGB) :param Width:Circle Width :param draw_top_right:Draw top right :param draw_top_left:Draw top left :param draw_bottom_left:Draw bottom left :param draw_bottom_right:Draw bottom right :return: """ if X - Radius < DISPLAY.get_width() and Y - Radius < DISPLAY.get_height( ) and X > -Radius and Y > -Radius and Radius > 1: Color = UTILS.FixColorRange(Color) pygame.draw.circle(DISPLAY, Color, (X, Y), Radius, Width, draw_top_right, draw_top_left, draw_bottom_left, draw_bottom_right)
def PreRender_ShapeRectangle(Rectangle, Color, BorderRadius, Border_TopRight_Radius, Border_TopLeft_Radius, Border_BottomLeft_Radius, Border_BottomRight_Radius, BorderWidth, DrawLines): PreRenderSurface = pygame.Surface( (Rectangle[2], Rectangle[3]), pygame.SRCALPHA | pygame.HWACCEL | pygame.HWSURFACE) # -- Fix the Color Range -- # Color = UTILS.FixColorRange(Color) # Set Opacity PreRenderSurface.set_alpha(Color[3]) # -- Border Radius-- # if BorderRadius > 0 and Border_TopRight_Radius == 0 and Border_TopLeft_Radius == 0 and Border_BottomLeft_Radius == 0 and Border_BottomRight_Radius == 0: Border_TopRight_Radius = BorderRadius Border_TopLeft_Radius = BorderRadius Border_BottomRight_Radius = BorderRadius Border_BottomLeft_Radius = BorderRadius # -- Render the Rectangle -- # if not DrawLines: pygame.draw.rect(PreRenderSurface, Color, (0, 0, Rectangle[2], Rectangle[3]), BorderWidth, BorderRadius, Border_TopLeft_Radius, Border_TopRight_Radius, Border_BottomLeft_Radius, Border_BottomRight_Radius) else: gFxdraw.rectangle(PreRenderSurface, (0, 0, Rectangle[2], Rectangle[3]), Color) return PreRenderSurface
def Shape_Line(DISPLAY, Color, startX, startY, endX, endY, LineWidth, FoldLine=True): """ Draw a Line :param DISPLAY:Surface to be drawn :param Color:Color (RGB) :param startX:Line StartX :param startY:Line StartY :param endX:Line EndX :param endY:Line EndY :param LineWidth:Line Width :param FoldLine:Fold the line when getting offscreen :return: """ # -- Fix the Color Range -- # Color = UTILS.FixColorRange(Color) if FoldLine: if endX > DISPLAY.get_width(): endX = DISPLAY.get_width() if endY > DISPLAY.get_height(): endY = DISPLAY.get_height() if startX < 0: startX = 0 if startY < 0: startY = 0 pygame.draw.line(DISPLAY, Color, (startX, startY), (endX, endY), LineWidth)
def FontRender(self, DISPLAY, FontFileLocation, Size, Text, ColorRGB, X, Y, antialias=True, Opacity=255): """ Render a Text using a font loaded into Taiyou Font Cache :param DISPLAY:Surface Name :param FontFileLocation:Font Resource Name [starting with /] :param Size:Font Size :param Text:Text to be Rendered :param ColorRGB:Color in RGB Format [R, G, B] :param X:X Location :param Y:Y Location :param antialias:Smooth Pixels [This option can decrea se peformace] :return: """ if not FontRenderingDisabled: # -- Get the FontFileObject, required for all functions here -- # FontFileObject = self.GetFont_object(FontFileLocation, Size) ColorRGB = UTILS.FixColorRange(ColorRGB) if X <= DISPLAY.get_width( ) and Y <= DISPLAY.get_height() and X >= -FontFileObject.render( Text, antialias, ColorRGB ).get_width() and Y >= -FontFileObject.render( Text, antialias, ColorRGB).get_height() and not Text == "": # -- Fix Opacity Range -- # if Opacity < 0: Opacity = 0 if Opacity > 255: Opacity = 255 # -- Render Multiple Lines -- # for i, l in enumerate(Text.splitlines()): # FontSurface Object FontSurface = FontFileObject.render(l, antialias, ColorRGB) # Set Font Opacity FontSurface.set_alpha(Opacity) # Blit Font Surface DISPLAY.blit(FontSurface, (X, Y + Size * i))