6 from .base
import exporter
7 from ..utils.file
import open_file
8 from ..parsers.baseporter
import ExtraOption
9 from .tgs_validator
import TgsValidator
12 @exporter("Lottie JSON", ["json"], [], {"pretty"}, "lottie")
18 json.dump(animation.to_dict(), fp, **kw)
21 @exporter("Telegram Animated Sticker", ["tgs"], [
ExtraOption("no_sanitize", help="Disable Sticker fit", action="store_false", dest="sanitize"),
22 ExtraOption(
"no_validate", help=
"Disable feature validation", action=
"store_false", dest=
"validate"),
24 def export_tgs(animation, file, sanitize=False, validate=False):
26 animation.tgs_sanitize()
28 with gzip.open(file,
"wb")
as gzfile:
29 lottie_dict = animation.to_dict()
30 lottie_dict[
"tgs"] = 1
31 json.dump(lottie_dict, codecs.getwriter(
'utf-8')(gzfile))
36 validator.check_file_size(file)
38 sys.stdout.write(
"\n".join(map(str, validator.errors))+
"\n")
49 #bodymovin { width: %spx; height: %spx; margin: auto;
50 background-color: white;
51 background-size: 64px 64px;
53 linear-gradient(to right, rgba(0, 0, 0, .3) 50%%, transparent 50%%),
54 linear-gradient(to bottom, rgba(0, 0, 0, .3) 50%%, transparent 50%%),
55 linear-gradient(to bottom, white 50%%, transparent 50%%),
56 linear-gradient(to right, transparent 50%%, rgba(0, 0, 0, .5) 50%%);
59 <script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.5.3/lottie.js"></script>
64 <div id="bodymovin"></div>
68 container: document.getElementById('bodymovin'),
75 self.
filefile.write(
"animationData: ")
81 var anim = bodymovin.loadAnimation(animData);
85 self.
filefile.write(
"""<!DOCTYPE html>
88 <meta charset="utf-8" />
90 html, body { width: 100%; height: 100%; margin: 0; }
91 body { display: flex; }
94 self.
filefile.write(
"</head><body>")
97 self.
filefile.write(
"</body></html>")
100 @exporter("Lottie HTML", ["html", "htm"])
116 file.write(
"path: %r" % path)
119
def __init__(self, animation, file)
def export_embedded_html(animation, file)
def export_linked_html(animation, file, path)
def export_lottie(animation, file, pretty=False)
def export_tgs(animation, file, sanitize=False, validate=False)
def open_file(file_or_name, mode="w")