fix(script): add ending for raw loader of ThorVG (#7186)
Co-authored-by: SamNofee <sam@nofee.fun>
This commit is contained in:
@@ -81,7 +81,9 @@ array. E.g.:
|
|||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
./filetohex.py path/to/lottie.json > out.txt
|
./filetohex.py path/to/lottie.json --filter-character --null-terminate > out.txt
|
||||||
|
|
||||||
|
``--filter-character`` filters out non-ASCII characters and ``--null-terminate`` makes sure that a trailing zero is appended to properly close the string.
|
||||||
|
|
||||||
To create an animation from raw data:
|
To create an animation from raw data:
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ array. E.g.:
|
|||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
./filetohex.py path/to/lottie.json > out.txt
|
./filetohex.py path/to/lottie.json --filter-character --null-terminate > out.txt
|
||||||
|
|
||||||
|
``--filter-character`` filters out non-ASCII characters and ``--null-terminate`` makes sure that a trailing zero is appended to properly close the string.
|
||||||
|
|
||||||
To create an animation from data use
|
To create an animation from data use
|
||||||
:cpp:expr:`lv_lottie_set_src_data(lottie, data, sizeof(data))`
|
:cpp:expr:`lv_lottie_set_src_data(lottie, data, sizeof(data))`
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
|
import textwrap
|
||||||
|
import re
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as file:
|
with open(sys.argv[1], 'r') as file:
|
||||||
s = file.read()
|
s = file.read()
|
||||||
|
|
||||||
b = bytearray()
|
b = bytearray()
|
||||||
|
|
||||||
|
if '--filter-character' in sys.argv:
|
||||||
|
s = re.sub(r'[^\x00-\xff]', '', s)
|
||||||
|
if '--null-terminate' in sys.argv:
|
||||||
|
s += '\x00'
|
||||||
|
|
||||||
b.extend(map(ord, s))
|
b.extend(map(ord, s))
|
||||||
|
|
||||||
for a in b: print(hex(a), end =", ")
|
print(textwrap.fill(', '.join([hex(a) for a in b]), 96))
|
||||||
|
|
||||||
Reference in New Issue
Block a user