rgbas¶
- class janim.components.rgbas.Cmpt_Rgbas(*args, **kwargs)¶
Bases:
Component,GenericColor component
- copy() Self¶
- become(other: Cmpt_Rgbas) Self¶
- not_changed(other: Cmpt_Rgbas) bool¶
- classmethod align_for_interpolate(cmpt1: Cmpt_Rgbas, cmpt2: Cmpt_Rgbas)¶
- interpolate(cmpt1: Cmpt_Rgbas, cmpt2: Cmpt_Rgbas, alpha: float, *, path_func=None) None¶
- is_transparent() None¶
- get() ndarray¶
- static format_rgbas(rgbas: RgbaArray) ndarray¶
Convert the passed value to a numeric array
- static format_colors(colors: ColorArray) ndarray¶
Format
ColorArray(each element may be a string or[r, g, b]) into a numeric array format where elements are only[r, g, b]
- static format_color(color: JAnimColor) ndarray¶
Unify strings,
[r, g, b], etc. into[r, g, b]numeric array format
- static format_alphas(alphas: AlphaArray) ndarray¶
Convert the passed value to a numeric array
- set_rgbas(rgbas: RgbaArray) Self¶
Directly set rgba data
- set(color: JAnimColor | ColorArray | None = None, alpha: Alpha | AlphaArray | None = None, *, root_only: bool = False) Self¶
colorsrepresents theRGBcolor data passed in, which can be a single color or a color array (for single data, supports formats like'#FF0000','red',[1, 0, 0.5])alphasrepresents the transparency data passed in, which can be a single number or an array (for single data,1means opaque,0means fully transparent)By default, all descendant items will also be set to the specified color; passing
root_only=Truewill only set the root item’s color
Special parameter passing:
When
colorsis four-componentRGBAcolor data, it represents bothcolorsandalphas, so thealphasparameter cannot be passed separately
- clear() Self¶
Reset color data to default value
- reverse() Self¶
- resize(length: int) Self¶
- count() int¶
- apart_alpha(n: int) Self¶
Apply
apart_alpha()to each color data
- fade(factor: float, *, root_only: bool = False) Self¶
Fade color,
factoris a value from 0~1, for example 0 has no effect, 0.5 fades half, 1 completely fades (becomes invisible)
- mix(color: JAnimColor, factor: float = 0.5, *, root_only: bool = False) Self¶
Mix colors, by default get the intermediate color mixed with
color
- mix_alpha(alpha: float, factor: float = 0.5, *, root_only: bool = False) Self¶
Mix transparency, by default get the intermediate color mixed with
alpha
- janim.components.rgbas.merge_alpha(alpha: float, n: int) float¶
Calculate the transparency after
alphais overlapped and mixedntimes
- janim.components.rgbas.apart_alpha(alpha: float, n: int, *, eps: float = 0.001) float¶
Separate transparency into
nparts, so that when thesenparts are mixed, they still appear as the original transparencyEnables better rendering of overlapping parts that occur during alignment