mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 05:24:22 +08:00
Merge branch 'master' of github.com:3b1b/manim into wallis-g
This commit is contained in:
@ -717,6 +717,41 @@ class Square(Rectangle):
|
||||
)
|
||||
|
||||
|
||||
class RoundedRectangle(Rectangle):
|
||||
CONFIG = {
|
||||
"corner_radius" : 0.5,
|
||||
"close_new_points" : True
|
||||
}
|
||||
|
||||
def generate_points(self):
|
||||
y, x = self.height / 2., self.width / 2.
|
||||
r = self.corner_radius
|
||||
|
||||
arc_ul = ArcBetweenPoints(x * LEFT + (y - r) * UP, (x - r) * LEFT + y * UP, angle = -TAU/4)
|
||||
arc_ur = ArcBetweenPoints((x - r) * RIGHT + y * UP, x * RIGHT + (y - r) * UP, angle = -TAU/4)
|
||||
arc_lr = ArcBetweenPoints(x * RIGHT + (y - r) * DOWN, (x - r) * RIGHT + y * DOWN, angle = -TAU/4)
|
||||
arc_ll = ArcBetweenPoints(x * LEFT + (y - r) * DOWN, (x - r) * LEFT + y * DOWN, angle = TAU/4) # sic! bug in ArcBetweenPoints?
|
||||
|
||||
points = arc_ul.points
|
||||
points = np.append(points,np.array([y * UP]), axis = 0)
|
||||
points = np.append(points,np.array([y * UP]), axis = 0)
|
||||
points = np.append(points,arc_ur.points, axis = 0)
|
||||
points = np.append(points,np.array([x * RIGHT]), axis = 0)
|
||||
points = np.append(points,np.array([x * RIGHT]), axis = 0)
|
||||
points = np.append(points,arc_lr.points, axis = 0)
|
||||
points = np.append(points,np.array([y * DOWN]), axis = 0)
|
||||
points = np.append(points,np.array([y * DOWN]), axis = 0)
|
||||
points = np.append(points,arc_ll.points[::-1], axis = 0) # sic! see comment above
|
||||
points = np.append(points,np.array([x * LEFT]), axis = 0)
|
||||
points = np.append(points,np.array([x * LEFT]), axis = 0)
|
||||
points = np.append(points,np.array([x * LEFT + (y - r) * UP]), axis = 0)
|
||||
|
||||
points = points[::-1]
|
||||
|
||||
self.set_points(points)
|
||||
|
||||
|
||||
|
||||
class Grid(VMobject):
|
||||
CONFIG = {
|
||||
"height": 6.0,
|
||||
|
Reference in New Issue
Block a user