Skip to content

Commit d2abc7d

Browse files
authored
Merge pull request #15 from lucmos/develop
Release 0.0.6
2 parents 3332f21 + 43eef86 commit d2abc7d

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed
Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,49 @@ def build_shapes(self):
1515
logo_green = "#87c2a5"
1616
logo_blue = "#525893"
1717
logo_red = "#e07a5f"
18+
1819
circle = Circle(color=logo_green, fill_opacity=1).shift(LEFT)
19-
square = Difference(Square().shift(UP), circle, color=logo_blue, fill_opacity=1).shift(UR * 0.2)
20-
triangle = Difference(Triangle().shift(RIGHT), square, color=logo_red, fill_opacity=1).shift(DR * 0.2)
20+
21+
square = Square(color=logo_blue, fill_opacity=1).shift(UP)
22+
triangle = Triangle(color=logo_red, fill_opacity=1).shift(RIGHT)
23+
24+
square = Difference(square, circle, color=logo_blue, fill_opacity=1)
25+
triangle = Difference(triangle, square, color=logo_red, fill_opacity=1)
26+
27+
circle.shift(DL * self.gap)
28+
triangle.shift(DR * self.gap)
29+
2130
return VGroup(circle, square, triangle)
2231

2332
def build_text(self):
24-
logo_black = "#343434"
25-
ds_m = MathTex(r"\mathbb{PM}", fill_color=logo_black).scale(5)
33+
ds_m = MathTex(r"\mathbb{PM}", fill_color=self.logo_black).scale(5)
2634
ds_m.shift(4.25 * LEFT + 1.5 * UP)
2735
return ds_m
2836

2937
def build_banner(self):
3038
shapes = self.build_shapes()
3139

32-
font_color = "#343434"
33-
logo_black = "#343434"
34-
35-
ds_p = MathTex(r"\mathbb{P}", fill_color=logo_black).scale(2)
40+
ds_p = MathTex(r"\mathbb{P}", fill_color=self.logo_black).scale(2)
3641
ower = Tex("ower", tex_template=TexFontTemplates.gnu_freeserif_freesans).scale(2)
37-
ower.next_to(ds_p, RIGHT, buff=SMALL_BUFF).align_to(ds_p, DOWN).set_color(font_color)
42+
ower.next_to(ds_p, RIGHT, buff=SMALL_BUFF).align_to(ds_p, DOWN).set_color(self.font_color)
3843
power = VGroup(ds_p, ower)
3944

40-
ds_m = MathTex(r"\mathbb{M}", fill_color=logo_black).scale(2)
45+
ds_m = MathTex(r"\mathbb{M}", fill_color=self.logo_black).scale(2)
4146
anim = Tex("anim", tex_template=TexFontTemplates.gnu_freeserif_freesans).scale(2)
42-
anim.next_to(ds_m, RIGHT, buff=SMALL_BUFF).align_to(ds_m, DOWN).set_color(font_color)
47+
anim.next_to(ds_m, RIGHT, buff=SMALL_BUFF).align_to(ds_m, DOWN).set_color(self.font_color)
4348
tmanim = VGroup(ds_m, anim)
4449

4550
banner = VGroup(power, tmanim).arrange(RIGHT, buff=MED_SMALL_BUFF).move_to(ORIGIN).scale(1.5)
46-
banner.shift(UP * 0.5 + LEFT * 0.5)
47-
shapes.next_to(banner.get_critical_point(DR), DR, buff=-1)
51+
banner.next_to(shapes[1], LEFT)
52+
banner.align_to(shapes[0].get_critical_point(UP) + self.gap, DOWN)
4853

4954
return VGroup(shapes, banner).move_to(ORIGIN)
5055

51-
def __init__(self):
56+
def __init__(self, font_color="#343434", logo_black="#343434", gap=0.4):
57+
self.font_color = font_color
58+
self.logo_black = logo_black
59+
self.gap = gap
60+
5261
shapes = self.build_shapes()
5362
ds_m = self.build_text()
5463
super().__init__(*shapes, ds_m)

src/powermanim/layouts/arrangedbullets.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def __init__(
1212
group: T.Optional[int] = None,
1313
adjustment: float = 0.0,
1414
symbol: T.Optional[str] = r"\bullet",
15+
autoplace: bool = True,
1516
**kwargs,
1617
):
1718
"""A class to represent a bullet point.
@@ -22,13 +23,13 @@ def __init__(
2223
group: The group the bullet point belongs to, controls the animations.
2324
adjustment: The adjustment of the bullet.
2425
symbol: The symbol to be displayed as the bullet.
25-
symbol_buff: The spacing between the bullet and the text.
26-
text_components_buff: The spacing between the text components.
26+
autoplace: Whether to automatically place the bullet point.
2727
"""
2828
self.level = level
2929
self.adjustment = adjustment
3030
self.group = group
3131
self.symbol = symbol
32+
self.autoplace = autoplace
3233

3334
first_text, *rest_text = text
3435
if symbol is not None:
@@ -95,6 +96,18 @@ def __init__(
9596

9697

9798
class ArrangedBullets(VGroup):
99+
def arrage_rows(self, rows: T.Iterable[T.Union[MathBullet, Bullet, MathTex, Tex, Text]]):
100+
bullet_rows: T.Iterable[MathBullet] = (
101+
VGroup(*rows)
102+
.arrange(DOWN, aligned_edge=LEFT, buff=self.line_spacing)
103+
.to_edge(LEFT, buff=self.left_buff)
104+
.shift(self.global_shift)
105+
)
106+
107+
for row in bullet_rows:
108+
row.indent(indent_buff=self.indent_buff)
109+
row.adjust()
110+
98111
def __init__(
99112
self,
100113
*rows: T.Union[MathBullet, Bullet, MathTex, Tex, Text],
@@ -118,25 +131,17 @@ def __init__(
118131
self.global_shift = global_shift
119132

120133
rows = [(row if isinstance(row, MathBullet) else Bullet(row)) for row in rows]
121-
bullet_rows: T.Iterable[MathBullet] = (
122-
VGroup(*rows)
123-
.arrange(DOWN, aligned_edge=LEFT, buff=line_spacing)
124-
.to_edge(LEFT, buff=left_buff)
125-
.shift(global_shift)
126-
)
127134

128-
for row in bullet_rows:
129-
row.indent(indent_buff=indent_buff)
130-
row.adjust()
135+
self.arrage_rows((row for row in rows if row.autoplace))
131136

132-
groups = [row.group for row in bullet_rows]
137+
groups = [row.group for row in rows]
133138

134139
# If there is a None and aso something else
135140
if (None in groups) and len(set(groups)) != 1:
136141
raise ValueError("The groups must be specified for all or no bullets at all.")
137142

138143
group2bullet = defaultdict(list)
139-
for i, row in enumerate(bullet_rows):
144+
for i, row in enumerate(rows):
140145
group = row.group
141146
if group is None:
142147
group = i

0 commit comments

Comments
 (0)