forked from Pymol-Scripts/Pymol-script-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie_fade.py
54 lines (37 loc) · 1.33 KB
/
movie_fade.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
http://pymolwiki.org/index.php/movie_fade
(c) 2011 Jason Vertrees
(c) 2013 Thomas Holder
License: BSD-2-Clause
'''
from pymol import cmd, CmdException
def movie_fade(setting, startFrame, startVal, endFrame, endVal=None, selection=""):
"""
DESCRIPTION
Fades representations in movies with their transparency settings.
USAGE
movie_fade setting, startFrame, startVal, endFrame, endVal [, selection ]
EXAMPLE
fetch 1rx1, async=0
as cartoon
show surface
mset 1x80
movie.roll
movie_fade transparency, 1, 0., 40, 1.
movie_fade transparency, 41, 1., 80, 0.
SEE ALSO
mdo, mappend, set
"""
startFrame, endFrame, startVal = int(startFrame), int(endFrame), float(startVal)
endVal = abs(1.0 - startVal) if endVal is None else float(endVal)
if startFrame == endFrame:
raise CmdException("start == end")
if startFrame > endFrame:
startFrame, endFrame = endFrame, startFrame
startVal, endVal = endVal, startVal
for frame in range(startFrame, endFrame + 1):
frac = float(frame - startFrame) / (endFrame - startFrame)
value = (1.0 - frac) * startVal + frac * endVal
cmd.mappend(frame, "/cmd.set(%s, %f, %s)" % (repr(setting), value, repr(selection)))
cmd.extend("movie_fade", movie_fade)
cmd.auto_arg[0]["movie_fade"] = cmd.auto_arg[0]["set"]