From 3f98d1aeadd07d2fcf37c8a645ef6d5afb7eb7dd Mon Sep 17 00:00:00 2001 From: László Németh Date: Wed, 23 Oct 2013 10:51:32 +0200 Subject: librelogo: optional SVG/SMIL looping (at ending SLEEP) Change-Id: I3c05c5f7e1721a20e6eab12e2aa620aa917b7378 --- librelogo/source/LibreLogo/LibreLogo.py | 19 +++++++++++++------ 1 file 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 '' % (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 '' % (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).*(?=', create_svg_animation, s) + if _.time > 0: + s = re.sub('', create_svg_animation, s) + m = re.match('(?s)(.*]*first[.]end.([0-9]+)[^>]* dur=")1ms"', s) + lasttime = _.time - int(m.group(2)) - int(_.shapecache[0]) + 1 + if lasttime > 1: + s = re.sub('(?s)(.*]*first[.]end.([0-9]+)[^>]* dur=")1ms"', m.group(1) + str(lasttime) + 'ms" id="last"', s) with open(filename, 'w') as f: f.write(s) -- cgit