Esempio n. 1
0
    def calculate_led_size(self):
        """
        Calculate the led size for each cell.

        :return: None
        """

        if self.draw_borders:
            self.border_size = Vector2(config.get("BORDER_SIZE"))
        else:
            self.border_size = Vector2(0, 0)

        width = self.cell_size.x - (self.border_size.x * 2)
        height = self.cell_size.y - (self.border_size.y * 2)

        self.led_size = vector2_to_floor(Vector2(width, height))

        self.led_surface = pygame.Surface(self.led_size)

        # Check that the LED size is at least 1px
        if self.led_size.x <= 1.0 or self.led_size.y <= 1.0:
            log.error(
                "LED border size is to large for calculated LED size '(%s, %s) pixels'",
                self.cell_size.x, self.cell_size.y)
            raise Exception("LED border size is to large.")
Esempio n. 2
0
    def calculate_cell_size(self, max_grid_pixel_size):
        """
        Given the max grid pixel size, determine the size of the individual grid cells.

        :param max_grid_pixel_size: pygame.math.Vector2 of the max size of the whole grid.
        :return: None
        """

        width = max_grid_pixel_size.x / float(self.grid_size.x)
        height = max_grid_pixel_size.y / float(self.grid_size.y)

        # Check that the LED size is at least 1px
        if width <= 1.0 or height <= 1.0:
            log.error(
                "Calculated LED cell size less than 1 pixel.  The WINDOW_SIZE is to small to fit "
                "the configured GRID_SIZE")
            raise Exception("LED size less than 1 pixel")

        # Sqaure up the LED
        if config.get("SQUARE_LED"):
            if width < height:
                height = width
            else:
                width = height

        self.cell_size = vector2_to_floor(Vector2(width, height))
Esempio n. 3
0
    def calculate_cell_size(self, max_grid_pixel_size):
        """
        Given the max grid pixel size, determine the size of the individual grid cells.

        :param max_grid_pixel_size: pygame.math.Vector2 of the max size of the whole grid.
        :return: None
        """

        width = max_grid_pixel_size.x / float(self.grid_size.x)
        height = max_grid_pixel_size.y / float(self.grid_size.y)

        # Check that the LED size is at least 1px
        if width <= 1.0 or height <= 1.0:
            log.error("Calculated LED cell size less than 1 pixel.  The WINDOW_SIZE is to small to fit "
                      "the configured GRID_SIZE")
            raise Exception("LED size less than 1 pixel")

        # Sqaure up the LED
        if config.get("SQUARE_LED"):
            if width < height:
                height = width
            else:
                width = height

        self.cell_size = vector2_to_floor(Vector2(width, height))
Esempio n. 4
0
    def calculate_led_size(self):
        """
        Calculate the led size for each cell.

        :return: None
        """

        if self.draw_borders:
            self.border_size = Vector2(config.get("BORDER_SIZE"))
        else:
            self.border_size = Vector2(0, 0)

        width = self.cell_size.x - (self.border_size.x * 2)
        height = self.cell_size.y - (self.border_size.y * 2)

        self.led_size = vector2_to_floor(Vector2(width, height))

        self.led_surface = pygame.Surface(self.led_size)

        # Check that the LED size is at least 1px
        if self.led_size.x <= 1.0 or self.led_size.y <= 1.0:
            log.error("LED border size is to large for calculated LED size '(%s, %s) pixels'",
                      self.cell_size.x, self.cell_size.y)
            raise Exception("LED border size is to large.")