ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

Write

Draw text outlines and then fill the glyphs.

python
from proteinmotion import Write

Constructor

python
Write(target, *, lag_ratio=None, stroke_width=1.5, reverse=False, rate_func=linear)

Parameters

ParameterDefaultDescription
targetRequiredAnnotation to draw: Text, Callout, ResidueLabel, ResidueLabels, Distance, or InteractionHighlight.
lag_ratiokeyword onlyNoneDelay between glyph starts relative to glyph duration; None chooses a value from glyph count.
stroke_widthkeyword only1.5Glyph outline width in design pixels at 1080p.
reversekeyword onlyFalseReverse residue or glyph order.
rate_funckeyword onlylinearCallable that maps progress in [0, 1] to a finite value in [0, 1].

Notes

Works on text, callouts, residue labels, rulers, and interaction lines. Timing follows Manim’s MIT-licensed writing animation. lag_ratio=None chooses a delay based on the glyph count.

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
title = Text(
    "Protein motion",
    font_size=130,
    font="semibold",
    position=(0.1, 0.38),
)
self.play(
    Write(title, lag_ratio=0.12, stroke_width=1.8),
    run_time=2.5,
)
self.wait(1)
self.play(Unwrite(title), run_time=1.5)
Output Preview · 5.0 s · 60 fps
Write and Unwrite

Letter outlines are drawn, filled, and erased.

Methods and properties

NameDescription
apply()methodEvaluate the animation at eased progress alpha. Called by the timeline.
bind()method · inherited from AnimationCapture starting values when the scene schedules the animation.
targetsproperty · inherited from AnimationObjects whose state this animation changes.
python
Write.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
Write.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.Animation.

python
Write.targets

Objects whose state this animation changes.