geepillow.blocks ================ .. py:module:: geepillow.blocks .. autoapi-nested-parse:: Blocks module. Blocks are the basic units to use in strips and grids, and do not overlay with each other. There are 2 types: - ImageBlock: contains an image inside. - TextBlock: contains text inside. If the user needs to add text overlaying the image, can do it using the PIL library. Attributes ---------- .. autoapisummary:: geepillow.blocks.DEFAULT_FONT geepillow.blocks.DEFAULT_MODE geepillow.blocks.FontType geepillow.blocks.PositionType Classes ------- .. autoapisummary:: geepillow.blocks.Block geepillow.blocks.ImageBlock geepillow.blocks.TextBlock Module Contents --------------- .. py:class:: Block(size = DEFAULT_SIZE, background_color = 'white', background_opacity = 1, mode = DEFAULT_MODE) Basic Block. The background will always be an image that will cover the whole block. Then the inner element will be painted on top of the background image. This object is mutable. All properties, except "element" can be modified. :param size: size of the block in pixels. :param background_color: color of the background. :param background_opacity: opacity of the background. :param mode: mode of the background image. .. py:method:: set_size(size) Set or modify the size of the block. .. py:attribute:: DEFAULT_SIZE :value: (500, 500) .. py:attribute:: _background_color .. py:attribute:: _size :value: (500, 500) .. py:property:: background_color Background color. .. py:property:: background_hex Background hex color. .. py:property:: background_image The background image. .. py:attribute:: background_opacity :value: 1 .. py:property:: height Height of the block. .. py:property:: image For basic blocks the image is the background image. .. py:attribute:: mode :value: 'RGBA' .. py:property:: size Size of the block. .. py:property:: width Width of the block. .. py:class:: ImageBlock(image, position = 'center-center', fit_block = True, keep_proportion = True, size = None, background_color = 'white', background_opacity = 1, mode = DEFAULT_MODE) Bases: :py:obj:`Block` Image Block for PIL images. :param image: the image. :param position: position of the image inside the block. :param fit_block: if True the element's boundaries will never exceed the block. :param keep_proportion: keep proportion (ratio) of the image. :param size: size of the block (not the image). Defaults to the image size. :param background_color: color of the background. :param background_opacity: opacity of the background. :param mode: mode of the background image. .. py:method:: from_file(filename, **kwargs) :classmethod: Create an ImageBlock from a file. .. py:attribute:: _image .. py:property:: element :type: PIL.Image.Image Element. The original image will be modified according to size of the block and properties fit_block and keep_proportion. .. py:attribute:: fit_block :value: True .. py:property:: image :type: PIL.Image Image of the block. .. py:attribute:: keep_proportion :value: True .. py:attribute:: position :value: 'center-center' .. py:property:: xy Coordinates (X,Y) of the top-left corner of the inner image. .. py:class:: TextBlock(text, position = 'center-center', font = DEFAULT_FONT, text_color = 'black', text_opacity = 1, background_color = 'white', background_opacity = 1, fit_block = False, keep_proportion = True, size = None, mode = DEFAULT_MODE) Bases: :py:obj:`ImageBlock` TextBlock. :param text: text to display. :param position: position of the text inside the block. :param font: font to use. The size the font is included in this parameter. :param text_color: color of the text. :param text_opacity: opacity of the text. :param background_color: color of the background. :param background_opacity: opacity of the background. :param fit_block: if True the element' :param keep_proportion: keep proportion (ratio) of the image. :param size: size of the block (not the image). Defaults to the image size. :param mode: mode of the background image. .. py:method:: create_text_image() Create a text image. .. py:attribute:: _background_color .. py:attribute:: _font .. py:attribute:: _text .. py:attribute:: _text_color .. py:attribute:: background_opacity :value: 1 .. py:property:: font Font to use. .. py:attribute:: mode :value: 'RGBA' .. py:property:: text :type: str Text to display. .. py:property:: text_color :type: geepillow.colors.Color Text color. .. py:property:: text_height :type: int Calculate height for a multiline text. .. py:attribute:: text_opacity :value: 1 .. py:property:: text_width :type: int Calculate width for a multiline text. .. py:data:: DEFAULT_FONT .. py:data:: DEFAULT_MODE :value: 'RGBA' .. py:data:: FontType .. py:data:: PositionType