mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Made Rectangle a Polygon
This commit is contained in:
parent
2730c1036b
commit
d695e2cc0b
1 changed files with 11 additions and 11 deletions
|
@ -702,15 +702,13 @@ class Polygon(VMobject):
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *vertices, **kwargs):
|
def __init__(self, *vertices, **kwargs):
|
||||||
assert len(vertices) > 1
|
|
||||||
digest_locals(self)
|
|
||||||
VMobject.__init__(self, **kwargs)
|
VMobject.__init__(self, **kwargs)
|
||||||
|
self.set_points_as_corners(
|
||||||
def generate_points(self):
|
[*vertices, vertices[0]]
|
||||||
self.set_anchor_points(self.vertices, mode="corners")
|
)
|
||||||
|
|
||||||
def get_vertices(self):
|
def get_vertices(self):
|
||||||
return self.get_anchors_and_handles()[0]
|
return self.get_start_anchors()
|
||||||
|
|
||||||
|
|
||||||
class RegularPolygon(Polygon):
|
class RegularPolygon(Polygon):
|
||||||
|
@ -725,7 +723,7 @@ class RegularPolygon(Polygon):
|
||||||
Polygon.__init__(self, *vertices, **kwargs)
|
Polygon.__init__(self, *vertices, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class Rectangle(VMobject):
|
class Rectangle(Polygon):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"color": WHITE,
|
"color": WHITE,
|
||||||
"height": 2.0,
|
"height": 2.0,
|
||||||
|
@ -734,14 +732,16 @@ class Rectangle(VMobject):
|
||||||
"close_new_points": True,
|
"close_new_points": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_points(self):
|
def __init__(self, **kwargs):
|
||||||
y, x = self.height / 2., self.width / 2.
|
digest_config(self, kwargs)
|
||||||
self.set_anchor_points([
|
x, y = self.width / 2., self.height / 2.
|
||||||
|
vertices = [
|
||||||
x * LEFT + y * UP,
|
x * LEFT + y * UP,
|
||||||
x * RIGHT + y * UP,
|
x * RIGHT + y * UP,
|
||||||
x * RIGHT + y * DOWN,
|
x * RIGHT + y * DOWN,
|
||||||
x * LEFT + y * DOWN
|
x * LEFT + y * DOWN
|
||||||
], mode="corners")
|
]
|
||||||
|
Polygon.__init__(self, *vertices, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class Square(Rectangle):
|
class Square(Rectangle):
|
||||||
|
|
Loading…
Add table
Reference in a new issue