def generator()

in src/spg_icvfxpatterns/PatternGenerators/bitdepth.py [0:0]


    def generator(cls, frame, kwargs, results):
        """ The method which creates the checkerboard images based on the kwargs provided

        :param frame: the frame number we are generating
        :param kwargs: a dictionary of the arguments for the generator
        :param results: a dictionary to store the results
        """
        led_wall = kwargs.get("led_wall", None)
        if led_wall is None:
            raise ValueError("led_wall not found in kwargs")

        frame_num, full_file_path = cls.get_frame_num_and_file_path(frame, led_wall.name)

        led_wall_image = cls.create_solid_color_image(
            led_wall.resolution_width, led_wall.resolution_height
        )

        # Calculate the code values for the given bit depth
        image_bit_depth = cls.bit_depth_value
        min_code_value = 0
        max_code_value = (2 ** image_bit_depth)

        # How many rows of pixels do we need to display all the code values
        number_of_rows = int(math.ceil(max_code_value/led_wall.resolution_width))

        # We assume the whole height of the led wall for the length of the strip per code value
        # and each code value is a single pixel wide
        per_value_height = led_wall.resolution_height
        per_value_width = 1

        # If we can't fit each code value on a single line we need to do multiple rows and the height of each strip
        # calculated so all rows can fit on the led wall but fill as much of it as possible
        if number_of_rows > 1:
            per_value_height = int(led_wall.resolution_height/number_of_rows)
        else:
            # If we can fit all values on a single row, we make each of the strips wider so we fill the led wall as
            # much as possible
            per_value_width = int(led_wall.resolution_width/max_code_value)

        x_value = 0
        y_value = 0
        for code_value in range(max_code_value+1):
            norm_code_value = normalize(code_value, min_code_value, max_code_value)
            for x in range(per_value_width):
                for y in range(per_value_height):
                    led_wall_image.setpixel(
                        x + x_value,
                        y + y_value, 0,
                        [norm_code_value, norm_code_value, norm_code_value])

            x_value += per_value_width
            if x_value == led_wall.resolution_width:
                x_value = 0
                y_value += per_value_height

        # Write the image to disk and store the result
        cls.write_image_and_store_result(
            frame_num, full_file_path, led_wall.name, led_wall_image, results
        )