types

class janim.items.three_d.types.SurfaceFace(*args, **kwargs)

Bases: Polygon

Each face of VCheckerboardSurface

class janim.items.three_d.types.NormSurface(geometry: T, resolution: Resolution | None = None, epsilon: float = 0.001, **kwargs)

Bases: Points, Generic

Base class for CheckerboardSurface and SmoothSurface

Provides wrappers around du_points and dv_points for computing normal vectors

resolution_type: str | None = None
init_connect() None
classmethod align_for_interpolate(item1: Item, item2: Item) AlignedData[Self]

Align the sampling resolution and triangle indices according to the UV grid, instead of simply aligning point by point as before

class janim.items.three_d.types.CheckerboardSurface(geometry: T, resolution: Resolution | None = None, checkerboard_colors: ColorArray = ['#29ABCA', '#1C758A'], alpha: float = 1.0, epsilon: float = 0.001, **kwargs)

Bases: NormSurface, Generic

Checkerboard-style surface, default shaded with alternating blue grid cells

Note

The behavior of this surface style under semi-transparent conditions still needs improvement

Note

This surface style is rendered as a whole, so each face cannot be manipulated as a separate item

For a version where each face exists as an independent item, see VCheckerboardSurface

Parameters:
  • geometry – Provided automatically by SurfaceGeometry.into()

  • resolution – Override the default resolution setting. You can pass a single value or a pair of values to represent the resolution in the u and v directions

  • checkerboard_colors – A list of checkerboard colors, cycled through on the grid

resolution_type: str | None = 'face'
color
renderer_cls

alias of CheckerboardSurfaceRenderer

apply_style(color: JAnimColor | ColorArray | None = None, alpha: float | None = None, **kwargs) Self

Set the item’s own style without affecting child items

See also: set()

class janim.items.three_d.types.VCheckerboardSurface(geometry: T, resolution: Resolution | None = None, fill_color: JAnimColor | None = None, fill_alpha: float = 1.0, checkerboard_colors: ColorArray = ['#29ABCA', '#1C758A'], stroke_color: JAnimColor = '#BBBBBB', stroke_radius: float = 0.0025, should_make_jagged: bool = False, **kwargs)

Bases: Group[SurfaceFace], VItem, Generic

Checkerboard-style surface, default shaded with alternating blue grid cells

Warning

Since each grid face of this surface style is an independent VItem, performance is generally worse

For a more performant approach, see CheckerboardSurface

Parameters:
  • geometry – Provided automatically by SurfaceGeometry.into()

  • resolution – Override the default resolution setting. You can pass a single value or a pair of values to represent the resolution in the u and v directions

  • checkerboard_colors – A list of checkerboard colors, cycled through on the grid

  • stroke_color – Grid line color

  • stroke_radius – Grid line thickness

set_fill_by_checkerboard(*colors: JAnimColor, alpha: float | None = None) Self

Set fill color in a checkerboard pattern

Parameters:
  • colors – Sequence of colors used for alternating fills (cycled in order), e.g. with two colors this becomes the classic checkerboard pattern

  • alpha – Fill opacity; if None, keep the current opacity unchanged

classmethod align_for_interpolate(item1: CheckerboardSurface, item2: CheckerboardSurface) AlignedData[Self]

Align checkerboard items according to the UV grid, instead of simply aligning them one by one as before

get_children_in_grid() list[list[SurfaceFace]]

Get the checkerboard 2D array, v major order

class janim.items.three_d.types.WireframeSurface(geometry: T, resolution: Resolution | None = None, stroke_color: JAnimColor = '#DDDDDD', stroke_radius: float = 0.005, depth_test: bool = False, should_make_smooth: bool = True, **kwargs)

Bases: Group[VItem], VItem, Generic

Wireframe-style surface

Warning

Since each wireframe of this surface style is an independent VItem, performance is generally worse

Parameters:
  • geometry – Provided automatically by SurfaceGeometry.into()

  • resolution – Override the default resolution setting. You can pass a single value or a pair of values to represent the resolution in the u and v directions

  • stroke_color – Wireframe color

  • stroke_radius – Wireframe thickness

classmethod align_for_interpolate(item1: WireframeSurface, item2: WireframeSurface) AlignedData[Self]

Align the wireframe according to the UV grid, instead of simply aligning them one by one as before

class janim.items.three_d.types.SmoothSurface(geometry: T, resolution: Resolution | None = None, epsilon: float = 0.001, **kwargs)

Bases: NormSurface, Generic

Surface with smooth shading

Note

The behavior of this surface style under semi-transparent conditions still needs improvement

Parameters:
  • geometry – Provided automatically by SurfaceGeometry.into()

  • resolution – Override the default resolution setting. You can pass a single value or a pair of values to represent the resolution in the u and v directions

resolution_type: str | None = 'smooth'
class Cmpt_SurfaceRgba(*args, **kwargs)

Bases: Cmpt_Rgba, Generic

DEFAULT_RGBA_ARRAY = <janim.utils.data.Array object>
color
renderer_cls

alias of SmoothSurfaceRenderer

apply_style(color: JAnimColor | None = None, alpha: float | None = None, **kwargs) Self

Set the item’s own style without affecting child items

See also: set()

class janim.items.three_d.types.DotCloudSurface(geometry: T, resolution: Resolution | None = None, radius: float | Iterable[float] = 0.01, **kwargs)

Bases: DotCloud, Generic

Point-cloud surface

Parameters:
  • geometry – Provided automatically by SurfaceGeometry.into()

  • resolution – Override the default resolution setting. You can pass a single value or a pair of values to represent the resolution in the u and v directions

  • radius – Radius of each point. Since points are relatively dense, the default here is smaller

get_points_in_grid() ndarray

Get the point-cloud 2D array, v major order

classmethod align_for_interpolate(item1: DotCloudSurface, item2: DotCloudSurface) AlignedData[DotCloud]

Align points according to the UV grid, instead of simply aligning point by point as before

class janim.items.three_d.types.SurfaceGeometry(uv_func: Callable[[float, float], Vect], u_range: tuple[float, float], v_range: tuple[float, float], **kwargs)

Bases: object

RESOLUTIONS: dict[str, Resolution] = {'face': 32, 'smooth': 101}
SURFACE_TYPES: dict[str, Any] = {'checker': <class 'janim.items.three_d.types.CheckerboardSurface'>, 'dots': <class 'janim.items.three_d.types.DotCloudSurface'>, 'smooth': <class 'janim.items.three_d.types.SmoothSurface'>, 'vchecker': <class 'janim.items.three_d.types.VCheckerboardSurface'>, 'wire': <class 'janim.items.three_d.types.WireframeSurface'>}
into(mode: Literal['checker'], **kwargs) CheckerboardSurface[Self]
into(mode: Literal['vchecker'], **kwargs) VCheckerboardSurface[Self]
into(mode: Literal['wire'], **kwargs) WireframeSurface[Self]
into(mode: Literal['smooth'], **kwargs) SmoothSurface[Self]
into(mode: Literal['dots'], **kwargs) DotCloudSurface[Self]
into(mode: type[T], **kwargs) T

Construct an item of the specified type from surface geometry information

Available values:

Example:

Sphere().into('checker')

For style settings specific to different item types, they can be placed either in into or in the geometry constructor (for example, Sphere())

Sphere().into('vchecker', fill_alpha=0.5)
Sphere(fill_alpha=0.5).into('vchecker')
resolve_resolution(type: str, override: Resolution | None) tuple[int, int]