vxSDK/vxsdk/core/conv/__init__.py

73 lines
2.8 KiB
Python

"""
core.conv - Vhex converter module
"""
from core.conv.assets import assets_generate
__all__ = [
'generate_assets'
]
#---
# Public
#---
def generate_assets(prefix_assets, prefix_src, force_generate=True):
r"""Generate Vhex assets.
This function abstract the asset convertion for the Vhex Operating System.
It will walk througt the `<source_prefix>` folder and will try to find some
files named 'vxconv.txt' wich discribe assets information of a potential
project. Then it will use them to convert assets into an appropriate source
file in C without using any Vhex-specific function (so, you can use this
converter for other project).
The vxconv.txt file is structured like basic key/value file:
```
<exposed_symbols_name>:
type: <image type> (font, bitmap) - required
path: <image path> - required
...
<next_exposed_symbols_name>:
...
```
Each asset file description should have at least type and name information,
and each type have potentially its own requierements.
type = bitmap:
================================== ========================================
Keys name and value type Description
================================== ========================================
profile: <name> Select the bitmap pixel profile
| rgb4 | RGB 4 (indexed)
| rgb4a | RGBA 4 (indexed)
| rgb8 | RGB 8 (indexed)
| rgb8a | RGBA 8 (indexed)
| rgb16 | RGB 16 (5:R, 6:G, 5:B)
| rgb16a | RGBA 16 (5:R, 5:G, 5:B, 1:A)
================================== ========================================
type = font:
================================== ========================================
Keys name and value type Description
================================== ========================================
grid.size: 8x9 (widthxheight) caracter size in pixel
grid.padding: <pixel> space between caracter
grig.border: <pixel> space around grid
proportional: <true,false> caracter are cropped
line_height: <pixel> caracter line alignement
charset: <print,unicode> charset specification
================================== ========================================
@args:
> path (str) - the path to find assets
> source_prefix (str) - the path to generate image source file
@return:
> a list of string which represents all assets sources files path
"""
return assets_generate(prefix_assets, prefix_src, force_generate)