Reference navigation
On this page
Colorize
Animate a tint on a whole protein or a selected region.
from proteinmotion import ColorizeConstructor
Colorize(target, color, **kwargs)Parameters
| Parameter | Default | Description |
|---|---|---|
target | Required | Protein or Region to style. |
color | Required | Hex color or RGB values. For tint setters, None restores the representation’s base palette. |
**kwargs | — | Additional keyword options described below or in the linked constructor. |
Additional keyword arguments
| Parameter | Default | Description |
|---|---|---|
residue_delaykeyword only | 0 | Delay in seconds between successive residue starts. |
delay_secondskeyword only | None | Delay between successive residue, chain, or glyph starts, in seconds. Choose one delay option. |
staggerkeyword only | None | Total fraction of the clip reserved for residue starts, in [0, 1). |
reversekeyword only | False | Reverse residue or glyph order. |
easingkeyword only | 'smooth' | Named easing (smooth, linear, ease_in_out_sine, there_and_back) or callable mapping [0, 1] to [0, 1]. Per-item easing preserves stagger timing. |
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.
p = ubiquitin()
frame(self, p)
helix = p.select(residues=(23, 34))
strand = p.select(residues=(2, 7))
self.play(
Colorize(helix, "#50e0d0", residue_delay=0.09),
Colorize(strand, "#f2ba67", residue_delay=0.15),
run_time=2.5,
)
self.wait(1)
self.play(Colorize(helix, None), run_time=1.5)
self.wait(0.5)Residues change color in sequence from N to C.
Methods and properties
| Name | Description |
|---|---|
| bind()method · inherited from _AppearanceAnimation | Capture starting values when the scene schedules the animation. |
| apply()method · inherited from _AppearanceAnimation | Evaluate the animation at eased progress alpha. Called by the timeline. |
| during()method · inherited from Animation | Set this animation duration and start delay in seconds. |
| targetsproperty · inherited from Animation | Objects whose state this animation changes. |
Inherited from styling._AppearanceAnimation.
Colorize.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.
Colorize.apply(alpha)Evaluate the animation at eased progress alpha. Called by the timeline.
| Parameter | Default | Description |
|---|---|---|
alpha | Required | Eased animation progress in [0, 1]. |
Returns: None
Inherited from animation.Animation.
Colorize.during(seconds, *, delay=0)Set this animation duration and start delay in seconds.
| Parameter | Default | Description |
|---|---|---|
seconds | Required | Positive animation duration in seconds. |
delaykeyword only | 0 | Nonnegative animation start delay in seconds. |
Inherited from animation.Animation.
Colorize.targetsObjects whose state this animation changes.