Commit bc8ba1cb authored by gijs's avatar gijs

Updated animation hollands kabinet

parent 511d050e
......@@ -12,8 +12,8 @@ sources = [
]
fps = 25
still = [0, 3]
transition = [.75, .5]
still = [0, 2, 5, 5, 5, 5, 2, 3.5, 0]
transition = [.6, .5, .5, .5, .5, .5, .5, .6]
def parse_viewbox (viewboxstring):
pattern = re.compile(r'(-?[\d\.]+) (-?[\d\.]+) (-?[\d\.]+) (-?[\d\.]+)')
......@@ -56,11 +56,14 @@ def write_frame(f, svg, folder = ''):
with open(os.path.join(folder, '{:05d}.svg'.format(f)), 'w') as o:
o.write(svg.prettify(formatter=None)
.replace('lineargradient', 'linearGradient')
.replace('radialgradient', 'radialGradient')
.replace('gradienttransform', 'gradientTransform')
.replace('gradientunits', 'gradientUnits')
.replace('spreadmethod', 'spreadMethod')
.replace('viewbox', 'viewBox')
.replace('flowroot', 'flowRoot')
.replace('flowpara', 'flowPara')
.replace('flowregion', 'flowRegion')
.replace('textpath', 'textPath')
.replace('startoffset', 'startOffset')
.replace('spreadmethod', 'spreadMethod')
......@@ -81,6 +84,8 @@ for drawing, target in sources:
keypoints_layer = get_group_by_label(soup, 'keypoints')
keypoints = sorted(get_keypoints(soup), key=lambda point: point.real)
get_group_by_label(svg, 'sticky_title_ghost').extract()
animation = get_group_by_label(soup, 'animation')
translation = get_translation(animation)
......@@ -91,24 +96,46 @@ for drawing, target in sources:
for k, center in enumerate(keypoints):
if k > 0:
# Generate transition
for i in range(framecount(transition[min(k, len(transition) - 1)])):
t = i / float(framecount(transition[min(k, len(transition) - 1)]))
d = keypoints[k].real - keypoints[k-1].real
x = translation[0] - keypoints[k-1].real - (t * d) + (float(width) / 2)
y = translation[1]
animation['transform'] = 'translate({}, {})'.format(x, y)
if k > 2 and k < 6:
# Compensate the movement of the animated layer to
# make the title 'stick' in its position
get_group_by_label(svg, 'sticky_title')['transform'] = 'translate({},{})'.format(sticky_x - x, sticky_y - y)
get_group_by_label(svg, 'text')['style'] = 'display:none;visibility:hidden;'
write_frame(f, svg, folder=os.path.join(target, 'svg'))
f += 1
for i in range(framecount(still[min(k, len(still) - 1)])):
if framecount(still[min(k, len(still) - 1)]) > 0:
# Generate still frames
x = translation[0] + (-1 * (center.real - (float(width) / 2)))
y = translation[1]
if k > 2 and k < 6:
# Compensate the movement of the animated layer to
# make the title 'stick' in its position
get_group_by_label(svg, 'sticky_title')['transform'] = 'translate({},{})'.format(sticky_x - x, sticky_y - y)
animation['transform'] = 'translate({}, {})'.format(x, y)
get_group_by_label(svg, 'text')['style'] = 'display:inline;visibility:visible;'
write_frame(f, svg, folder=os.path.join(target, 'svg'))
f += 1
for i in range(framecount(still[min(k, len(still) - 1)])):
write_frame(f, svg, folder=os.path.join(target, 'svg'))
f += 1
# print(path, 'translate({}, {})'.format(center.real - (width / 2), 0))
if k == 2:
# Title hollands kabinet from frame 2 needs to stick untill
# frame 5
sticky_x = translation[0]
sticky_y = translation[1]
# output = svgwrite.Drawing(filename="frames/output.svg", size=(width, height))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment