in src/spg_icvfxpatterns/PatternGenerators/alignment.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
)
# We create an image for the resolution of our panel
panel_image = cls.create_solid_color_image(
led_wall.panel.panel_resolution_width,
led_wall.panel.panel_resolution_height,
color=[0, 0, 0]
)
# We add a border of given border width and color
if cls.enable_border:
_imageUtils.add_border_to_image(
panel_image, cls.border_width, border_color=cls.border_color)
centre_x_pos = int(led_wall.panel.panel_resolution_width * 0.5)
centre_y_pos = int(led_wall.panel.panel_resolution_height * 0.5)
half_width_border = int(cls.width + (cls.line_border_width * 2) * 0.5)
half_width = int(cls.width * 0.5)
start_border_range = 0 - half_width
end_border_range = 0 + half_width
start_range = 0 - half_width_border
end_range = 0 + half_width_border
for x in range(start_range, end_range, 1):
color = cls.line_color
if x < start_border_range or x > end_border_range:
color = cls.line_border_color
oiio.ImageBufAlgo.render_line(
panel_image, centre_x_pos + x, 0, centre_x_pos + x, led_wall.panel.panel_resolution_height, color=color,
skip_first_point=False
)
for y in range(start_range, end_range, 1):
color = cls.line_color
if y < start_border_range or y > end_border_range:
color = cls.line_border_color
oiio.ImageBufAlgo.render_line(
panel_image, 0, centre_y_pos + y, int(led_wall.panel.panel_resolution_width * 0.5) - (cls.line_border_width * 2),
centre_y_pos + y, color=color, skip_first_point=False
)
oiio.ImageBufAlgo.render_line(
panel_image, int(led_wall.panel.panel_resolution_width * 0.5) + (cls.line_border_width * 2), centre_y_pos + y,
led_wall.panel.panel_resolution_width,
centre_y_pos + y, color=color, skip_first_point=False
)
for panel_count_width in range(led_wall.panel_count_width):
x_offset = led_wall.panel.panel_resolution_width * panel_count_width
for panel_count_height in range(led_wall.panel_count_height):
y_offset = led_wall.panel.panel_resolution_height * panel_count_height
per_panel_image = panel_image.copy()
# We insert the panel image into the whole led wall image
oiio.ImageBufAlgo.paste(
led_wall_image, x_offset, y_offset, 0, 0, per_panel_image, roi=oiio.ROI.All
)
# 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
)