当前位置: 首页>>代码示例>>Python>>正文


Python Scene.remove方法代码示例

本文整理汇总了Python中scene.Scene.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.remove方法的具体用法?Python Scene.remove怎么用?Python Scene.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scene.Scene的用法示例。


在下文中一共展示了Scene.remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: summarize_pattern

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import remove [as 别名]
def summarize_pattern(*radians):
    sc = Scene()
    circle = Circle(density = CIRCLE_DENSITY).scale(RADIUS)
    sc.add(circle)
    points = [
        (RADIUS * np.cos(angle), RADIUS * np.sin(angle), 0)
        for angle in radians
    ]
    dots = [Dot(point) for point in points]
    last_num = None
    for x in xrange(len(points)):
        new_lines = Mobject(*[
            Line(points[x], points[y]) for y in xrange(x)
        ])
        num = TexMobject(str(moser_function(x + 1))).center()
        sc.animate(
            Transform(last_num, num) if last_num else ShowCreation(num),
            FadeIn(new_lines),
            FadeIn(dots[x]),
            run_time = 0.5,
        )
        sc.remove(last_num)
        last_num = num
        sc.add(num, dots[x], new_lines)
        sc.dither()
    return sc
开发者ID:astoeckley,项目名称:manim,代码行数:28,代码来源:moser_intro.py

示例2: count_sections

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import remove [as 别名]
def count_sections(*radians):
    sc = Scene()
    circle = Circle(density = CIRCLE_DENSITY).scale(RADIUS)
    sc.add(circle)
    points = [
        (RADIUS * np.cos(angle), RADIUS * np.sin(angle), 0)
        for angle in radians
    ]
    dots = [Dot(point) for point in points]
    interior = Region(lambda x, y : x**2 + y**2 < RADIUS**2)    
    for x in xrange(1, len(points)):
        if x == 1:
            sc.animate(ShowCreation(dots[0]), ShowCreation(dots[1]))
            sc.add(dots[0], dots[1])
        else:
            sc.animate(ShowCreation(dots[x]))
            sc.add(dots[x])
        new_lines = Mobject(*[
            Line(points[x], points[y]) for y in xrange(x)
        ])
        sc.animate(Transform(deepcopy(dots[x]), new_lines, run_time = 2.0))
        sc.add(new_lines)
        sc.dither()
        regions = plane_partition_from_points(*points[:x+1])
        for reg in regions:
            reg.intersect(interior)
        regions = filter(lambda reg : reg.bool_grid.any(), regions)

        last_num = None
        for reg, count in zip(regions, it.count(1)):
            number = TexMobject(str(count)).shift((RADIUS, 3, 0))
            sc.highlight_region(reg)
            rt = 1.0 / (x**0.8)
            sc.add(number)
            sc.remove(last_num)
            last_num = number
            sc.dither(rt)
            sc.reset_background()
        sc.remove(last_num)
        sc.animate(Transform(last_num, deepcopy(last_num).center()))
        sc.dither()
        sc.remove(last_num)
    return sc
开发者ID:astoeckley,项目名称:manim,代码行数:45,代码来源:moser_intro.py

示例3: WhackAMole

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import remove [as 别名]
class WhackAMole(object):
    
    title = "Whack A Mole"
        
    def __init__(self):
        
        if not os.path.exists("data"): os.mkdir("data")
            
        pyglet.resource.path.append('resources')
        pyglet.resource.reindex()
        pyglet.resource.add_font('cutouts.ttf')
        pyglet.resource.add_font('scoreboard.ttf')
        
        director.init(width=int(1024*1.0), height=int(768*1.1),
                  caption=self.title, visible=False, resizable=True)
        director.window.set_size(int(1024*1.0), int(768*1.1))
        
        director.window.pop_handlers()
        director.window.push_handlers(DefaultHandler())
                    
        director.settings = {'overlay': False,
                             'eyetracker': True,
                             'eyetracker_ip': '127.0.0.1',
                             'eyetracker_out_port': '4444',
                             'eyetracker_in_port': '5555',
                             'calibration_speed': 1,
                             'calibration_wait': 1,
                             'calibration_random': 1,
                             'calibration_level': 3,
                             'calibration_auto': 1,
                             'calibration_points': 2,
                             'calibration_eye': 0
                            }
        
        self.client = None
        
        self.client = iViewXClient(director.settings['eyetracker_ip'], int(director.settings['eyetracker_out_port']))
        self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client)

        director.set_show_FPS(False)
        director.window.set_fullscreen(False)
        if director.settings['eyetracker']:
            director.window.set_mouse_visible(False)
        else:
            director.window.set_mouse_visible(True)
                
        # Intro scene and its layers        
        self.introScene = Scene()
                    
        self.mainMenu = MainMenu()
        self.optionsMenu = OptionsMenu()
        self.eyetrackerScrim = EyetrackerScrim()
        
        self.mplxLayer = MultiplexLayer(self.mainMenu, self.optionsMenu)
        self.introScene.add(self.mplxLayer, 1)
        
        self.introScene.register_event_type('start_task')
        self.introScene.register_event_type('eyetracker_info_changed')
        self.introScene.push_handlers(self)
                
        # Task scene and its layers
        self.taskScene = Scene()
        self.taskLayer = Task(self.client)

        self.calibrationLayer = CalibrationLayer(self.client)
        self.calibrationLayer.register_event_type('show_headposition')
        self.calibrationLayer.register_event_type('hide_headposition')
        self.calibrationLayer.push_handlers(self)
        
        self.taskLayer.register_event_type('new_trial')
        self.taskLayer.register_event_type('start_calibration')
        self.taskLayer.register_event_type('stop_calibration')
        self.taskLayer.push_handlers(self)
                
        self.taskScene.add(self.taskLayer, 1)
        
        self.taskScene.register_event_type('show_intro_scene')
        self.taskScene.push_handlers(self)
            
        director.window.set_visible(True)
        
    def start_calibration(self, on_success, on_failure):
        self.calibrationLayer.on_success = on_success
        self.calibrationLayer.on_failure = on_failure
        self.calibrationLayer.points = director.settings['calibration_points']
        self.calibrationLayer.eye = director.settings['calibration_eye']
        self.calibrationLayer.level = director.settings['calibration_level']
        self.calibrationLayer.speed = director.settings['calibration_speed']
        self.calibrationLayer.auto = director.settings['calibration_auto']
        self.calibrationLayer.wait = director.settings['calibration_wait']
        self.calibrationLayer.random = director.settings['calibration_random']
        self.taskScene.add(self.calibrationLayer, 2)
        
    def stop_calibration(self):
        self.taskScene.remove(self.calibrationLayer)
            
    def eyetracker_listen(self, _):
        self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client)
        self.introScene.remove(self.eyetrackerScrim)
        self.introScene.enable_handlers(True)
#.........这里部分代码省略.........
开发者ID:CogWorks,项目名称:WhackAMole,代码行数:103,代码来源:whack_a_mole.py

示例4: WilliamsEnvironment

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import remove [as 别名]

#.........这里部分代码省略.........
        self.introScene = Scene()
                    
        self.mainMenu = MainMenu()
        self.optionsMenu = OptionsMenu()
        self.participantMenu = ParticipantMenu()
        self.introBackground = BackgroundLayer()
        self.eyetrackerScrim = EyetrackerScrim()
        
        self.introScene.add(self.introBackground)
        self.mplxLayer = MultiplexLayer(self.mainMenu, self.optionsMenu, self.participantMenu)
        self.introScene.add(self.mplxLayer, 1)
        
        self.introScene.register_event_type('start_task')
        self.introScene.register_event_type('eyetracker_info_changed')
        self.introScene.push_handlers(self)
        
        # Task scene and its layers
        self.taskScene = Scene()
        
        self.taskBackgroundLayer = TaskBackground()
        self.taskLayer = Task(self.client, self.client_actr)
        self.actrScrim = ACTRScrim()
        
        if self.client:
            self.calibrationLayer = CalibrationLayer(self.client)
            self.calibrationLayer.register_event_type('show_headposition')
            self.calibrationLayer.register_event_type('hide_headposition')
            self.calibrationLayer.push_handlers(self)
            self.headpositionLayer = HeadPositionLayer(self.client)
        
        self.taskLayer.register_event_type('new_trial')
        self.taskLayer.push_handlers(self.taskBackgroundLayer)
        self.taskLayer.register_event_type('start_calibration')
        self.taskLayer.register_event_type('stop_calibration')
        self.taskLayer.register_event_type('show_headposition')
        self.taskLayer.register_event_type('hide_headposition')
        self.taskLayer.register_event_type('actr_wait_connection')
        self.taskLayer.register_event_type('actr_wait_model')
        self.taskLayer.register_event_type('actr_running')
        self.taskLayer.push_handlers(self)
        
        self.taskScene.add(self.taskBackgroundLayer)
        self.taskScene.add(self.taskLayer, 1)
        self.actrScrim.visible = False
        self.taskScene.add(self.actrScrim, 3)
        
        self.taskScene.register_event_type('show_intro_scene')
        self.taskScene.push_handlers(self)
            
        director.window.set_visible(True)
    
    def actr_wait_connection(self):
        self.actrScrim.setWaitConnection()
        self.actrScrim.visible = True
        
    def actr_wait_model(self):
        self.actrScrim.setWaitModel()
        self.actrScrim.visible = True
    
    def actr_running(self):
        self.actrScrim.visible = False

    def start_calibration(self, on_success, on_failure):
        self.calibrationLayer.on_success = on_success
        self.calibrationLayer.on_failure = on_failure
        self.taskScene.add(self.calibrationLayer, 2)
        
    def stop_calibration(self):
        self.taskScene.remove(self.calibrationLayer)
    
    def show_headposition(self):
        self.taskScene.add(self.headpositionLayer, 3)
        
    def hide_headposition(self):
        self.taskScene.remove(self.headpositionLayer)
        
    def eyetracker_listen(self, _):
        self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client)
        self.introScene.remove(self.eyetrackerScrim)
        self.introScene.enable_handlers(True)
        
    def eyetracker_info_changed(self):
        if self.client.remoteHost != director.settings['eyetracker_ip'] or \
        self.client.remotePort != int(director.settings['eyetracker_out_port']):
            self.client.remoteHost = director.settings['eyetracker_ip']
            self.client.remotePort = int(director.settings['eyetracker_out_port'])
        else:
            self.introScene.add(self.eyetrackerScrim, 2)
            self.introScene.enable_handlers(False)
            d = self.listener.stopListening()
            d.addCallback(self.eyetracker_listen)
        
    def show_intro_scene(self):
        director.window.set_mouse_visible(True)
        self.mplxLayer.switch_to(0)
        director.replace(self.introScene)
        
    def start_task(self):
        director.window.set_mouse_visible(False)
        director.replace(SplitRowsTransition(self.taskScene))
开发者ID:CogWorks,项目名称:WilliamsTask,代码行数:104,代码来源:main.py

示例5: SnakeEnvironment

# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import remove [as 别名]

#.........这里部分代码省略.........
        self.mplxLayer = MultiplexLayer(self.mainMenu, self.optionsMenu, self.participantMenu)
        self.introScene.add(self.mplxLayer, 1)
        
        self.introScene.register_event_type('start_task')
        self.introScene.register_event_type('eyetracker_info_changed')
        self.introScene.push_handlers(self)
        
        # Task scene and its layers
        self.taskScene = Scene()
        
        self.taskBackgroundLayer = TaskBackground()
        self.taskLayer = Task(self.client, self.client_actr)
        self.scoreLayer = self.taskLayer.score_layer
        self.actrScrim = ACTRScrim()
        
        if self.client:
            self.calibrationLayer = CalibrationLayer(self.client)
            self.calibrationLayer.register_event_type('show_headposition')
            self.calibrationLayer.register_event_type('hide_headposition')
            self.calibrationLayer.push_handlers(self)
            self.headpositionLayer = HeadPositionLayer(self.client)
            self.fixationLayer = FixationLayer(self.client)
        
        self.taskLayer.register_event_type('new_trial')
        self.taskLayer.push_handlers(self.taskBackgroundLayer)
        self.taskLayer.register_event_type('start_calibration')
        self.taskLayer.register_event_type('stop_calibration')
        self.taskLayer.register_event_type('show_headposition')
        self.taskLayer.register_event_type('hide_headposition')
        self.taskLayer.register_event_type('show_fixation')
        self.taskLayer.register_event_type('hide_fixation')
        self.taskLayer.register_event_type('actr_wait_connection')
        self.taskLayer.register_event_type('actr_wait_model')
        self.taskLayer.register_event_type('actr_running')
        self.taskLayer.push_handlers(self)
        
        self.taskScene.add(self.taskBackgroundLayer)
        self.taskScene.add(self.taskLayer, 1)
        self.taskScene.add(self.scoreLayer, 1)
        self.actrScrim.visible = False
        self.taskScene.add(self.actrScrim, 3)
        
        self.taskScene.register_event_type('show_intro_scene')
        self.taskScene.push_handlers(self)
            
        director.window.set_visible(True)
    
    def actr_wait_connection(self):
        self.actrScrim.setWaitConnection()
        self.actrScrim.visible = True
        
    def actr_wait_model(self):
        self.actrScrim.setWaitModel()
        self.actrScrim.visible = True
    
    def actr_running(self):
        self.actrScrim.visible = False

    def start_calibration(self, on_success, on_failure):
        self.calibrationLayer.on_success = on_success
        self.calibrationLayer.on_failure = on_failure
        self.taskScene.add(self.calibrationLayer, 2)
        
    def stop_calibration(self):
        self.taskScene.remove(self.calibrationLayer)
    
    def show_headposition(self):
        self.taskScene.add(self.headpositionLayer, 3)
        
    def hide_headposition(self):
        self.taskScene.remove(self.headpositionLayer)
        
    def show_fixation(self):
        self.taskScene.add(self.fixationLayer, 4)
        
    def hide_fixation(self):
        self.taskScene.remove(self.fixationLayer)
        
    def eyetracker_listen(self, _):
        self.listener = reactor.listenUDP(int(director.settings['eyetracker_in_port']), self.client)
        self.introScene.remove(self.eyetrackerScrim)
        self.introScene.enable_handlers(True)
        
    def eyetracker_info_changed(self):
        if self.client.remoteHost != director.settings['eyetracker_ip'] or \
        self.client.remotePort != int(director.settings['eyetracker_out_port']):
            self.client.remoteHost = director.settings['eyetracker_ip']
            self.client.remotePort = int(director.settings['eyetracker_out_port'])
        else:
            self.introScene.add(self.eyetrackerScrim, 2)
            self.introScene.enable_handlers(False)
            d = self.listener.stopListening()
            d.addCallback(self.eyetracker_listen)
        
    def show_intro_scene(self):
        self.mplxLayer.switch_to(0)
        director.replace(self.introScene)
        
    def start_task(self):
        director.replace(SplitRowsTransition(self.taskScene))
开发者ID:CogWorks,项目名称:pySnake,代码行数:104,代码来源:main.py


注:本文中的scene.Scene.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。