clip¶
- class janim.items.effect.clip.Cmpt_FrameClip(*args, **kwargs)¶
Bases:
Component,Generic- copy() Self¶
- become(other: Cmpt_FrameClip) Self¶
- not_changed(other: Cmpt_FrameClip) bool¶
- classmethod align_for_interpolate(cmpt1: Cmpt_FrameClip, cmpt2: Cmpt_FrameClip)¶
- interpolate(cmpt1: Self, cmpt2: Self, alpha: float, *, path_func=None) None¶
- set(left: float | None = None, top: float | None = None, right: float | None = None, bottom: float | None = None) Self¶
- class janim.items.effect.clip.FrameClip(*items: Item, clip: tuple[float, float, float, float] = (0, 0, 0, 0), debug: bool = False, root_only: bool = False, **kwargs)¶
Bases:
FrameEffectA class for creating simple rectangular clipping effects
- Parameters:
clip – The four boundaries of the clipping region: left, top, right, and bottom. Values in the range 0~1 represent percentages
debug – Whether to enable debug mode. When enabled, parts outside the clipping region are shown in semi-transparent red
- clip¶
- dynamic_uniforms()¶
- class janim.items.effect.clip.Cmpt_Attrs(*args, **kwargs)¶
Bases:
Component,GenericBase class of
Cmpt_TransformableFrameClipandCmpt_RectClipTransform- size: int = 1¶
- copy() Self¶
- become(other: Cmpt_TransformableFrameClip) Self¶
- not_changed(other: Cmpt_TransformableFrameClip) bool¶
- classmethod align_for_interpolate(cmpt1: Cmpt_TransformableFrameClip, cmpt2: Cmpt_TransformableFrameClip)¶
- interpolate(cmpt1: Self, cmpt2: Self, alpha: float, *, path_func=None) None¶
- class janim.items.effect.clip.Cmpt_TransformableFrameClip(*args, **kwargs)¶
Bases:
Cmpt_Attrs,Generic- size: int = 9¶
- set(left: float | None = None, top: float | None = None, right: float | None = None, bottom: float | None = None, x_offset: float | None = None, y_offset: float | None = None, x_scale: float | None = None, y_scale: float | None = None, rotate: float | None = None, *, scale: float | None = None) Self¶
- class janim.items.effect.clip.TransformableFrameClip(*items: Item, clip: tuple[float, float, float, float] = (0, 0, 0, 0), offset: tuple[float, float] = (0, 0), scale: tuple[float, float] | float = (1, 1), rotate: float = 0, debug: bool = False, root_only: bool = False, **kwargs)¶
Bases:
FrameEffectSimilar to
FrameClip, but supports more transformation operations (offset, scale, rotation)- Parameters:
clip – The four boundaries of the clipping region: left, top, right, and bottom. Values in the range 0~1 represent percentages
offset – Offset of the clipping region in the x and y directions, in percentages
scale – Scale of the clipping region in the x and y directions, in percentages
rotate – Rotation angle of the clipping region
debug – Whether to enable debug mode. When enabled, parts outside the clipping region are shown in semi-transparent red
You can also refer to
RectClip, which can be much more convenient in some cases- clip¶
- dynamic_uniforms()¶
- class janim.items.effect.clip.Cmpt_RectClipTransform(*args, **kwargs)¶
Bases:
Cmpt_Attrs,Generic- size: int = 2¶
- set(scale: float | None = None, rotate: float | None = None) Self¶
- class janim.items.effect.clip.RectClip(*args, **kwargs)¶
Bases:
FrameEffect,FrameRectRectangular clipping effect
Unlike
FrameClip, the clipping region is dynamically determined by the current geometry ofFrameRectand follows the rectangle’s geometric state- Parameters:
*items – Items to which this clipping effect should be applied
anchor – Anchor point (scene coordinates) when transforming clipped content
center_on – Whether to keep the anchor centered at the rectangle center at all times. Defaults to
False: the anchor’s relative percentage position with respect to the rectangle border stays unchanged. IfTrue, the whole content is translated so that the anchor is at the rectangle centerscale – Scale factor of clipped content relative to the anchor
rotate – Rotation angle (in radians) of clipped content relative to the anchor
border – Whether to draw the clipping rectangle border
Where:
anchorcan also be set withset_anchor()center_oncan also be set withset_center_on()scaleandrotatecan also be set with.transform.set(...)
Tip
RectClipcan be manipulated almost like aRectfor various transformations and alignments, making it easier to place in the right positionAnd when
border=True, various visual properties ofRect, such as border color and glow effects, are availableRectClipExample ¶
from janim.imports import * class RectClipExample(Timeline): def construct(self): ANCHOR = LEFT * 2 plane = NumberPlane(faded_line_ratio=1) dot = Dot(ANCHOR) txt = Text('Anchor') txt.points.next_to(dot, UP, buff=SMALL_BUFF) rect = RectClip(plane, dot, txt, anchor=ANCHOR, border=True) self.show(plane, dot, txt, rect) self.forward() self.play( rect.anim.points.scale([0.3, 0.5, 1]), rect.anim.points.shift(LEFT * 2), rect.anim.points.shift(UR), rect.anim.transform.set(scale=1.5, rotate=20 * DEGREES), Wait(0.5), rect.anim.transform.set(scale=1, rotate=0), rect.anim.set_center_on().color.set(RED), rect.anim.transform.set(scale=1.5, rotate=20 * DEGREES), Wait(0.5), rect.anim.transform.set(scale=1, rotate=0), lag_ratio=1, ) self.forward()
- renderer_cls¶
alias of
RCRenderer
- transform¶
- set_anchor(point: Vect) Self¶
- get_anchor() ndarray¶
- set_center_on(center_on: bool = True) Self¶
- is_center_on() bool¶
- dynamic_uniforms()¶