ManimCompatMob¶
Qualified name: algan.mobs.manim\_compat.ManimCompatMob
- class ManimCompatMob(*args, **kwargs)[source]¶
Bases:
ManimMobBase class for Mobs whose construction/query API is supplied by Manim.
Subclasses define
_manim_class. Constructor arguments use Manim’s API;add_to_scene,glowandglow_radiusremain Algan-only options. Methods not implemented by Algan are delegated to the backing Manim object. Returned Mobjects are converted to Algan Mobs – newly built ones are registered with the owning Scene, soaxes.plot(...).spawn()renders – while mutations of the backing object are immediately resynchronised into this Mob’s geometry.Methods
copyReturn the backing Manim object used for compatibility operations.
Move by a displacement, applying it as a Manim
shift.Move the Mob to an absolute location.
Rotate the Mob, using Algan's rotation rather than Manim's.
Resize the Mob relative to its current size.
Set several animatable attributes at once, as one animation.
Refresh converted geometry after directly editing the backing object.
Attributes
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).stroke_colorThe color of the circuit's border stroke.
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).z_indexWhich of two exactly coplanar circuits draws in front (higher wins).
- move(displacement, arc_angle=None, recursive=True, **kwargs)[source]¶
Move by a displacement, applying it as a Manim
shift.Algan’s generic implementation moves to
self.location + displacement, but a compatibility Mob’s location is the center of the backing Mobject’s own points, which is not the composite’s center whenever it also has submobjects (anArrow’s tip, for example). Shifting the backing geometry instead keeps the travelled displacement exact for every Mob, and is what the relative-placement helpers (move_to_screen_edge(),move_next_to(), …) are built on.
- move_to(point_or_mobject, aligned_edge=array([0., 0., 0.]), coor_mask=array([1, 1, 1]))[source]¶
Move the Mob to an absolute location.
The path is a straight line unless
arc_angleis given, in which case the Mob swings to the target along a circular arc.Animation
Recorded as an animation: the Mob travels from where it is to
locationover the current context’s runtime (1 second by default). Usewith Off(): mob.move_to(...)to teleport it instead. Applies to this Mob and its descendants.- Parameters:
location – The target location, shape
(*, 3).arc_angle – Signed sweep of the curved path, in degrees. Defaults to
None, meaning travel in a straight line.**kwargs – Passed to
set_location()(notablyrecursive), or tomove_to_point_along_arc()whenarc_angleis given (notablyarc_normal).
- Returns:
This Mob, so calls can be chained.
- Return type:
See also
move()Move by a relative displacement instead.
move_to_screen_position()Place the Mob in screen space.
- rotate(angle, axis=tensor([0., 0., 1.]), about=None, *, degrees=True)[source]¶
Rotate the Mob, using Algan’s rotation rather than Manim’s.
rotateis one of the names this class shares withMob, and the two libraries mean different things by it: Algan measuresanglein degrees where Manim’s angle is in radians, and an explicitaxisturns the opposite way in each (their default z axis are opposite vectors, which is exactly what makes the default rotation agree). A compatibility Mob is animated as an Algan Mob, so this followsrotate()exactly – degrees, Algan’s direction constants, and a real rotation of the Mob’s basis that sweeps from 0 rather than a linear morph between the two poses (which cannot express a turn of 180 degrees, let alone a full one). The backing Manim object picks the new pose up through the usual lazy synchronization.Only the pivot is taken from Manim: it rotates about the composite’s center, whereas Algan’s generic implementation uses
location, the center of the backing Mobject’s own points. The two differ for every Mob that also has submobjects – anArrowwould otherwise turn about its shaft rather than in place – soaboutdefaults toget_center(), which agrees with Manim’sget_centerfor these objects.- Parameters:
angle (float | Tensor)
axis (Tensor)
about (Tensor | None)
degrees (bool)
- Return type:
- scale(scale_factor, **kwargs)[source]¶
Resize the Mob relative to its current size.
The factor multiplies the size the Mob has now, so two calls to
scale(2)leave it four times its original size. For an absolute target, useset_scale().Animation
Recorded as an animation: the Mob grows or shrinks over the current context’s runtime (1 second by default).
- Parameters:
scale_factor – Multiplier on the current size:
2for twice as big,0.5for half. A tensor of shape(*, 3)scales the Mob’s right, up and forward axes separately, which is how you stretch a shape.recursive – Whether descendants scale too, keeping the Mob’s proportions. Defaults to True; False scales this Mob alone, so a Group’s children keep their own sizes.
- Returns:
This Mob, so calls can be chained.
- Return type:
- set(**kwargs)[source]¶
Set several animatable attributes at once, as one animation.
The attributes change together rather than one after another, which is what you want for a single visual beat:
mob.set(location=RIGHT, color=BLUE)slides and recolors in the same second, where two separate statements would take two seconds inside aSeq.Animation
Recorded as an animation: all the writes go into one
Syncspanning the current context’s runtime (1 second by default). Changes propagate to descendants; useset_non_recursive()if they should not.- Parameters:
**kwargs – Animatable attribute names and their target values, e.g.
location,color,opacity,glow,scale_coefficient.- Returns:
This Mob, so calls can be chained.
- Return type:
- Raises:
AttributeError – If a name is not an animatable attribute of this Mob. The message lists the ones that are.
Examples
Move a square to the right and change its color to blue:
Example: Example1MobSet ¶
from algan import * mob = Square().spawn() mob.set(location=ORIGIN+RIGHT, color=BLUE) Scene.save_video()