Esempio n. 1
0
def region_text(image: np.array, display_text: str):
    """ Write text into the specified region, with the anchor. """
    region = create_region_with_padding(image, 15)
    return text.write_into_region(image=image,
                                  text=display_text,
                                  region=region,
                                  show_region_outline=True)
Esempio n. 2
0
def small_text(image: np.array, display_text: str):
    """ Write text into the specified region, with the anchor. """
    region = create_region_with_padding(image, 15)
    return text.write_into_region(image=image,
                                  text=display_text,
                                  region=region,
                                  font_size=12)
Esempio n. 3
0
def region_with_bg(image: np.array, display_text: str):
    """ Write text into the specified region, with a solid BG. """
    region = create_region_with_padding(image, 15)
    return text.write_into_region(image=image,
                                  text=display_text,
                                  region=region,
                                  bg_color=(0, 0, 0))
Esempio n. 4
0
def overlay_text(image: np.array, display_text: str):
    """ Write text into the specified region, with the anchor. """
    region = create_region_with_padding(image, 15)
    return text.write_into_region(image=image,
                                  text=display_text,
                                  region=region,
                                  color=(0, 255, 0),
                                  overlay=True)
Esempio n. 5
0
def region_with_clear_bg(image: np.array, display_text: str):
    """ Write text into the specified region, with a transparent BG. """
    region = create_region_with_padding(image, 15)
    return text.write_into_region(image=image,
                                  text=display_text,
                                  region=region,
                                  bg_color=(0, 0, 0),
                                  bg_opacity=0.5)
Esempio n. 6
0
def inline_icon_center(image: np.array, display_text: str):
    """ Write text into the specified region, with a transparent BG. """
    region = create_region_with_padding(image, 15)
    return text.write_into_region(image=image,
                                  text=display_text,
                                  region=region,
                                  icon=u"\uf447",
                                  pad=12,
                                  show_region_outline=True)
Esempio n. 7
0
    def test_region_rendering(self):
        """ Able to use text-region writing functions without fail. """
        region = Region(10, 100, 10, 100)

        # Test all the different branches of this function.
        self.validate(text.write_into_region(self.image, "Hell World", region))
        self.validate(text.write_into_region(self.image, "Hell World", region, overlay=True))
        self.validate(text.write_into_region(self.image, "Hell World", region, h_align=text.ALIGN_LEFT))
        self.validate(text.write_into_region(self.image, "Hell World", region, h_align=text.ALIGN_RIGHT))
        self.validate(text.write_into_region(self.image, "Hell World", region,
                                             icon=u"\uf007", show_region_outline=True))

        # Test Region edge cases.
        self.validate(text.write_into_region(self.image, "Hell World", Region(-50, 50, 450, 550), font_size=42))
        self.validate(text.write_into_region(self.image, "Hell World", Region(450, 550, -50, 50), font_size=42))

        # Test Region labelling.
        self.validate(text.label_region(self.image, "Hello World", region))
        self.validate(text.label_region(self.image, "Hello World", region, show_at_bottom=True))
        self.validate(text.label_region(self.image, "Hello World", region, inside=True))