Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
work.contour
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
osp
work.contour
Commits
d7981276
Commit
d7981276
authored
Dec 19, 2018
by
gijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Animation generation scripts
parent
a957026e
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59985 additions
and
85 deletions
+59985
-85
communication/animation/1080x1920/make-movie.sh
communication/animation/1080x1920/make-movie.sh
+8
-0
communication/animation/1920x1080/make-movie.sh
communication/animation/1920x1080/make-movie.sh
+8
-0
communication/animation/1920x2160/make-movie.sh
communication/animation/1920x2160/make-movie.sh
+8
-0
communication/animation/digital-city-poster-1080x1920.svg
communication/animation/digital-city-poster-1080x1920.svg
+20005
-0
communication/animation/digital-city-poster-1920x1080.svg
communication/animation/digital-city-poster-1920x1080.svg
+19981
-0
communication/animation/digital-city-poster-1920x2160.svg
communication/animation/digital-city-poster-1920x2160.svg
+19860
-0
communication/animation/drawer.py
communication/animation/drawer.py
+0
-85
communication/animation/make-frames.py
communication/animation/make-frames.py
+115
-0
No files found.
communication/animation/1080x1920/make-movie.sh
0 → 100644
View file @
d7981276
# Transform SVG to PNG
for
FILE
in
svg/
*
.svg
do
FILENAME
=
$(
basename
$FILE
)
inkscape
-z
-e
png/
${
FILENAME
%.*
}
.png
-w
1080
-h
1920
$FILE
;
done
ffmpeg
-i
png/%05d.png
-c
:v libx264
-vf
fps
=
25
-pix_fmt
yuv420p poster.mp4
;
\ No newline at end of file
communication/animation/1920x1080/make-movie.sh
0 → 100644
View file @
d7981276
# Transform SVG to PNG
for
FILE
in
svg/
*
.svg
do
FILENAME
=
$(
basename
$FILE
)
inkscape
-z
-e
png/
${
FILENAME
%.*
}
.png
-w
1920
-h
1080
$FILE
;
done
ffmpeg
-i
png/%05d.png
-c
:v libx264
-vf
fps
=
25
-pix_fmt
yuv420p poster.mp4
;
\ No newline at end of file
communication/animation/1920x2160/make-movie.sh
0 → 100644
View file @
d7981276
# Transform SVG to PNG
for
FILE
in
svg/
*
.svg
do
FILENAME
=
$(
basename
$FILE
)
inkscape
-z
-e
png/
${
FILENAME
%.*
}
.png
-w
1920
-h
2160
$FILE
;
done
ffmpeg
-i
png/%05d.png
-c
:v libx264
-vf
fps
=
25
-pix_fmt
yuv420p poster.mp4
;
\ No newline at end of file
communication/animation/digital-city-poster-1080x1920.svg
0 → 100644
View file @
d7981276
This diff is collapsed.
Click to expand it.
communication/animation/digital-city-poster-1920x1080.svg
0 → 100644
View file @
d7981276
This diff is collapsed.
Click to expand it.
communication/animation/digital-city-poster-1920x2160.svg
0 → 100644
View file @
d7981276
This diff is collapsed.
Click to expand it.
communication/animation/drawer.py
deleted
100644 → 0
View file @
a957026e
from
svg.path
import
parse_path
from
svg.path.path
import
Move
,
Line
,
CubicBezier
from
bs4
import
BeautifulSoup
import
re
# height = 800
# width = height/(1920/1080)
def
get_group_by_label
(
svg
,
label
):
for
group
in
svg
.
find_all
(
'g'
):
if
group
.
get
(
'inkscape:label'
)
==
label
:
return
group
def
get_keypoints
(
svg
):
return
[
complex
(
float
(
point
.
get
(
'cx'
)),
float
(
point
.
get
(
'cy'
)))
for
point
in
get_group_by_label
(
svg
,
'keypoints'
).
find_all
(
'circle'
)]
with
open
(
'timeline.inkscape.svg'
,
'r'
)
as
handle
:
# use bs 4 to find paths
soup
=
BeautifulSoup
(
handle
.
read
(),
'lxml'
)
svg
=
soup
.
find
(
'svg'
)
# path = soup.find('path')
# segments = parse_path(path.get('d'))
# svg['width'] = width
# svg['height'] = height
# svg['viewbox'] = '0 0 {} {}'.format(width, height)
# layers = [
# {
# 'keyframes': [
# (0, (-200,0))
# (30, (-200,0))
# ]
# }
# ]
# lines = []
keypoints_layer
=
get_group_by_label
(
soup
,
'keypoints'
)
keypoints
=
sorted
(
get_keypoints
(
soup
),
key
=
lambda
point
:
point
.
real
)
# for segment in segments:
# if isinstance(segment, Line):
# lines.append(segment)
# for i in range(0,len(lines)-1):
# # print(lines[i].start.real)
# center = lines[i].end + (lines[i+1].start - lines[i].end) / 2
# # print(center.real)
# print(center)
# loopcenters.append(center)
pattern
=
re
.
compile
(
'translate\(([\d\.]+),\s*([\d\.]+)\)'
)
animation
=
get_group_by_label
(
soup
,
'animation'
)
transform
=
animation
.
get
(
'transform'
)
if
transform
:
m
=
pattern
.
match
(
transform
)
if
m
:
translation
=
(
float
(
m
.
group
(
1
)),
float
(
m
.
group
(
2
)))
else
:
translation
=
(
0
,
0
)
else
:
translation
=
(
0
,
0
)
keypoints_layer
.
extract
()
for
i
,
center
in
enumerate
(
keypoints
):
animation
[
'transform'
]
=
'translate({}, {})'
.
format
(
translation
[
0
]
+
(
-
1
*
(
center
.
real
-
(
float
(
svg
[
'width'
])
/
2
))),
translation
[
1
])
# print(path, 'translate({}, {})'.format(center.real - (width / 2), 0))
with
open
(
'frames/{}.svg'
.
format
(
i
),
'w'
)
as
o
:
o
.
write
(
svg
.
prettify
(
formatter
=
None
)
.
replace
(
'lineargradient'
,
'linearGradient'
)
.
replace
(
'gradienttransform'
,
'gradientTransform'
)
.
replace
(
'gradientunits'
,
'gradientUnits'
)
.
replace
(
'spreadmethod'
,
'spreadMethod'
))
o
.
close
()
# output = svgwrite.Drawing(filename="frames/output.svg", size=(width, height))
\ No newline at end of file
communication/animation/make-frames.py
0 → 100644
View file @
d7981276
from
svg.path
import
parse_path
from
svg.path.path
import
Move
,
Line
,
CubicBezier
from
bs4
import
BeautifulSoup
import
re
import
os.path
# height = 800
# width = height/(1920/1080)
sources
=
[
# ('digital-city-poster-1080x1920.svg', '1080x1920'),
(
'digital-city-poster-1920x1080.svg'
,
'1920x1080'
),
(
'digital-city-poster-1920x2160.svg'
,
'1920x2160'
)
]
fps
=
25
still
=
3
transition
=
.
5
def
parse_viewbox
(
viewboxstring
):
pattern
=
re
.
compile
(
r'(-?[\d\.]+) (-?[\d\.]+) (-?[\d\.]+) (-?[\d\.]+)'
)
m
=
pattern
.
match
(
viewboxstring
)
return
(
float
(
m
.
group
(
1
)),
float
(
m
.
group
(
2
)),
float
(
m
.
group
(
3
)),
float
(
m
.
group
(
4
)))
def
framecount
(
length
):
return
int
(
length
*
fps
)
def
get_translation
(
group
):
pattern
=
re
.
compile
(
r'translate\((-?[\d\.]+),\s*(-?[\d\.]+)\)'
)
transform
=
group
.
get
(
'transform'
)
if
transform
:
m
=
pattern
.
match
(
transform
)
if
m
:
translation
=
(
float
(
m
.
group
(
1
)),
float
(
m
.
group
(
2
)))
else
:
translation
=
(
0
,
0
)
else
:
translation
=
(
0
,
0
)
return
translation
def
get_group_by_label
(
svg
,
label
):
for
group
in
svg
.
find_all
(
'g'
):
if
group
.
get
(
'inkscape:label'
)
==
label
:
return
group
def
get_keypoints
(
svg
):
keypoints_layer
=
get_group_by_label
(
svg
,
'keypoints'
)
keypoints
=
keypoints_layer
.
find_all
(
'circle'
)
translation
=
get_translation
(
keypoints_layer
)
return
[
complex
(
translation
[
0
]
+
float
(
point
.
get
(
'cx'
)),
translation
[
1
]
+
float
(
point
.
get
(
'cy'
)))
for
point
in
keypoints
]
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
(
'gradienttransform'
,
'gradientTransform'
)
.
replace
(
'gradientunits'
,
'gradientUnits'
)
.
replace
(
'spreadmethod'
,
'spreadMethod'
)
.
replace
(
'viewbox'
,
'viewBox'
)
.
replace
(
'flowroot'
,
'flowRoot'
)
.
replace
(
'textpath'
,
'textPath'
)
.
replace
(
'spreadmethod'
,
'spreadMethod'
)
.
replace
(
'clippath'
,
'clipPath'
))
o
.
close
()
for
drawing
,
target
in
sources
:
print
(
drawing
)
with
open
(
drawing
,
'r'
)
as
handle
:
# use bs 4 to find paths
soup
=
BeautifulSoup
(
handle
.
read
(),
'lxml'
)
svg
=
soup
.
find
(
'svg'
)
viewbox
=
parse_viewbox
(
svg
[
'viewbox'
])
print
(
viewbox
)
width
=
viewbox
[
2
]
-
viewbox
[
0
]
keypoints_layer
=
get_group_by_label
(
soup
,
'keypoints'
)
keypoints
=
sorted
(
get_keypoints
(
soup
),
key
=
lambda
point
:
point
.
real
)
animation
=
get_group_by_label
(
soup
,
'animation'
)
translation
=
get_translation
(
animation
)
keypoints_layer
.
extract
()
f
=
0
for
k
,
center
in
enumerate
(
keypoints
):
if
k
>
0
:
for
i
in
range
(
framecount
(
transition
)):
t
=
i
/
float
(
framecount
(
transition
))
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
)
get_group_by_label
(
svg
,
'text'
)[
'visibility'
]
=
'hidden'
write_frame
(
f
,
svg
,
folder
=
os
.
path
.
join
(
target
,
'svg'
))
f
+=
1
for
i
in
range
(
framecount
(
still
)):
x
=
translation
[
0
]
+
(
-
1
*
(
center
.
real
-
(
float
(
width
)
/
2
)))
y
=
translation
[
1
]
animation
[
'transform'
]
=
'translate({}, {})'
.
format
(
x
,
y
)
get_group_by_label
(
svg
,
'text'
)[
'visibility'
]
=
'visible'
write_frame
(
f
,
svg
,
folder
=
os
.
path
.
join
(
target
,
'svg'
))
f
+=
1
# print(path, 'translate({}, {})'.format(center.real - (width / 2), 0))
# output = svgwrite.Drawing(filename="frames/output.svg", size=(width, height))
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment