ProteinMotion
Reference navigation
On this page

CLASS · v0.9.1

Callout

Connect an image label to a selected region with a line.

python
from proteinmotion import Callout

Constructor

python
Callout(
    region,
    text,
    *,
    subtitle=None,
    position=(0.73, 0.25),
    font_size=32,
    font='semibold',
    color='#edf3fc',
    subtitle_color='#a3b3c7',
    line_color=None,
    line_width=1.5,
    tip='dot',
    clamp=True,
    follow_opacity=True,
    opacity=1.0,
)

Parameters

ParameterDefaultDescription
regionRequiredRegion selection attached to a protein.
textRequiredText to display.
subtitlekeyword onlyNoneOptional second line of text.
positionkeyword only(0.73, 0.25)Image coordinates (x, y), with (0, 0) at the top-left and (1, 1) at the bottom-right.
font_sizekeyword only32Font size in pixels at a 1080-pixel image height.
fontkeyword only'semibold'Bundled "regular" or "semibold", or a path to a TTF/OTF font.
colorkeyword only'#edf3fc'Hex color or RGB values. For tint setters, None restores the representation’s base palette.
subtitle_colorkeyword only'#a3b3c7'Subtitle color.
line_colorkeyword onlyNoneCallout line color; None uses the main text color.
line_widthkeyword only1.5Line width in design pixels at 1080p for overlays; ångströms for 3D highlight boxes.
tipkeyword only'dot'Callout endpoint marker: "dot", "arrow", or "none".
clampkeyword onlyTrueKeep callout text inside the image bounds.
follow_opacitykeyword onlyTrueMultiply annotation opacity by its selected atom opacity.
opacitykeyword only1.0Opacity in [0, 1], from transparent to opaque.

Notes

The label uses a fixed image position. Its line follows the selected region as coordinates or the camera move.

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()
frame(self, p, margin=1.05)
helix = p.select(residues=(23, 34), atoms="CA")
note = helix.callout(
    "α helix",
    subtitle="Residues 23–34",
    position=(0.07, 0.38),
    font_size=48,
    color="#f2ba67",
    tip="arrow",
)
box = helix.highlight(style="box", color="#f2ba67")
self.play(Write(note), FadeIn(box), run_time=2)
self.play(self.camera.animate.orbit(0.5), run_time=3)
self.wait(1)
Output Preview · 6.0 s · 60 fps
Region callout

A line follows the selected helix as the camera moves.

Methods and properties

NameDescription
glyph_countpropertyNumber of shaped glyphs used for writing animation.
text_progresspropertyCurrent reveal progress for glyphs and annotation lines.
layout()methodProject text and line geometry for the renderer at the current frame.
set_opacity()method · inherited from AnnotationSet or animate opacity in [0, 1].
move_to()method · inherited from AnnotationSet or animate text position in normalized image coordinates.
shift()method · inherited from AnnotationTranslate the object by an offset.
snapshot()method · inherited from AnnotationCapture the current state for deterministic timeline evaluation.
restore()method · inherited from AnnotationRestore a state produced by snapshot().
animateproperty · inherited from AnnotationCreate a builder for fluent animation calls. Pass the result to scene.play().
python
Callout.glyph_count

Number of shaped glyphs used for writing animation.

python
Callout.text_progress

Current reveal progress for glyphs and annotation lines.

python
Callout.layout(camera, width, height, *, offset=None, progress=None)

Project text and line geometry for the renderer at the current frame.

ParameterDefaultDescription
cameraRequiredCamera used to project or frame objects.
widthRequiredImage width in pixels.
heightRequiredImage height in pixels.
offsetkeyword onlyNoneOffset (x, y) in design pixels at 1080p for residue labels; normalized image units for text shifts.
progresskeyword onlyNoneOptional reveal progress in [0, 1]; None uses the annotation’s current progress.

Returns: AnnotationLayout containing glyph placements and line paths.

Inherited from annotations.Annotation.

python
Callout.set_opacity(opacity)

Set or animate opacity in [0, 1].

ParameterDefaultDescription
opacityRequiredOpacity in [0, 1], from transparent to opaque.

Returns: The object or animation builder.

Inherited from annotations.Annotation.

python
Callout.move_to(position)

Set or animate text position in normalized image coordinates.

ParameterDefaultDescription
positionRequiredImage coordinates (x, y), with (0, 0) at the top-left and (1, 1) at the bottom-right.

Returns: The annotation or animation builder.

Inherited from annotations.Annotation.

python
Callout.shift(offset)

Translate the object by an offset.

ParameterDefaultDescription
offsetRequiredOffset (x, y) in design pixels at 1080p for residue labels; normalized image units for text shifts.

Returns: The object or animation builder.

Inherited from annotations.Annotation.

python
Callout.snapshot()

Capture the current state for deterministic timeline evaluation.

Returns: State dictionary.

Inherited from annotations.Annotation.

python
Callout.restore(state)

Restore a state produced by snapshot().

ParameterDefaultDescription
stateRequiredState returned by snapshot().

Returns: None

Inherited from annotations.Annotation.

python
Callout.animate

Create a builder for fluent animation calls. Pass the result to scene.play().