Skip to content

Commit

Permalink
Написал комментарии к большинству классов
Browse files Browse the repository at this point in the history
  • Loading branch information
Merzlikin-Matvey committed Nov 14, 2024
1 parent c4f3fa4 commit 1438cce
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 4 deletions.
28 changes: 26 additions & 2 deletions manimextra/algebra/bracket.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@


class Bracket(VMobjectFromSVGPath):
"""
Bracket is a class that creates a bracket that fits the height of a mobject.
Parameters
----------
mobject : Mobject
The mobject that the bracket will fit the height of.
direction : Sequence[float], optional
The direction of the bracket, by default DOWN
buff : float, optional
The distance between the bracket and the mobject, by default 0.2
"""
def __init__(
self,
mobject: Mobject,
Expand Down Expand Up @@ -45,10 +57,22 @@ def __init__(


class BracketBetweenPoints(Bracket):
"""
BracketBetweenPoints is a class that creates a bracket between two points.
Parameters
----------
point_1 : Sequence[float], optional
The first point, by default ORIGIN
point_2 : Sequence[float], optional
The second point, by default ORIGIN
direction : Sequence[float], optional
The direction of the bracket, by default ORIGIN
"""
def __init__(
self,
point_1: Sequence[float] | None,
point_2: Sequence[float] | None,
point_1: Sequence[float] = LEFT,
point_2: Sequence[float] = RIGHT,
direction: Sequence[float] | None = ORIGIN,
**kwargs,
):
Expand Down
20 changes: 20 additions & 0 deletions manimextra/algebra/system_of_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@


class SystemOfEquations(VGroup):
"""
A group of equations with a brace on the left side.
Parameters
----------
*equations : :class:`manim.mobject.Mobject`
The equations.
is_bracket : bool, optional
Whether to use bracket instead of brace. Default to False.
buff_between_equations : float, optional
The buffer between equations. Default to 0.2.
buff_between_brace_and_equations : float, optional
The buffer between brace and equations. Default to 0.05.
"""
def __init__(
self,
*equations,
Expand Down Expand Up @@ -41,6 +55,12 @@ def __init__(
super().__init__(self.equations, self.brace)

def swap(self, i, j):
"""
Swap the i-th and j-th equations.
:param i:
:param j:
:return:
"""
self.equations[i], self.equations[j] = self.equations[j], self.equations[i]

self.equations.arrange(DOWN, buff=self.buff_between_equations)
Expand Down
30 changes: 30 additions & 0 deletions manimextra/algebra/unit_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@


class UnitCircleLabel(MathTex):
"""
A label for the unit circle.
Parameters
----------
direction : np.ndarray
The direction of the label.
repeats : int
The number of repeats of the unit circle.
fraction : bool
Whether to use fraction. Default to True.
"""
def __init__(self, direction=RIGHT, repeats=0, fraction=True, **kwargs):
if (direction == RIGHT).all():
self.other = False
Expand Down Expand Up @@ -86,6 +98,24 @@ def __init__(self, unit_circle, *objects, **kwargs):


class UnitCircle(VGroup):
"""
A unit circle.
Parameters
----------
point : float
The point on the unit circle. Using this point we determine how many cycles have passed.
radius : float, optional
The radius of the circle. Default to 1.5.
color : :class:`manim.utils.color.Color`, optional
The color of the circle. Default to BLUE.
label_buff : float, optional
The buffer between the circle and the labels. Default to 0.2.
font_size : int, optional
The font size of the labels. Default to 32.
fractions : bool, optional
Whether to use fraction in the labels. Default to True.
"""
def __init__(self, point=0, radius=1.5, color=BLUE, label_buff=0.2, font_size=32, fractions=True):
self.circle = Circle(radius=radius, color=color)
self.circle.set_z_index(-5)
Expand Down
12 changes: 12 additions & 0 deletions manimextra/animations/fancy_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@

import manim
from manim.constants import *
from manim.utils.deprecation import deprecated

__all__ = [
"Fancy_label"
]




@deprecated(since="v1.11.4", message="Please, dont use this cringe.")
def Fancy_label(text: manim.Tex, mode='normal', buff=manim.MED_LARGE_BUFF):
"""
A function that writes text at the very top and adapts to its length
:param text:
:param mode:
:param buff:
:return:
"""
mode = mode.lower()
modes = ['vlow', 'low', 'normal', 'fast', 'vfast']

Expand Down
36 changes: 36 additions & 0 deletions manimextra/animations/transform_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@


class TransformSystem(AnimationGroup):
"""
Transform a system of equations to another system of equations.
Parameters
----------
system_1 : :class:`SystemOfEquations`
The first system of equations.
system_2 : :class:`SystemOfEquations`
The second system of equations.
"""
def __init__(self, system_1, system_2, **kwargs):
self.system_1 = system_1
self.system_2 = system_2
Expand Down Expand Up @@ -53,6 +64,18 @@ def clean_up_from_scene(self, scene):


class SwapEquations(AnimationGroup):
"""
Swap two equations in a system of equations.
Parameters
----------
system : :class:`SystemOfEquations`
The system of equations.
i : int
The index of the first equation.
j : int
The index of the second equation.
"""
def __init__(self, system, i, j, **kwargs):
self.system = system
self.i, self.j = min(i, j), max(i, j)
Expand All @@ -75,6 +98,19 @@ def finish(self):


class InsertEquation(AnimationGroup):
"""
Insert an equation to the system of equations.
Parameters
----------
system : :class:`SystemOfEquations`
The system of equations.
eq : :class:`manim.mobject.Mobject`
The equation to insert.
index : int
The index to insert.
direction : np.ndarray, optional
"""
def __init__(self,
system: SystemOfEquations,
eq,
Expand Down
38 changes: 38 additions & 0 deletions manimextra/diagrams/pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@


class PieChartSector(AnnularSector):
"""
A sector of a pie chart.
Parameters
----------
value : float
The value of the sector.
percent : float
The percentage of the sector.
label : str
The label of the sector.
"""
def __init__(self, value, percent, label, *args, **kwargs):
self.value = value
self.percent = percent
Expand All @@ -27,6 +39,25 @@ def __init__(self, value, percent, label, *args, **kwargs):


class PieChart(VGroup):
"""
A pie chart.
Parameters
----------
data : Union[dict, tuple]
The data of the pie chart. If it is a dictionary, the keys are the labels and the values are the values.
If it is a tuple, the first element is the labels and the second element is the values.
labels : Optional[List[str]]
The labels of the pie chart.
label_buff : float, optional
The buffer between the label and the sector. Default to 0.85.
colors : List[Union[str, Tuple[float, float, float]]], optional
The colors of the sectors. Default to PIE_CHART_COLORS.
inner_radius : float, optional
The inner radius of the sectors. Default to 1.
outer_radius : float, optional
The outer radius of the sectors. Default to 2.
"""
def __init__(self,
data,
labels=None,
Expand Down Expand Up @@ -87,6 +118,13 @@ def get_sectors(self):
return self.sectors

def get_sector(self, value=None, label=None):
"""
Get a sector by value or label.
:param value:
:param label:
:return:
"""
for sector in self.sectors:
if value:
if sector.value == value:
Expand Down
Loading

0 comments on commit 1438cce

Please sign in to comment.