Reference navigation
On this page
CLASS · v0.9.1
Deform
Interpolate coordinates toward the result of a user-supplied function.
from proteinmotion import DeformConstructor
Deform(protein, function, **kwargs)Parameters
| Parameter | Default | Description |
|---|---|---|
protein | Required | Protein object to read or animate. |
function | Required | Callable receiving a copy of the coordinates and returning an array of the same shape. |
**kwargs | — | Additional keyword options described below or in the linked constructor. |
Additional keyword arguments
| Parameter | Default | Description |
|---|---|---|
rate_funckeyword only | smooth | Callable that maps progress in [0, 1] to a finite value in [0, 1]. |
Notes
The function runs when the animation is scheduled. It must return finite coordinates with the original shape. This operation creates an illustrative shape change.
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, margin=1.05)
rest = p.positions.copy()
def stretch(xyz):
center = xyz.mean(axis=0)
return center + (xyz - center) * [1.4, 1, 1]
self.play(Deform(p, stretch), run_time=2)
self.wait(0.5)
self.play(Morph(p, rest, align=False), run_time=2)
self.wait(0.5)A synthetic stretch followed by a return to the original coordinates.
Methods and properties
| Name | Description |
|---|---|
| bind()method | Capture starting values when the scene schedules the animation. |
| apply()method · inherited from Morph | Evaluate the animation at eased progress alpha. Called by the timeline. |
| targetsproperty · inherited from Animation | Objects whose state this animation changes. |
Deform.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 animation.Morph.
Deform.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.
Deform.targetsObjects whose state this animation changes.