cardassembler module¶
Main script which handles communication with Gimp.
All code using gimpfu
is here. The rest can be found in blueprint
module.
Written for Gimp 2.10.18 which uses
Python 2.7.18.
Probably: Gimp runs this script through eval()
function inside
its installation folder and direct import from different folder raises
access denied error. See _run_code()
function in
Gimp installation folder/lib/python2.7/runpy.py
.
-
cardassembler.
card_creator
(data_folder, xml_file, card_IDs, save)[source]¶ Create board-game cards.
Registered function by
gimpfu.register()
. Main plugin functionality. Add “keepCmdOpen” among cardIDs to keep the cmd window open.
-
cardassembler.
palette_creator
(data_folder, xml_file, palette_ID, name)[source]¶ Create palette.
Registered function by
gimpfu.register()
. Supplemental plugin functionality.
-
class
cardassembler.
Toolbox
(data_folder, xml_file)[source]¶ Blueprint-to-image manipulation tool.
This class offers means for creating common card components (i.e. text, icons). Then completes the image and optionally saves it. Probably you’ll want to fine-tune the image manually.
- Parameters
-
create_image
(card_ID)[source]¶ Blueprint to image.
Layout consists of commands which are called alphabetically by name.
- Parameters
card_ID (str) – Path to the starting node.
- Raises
RuntimeError – If there is no blueprint
KeyError – If any of the layers has no type
ValueError – If any of the layers has unknown type
-
_layer_image
(size, name='Card Assembler Image', **kwargs)[source]¶ Create new image. Needed for layer creation.
- Parameters
size (tuple) – Image dimensions in pixels
name (str) – Image name, defaults to “Card Assembler Image”
-
_layer_monochrome
(size, color, name='Monochrome', position=(0, 0), add_to_position=0, **kwargs)[source]¶ Single color filled layer.
- Parameters
size (tuple) – Layer dimensions in pixels
color (str) – Layer color in hex code
name (str, optional) – Layer name, defaults to “Monochrome”
position (tuple, optional) – Defaults to (0, 0)
add_to_position (int, optional) – Position among layers (-1 adds the layer to a recently defined group), defaults to 0
- Raises
RuntimeError – If there is no image
-
_layer_import_layer_load
(filename, name, **kwargs)[source]¶ Load new data image.
The file has to be in the data folder. Filename is specified in the XML file. Name parameter is used in the XML file to reference the imported file. That’s why it’s not an optional parameter.
-
_layer_import_layer
(target_file, target_layer, add_to_position=0, name=None, position=(0, 0), **kwargs)[source]¶ Copy layer from a data image.
- Parameters
target_file (str) – Use name filled in
import_layer_load
target_layer (str) – Name of the layer to be imported in the target file
add_to_position (int, optional) – Position among layers (-1 adds the layer to a recently defined group), defaults to 0
name (str or None, optional) – Layer name, defaults to target_layer
position (tuple, optional) – Defaults to (0, 0)
- Raises
RuntimeError – If there is no image
-
_layer_group
(add_to_position=0, name='Group', **kwargs)[source]¶ Create new layer group.
To fill next layers in, set theirs add_to_position parameter to
-1
.
-
_layer_text
(text, font, font_size, font_scale=1, add_to_position=0, name=None, color='#000000', size=None, line_spacing=0, letter_spacing=0, justification=0, position=(0, 0), **kwargs)[source]¶ Text layer.
- Parameters
text (str) – Text
font (str) – Font name
font_size (int) – Font size
font_scale (float, optional) – Multiply font_size, defaults to 1
add_to_position (int, optional) – Position among layers (-1 adds the layer to a recently defined group), defaults to 0
name (str or None, optional) – Layer name, defaults to None (Gimp default)
color (str, optional) – Text color in hex code, defaults to “#000000”
size (tuple or None) – Layer dimensions in pixels, defaults to None (autosize)
line_spacing (float, optional) – Line separation change, defaults to 0
letter_spacing (float, optional) – Letters separation change, defaults to 0
justification (int, optional) – Either left(0), right(1), center(2) or fill(3), defaults to 0
position (tuple, optional) – Defaults to (0, 0)
- Raises
RuntimeError – If there is no image
-
_layer_select
(mode='select', left=0, right=100, top=0, bottom=100, **kwargs)[source]¶ New selection by percentage of image size.
- Parameters
mode (str) – Either “select”, “select_invert” or “deselect”, defaults to “select”
left (float, optional) – Left edge position in percentage of the image size, defaults to 0
right (float, optional) – Right edge position in percentage of the image size, defaults to 100
top (float, optional) – Top edge position in percentage of the image size, defaults to 0
botton – Bottom edge position in percentage of the image size, defaults to 100
- Raises
RuntimeError – If there is no image
ArithmeticError – If width is not positive
ArithmeticError – If height is not positive
ValueError – If mode is unknown
-
_layer_mask
(target_layer, **kwargs)[source]¶ Mask layer.
Create a mask for the given layer from the given selection.
- Parameters
target_layer (str) – Layer to be masked
kwargs (various, optional) – Additional named arguments are passed to
select
-
_layer_hide
(**kwargs)[source]¶ Ignore command.
Used for overrides, i.e. hiding a predefined (template) layer.