Skip to main content

_get_str

Safely retrieve a string value from a dictionary.

_get_number

Safely retrieve a number (int or float) from a dictionary

_get_bool

Safely retrieve a boolean value from a dictionary.

_parse_json_output

Extract JSON output from a string.

_reload_image

dom_rectangle_from_dict

Create a DOMRectangle object from a dictionary.

interactive_region_from_dict

Create an :class:InteractiveRegion object from a dictionary.

visual_viewport_from_dict

Create a :class:VisualViewport object from a dictionary.

add_set_of_mark

_add_set_of_mark

Add a set of marks to the screenshot. Parameters:
  • screenshot (Image.Image): The screenshot to add marks to.
  • ROIs (Dict[str, InteractiveRegion]): The regions to add marks to.
Returns: Tuple[Image.Image, List[str], List[str], List[str]]: A tuple containing the screenshot with marked ROIs, ROIs fully within the images, ROIs located above the visible area, and ROIs located below the visible area.

_draw_roi

Draw a ROI on the image. Parameters:
  • draw (ImageDraw.ImageDraw): The draw object.
  • idx (int): The index of the ROI.
  • font (ImageFont.FreeTypeFont | ImageFont.ImageFont): The font.
  • rect (DOMRectangle): The DOM rectangle.

_get_text_color

Determine the ideal text color (black or white) for contrast. Parameters:
  • bg_color: The background color (R, G, B, A).
Returns: A tuple representing black or white color for text.

_get_random_color

Generate a consistent random RGBA color based on the identifier. Parameters:
  • identifier: The ID used as a seed to ensure color consistency.
Returns: A tuple representing (R, G, B, A) values.