Skip to main content

Class: TypeWithCursor

Defined in: src/animation/creation/TypeWithCursor.ts:92

TypeWithCursor - Types text character by character with a blinking cursor

Works with Text mobjects that support getText/setText methods. Displays a blinking cursor at the end of the typed text.

Example​

const text = new Text({ text: 'Hello World' });
scene.play(typeWithCursor(text, { typingSpeed: 15 }));

Extends​

Constructors​

Constructor​

new TypeWithCursor(mobject, options): TypeWithCursor

Defined in: src/animation/creation/TypeWithCursor.ts:117

Parameters​

mobject​

Mobject

options​

TypeWithCursorOptions = {}

Returns​

TypeWithCursor

Overrides​

Animation.constructor

Properties​

_currentCharCount​

protected _currentCharCount: number = 0

Defined in: src/animation/creation/TypeWithCursor.ts:109

Currently displayed character count (excluding cursor)


_cursorVisible​

protected _cursorVisible: boolean = true

Defined in: src/animation/creation/TypeWithCursor.ts:111

Track cursor visibility for blinking


_fullText​

protected _fullText: string = ''

Defined in: src/animation/creation/TypeWithCursor.ts:107

Full text to type


_hasBegun​

protected _hasBegun: boolean = false

Defined in: src/animation/Animation.ts:49

Track if begin() has been called

Inherited from​

Animation._hasBegun


_isFinished​

protected _isFinished: boolean = false

Defined in: src/animation/Animation.ts:46

Whether the animation has finished

Inherited from​

Animation._isFinished


_lastCursorToggleTime​

protected _lastCursorToggleTime: number = 0

Defined in: src/animation/creation/TypeWithCursor.ts:113

Last cursor toggle time


_originalColor​

protected _originalColor: string = ''

Defined in: src/animation/creation/TypeWithCursor.ts:115

Original text color for highlighting


_startTime​

protected _startTime: number = null

Defined in: src/animation/Animation.ts:43

Time when the animation started (set by Timeline)

Inherited from​

Animation._startTime


cursorBlinkRate​

protected readonly cursorBlinkRate: number

Defined in: src/animation/creation/TypeWithCursor.ts:96

Cursor blink rate in blinks per second


protected readonly cursorBlinks: boolean

Defined in: src/animation/creation/TypeWithCursor.ts:100

Whether cursor blinks during typing


cursorChar​

protected readonly cursorChar: string

Defined in: src/animation/creation/TypeWithCursor.ts:94

Cursor character


duration​

readonly duration: number

Defined in: src/animation/Animation.ts:37

Duration of the animation in seconds

Inherited from​

Animation.duration


hideCursorOnComplete​

protected readonly hideCursorOnComplete: boolean

Defined in: src/animation/creation/TypeWithCursor.ts:102

Whether to hide cursor on complete


highlightColor?​

protected readonly optional highlightColor: string

Defined in: src/animation/creation/TypeWithCursor.ts:104

Highlight color for typed text


mobject​

readonly mobject: Mobject

Defined in: src/animation/Animation.ts:34

The mobject being animated

Inherited from​

Animation.mobject


rateFunc​

readonly rateFunc: RateFunction

Defined in: src/animation/Animation.ts:40

Rate function controlling the animation's pacing

Inherited from​

Animation.rateFunc


remover​

remover: boolean = false

Defined in: src/animation/Animation.ts:55

If true, the scene will remove this mobject after the animation finishes. Used by FadeOut (like Python manim's remover=True).

Inherited from​

Animation.remover


typingSpeed​

protected readonly typingSpeed: number

Defined in: src/animation/creation/TypeWithCursor.ts:98

Characters per second

Accessors​

startTime​

Get Signature​

get startTime(): number

Defined in: src/animation/Animation.ts:330

Get the start time of this animation (set by Timeline)

Returns​

number

Set Signature​

set startTime(time): void

Defined in: src/animation/Animation.ts:337

Set the start time of this animation (used by Timeline)

Parameters​
time​

number

Returns​

void

Inherited from​

Animation.startTime

Methods​

_calculateDuration()​

protected _calculateDuration(): number

Defined in: src/animation/creation/TypeWithCursor.ts:135

Get the calculated duration based on text length

Returns​

number


begin()​

begin(): void

Defined in: src/animation/creation/TypeWithCursor.ts:139

Called when the animation starts. Subclasses can override to set up initial state. On the very first call, captures a snapshot of the mobject so that reset() can restore it for clean backward seeking.

Returns​

void

Overrides​

Animation.begin


cleanUpFromScene()​

cleanUpFromScene(scene): void

Defined in: src/animation/Animation.ts:141

Hook called by Scene after the animation finishes, before the next play(). Default: removes mobject if remover is set (FadeOut, Write({remover:true})). Override for animations that need to mutate scene membership — e.g. ReplacementTransform swaps source for target.

Parameters​

scene​

AnimationScene

Returns​

void

Inherited from​

Animation.cleanUpFromScene


finish()​

finish(): void

Defined in: src/animation/creation/TypeWithCursor.ts:202

Called when the animation ends. Subclasses can override to clean up or finalize state.

Returns​

void

Overrides​

Animation.finish


getRatedSubAlpha()​

protected getRatedSubAlpha(alpha, index, count, lagRatio): number

Defined in: src/animation/Animation.ts:197

Like getSubAlpha, but with the rate function applied inside each member's lag window, as Manim CE's get_sub_alpha does: the window is cut from linear progress and eased on its own. Applying the rate function to the whole animation and then splitting it linearly makes the first and last members crawl and the middle ones rush.

Only an interpolateAt call knows the linear progress; a direct interpolate(alpha) call falls back to splitting alpha linearly.

Parameters​

alpha​

number

index​

number

count​

number

lagRatio​

number

Returns​

number

Inherited from​

Animation.getRatedSubAlpha


getSubAlpha()​

protected getSubAlpha(alpha, index, count, lagRatio): number

Defined in: src/animation/Animation.ts:179

Manim CE's get_sub_alpha: remaps a global progress alpha into the local progress of family member index (of count) under a lagRatio stagger. With lagRatio <= 0 (or a single member), every member tracks alpha directly. Subclasses that stagger across a mobject's family (e.g. Create) should index this by familyMembersWithPoints(), never by rendering-layer primitives.

Parameters​

alpha​

number

index​

number

count​

number

lagRatio​

number

Returns​

number

Inherited from​

Animation.getSubAlpha


interpolate()​

interpolate(alpha): void

Defined in: src/animation/creation/TypeWithCursor.ts:162

Apply the animation at a given progress value.

Parameters​

alpha​

number

Progress from 0 (start) to 1 (end)

Returns​

void

Overrides​

Animation.interpolate


interpolateAt()​

interpolateAt(linearAlpha): void

Defined in: src/animation/Animation.ts:162

Apply the animation at linear progress linearAlpha (elapsed / duration). Applies the rate function like update, and lets staggered subclasses apply it per family member (see getRatedSubAlpha).

Parameters​

linearAlpha​

number

Linear progress from 0 (start) to 1 (end)

Returns​

void

Inherited from​

Animation.interpolateAt


isFinished()​

isFinished(): boolean

Defined in: src/animation/Animation.ts:237

Check if the animation has finished

Returns​

boolean

Inherited from​

Animation.isFinished


reset()​

reset(): void

Defined in: src/animation/Animation.ts:246

Reset the animation to its initial state. Restores the mobject to its pre-animation visual state so that re-seeking (especially backward) produces correct results.

Returns​

void

Inherited from​

Animation.reset


update()​

update(_dt, currentTime): void

Defined in: src/animation/Animation.ts:215

Update the animation for the current frame.

Parameters​

_dt​

number

Time delta since last frame (unused, but available for subclasses)

currentTime​

number

Current time in the timeline

Returns​

void

Inherited from​

Animation.update