示例#1
0
 def set_color(self, color):
     """
     Sets the color to the specified value
     :param color: the color
     """
     self.color = convert_color(color)
     self.reload_text()
示例#2
0
 def draw_polygon(self, color, points:list, width:int=0):
     """
     Draws a polygon to the screen
     :param color: The color of the polygon
     :param points: the list of points (ex: [(x1, y1), (x2, y2), (x3, y3)] ) The first and last points will connect. Must have more than 3 points.
     :param width: the line thickness of the polygon (0 to fill completly)
     :return: the rectangle which surrounds this object (pygame rect)
     """
     return pygame.draw.polygon(self.screen, convert_color(color), points, width)
示例#3
0
 def draw_aalines(self, color, closed: bool, points: list, width: int = 1):
     """
     Draws a series of antialiased lines to the screen
     :param color: the color of the lines
     :param closed: if the engine should draw an additional line between the first an last point
     :param points: a list of points to be connected by lines (ex: [(x1, y1), (x2, y2), (x3, y3)] ) Must have more than 3 points.
     :param width: the line thicknesses
     :return: the rectangle which surrounds this object (pygame rect)
     """
     return pygame.draw.aalines(self.screen, convert_color(color), closed, points, width)
示例#4
0
 def draw_circle(self, color, x:int, y:int, radius:int, width:int=0):
     """
     Draws a circle to the screen
     :param color: the color of the circle
     :param x: the x position of the circle
     :param y: the y position of the circle
     :param radius: the radius of the circle
     :param width: the line thickness of the circle (0 to fill completly)
     :return: the rectangle which surrounds this object (pygame rect)
     """
     return pygame.draw.circle(self.screen, convert_color(color), (x, y), radius, width)
示例#5
0
 def draw_aaline(self, color, x1: int, y1: int, x2: int, y2: int, width: int = 1):
     """
     Draws an antialiased line to the screen
     :param color: the color of the line
     :param x1: the x position of the line's starting point
     :param y1: the y position of the line's starting point
     :param x2: the x position of the line's ending point
     :param y2: the y position of the line's ending point
     :param width: the line thickness
     :return: the rectangle which surrounds this object (pygame rect)
     """
     return pygame.draw.aaline(self.screen, convert_color(color), (x1, y1), (x2, y2), width)
示例#6
0
 def draw_elipse(self, color, x:int, y:int, w:int, h:int, width:int=0):
     """
     Draws an elipse to the screen
     :param color: the color of the circle
     :param x: the x position of the elipse
     :param y: the y position of the elipse
     :param w: the width of the elipse
     :param h: the height of the elipse
     :param width: the line thickness of the elipse (0 to fill completly)
     :return: the rectangle which surrounds this object (pygame rect)
     """
     return pygame.draw.ellipse(self.screen, convert_color(color), (x, y, w, h), width)
示例#7
0
 def draw_arc(self, color, x:int, y:int, w:int, h:int, angle1:float, angle2:float, width:int=1):
     """
     Draws an arc to the screen
     :param color: the color of the arc
     :param x: the x position of the arc
     :param y: the y position of the arc
     :param w: the width of the arc
     :param h: the height of the arc
     :param angle1: The starting angle in radians
     :param angle2: The ending angle in radians
     :param width: the line thickness of the arc
     :return: the rectangle which surrounds this object (pygame rect)
     """
     return pygame.draw.arc(self.screen, convert_color(color), (x, y, w, h), angle1, angle2, width)
示例#8
0
 def __init__(self, screen, data: dict, custom_objects: typing.List,
              parent):
     """
     The object which manages, and stores every object in a room
     NOTE: Only key functions are documented, which are available to each object via the "parent" variable in each class
     """
     ScreenBase.__init__(self, screen)
     self.tasks = []
     self.name = get_mandatory(data, "@name")
     self.props = ASQL()
     self.custom_objects = custom_objects
     self.parent = parent
     self.data = data
     self.background_color = convert_color(
         get_optional(data, "@color", self.parent.background_color))
     self.load_room()
示例#9
0
    def __init__(self, screen: pygame.Surface, args: dict, parent: 'Room'):
        ObjectBase.__init__(self, screen, args, parent)

        self.font = get_font(self.get_mandatory_arguement(
            "font", str))  # type: pygame.font.Font

        self.text = self.get_mandatory_arguement("text", str)
        self.antialiasing = bool(
            self.get_optional_arguement("antialiasing",
                                        1,
                                        int,
                                        blank_means_unset=True))
        self.color = utils.convert_color(
            self.get_optional_arguement("color",
                                        "White",
                                        str,
                                        blank_means_unset=True))

        self.text_object = None
        self.rebuild_text_object()
示例#10
0
    def __init__(self,
                 screen: pygame.Surface,
                 font: str,
                 text: str,
                 color,
                 antialiasing=True):
        """
        This class is to be used for all objects which are represented on the screen by text
        :param screen: The main pygame surface to draw the text to
        :param font: The reference to the font in the cache to use
        :param text: The text to render in the font
        :param color: The color to draw the text
        :param antialiasing: If antialiasing should be used
        """
        DisplayBase.__init__(self)
        self.color = convert_color(color)
        self.screen = screen
        self.font = get_font(font)
        self.text = text
        self.antialiasing = antialiasing

        self.text_object = None

        self.reload_text()
示例#11
0
 def set_color(self, color: str):
     self.color = utils.convert_color(color)
     self.rebuild_text_object()