stim = visual.Rect(win)
stim.units = 'deg'
stim.width = 3 # degrees
stim.units = 'pix'
print stim.width # should give a value in pixels, i.e. different than 5
stim.pos = (300, -200) # in pix
stim.units = 'cm'
print stim.width # should give a value in cm.
stim.height = 4 # in cmfrom __future__ import division
import sys, brewer2mpl
sys.path.append("C:\\Program Files (x86)\\PsychoPy2\\Lib\\site-packages")
import psychopy
from psychopy import core, visual, event
# creation of window; note that in the end I want to create it with varying monitorsettings (e.g. mon1, mon2 etc with different resolutions)
mainwin = visual.Window([800, 600], monitor = 'testMonitor', fullscr = False, units='norm')
ndecks = 4 # represents the number of stimuli I want to present, should be changeable in the end
# in the following I will generate the coordinates (and appearance properties) for the stimuli
stimprops = {'deck%i'%key : int for key in range(1,ndecks+1)}
for i in range(1, ndecks+1):
stimprops['deck%i'%i] = {'pos':[(-1 + 1/ndecks + (i-1)*(2/ndecks)),0],
'col':brewer2mpl.get_map('Set1','qualitative',
ndecks).mpl_colors[i-1]}
# now a way how the presentation works, but with changing sizes of the stimuli according to the monitorsize
width = 0.1
height = 0.2
stims = {'deck%i'%key : int for key in range(1,ndecks+1)}
for i in stims:
stims[i] = visual.Rect(mainwin, width, height, pos = stimprops[i]['pos'],
fillColor = stimprops[i]['col'],fillColorSpace = 'rgb')
#and here's how I tried to implement your suggestion, but it doesn't adjust the size of the stimuli properly
#width = 2
#height = 3
#stims = {'deck%i'%key : int for key in range(1,ndecks+1)}
#for i in stims:
# stims[i] = visual.Rect(mainwin, width, height, units = 'cm',
# fillColor = stimprops[i]['col'],fillColorSpace = 'rgb')
# stims[i].units = 'norm'
# stims[i].pos = stimprops[i]['pos']
# presenting the stimuli:
for i in stims:
stims[i].draw()
mainwin.flip()
event.waitKeys()
core.quit()
def norm2pix(norm, win):Then in your script you would have::
x = norm[0]*win.size[0]/2.0
y = norm[1]*win.size[1]/2.0
return [x,y]
stim = visual.Rect(win, .... units='pix')hope that helps. NB none of the code above is tested - it's to give you ideas. Make sure it's doing what you expect!
stim.pos = norm2pix([0.1,0.2], win)
stim.size = cm2pix([3,2.5], win.monitor) #needs monitor not just win
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/acbbaa69-3d74-4009-ab82-2db8bb597c3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jonathan Peirce Nottingham Visual Neuroscience http://www.peirce.org.uk/