geepillow.blocks#
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#
Classes#
Basic Block. |
|
Image Block for PIL images. |
|
TextBlock. |
Module Contents#
- class geepillow.blocks.Block(size=DEFAULT_SIZE, background_color='white', background_opacity=1, mode=DEFAULT_MODE)[source]#
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.
- Parameters:
size (tuple) – size of the block in pixels.
background_color (str | geepillow.colors.Color) – color of the background.
background_opacity (float) – opacity of the background.
mode (str) – mode of the background image.
- class geepillow.blocks.ImageBlock(image, position='center-center', fit_block=True, keep_proportion=True, size=None, background_color='white', background_opacity=1, mode=DEFAULT_MODE)[source]#
Bases:
BlockImage Block for PIL images.
- Parameters:
image (PIL.Image.Image) – the image.
position (tuple | PositionType) – position of the image inside the block.
fit_block (bool) – if True the element’s boundaries will never exceed the block.
keep_proportion (bool) – keep proportion (ratio) of the image.
size (tuple | None) – size of the block (not the image). Defaults to the image size.
background_color (str | geepillow.colors.Color) – color of the background.
background_opacity (float) – opacity of the background.
mode (str) – mode of the background image.
- classmethod from_file(filename, **kwargs)[source]#
Create an ImageBlock from a file.
- Parameters:
filename (str | pathlib.Path)
- class geepillow.blocks.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)[source]#
Bases:
ImageBlockTextBlock.
- Parameters:
text (str) – text to display.
position (tuple | PositionType) – position of the text inside the block.
font (FontType) – font to use. The size the font is included in this parameter.
text_color (str | geepillow.colors.Color) – color of the text.
text_opacity (float | int) – opacity of the text.
background_color (str | geepillow.colors.Color) – color of the background.
background_opacity (float | int) – opacity of the background.
fit_block (bool) – if True the element’
keep_proportion (bool) – keep proportion (ratio) of the image.
size (tuple | None) – size of the block (not the image). Defaults to the image size.
mode (str) – mode of the background image.
- property text_color: geepillow.colors.Color[source]#
Text color.
- Return type: