Example #1
0
 def setMask(self, value, log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message.
     """
     callAttributeSetter(self, 'mask', value, log)
Example #2
0
 def setWidth(self, width, log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     callAttributeSetter(self, 'width', width, log)
Example #3
0
 def setHeight(self, height, log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     callAttributeSetter(self, 'height', height, log)
Example #4
0
 def setPos(self, pos, needReset=True, log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     self._needReset = needReset
     callAttributeSetter(self, 'pos', pos, log)
Example #5
0
 def setOri(self, ori, needReset=True, log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message.
     """
     self._needReset = needReset
     callAttributeSetter(self, 'ori', ori, log)
Example #6
0
    def __init__(self, win,
                 text="Hello World",
                 font="",
                 pos=(0.0,0.0),
                 depth=0,
                 rgb=None,
                 color=(1.0,1.0,1.0),
                 colorSpace='rgb',
                 opacity=1.0,
                 contrast=1.0,
                 units="",
                 ori=0.0,
                 height=None,
                 antialias=True,
                 bold=False,
                 italic=False,
                 alignHoriz='center',
                 alignVert='center',
                 fontFiles=[],
                 wrapWidth=None,
                 flipHoriz=False, flipVert=False,
                 name='', autoLog=True):
        """
        **Performance OBS:** in general, TextStim is slower than many other visual
        stimuli, i.e. it takes longer to change some attributes. In general, it's
        the attributes that affect the shapes of the letters: 
        ``text``, ``height``, ``font``, ``bold`` etc. These make the next .draw()
        slower because that sets the text again. You can make the draw()
        quick by calling re-setting the text (```myTextStim.text = myTextStim.text) 
        when you've changed the parameters.
        
        In general, other attributes which merely affect the presentation of 
        unchanged shapes are as fast as usual. This includes ``pos``, ``opacity`` etc.
        """

        #what local vars are defined (these are the init params) for use by __repr__
        self._initParams = dir()
        self._initParams.remove('self')

        super(TextStim, self).__init__(win, units=units, name=name, autoLog=False)

        self._needUpdate = True
        self._needVertexUpdate = True
        self.__dict__['useShaders'] = win._haveShaders  #use shaders if available by default, this is a good thing
        self.__dict__['alignHoriz'] = alignHoriz
        self.__dict__['alignVert'] = alignVert
        self.__dict__['antialias'] = antialias
        self.__dict__['font'] = font
        self.__dict__['bold'] = bold
        self.__dict__['italic'] = italic
        self.__dict__['text'] = '' #NB just a placeholder - real value set below
        self.__dict__['depth'] = depth
        self.__dict__['ori'] = ori
        self.__dict__['flipHoriz']= flipHoriz
        self.__dict__['flipVert'] = flipVert
        self._pygletTextObj=None
        self.__dict__['pos']= numpy.array(pos, float)

        #generate the texture and list holders
        self._listID = GL.glGenLists(1)
        if not self.win.winType=="pyglet":#pygame text needs a surface to render to
            self._texID = GL.GLuint()
            GL.glGenTextures(1, ctypes.byref(self._texID))

        # Color stuff
        self.colorSpace=colorSpace
        if rgb!=None:
            logging.warning("Use of rgb arguments to stimuli are deprecated. Please use color and colorSpace args instead")
            self.setColor(rgb, colorSpace='rgb', log=False)
        else:
            self.setColor(color, log=False)

        self.__dict__['fontFiles'] = []
        self.fontFiles = fontFiles  # calls attributeSetter
        self.setHeight(height, log=False)  # calls setFont() at some point
        callAttributeSetter(self, 'wrapWidth', wrapWidth, log=False)  # calls attributeSetter without log
        self.__dict__['opacity'] = float(opacity)
        self.__dict__['contrast'] = float(contrast)
        self.setText(text, log=False) #self.width and self._fontHeightPix get set with text and calcSizeRendered is called
        self._needUpdate = True

        #set autoLog (now that params have been initialised)
        self.autoLog= autoLog
        if autoLog:
            logging.exp("Created %s = %s" %(self.name, str(self)))
Example #7
0
 def setFlipVert(self, newVal=True, log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message"""
     callAttributeSetter(self, 'flipVert', newVal, log)
Example #8
0
 def setText(self, text=None, log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message."""
     callAttributeSetter(self, 'text', text, log)