-
Notifications
You must be signed in to change notification settings - Fork 962
Description
For visual.textStim, using .setOpacity() has no effect on subsequent .draw(), unless .setText() is called between setOpacity() and draw(). Please note that opacity parameter (accessed by .opacity) does change, it is the stimulus appearance that doesn't change.
In the following example I am trying to present a sequence of letters in such a way that each letter fades in and out during a period of 60 screen flips.
from psychopy import core, visual, parallel
import numpy as np
win = visual.Window(size=(640,480), fullscr=False, allowGUI=True, units='pix')
myTextStim = visual.TextStim(win, font='Times New Roman', height=64, color='Black')
# generate some random letters
nletters = 10
randomAscii = np.random.random_integers(97,122, nletters)
letters = [chr(asc) for asc in randomAscii]
# let the opacity values change linearly from 0 to 1 to 0
n = np.arange(60)
opValues = np.bartlett(60)
# present letters one after another
for l in letters:
myTextStim.setText(l)
for nFrames in range(60):
myTextStim.setOpacity(opValues[nFrames])
# won't work without the line below
#myTextStim.setText(myTextStim.text)
myTextStim.draw()
win.flip()I know that this issue has been reported before via mailing list (for earlier psychoPy versions), but using setText() after every opacity change is inconvenient because of the recent memory issues (#973 and related). Also, replacing .setText() with using ._pygletTextObj.text = ... (which was suggested to circumvent memory problem) does not make opacity change become visible.
In my experiment I am using multiple words, presented as hundreds of letters (equivalent to large nletters in the above example), and thus memory usage (so far I have watched it only via task manager) grows very rapidly, becoming an issue itself.