Skip to content

Instantly share code, notes, and snippets.

@fladd
Created July 26, 2018 10:15
Show Gist options
  • Save fladd/c6916bddcd56461a2313b354b0d38c06 to your computer and use it in GitHub Desktop.
Save fladd/c6916bddcd56461a2313b354b0d38c06 to your computer and use it in GitHub Desktop.
Fading out a stimulus in Expyriment
import expyriment, os, pygame, time
from expyriment import design, control, stimuli, io
from expyriment.misc import constants
#expyriment.control.defaults.open_gl = 0
control.set_develop_mode(True)
exp = expyriment.control.initialize()
stim = stimuli.TextLine("A", text_colour=[255,255,255], text_size=100)
stim.preload(True)
bgcanvas_stimlist = []
for x in range(255): # prepare background stimulus with a certain transparency
c = stimuli.Canvas(stim.surface_size)
c._set_surface(c._get_surface().convert())
c._get_surface().set_alpha(x)
if expyriment.control.defaults.open_gl:
c2 = stimuli.Canvas(stim.surface_size)
c.plot(c2)
c = c2
c.preload(True)
bgcanvas_stimlist.append(c)
for x in range(255):
stim.present(update=False)
bgcanvas_stimlist[x].present(clear=False) #
exp.clock.wait(10)
expyriment.control.end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment