ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

SetOpacity

Animate transparency on a whole protein or a selected region.

python
from proteinmotion import SetOpacity

Constructor

python
SetOpacity(target, opacity, **kwargs)

Parameters

ParameterDefaultDescription
targetRequiredProtein or Region to style.
opacityRequiredOpacity in [0, 1], from transparent to opaque.
**kwargsAdditional keyword options described below or in the linked constructor.

Additional keyword arguments

ParameterDefaultDescription
residue_delaykeyword only0Delay in seconds between successive residue starts.
reversekeyword onlyFalseReverse residue or glyph order.
easingkeyword only'smooth'Per-residue interpolation: "smooth" or "linear".

Notes

Residues start in topology order from N to C. run_time must exceed (residue count − 1) × residue_delay. Use easing for each residue transition; the clip clock stays linear. Disjoint atom selections can animate together.

Example and output

This excerpt runs inside a scene’s construct() method. The full example file includes imports, structure loading, and camera setup. Run it from a repository checkout.

Code Scene excerpt
python
p = ubiquitin().ball_and_stick()
helix = p.select(residues=(23, 34))
helix.set_color("#50e0d0")
frame(self, p)
self.wait(0.5)
self.play(
    SetOpacity(helix, 0.1, residue_delay=0.06),
    run_time=2,
)
self.wait(0.7)
self.play(SetOpacity(helix, 1), run_time=1.5)
self.wait(0.5)
Output Preview · 5.2 s · 60 fps
Residue transparency

The selected helix fades and returns.

Methods and properties

NameDescription
bind()method · inherited from _AppearanceAnimationCapture starting values when the scene schedules the animation.
apply()method · inherited from _AppearanceAnimationEvaluate the animation at eased progress alpha. Called by the timeline.
targetsproperty · inherited from AnimationObjects whose state this animation changes.

Inherited from styling._AppearanceAnimation.

python
SetOpacity.bind()

Capture starting values when the scene schedules the animation.

Returns: None

Called by ProteinScene.play(). An animation instance can be bound once.

Inherited from styling._AppearanceAnimation.

python
SetOpacity.apply(alpha)

Evaluate the animation at eased progress alpha. Called by the timeline.

ParameterDefaultDescription
alphaRequiredEased animation progress in [0, 1].

Returns: None

Inherited from animation.Animation.

python
SetOpacity.targets

Objects whose state this animation changes.