DecimalNumber¶
Qualified name: algan.mobs.numeric\_display.DecimalNumber
- class DecimalNumber(value, decimal_places=2, integer_places=None, **kwargs)[source]¶
Bases:
MobA number drawn on screen, which counts when you assign to it.
valueis an animatable attribute, socounter.value = 100is recorded like a move or a color change and the display counts from wherever it was to 100 over the surrounding context’s runtime. The glyphs are re-typeset each frame rather than morphed into one another, which is what makes7become8rather than bending into it.The number is laid out to a fixed width from
decimal_placesandinteger_places, so it does not jitter sideways as digits come and go. Leading-digit slots are added automatically when the value outgrows them.Animation
Constructing one records nothing; the Mob joins the active Scene unspawned, and
spawn()makes it appear. Assigning tovalueafterwards is recorded and interpolates from the current value over the current context’s runtime (1 second by default) –with Seq(runtime=3): counter.value = 100to change that, orwith Off():to jump.- Parameters:
value – The number shown at construction.
decimal_places – Digits after the decimal point. Defaults to
2;0shows no decimal point at all.integer_places – Minimum digits before the decimal point. Defaults to
None, meaning take it fromvalue(at least 1). More are allocated automatically when the value grows past the reserved width.**kwargs – Passed to
Tex, which typesets the digits – notablycolorandfont_size– and on toMob.
- value¶
The number displayed, shape
(*, 1). Assigning to it records a counting animation.
Examples
A counter that runs from 0 to 50 over two seconds:
Example: Example1DecimalNumber ¶
from algan import * counter = DecimalNumber(0, decimal_places=1).spawn() with Seq(runtime=2): counter.value = 50 Scene.save_video()
Methods
get_valuePlay this Mob's spawn-in animation: a fade from transparent.
set_valueupdate_displayAttributes
animation_managerThis mob's scene-owned animation manager.
basisThe Mob's orientation and scale, as a flattened 3x3 matrix of shape
(*, 9).casts_shadowsWhether this Mob's geometry blocks light on its way from a light source to another surface -- whether it casts a shadow.
childrenThe Mobs attached below this one, in attachment order.
closed_shellWhether this Mob's triangles form a CLOSED shell -- every camera ray that enters the geometry crosses a second time on its way out.
draws_descendantsWhether
get_render_primitivesreturns geometry belonging to this Mob's DESCENDANTS as well as its own.forwardGet the direction the Mob is facing.
lifespanThis mob's [spawn, despawn) interval on its Scene timeline (a
Lifespan).locationThe Mob's position in world space, shape
(*, 3).normalized_basisThe Mob's orientation with scale divided out, shape
(*, 9).parentsThe Mobs this one is attached to, in attachment order.
receives_shadowsWhether this Mob's surfaces are darkened by shadows cast onto them.
rightGet the Mob's own rightward direction.
scale_coefficientThe Mob's scale along its own right, up and forward axes, shape
(*, 3).two_sidedWhether this Mob's geometry should be lit from whichever side the ray arrives on.
upGet the Mob's own upward direction.
xThe Mob's x coordinate in world units, shape
(*, 1).xyThe Mob's x and y coordinates in world units, shape
(*, 2).yThe Mob's y coordinate in world units, shape
(*, 1).zThe Mob's z coordinate in world units, shape
(*, 1).- on_create()[source]¶
Play this Mob’s spawn-in animation: a fade from transparent.
Called by
spawn()whenanimate=True. Override it in a subclass to give a Mob its own entrance; the override should record its animation the same way, and is free to ignore opacity entirely.Animation
Recorded as an animation over the current context’s runtime (1 second by default). The opacity write is non-recursive, so descendants run their own
on_create.