def main(): """Launch VisionEgg and demo the WrappedText object""" import VisionEgg VisionEgg.start_default_logging(); VisionEgg.watch_exceptions() import VisionEgg.FlowControl screen = VisionEgg.Core.get_default_screen() message="""Hello. This is a demonstration of the WrappedText object, which was created to allow users of VisionEgg to include large blocks of text in their programs. While this stimulus has many limitations, it should be useful for presenting on-screen instructions in experiments. While you are welcome to modify this file to extend its functionality, I hope you consider sharing any such modifications with the VisionEgg community. Eamon Caddigan,\nUniversity of Illinois\n15 November 2007""" wt = WrappedText(text=message, position=(50,screen.size[1]-50), size=(screen.size[0]-100, screen.size[1]-100)) viewport = VisionEgg.Core.Viewport(screen=screen, stimuli=[wt]) # Frame-based presentation duration makes it easier to use pdb p = VisionEgg.FlowControl.Presentation(viewports=[viewport], go_duration=(VisionEgg.config.VISIONEGG_MONITOR_REFRESH_HZ*30,'frames')) p.go() screen.close() # Called explicitly to behave better in interactive shells
def __init__(self): """We break up initialization a bit as we need to go back and forth with some information. In this case, we need screen size before specifying the stimuli""" VisionEgg.start_default_logging() VisionEgg.watch_exceptions() # get screen size for setting fullscreen resolution # comment this block out if you don't want to use full-screen. screen = pygame.display.set_mode((0, 0)) # this opens up a pygame window WIDTH, HEIGHT = screen.get_size() pygame.quit() # close this pygame window, or else it interferes w/ VE VisionEgg.config.VISIONEGG_SCREEN_W = WIDTH VisionEgg.config.VISIONEGG_SCREEN_H = HEIGHT self.screen = get_default_screen() self.keys = [] self.presses = [] self.releases = []
def __init__(self): """We break up initialization a bit as we need to go back and forth with some information. In this case, we need screen size before specifying the stimuli""" # pasted in from where it used to be at the beginning of the script # used to be outside of any methods... VisionEgg.start_default_logging() VisionEgg.watch_exceptions() # get screen size for setting fullscreen resolution # comment this block out if you don't want to use full-screen. screen = pygame.display.set_mode((0,0)) WIDTH, HEIGHT = screen.get_size() pygame.quit() VisionEgg.config.VISIONEGG_SCREEN_W = WIDTH VisionEgg.config.VISIONEGG_SCREEN_H = HEIGHT self.screen = get_default_screen() self.keys = [] self.presses = [] self.releases = []
#!/usr/bin/env python """Sinusoidal grating calculated in realtime.""" ############################ # Import various modules # ############################ import VisionEgg VisionEgg.start_default_logging(); VisionEgg.watch_exceptions() from VisionEgg.Core import * from VisionEgg.FlowControl import Presentation from VisionEgg.Gratings import * ##################################### # Initialize OpenGL window/screen # ##################################### screen = get_default_screen() ###################################### # Create sinusoidal grating object # ###################################### stimulus = SinGrating2D(position = ( screen.size[0]/2.0, screen.size[1]/2.0 ), anchor = 'center', size = ( 300.0 , 300.0 ), spatial_freq = 10.0 / screen.size[0], # units of cycles/pixel temporal_freq_hz = 1.0, orientation = 45.0 )
#! /usr/env/python import VisionEgg VisionEgg.start_default_logging() VisionEgg.watch_exceptions() from VisionEgg.Core import get_default_screen, Viewport from VisionEgg.FlowControl import Presentation, FunctionController, TIME_SEC_ABSOLUTE, FRAMES_ABSOLUTE from VisionEgg.Textures import * from VisionEgg.Text import * import serial import pickle import time import random import copy from pygame.locals import * import sys import os sys.path.append(os.path.split(os.getcwd())[0]) import subject from experiments import printWord, printText from mongoTools import MongoAdmin import shuffler ###COLLECT SUBJECT INFO
#!/usr/bin/env python """ Textures with alpha (transparency). """ import VisionEgg as ve ve.start_default_logging(); ve.watch_exceptions() import VisionEgg.Core as vec from VisionEgg.FlowControl import Presentation import VisionEgg.Textures as vet import Image, ImageDraw # Python Imaging Library (PIL) import OpenGL.GL as gl # PyOpenGL import os import numpy # Numeric screen = vec.get_default_screen() texel_scale = 5 # create background texture from image file bg_filename = os.path.join(ve.config.VISIONEGG_SYSTEM_DIR,"data","panorama.jpg") bg_texture = vet.Texture(bg_filename) bg = vet.TextureStimulus(texture = bg_texture, size = bg_texture.size, shrink_texture_ok=False, mipmaps_enabled=False, )
#!/usr/bin/env python """Demo for the arrow stimulus.""" # Author(s): Hubertus Becker <*****@*****.**> # Copyright: (C) 2004-2005 by Hertie Institute for Clinical Brain Research, # Department of Cognitive Neurology, University of Tuebingen # URL: http://www.hubertus-becker.de/resources/visionegg/ # $Revision$ $Date$ ############################ # Import various modules # ############################ import VisionEgg VisionEgg.start_default_logging() VisionEgg.watch_exceptions() from VisionEgg.Core import * from VisionEgg.FlowControl import Presentation from VisionEgg.MoreStimuli import * ##################################### # Initialize OpenGL window/screen # ##################################### screen = get_default_screen() screen.parameters.bgcolor = (0.0, 0.0, 0.0, 0.0) # Make it black (RGBA) ###################################### # Arrow stimulus #
#!/usr/bin/env python """Colored sine wave grating in circular mask""" ############################ # Import various modules # ############################ import VisionEgg VisionEgg.start_default_logging(); VisionEgg.watch_exceptions() from VisionEgg.Core import * from VisionEgg.FlowControl import Presentation, FunctionController from VisionEgg.Gratings import SinGrating2D from VisionEgg.Textures import Mask2D from math import * ##################################### # Initialize OpenGL window/screen # ##################################### screen = get_default_screen() ###################################### # Create sinusoidal grating object # ###################################### mask = Mask2D(function='circle', # also supports 'circle' radius_parameter=100, # sigma for gaussian, radius for circle (units: num_samples) num_samples=(256,256)) # this many texture elements in mask (covers whole size specified below) # NOTE: I am not a color scientist, and I am not familiar with the