ProteinMotion
Reference navigation
On this page

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,
    easing=None,
    delay_seconds=None,
)

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].
easingkeyword onlyNoneNamed easing (smooth, linear, ease_in_out_sine, there_and_back) or callable mapping [0, 1] to [0, 1]. Per-item easing preserves stagger timing.
delay_secondskeyword onlyNoneDelay between successive residue, chain, or glyph starts, in seconds. Choose one delay option.

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
bind()methodCapture starting values when the scene schedules the animation.
apply()methodEvaluate the animation at eased progress alpha. Called by the timeline.
during()method · inherited from AnimationSet this animation duration and start delay in seconds.
targetsproperty · inherited from AnimationObjects whose state this animation changes.
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.

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.during(seconds, *, delay=0)

Set this animation duration and start delay in seconds.

ParameterDefaultDescription
secondsRequiredPositive animation duration in seconds.
delaykeyword only0Nonnegative animation start delay in seconds.

Inherited from animation.Animation.

python
Write.targets

Objects whose state this animation changes.