mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Added Surround method to MObject, as well as special-case implementation of it to Circle
This commit is contained in:
parent
a0fc3ce324
commit
0ce1a528c6
2 changed files with 11 additions and 0 deletions
|
@ -384,6 +384,10 @@ class Mobject(object):
|
|||
self.shift(mobject.get_center() - self.get_center())
|
||||
return self
|
||||
|
||||
def surround(self, mobject, dim_to_match = 0, stretch = False, buffer_factor = 1.2):
|
||||
self.replace(mobject, dim_to_match, stretch)
|
||||
self.scale_in_place(buffer_factor)
|
||||
|
||||
def position_endpoints_on(self, start, end):
|
||||
curr_vect = self.points[-1] - self.points[0]
|
||||
if np.all(curr_vect == 0):
|
||||
|
|
|
@ -47,6 +47,13 @@ class Circle(Arc):
|
|||
def __init__(self, **kwargs):
|
||||
Arc.__init__(self, 2*np.pi, **kwargs)
|
||||
|
||||
def surround(self, mobject, dim_to_match = 0, stretch = False, buffer_factor = 1.2):
|
||||
# Ignores dim_to_match and stretch; result will always be a circle
|
||||
# TODO: Perhaps create an ellipse class to handle singele-dimension stretching
|
||||
self.replace(mobject, dim_to_match, stretch)
|
||||
self.scale_to_fit_width(np.sqrt(mobject.get_width()**2 + mobject.get_height()**2))
|
||||
self.scale(buffer_factor)
|
||||
|
||||
class Dot(Circle):
|
||||
CONFIG = {
|
||||
"radius" : 0.08,
|
||||
|
|
Loading…
Add table
Reference in a new issue