mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Cleanup to square and rectangle init
This commit is contained in:
parent
222b6d1220
commit
00ad9d7f95
1 changed files with 14 additions and 11 deletions
|
@ -766,10 +766,14 @@ class Rectangle(Polygon):
|
||||||
|
|
||||||
def __init__(self, width=None, height=None, **kwargs):
|
def __init__(self, width=None, height=None, **kwargs):
|
||||||
Polygon.__init__(self, UR, UL, DL, DR, **kwargs)
|
Polygon.__init__(self, UR, UL, DL, DR, **kwargs)
|
||||||
self.width = width or self.width
|
|
||||||
self.height = height or self.height
|
if width is None:
|
||||||
self.set_width(self.width, stretch=True)
|
width = self.width
|
||||||
self.set_height(self.height, stretch=True)
|
if height is None:
|
||||||
|
height = self.height
|
||||||
|
|
||||||
|
self.set_width(width, stretch=True)
|
||||||
|
self.set_height(height, stretch=True)
|
||||||
|
|
||||||
|
|
||||||
class Square(Rectangle):
|
class Square(Rectangle):
|
||||||
|
@ -777,14 +781,13 @@ class Square(Rectangle):
|
||||||
"side_length": 2.0,
|
"side_length": 2.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, side_length=None, **kwargs):
|
||||||
digest_config(self, kwargs)
|
digest_config(self, kwargs)
|
||||||
Rectangle.__init__(
|
|
||||||
self,
|
if side_length is None:
|
||||||
height=self.side_length,
|
side_length = self.side_length
|
||||||
width=self.side_length,
|
|
||||||
**kwargs
|
super().__init__(side_length, side_length, **kwargs)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class RoundedRectangle(Rectangle):
|
class RoundedRectangle(Rectangle):
|
||||||
|
|
Loading…
Add table
Reference in a new issue