本文整理汇总了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)
示例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)