Created
July 26, 2018 11:55
-
-
Save fladd/68016750066193af3a4b7faad6199c9f to your computer and use it in GitHub Desktop.
Fade between stimuli in Expyriment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.design.Experiment(background_colour=[150,150,150]) | |
expyriment.control.initialize(exp) | |
black_stim = stimuli.TextLine("A", text_colour=[0,0,0], text_size=100) | |
black_stim.preload(True) | |
white_stimlist = [] | |
for x in range(255): # prepare background stimulus with a certain transparency | |
c = stimuli.Canvas(black_stim.surface_size) | |
c._set_surface(c._get_surface().convert()) | |
white_stim = stimuli.TextLine("A", text_colour=[255,255,255], | |
background_colour=[150,150,150], | |
text_size=100) | |
white_stim.plot(c) | |
c._get_surface().set_alpha(x) | |
if expyriment.control.defaults.open_gl: | |
c2 = stimuli.Canvas(black_stim.surface_size) | |
c.plot(c2) | |
c = c2 | |
c.preload(True) | |
white_stimlist.append(c) | |
for x in range(255): | |
black_stim.present(update=False) | |
white_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