mirror of
https://github.com/iluvcapra/pycmx.git
synced 2025-12-31 08:50:54 +00:00
87 lines
2.2 KiB
Python
87 lines
2.2 KiB
Python
# pycmx
|
|
# (c) 2018 Jamie Hardt
|
|
|
|
class Transition:
|
|
"""
|
|
A CMX transition: a wipe, dissolve or cut.
|
|
"""
|
|
|
|
Cut = "C"
|
|
Dissolve = "D"
|
|
Wipe = "W"
|
|
KeyBackground = "KB"
|
|
Key = "K"
|
|
KeyOut = "KO"
|
|
|
|
def __init__(self, transition, operand, name=None):
|
|
self.transition = transition
|
|
self.operand = operand
|
|
self.name = name
|
|
|
|
@property
|
|
def kind(self):
|
|
"""
|
|
Return the kind of transition: Cut, Wipe, etc
|
|
"""
|
|
if self.cut:
|
|
return Transition.Cut
|
|
elif self.dissolve:
|
|
return Transition.Dissolve
|
|
elif self.wipe:
|
|
return Transition.Wipe
|
|
elif self.key_background:
|
|
return Transition.KeyBackground
|
|
elif self.key_foreground:
|
|
return Transition.Key
|
|
elif self.key_out:
|
|
return Transition.KeyOut
|
|
|
|
@property
|
|
def cut(self):
|
|
"`True` if this transition is a cut."
|
|
return self.transition == 'C'
|
|
|
|
@property
|
|
def dissolve(self):
|
|
"`True` if this traansition is a dissolve."
|
|
return self.transition == 'D'
|
|
|
|
@property
|
|
def wipe(self):
|
|
"`True` if this transition is a wipe."
|
|
return self.transition.startswith('W')
|
|
|
|
@property
|
|
def effect_duration(self):
|
|
"""The duration of this transition, in frames of the record target.
|
|
|
|
In the event of a key event, this is the duration of the fade in.
|
|
"""
|
|
return int(self.operand)
|
|
|
|
@property
|
|
def wipe_number(self):
|
|
"Wipes are identified by a particular number."
|
|
if self.wipe:
|
|
return int(self.transition[1:])
|
|
else:
|
|
return None
|
|
|
|
@property
|
|
def key_background(self):
|
|
"`True` if this edit is a key background."
|
|
return self.transition == Transition.KeyBackground
|
|
|
|
@property
|
|
def key_foreground(self):
|
|
"`True` if this edit is a key foreground."
|
|
return self.transition == Transition.Key
|
|
|
|
@property
|
|
def key_out(self):
|
|
"""
|
|
`True` if this edit is a key out. This material will removed from
|
|
the key foreground and replaced with the key background.
|
|
"""
|
|
return self.transition == Transition.KeyOut
|