Example #1
0
    def draw_on_texture(self, texture_path=None):
        '''Draws preinitialized image and its attributes on a texture

        If ``texture_path`` is set to ``None``, random texture from ``nider/textures`` will be taken.

        Args:
            texture_path (str): path of the texture to use.

        Raises:
            FileNotFoundError: if texture file at path ``texture_path`` cannot be found.
            nider.exceptions.ImageSizeFixedWarning: if the image size has to be adjusted to the provided content's size because the content takes too much space.
        '''
        if texture_path is None:
            texture_path = get_random_texture()
        elif not os.path.isfile(texture_path):
            raise FileNotFoundError(
                'Can\'t find texture {}. Please, choose an existing texture'.
                format(texture_path))
        if self.content.depends_on_opposite_to_bg_color:
            self.opposite_to_bg_color = generate_opposite_color(
                get_img_dominant_color(texture_path))
        self._create_image()
        self._create_draw_object()
        self._fill_image_with_texture(texture_path)
        self._draw_content()
        self._save()
Example #2
0
    def draw_on_texture(self, texture_path=None):
        '''Draws preinitialized image and its attributes on a texture

        Draws preinitiated image and its attributes on a texture. If texture_path
        is set to None, takes random textures from textures/

        Attributes:
            texture_path (str): path of the texture to use.
        '''
        if texture_path is None:
            texture_path = get_random_texture()
        elif not os.path.isfile(texture_path):
            raise FileNotFoundError(
                'Can\'t find texture {}. Please, choose an existing texture'.format(texture_path))
        if self.content.depends_on_opposite_to_bg_color:
            self.opposite_to_bg_color = generate_opposite_color(
                get_img_dominant_color(texture_path)
            )
        self._create_image()
        self._create_draw_object()
        self._fill_image_with_texture(texture_path)
        self._draw_content()
        self._save()
Example #3
0
 def test_fill_img_with_texture(self, mock):
     texture = get_random_texture()
     self.img._fill_image_with_texture(texture)
     self.assertTrue(mock.called)