mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Add smarter default radius to round_corners
This commit is contained in:
parent
aaea3f40f6
commit
4c1210b3ab
1 changed files with 9 additions and 1 deletions
|
@ -895,7 +895,15 @@ class Polygon(VMobject):
|
|||
def get_vertices(self) -> list[np.ndarray]:
|
||||
return self.get_start_anchors()
|
||||
|
||||
def round_corners(self, radius: float = 0.5):
|
||||
def round_corners(self, radius: float | None = None):
|
||||
if radius is None:
|
||||
verts = self.get_vertices()
|
||||
min_edge_length = min(
|
||||
get_norm(v1 - v2)
|
||||
for v1, v2 in zip(verts, verts[1:])
|
||||
if not np.isclose(v1, v2).all()
|
||||
)
|
||||
radius = 0.25 * min_edge_length
|
||||
vertices = self.get_vertices()
|
||||
arcs = []
|
||||
for v1, v2, v3 in adjacent_n_tuples(vertices, 3):
|
||||
|
|
Loading…
Add table
Reference in a new issue