当前位置: 首页>>代码示例>>Python>>正文


Python helpers.setColor函数代码示例

本文整理汇总了Python中psychopy.visual.helpers.setColor函数的典型用法代码示例。如果您正苦于以下问题:Python setColor函数的具体用法?Python setColor怎么用?Python setColor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setColor函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setColors

    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
开发者ID:neuroidss,项目名称:psychopy,代码行数:26,代码来源:elementarray.py

示例2: lineColor

    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')
开发者ID:neuroidss,项目名称:psychopy,代码行数:7,代码来源:shape.py

示例3: color

    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')
开发者ID:larigaldie-n,项目名称:psychopy,代码行数:30,代码来源:basevisual.py

示例4: setLineColor

 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)
开发者ID:9173860,项目名称:psychopy,代码行数:8,代码来源:shape.py

示例5: setColor

 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)
开发者ID:larigaldie-n,项目名称:psychopy,代码行数:8,代码来源:basevisual.py

示例6: setColors

    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
开发者ID:kastman,项目名称:psychopy,代码行数:58,代码来源:elementarray.py

示例7: fillColor

    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')
开发者ID:9173860,项目名称:psychopy,代码行数:9,代码来源:shape.py

示例8: setLineColor

    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))
开发者ID:ChenTzuYin,项目名称:psychopy,代码行数:10,代码来源:shape.py

示例9: setFillColor

    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)
开发者ID:9173860,项目名称:psychopy,代码行数:12,代码来源:shape.py

示例10: color

    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')
开发者ID:Gianluigi,项目名称:psychopy,代码行数:45,代码来源:basevisual.py

示例11: setColor

    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)
开发者ID:Gianluigi,项目名称:psychopy,代码行数:20,代码来源:basevisual.py


注:本文中的psychopy.visual.helpers.setColor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。