π Python APIο
Builderο
The CI/CD builder script.
- class confirm.ci.builder.Builder(image, names, templates_dir, build_dir)ο
The corporate identity / corporate design builder.
- Parameters:
image (str) β The image path
names (str) β The family names
- build()ο
Build all colour assets.
- build_ase()ο
Build the ASE file.
The βASEβ file is an βAdobe Swatch Exchangeβ file, thus the name. Unfortunately, the ASE file is a binary file which is using the big-endian format. Therefor we need to build the file manually.
- build_clr()ο
Build the CLR file.
The βCLRβ file is an βApple Color Listβ file. To create it, we need the self-compiled / written
json2clr
binary.
- build_css()ο
Build the CSS.
The CSS file can be used to implement the colours in a website.
- build_json()ο
Build the JSON file.
JSON files can be dumped via Python built-ins.
- build_rest()ο
Build the reStructuredText files.
The reST files describe all colours.
- build_svg()ο
Build the SVG.
While an SVG is basically a vector image format, it still uses normal a normal ASCII / XML format. Thus, we can render them via Jinja2 template engine.
- build_txt()ο
Build the text files.
Since these are simple text files, we can render them via Jinja2 template engine.
- copy_static_files()ο
Copy the static files.
- classmethod get_file_items(path)ο
Get items from a text file, separated by newline characters. All white spaces are stripped.
- Parameters:
path (str) β The path to a file
- Returns:
The items
- Return type:
list
- render_template(template)ο
Load a Jinja2 template, render it and dump the file to the build directory, relatively based on the template name.
- Parameters:
template (str) β The filename of the template
Colourο
The colour classes.
- class confirm.ci.colour.Colour(index, brightness, red, green, blue)ο
A single colour.
- Parameters:
index (int) β The colour index
brightness (int) β The colour brightness
red (int) β The red colour amount
green (int) β The green colour amount
blue (int) β The blue colour amount
- asdict()ο
The dict version of the colour, including all required informations.
- Returns:
The dict version
- Return type:
dict
- property css_nameο
The CSS variable name of the colour.
- Returns:
The CSS class name
- Return type:
str
- property nameο
The name of the colour.
- Returns:
The name
- Return type:
str
- property rgb_decο
The RGB decimal format of the colour.
- Returns:
The decimal RGB colour
- Return type:
str
- property rgb_hexο
The RGB hex format of the colour.
- Returns:
The HEX RGB colour
- Return type:
str
Imageο
The image module.
- class confirm.ci.image.Image(path, family_names)ο
The image class.
- Parameters:
path (str) β The image path
- detect_colours_per_family()ο
Detect the total colours per family.
Hint
This is achieved by cropping the first horizontal line of pixels and counting the amount of different colours found.
- Returns:
The colours per family
- Return type:
int
- detect_tile_size_and_brightness_step()ο
Detect the tile size & brightness step.
Hint
The tile size is detected by dividing the image width through the
colours per family
.The brightness step is calculated by dividing
100
through thecolours per family
.
- Returns:
The tile size & brightness step
- Return type:
tuple(int, int)
- property heightο
The height of the image.
- Returns:
The height
- Return type:
int
- parse()ο
Parse the image and fetch all colours / colour families from it.
- property widthο
The width of the image.
- Returns:
The width
- Return type:
int
ASEο
The ASE file class.
- class confirm.ci.ase.ASE(path)ο
The class to create an ASE - Adobe Swatch Exchange file.
- Parameters:
path (str) β The file path
- add_colour(name, red, green, blue)ο
Add a colour.
Hint
A colour ASE block includes:
Header of
create_named_block()
Colour space:
4 bytes
RGB values:
4 bytes
per valueColour type:
2 bytes
- Parameters:
name (str) β The colour name
red (int) β The red value (0-255)
green (int) β The green value (0-255)
blue (int) β The blue value (0-255)
- begin_group(name)ο
Begin a group.
Important
Remember to call
end_group()
when the group is finished.- Parameters:
name (str) β The group name
- create_block(block_type, data=None)ο
Create an ASE bytes block.
Hint
An ASE block includes:
Block Type:
2 bytes
Block Length:
4 bytes
Block Data: variable length
- Parameters:
block_type (int) β The block type
data (bytes) β Additional data
- Returns:
The ASE block
- Return type:
bytes
- create_named_block(block_type, name, data=None)ο
Create a named ASE bytes block.
Hint
An named ASE block includes:
Header of
create_block()
Name length:
2 bytes
Name:
2 bytes
per characterBlock Data: variable length
- Parameters:
block_type (int) β The block type
name (str) β The name of the block
data (bytes) β Additional data
- Returns:
The ASE block
- Return type:
bytes
- end_group()ο
End a group.
- init_ase()ο
Init the ASE file.
- write()ο
Write the ASE file.