
複数物体のプロパティを一括操作できるElementArrayStimのデモ。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
from psychopy import visual,core
import numpy as np
win = visual.Window([800, 800], units='pix', monitor='testMonitor')
N = 3 #Num of rows=Set size
fieldSize = 200 #Field size
xys = np.array([[-1*fieldSize,0],[0,0],[fieldSize,0]]) #Element positions
elemSize = [50,10,70] #Element sizes
cols = np.array([[1,-1,-1],[-1,1,-1],[-1,-1,1]]) #R,G,B
masks = 'circle' #Element shapes
cs = 'rgb' #RGB color space
tget = visual.ElementArrayStim(win,
nElements=N, sizes=elemSize, sfs=0, phases=0,
xys=xys, colors=cols, colorSpace=cs,
elementMask=masks
)
tget.draw() #Draw the image.
win.flip() #Show the drawn image.
core.wait(2) #Wait 2 seconds.
win.close()
core.quit()

N=100 #Num of rows = Set size fieldSize = 600 #Field size xys = np.random.random_sample([N, 2]) * fieldSize - fieldSize / 2.0 #Random element positions elemSize=np.random.random_sample(N) * 100 #Random element sizes cols=np.random.uniform(low=-1,high=1,size=(N,3)) #Random RGB colors


win.getMovieFrame('front') #当然、'win'はvisual.Windowオブジェクトの変数名によって変わります。
win.saveMovieFrames('screenshot.jpg')
Builderを使った方法に続きます。