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


Python Simulation.drawImage方法代码示例

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


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

示例1: startStandalone

# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import drawImage [as 别名]
def startStandalone():
    import Simulation
    print('MagneticPendulum  -Standalone')
    print('--------------------------------------------')
    print('Image resolution: {0}x{0} Output: {1}'.format(Parameter.RESOLUTION, Parameter.IMG_NAME))
    print('Working with {0} sub-processes in total.'.format(Parameter.MAX_PROCESSES))
    print('============================================')
    start = time.time()
    im= Image.new('RGB', (Parameter.RESOLUTION, Parameter.RESOLUTION))
    data = []
    pixel = [] + [0]*(Parameter.RESOLUTION**2)
    manager = Manager()
    coordinates = manager.Queue()
    values = manager.Queue()
    workerRunning = manager.Value('i', 0)
    Simulation.createAllCoordinates(coordinates, data) 
    while workerRunning.get() < Parameter.MAX_PROCESSES:
        Process(target=Simulation.workerThread,args=(coordinates, workerRunning, values)).start()
        time.sleep(1)
    while workerRunning.value > 0:
        Simulation.drawImage(im, data, pixel, values)
        time.sleep(Parameter.REPAINT)
    Simulation.drawImage(im, data, pixel, values)
    print('Image succeeded. Time consumed: {0:.2f}s'.format((time.time() - start)))
    print('Exiting...')
    sys.exit(0)     
开发者ID:Schille,项目名称:MagneticPendulum,代码行数:28,代码来源:Standalone.py

示例2: startServer

# 需要导入模块: import Simulation [as 别名]
# 或者: from Simulation import drawImage [as 别名]
def startServer():
    freeze_support()
    print('MagneticPendulum  -Cluster/Server')
    print('--------------------------------------------')
    print('Image resolution: {0}x{0} Output: {1}'.format(Parameter.RESOLUTION, Parameter.IMG_NAME))
    print('============================================')
    print('Now waiting to have some working clients.')
    import Simulation
    manager = ClusterQueueManager()
    data = []
    coordinates = manager.getCoordinates()
    values = manager.getValues()
    im= Image.new('RGB', (Parameter.RESOLUTION, Parameter.RESOLUTION))
    pixel = [] + [0]*(Parameter.RESOLUTION**2)
    Simulation.createAllCoordinates(coordinates, data)
    start = time.time()
    manager.start()
    while not coordinates.empty():
        while manager.getRunningClients() > 0:
            if not values.empty():
                Simulation.drawImage(im, data, pixel, values)
            time.sleep(Parameter.REPAINT)
        time.sleep(.5)
    print("Coordinates are now completely distributed.")
    
    while manager.getRunningClients() > 0:
        time.sleep(Parameter.REPAINT)
        print('Waiting for {0} clients to be done'.format(manager.getRunningClients()))
    Simulation.drawImage(im, data, pixel, values)
    print('Image succeeded. Time consumed: {0:.2f}s'.format((time.time() - start)))
    print('Exiting...')
    sys.exit(0)
开发者ID:Schille,项目名称:MagneticPendulum,代码行数:34,代码来源:ClusterServer.py


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