diff options
author | László Németh <nemeth@numbertext.org> | 2013-10-23 10:51:32 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2013-10-23 10:57:24 +0200 |
commit | 3f98d1aeadd07d2fcf37c8a645ef6d5afb7eb7dd (patch) | |
tree | 918cb9abcfffc2149f05b9e98844a4655b7cbf04 /librelogo | |
parent | 1ed2c24a6e638ad7793c46427e4c49e42d435239 (diff) |
librelogo: optional SVG/SMIL looping (at ending SLEEP)
Change-Id: I3c05c5f7e1721a20e6eab12e2aa620aa917b7378
Diffstat (limited to 'librelogo')
-rw-r--r-- | librelogo/source/LibreLogo/LibreLogo.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py index 5fc3aa532c01..6db81d649433 100644 --- a/librelogo/source/LibreLogo/LibreLogo.py +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -1237,11 +1237,13 @@ def __groupstart__(name = ""): def create_svg_animation(m): global _ - if int(m.group(1)) > 2: - if int(m.group(1))-3 in _.shapecache: - t = _.shapecache[int(m.group(1))-3] - if t != "0": - return '<g id="id%s" opacity="0"><animate attributeName="opacity" from="0" to="100" begin="%sms" dur="1ms" fill="freeze"/>' % (m.group(1), t) + id = int(m.group(1)) + if id - 3 in _.shapecache: + t = _.shapecache[id-3] + opacity = "100" if t == "0" else "0" + name = "" if id != 3 else "id=\"first\"" + start = "%sms;last.end+%sms" % (t, t) if id == 3 else "first.end+%dms" % (int(t) - int(_.shapecache[0])) + return '<g id="id%s" opacity="0"><animate %s attributeName="opacity" from="100" to="100" begin="%s" dur="1ms" fill="freeze"/><animate attributeName="opacity" from="100" to="%s" begin="last.end" dur="1ms" fill="freeze"/>' % (m.group(1), name, start, opacity) return m.group() def create_valid_svg_file(filename): @@ -1252,7 +1254,12 @@ def create_valid_svg_file(filename): s = re.sub('(?s)<defs class="EmbeddedBulletChars">.*(?=<defs class="TextEmbeddedBitmaps")', '', s) # remove unused parts s = re.sub('(?s)(<path stroke-width="[^"]*"[^<]*)stroke-width="[^"]*"', '\\1', s) # double stroke-width s = re.sub('(?s)<svg\\s+version="1.2"', '<svg version="1.1"', s) # for W3C Validator - s = re.sub('<g id="id([0-9]+)">', create_svg_animation, s) + if _.time > 0: + s = re.sub('<g id="id([0-9]+)">', create_svg_animation, s) + m = re.match('(?s)(.*<animate[^>]*first[.]end.([0-9]+)[^>]* dur=")1ms"', s) + lasttime = _.time - int(m.group(2)) - int(_.shapecache[0]) + 1 + if lasttime > 1: + s = re.sub('(?s)(.*<animate[^>]*first[.]end.([0-9]+)[^>]* dur=")1ms"', m.group(1) + str(lasttime) + 'ms" id="last"', s) with open(filename, 'w') as f: f.write(s) |