mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Add Scene.point_to_mobject
This commit is contained in:
parent
61aec6051a
commit
acba13f499
1 changed files with 13 additions and 1 deletions
|
@ -104,7 +104,7 @@ class Scene(object):
|
||||||
self.quit_interaction = False
|
self.quit_interaction = False
|
||||||
self.lock_static_mobject_data()
|
self.lock_static_mobject_data()
|
||||||
while not (self.window.is_closing or self.quit_interaction):
|
while not (self.window.is_closing or self.quit_interaction):
|
||||||
self.update_frame()
|
self.update_frame(1 / self.camera.frame_rate)
|
||||||
if self.window.is_closing:
|
if self.window.is_closing:
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
if self.quit_interaction:
|
if self.quit_interaction:
|
||||||
|
@ -248,6 +248,18 @@ class Scene(object):
|
||||||
def get_mobject_copies(self):
|
def get_mobject_copies(self):
|
||||||
return [m.copy() for m in self.mobjects]
|
return [m.copy() for m in self.mobjects]
|
||||||
|
|
||||||
|
def point_to_mobject(self, point, search_set=None, buff=0):
|
||||||
|
"""
|
||||||
|
E.g. if clicking on the scene, this returns the top layer mobject
|
||||||
|
under a given point
|
||||||
|
"""
|
||||||
|
if search_set is None:
|
||||||
|
search_set = self.mobjects
|
||||||
|
for mobject in reversed(search_set):
|
||||||
|
if mobject.is_point_touching(point, buff=buff):
|
||||||
|
return mobject
|
||||||
|
return None
|
||||||
|
|
||||||
# Related to skipping
|
# Related to skipping
|
||||||
def update_skipping_status(self):
|
def update_skipping_status(self):
|
||||||
if self.start_at_animation_number is not None:
|
if self.start_at_animation_number is not None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue