def color(self, value): """Color of the stimulus Value should be one of: + string: to specify a :ref:`colorNames` or :ref:`hexColors` + numerically: (scalar or triplet) for DKL, RGB or other :ref:`colorspaces`. For these, :ref:`operations <attrib-operations>` are supported. When color is specified using numbers, it is interpreted with respect to the stimulus' current colorSpace. If color is given as a single value (scalar) then this wil be applied to all 3 channels. Examples:: myStim.color = 'white' myStim.color = 'RoyalBlue' #(the case is actually ignored) myStim.color = '#DDA0DD' #DDA0DD is hexadecimal for plum myStim.color = [1.0,-1.0,-1.0] #if colorSpace='rgb': a red color in rgb space myStim.color = [0.0,45.0,1.0] #if colorSpace='dkl': DKL space with elev=0, azimuth=45 myStim.color = [0,0,255] #if colorSpace='rgb255': a blue stimulus using rgb255 space :ref:`Operations <attrib-operations>` work as normal. For example, assuming that colorSpace='rgb':: thisStim.color += [1,1,1] #increment all guns by 1 value thisStim.color *= -1 #multiply the color by -1 (which in this space inverts the contrast) thisStim.color *= [0.5, 0, 1] #decrease red, remove green, keep blue """ setColor(self, value, rgbAttrib='rgb', colorAttrib='color')
def setColors(self, color, colorSpace=None, operation='', log=None): """See ``color`` for more info on the color parameter and ``colorSpace`` for more info in the colorSpace parameter. """ setColor( self, color, colorSpace=colorSpace, operation=operation, rgbAttrib='rgbs', # or 'fillRGB' etc colorAttrib='colors', colorSpaceAttrib='colorSpace') logAttrib(self, log, 'colors', value='%s (%s)' % (self.colors, self.colorSpace)) # check shape if self.rgbs.shape in ((), (1, ), (3, )): self.rgbs = numpy.resize(self.rgbs, [self.nElements, 3]) elif self.rgbs.shape in ((self.nElements, ), (self.nElements, 1)): self.rgbs.shape = (self.nElements, 1) # set to be 2D self.rgbs = self.rgbs.repeat(3, 1) # repeat once on dim 1 elif self.rgbs.shape == (self.nElements, 3): pass # all is good else: raise ValueError("New value for setRgbs should be either " "Nx1, Nx3 or a single value") self._needColorUpdate = True
def lineColor(self, color): """Sets the color of the shape lines. See :meth:`psychopy.visual.GratingStim.color` for further details of how to use colors. """ setColor(self, color, rgbAttrib='lineRGB', colorAttrib='lineColor')
def setColors(self, color, colorSpace=None, operation='', log=True): """Set the color of the stimulus. See :ref:`colorspaces` for further information about the various ways to specify colors and their various implications. :Parameters: color : Can be specified in one of many ways. You must provide a triplet of values, which refer to the coordinates in one of the :ref:`colorspaces`. If no color space is specified then the color space most recently used for this stimulus is used again. myStim.setColor([1.0,-1.0,-1.0], 'rgb')#a red color in rgb space myStim.setColor([0.0,45.0,1.0], 'dkl') #DKL space with elev=0, azimuth=45 myStim.setColor([0,0,255], 'rgb255') #a blue stimulus using rgb255 space Lastly, a single number can be provided, x, which is equivalent to providing [x,x,x]. myStim.setColor(255, 'rgb255') #all guns o max colorSpace : string or None defining which of the :ref:`colorspaces` to use. For strings and hex values this is not needed. If None the default colorSpace for the stimulus is used (defined during initialisation). operation : one of '+','-','*','/', or '' for no operation (simply replace value) for colors specified as a triplet of values (or single intensity value) the new value will perform this operation on the previous color thisStim.setColor([1,1,1],'rgb255','+')#increment all guns by 1 value thisStim.setColor(-1, 'rgb', '*') #multiply the color by -1 (which in this space inverts the contrast) thisStim.setColor([10,0,0], 'dkl', '+')#raise the elevation from the isoluminant plane by 10 deg """ setColor( self, color, colorSpace=colorSpace, operation=operation, rgbAttrib='rgbs', #or 'fillRGB' etc colorAttrib='colors', colorSpaceAttrib='colorSpace', log=log) #check shape if self.rgbs.shape in [(), (1, ), (3, )]: self.rgbs = numpy.resize(self.rgbs, [self.nElements, 3]) elif self.rgbs.shape in [(self.nElements, ), (self.nElements, 1)]: self.rgbs.shape = (self.nElements, 1) #set to be 2D self.rgbs = self.rgbs.repeat(3, 1) #repeat once on dim 1 elif self.rgbs.shape == (self.nElements, 3): pass #all is good else: raise ValueError( "New value for setRgbs should be either Nx1, Nx3 or a single value" ) self._needColorUpdate = True
def setColor(self, color, colorSpace=None, operation='', log=True): """Usually you can use 'stim.attribute = value' syntax instead, but use this method if you need to suppress the log message """ setColor(self,color, colorSpace=colorSpace, operation=operation, rgbAttrib='rgb', #or 'fillRGB' etc colorAttrib='color', log=log)
def setLineColor(self, color, colorSpace=None, operation='', log=True): """Sets the color of the shape edge. See :meth:`psychopy.visual.GratingStim.color` for further details of how to use this function. """ setColor(self,color, colorSpace=colorSpace, operation=operation, rgbAttrib='lineRGB',#the name for this rgb value colorAttrib='lineColor',#the name for this color log=log)
def setColors(self, color, colorSpace=None, operation="", log=True): """Set the color of the stimulus. See :ref:`colorspaces` for further information about the various ways to specify colors and their various implications. :Parameters: color : Can be specified in one of many ways. You must provide a triplet of values, which refer to the coordinates in one of the :ref:`colorspaces`. If no color space is specified then the color space most recently used for this stimulus is used again. myStim.setColor([1.0,-1.0,-1.0], 'rgb')#a red color in rgb space myStim.setColor([0.0,45.0,1.0], 'dkl') #DKL space with elev=0, azimuth=45 myStim.setColor([0,0,255], 'rgb255') #a blue stimulus using rgb255 space Lastly, a single number can be provided, x, which is equivalent to providing [x,x,x]. myStim.setColor(255, 'rgb255') #all guns o max colorSpace : string or None defining which of the :ref:`colorspaces` to use. For strings and hex values this is not needed. If None the default colorSpace for the stimulus is used (defined during initialisation). operation : one of '+','-','*','/', or '' for no operation (simply replace value) for colors specified as a triplet of values (or single intensity value) the new value will perform this operation on the previous color thisStim.setColor([1,1,1],'rgb255','+')#increment all guns by 1 value thisStim.setColor(-1, 'rgb', '*') #multiply the color by -1 (which in this space inverts the contrast) thisStim.setColor([10,0,0], 'dkl', '+')#raise the elevation from the isoluminant plane by 10 deg """ setColor( self, color, colorSpace=colorSpace, operation=operation, rgbAttrib="rgbs", # or 'fillRGB' etc colorAttrib="colors", colorSpaceAttrib="colorSpace", log=log, ) # check shape if self.rgbs.shape in [(), (1,), (3,)]: self.rgbs = numpy.resize(self.rgbs, [self.nElements, 3]) elif self.rgbs.shape in [(self.nElements,), (self.nElements, 1)]: self.rgbs.shape = (self.nElements, 1) # set to be 2D self.rgbs = self.rgbs.repeat(3, 1) # repeat once on dim 1 elif self.rgbs.shape == (self.nElements, 3): pass # all is good else: raise ValueError("New value for setRgbs should be either Nx1, Nx3 or a single value") self._needColorUpdate = True
def fillColor(self, color): """ Sets the color of the shape fill. See :meth:`psychopy.visual.GratingStim.color` for further details of how to use colors. Note that shapes where some vertices point inwards will usually not 'fill' correctly. """ setColor(self, color, rgbAttrib='fillRGB', colorAttrib='fillColor')
def setLineColor(self, color, colorSpace=None, operation='', log=None): """Sets the color of the shape edge. See :meth:`psychopy.visual.GratingStim.color` for further details. """ setColor(self, color, colorSpace=colorSpace, operation=operation, rgbAttrib='lineRGB', # the name for this rgb value colorAttrib='lineColor') # the name for this color logAttrib(self, log, 'lineColor', value='%s (%s)' % (self.lineColor, self.lineColorSpace))
def setFillColor(self, color, colorSpace=None, operation='', log=True): """Sets the color of the shape fill. See :meth:`psychopy.visual.GratingStim.color` for further details of how to use this function. Note that shapes where some vertices point inwards will usually not 'fill' correctly. """ #run the original setColor, which creates color and setColor(self,color, colorSpace=colorSpace, operation=operation, rgbAttrib='fillRGB',#the name for this rgb value colorAttrib='fillColor',#the name for this color log=log)
def setColor(self, color, colorSpace=None, operation='', log=True): """Usually you can use 'stim.attribute = value' syntax instead, but use this method if you need to suppress the log message """ setColor( self, color, colorSpace=colorSpace, operation=operation, rgbAttrib='rgb', #or 'fillRGB' etc colorAttrib='color', log=log)
def setColor(self, color, colorSpace=None, operation='', log=True): """Usually you can use 'stim.attribute = value' syntax instead, but use this method if you need to suppress the log message and/or set colorSpace simultaneously. """ # NB: the setColor helper function! Not this function itself :-) setColor(self,color, colorSpace=colorSpace, operation=operation, rgbAttrib='rgb', #or 'fillRGB' etc colorAttrib='color', log=log) if self.__class__.__name__ == 'TextStim' and not self.useShaders: self._needSetText = True
def setLineColor(self, color, colorSpace=None, operation="", log=None): """Sets the color of the shape edge. See :meth:`psychopy.visual.GratingStim.color` for further details of how to use this function. """ setColor( self, color, colorSpace=colorSpace, operation=operation, rgbAttrib="lineRGB", # the name for this rgb value colorAttrib="lineColor", # the name for this color ) logAttrib(self, log, "lineColor", value="%s (%s)" % (self.lineColor, self.lineColorSpace))
def color(self, value): """ String: color name or hex. Scalar or sequence for rgb, dkl or other :ref:`colorspaces`. :ref:`operations <attrib-operations>` supported for these. OBS: when color is specified using numbers, it is interpreted with respect to the stimulus' current colorSpace. Can be specified in one of many ways. If a string is given then it is interpreted as the name of the color. Any of the standard html/X11 `color names <http://www.w3schools.com/html/html_colornames.asp>`_ can be used. e.g.:: myStim.color = 'white' myStim.color = 'RoyalBlue' #(the case is actually ignored) A hex value can be provided, also formatted as with web colors. This can be provided as a string that begins with # (not using python's usual 0x000000 format):: myStim.color = '#DDA0DD' #DDA0DD is hexadecimal for plum You can also provide a triplet of values, which refer to the coordinates in one of the :ref:`colorspaces`. If no color space is specified then the color space most recently used for this stimulus is used again.:: myStim.color = [1.0,-1.0,-1.0] #if colorSpace='rgb': a red color in rgb space myStim.color = [0.0,45.0,1.0] #if colorSpace='dkl': DKL space with elev=0, azimuth=45 myStim.color = [0,0,255] #if colorSpace='rgb255': a blue stimulus using rgb255 space Lastly, a single number can be provided, x, which is equivalent to providing [x,x,x].:: myStim.color = 255 #if colorSpace='rgb255': all guns o max :ref:`Operations <attrib-operations>` work just like with x-y pairs, but has a different meaning here. For colors specified as a triplet of values (or single intensity value) the new value will perform this operation on the previous color. Assuming that colorSpace='rgb':: thisStim.color += [1,1,1] #increment all guns by 1 value thisStim.color *= -1 #multiply the color by -1 (which in this space inverts the contrast) thisStim.color *= [0.5, 0, 1] #decrease red, remove green, keep blue """ setColor(self, value, rgbAttrib='rgb', colorAttrib='color')
def setColor(self, color, colorSpace=None, operation='', log=True): """ Set the color of the stimulus. OBS: can be set using stim.color = value syntax instead. :Parameters: color : see documentation for color. colorSpace : string or None see documentation for colorSpace operation : one of '+','-','*','/', or '' for no operation (simply replace value) see documentation for color. """ setColor(self,color, colorSpace=colorSpace, operation=operation, rgbAttrib='rgb', #or 'fillRGB' etc colorAttrib='color', log=log)
def textColor(self, color): """ Sets the color of the button text. See :meth:`psychopy.visual.GratingStim.color` for further details of how to use colors. """ setColor(self, color, rgbAttrib='textRGB', colorAttrib='textColor')
def setColors(self, color, colorSpace=None, operation="", log=None): """See ``color`` for more info on the color parameter and ``colorSpace`` for more info in the colorSpace parameter. """ setColor( self, color, colorSpace=colorSpace, operation=operation, rgbAttrib="rgbs", # or 'fillRGB' etc colorAttrib="colors", colorSpaceAttrib="colorSpace", ) logAttrib(self, log, "colors", value="%s (%s)" % (self.colors, self.colorSpace)) # check shape if self.rgbs.shape in ((), (1,), (3,)): self.rgbs = numpy.resize(self.rgbs, [self.nElements, 3]) elif self.rgbs.shape in ((self.nElements,), (self.nElements, 1)): self.rgbs.shape = (self.nElements, 1) # set to be 2D self.rgbs = self.rgbs.repeat(3, 1) # repeat once on dim 1 elif self.rgbs.shape == (self.nElements, 3): pass # all is good else: raise ValueError("New value for setRgbs should be either " "Nx1, Nx3 or a single value") self._needColorUpdate = True