Creates a Line between two points.
(New in version 1.72.00)
Line accepts all input parameters, that ShapeStim accepts, except for vertices, closeShape and fillColor.
The methods contains and overlaps are inherited from ~psychopy.visual.ShapeStim, but always return False (because a line is not a proper (2D) polygon).
Determines whether the stimulus should be automatically drawn on every frame flip.
Value should be: True or False. You do NOT need to set this on every frame flip!
Whether every change in this stimulus should be logged automatically
Value should be: True or False. Set to False if your stimulus is updating frequently (e.g. updating its position every frame) and you want to avoid swamping the log file with messages that aren’t likely to be useful.
True or False Do you want the last vertex to be automatically connected to the first?
If you’re using Polygon, Circle or Rect, closeShape=True is assumed and shouldn’t be changed.
Color of the stimulus
string: to specify a Colors by name. Any of the standard html/X11 color names <http://www.w3schools.com/html/html_colornames.asp> can be used.
these, 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 will be applied to all 3 channels.
Operations work as normal for all numeric colorSpaces (e.g. ‘rgb’, ‘hsv’ and ‘rgb255’) but not for strings, like named and hex. For example, assuming that colorSpace=’rgb’:
stim.color += [1, 1, 1] # increment all guns by 1 value
stim.color *= -1 # multiply the color by -1 (which in this space inverts the contrast)
stim.color *= [0.5, 0, 1] # decrease red, remove green, keep blue
You can use setColor if you want to set color and colorSpace in one line. These two are equivalent:
stim.setColor((0, 128, 255), 'rgb255')
# ... is equivalent to
stim.colorSpace = 'rgb255'
stim.color = (0, 128, 255)
The name of the color space currently being used (for numeric colors)
Value should be: a string or None
For strings and hex values this is not needed. If None the default colorSpace for the stimulus is used (defined during initialisation).
Please note that changing colorSpace does not change stimulus parameters. Thus you usually want to specify colorSpace before setting the color. Example:
# A light green text
stim = visual.TextStim(win, 'Color me!', color=(0, 1, 0), colorSpace='rgb')
# An almost-black text
stim.colorSpace = 'rgb255'
# Make it light green again
stim.color = (128, 255, 128)
A value that is simply multiplied by the color
Set the contrast of the stimulus, i.e. scales how far the stimulus deviates from the middle grey. You can also use the stimulus opacity to control contrast, but that cannot be negative.
Examples:
stim.contrast = 1.0 # unchanged contrast
stim.contrast = 0.5 # decrease contrast
stim.contrast = 0.0 # uniform, no contrast
stim.contrast = -0.5 # slightly inverted
stim.contrast = -1.0 # totally inverted
Setting contrast outside range -1 to 1 is permitted, but may produce strange results if color values exceeds the monitor limits.:
stim.contrast = 1.2 # increases contrast
stim.contrast = -1.2 # inverts with increased contrast
DEPRECATED. Depth is now controlled simply by drawing order.
Draw the stimulus in its relevant window. You must call this method after every MyWin.flip() if you want the stimulus to appear on that frame and then update the screen again.
tuple, list or 2x1 array
Specifies the position of the end of the line. Operations supported.
Sets the color of the shape fill. See 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.
Sets color space for fill color. See documentation for fillColorSpace
True or False If True the edge of the line will be antialiased.
Sets the color of the shape lines. See psychopy.visual.GratingStim.color() for further details of how to use colors.
Sets color space for line color. See documentation for lineColorSpace
int or float specifying the line width in pixels
Operations supported.
String or None. The name of the object to be using during logged messages about this stim. If you have multiple stimuli in your experiment this really helps to make sense of log files!
If name = None your stimulus will be called “unnamed <type>”, e.g. visual.TextStim(win) will be called “unnamed TextStim” in the logs.
Determines how visible the stimulus is relative to background
The value should be a single float ranging 1.0 (opaque) to 0.0 (transparent). Operations are supported. Precisely how this is used depends on the Blend Mode.
The orientation of the stimulus (in degrees).
Should be a single value (scalar). Operations are supported.
Orientation convention is like a clock: 0 is vertical, and positive values rotate clockwise. Beyond 360 and below zero values wrap appropriately.
The position of the center of the stimulus in the stimulus units
value should be an x,y-pair. Operations are also supported.
Example:
stim.pos = (0.5, 0) # Set slightly to the right of center
stim.pos += (0.5, -1) # Increment pos rightwards and upwards. Is now (1.0, -1.0)
stim.pos *= 0.2 # Move stim towards the center. Is now (0.2, -0.2)
Tip: If you need the position of stim in pixels, you can obtain it like this:
from psychopy.tools.monitorunittools import posToPix posPix = posToPix(stim)
Sets autoDraw. Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
For ShapeStim use lineColor() or fillColor()
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
DEPRECATED since v1.60.05: Please use the color attribute
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Sets the color of the shape fill. See 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.
DEPRECATED since v1.60.05: Please use fillColor()
DEPRECATED since v1.60.05: Please use the color attribute
Sets the color of the shape edge. See psychopy.visual.GratingStim.color() for further details of how to use this function.
DEPRECATED since v1.60.05: Please use lineColor()
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
DEPRECATED since v1.60.05: Please use the color attribute
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Int/Float or x,y-pair. Sets the size of the shape. Size is independent of the units of shape and will simply scale the shape’s vertices by the factor given. Use a tuple or list of two values to scale asymmetrically.
Operations supported.
tuple, list or 2x1 array.
Specifies the position of the start of the line. Operations supported.
None, ‘norm’, ‘cm’, ‘deg’, ‘degFlat’, ‘degFlatPos’, or ‘pix’
If None then the current units of the Window will be used. See Units for the window and stimuli for explanation of other options.
Note that when you change units, you don’t change the stimulus parameters and it is likely to change appearance. Example:
# This stimulus is 20% wide and 50% tall with respect to window
stim = visual.PatchStim(win, units='norm', size=(0.2, 0.5)
# This stimulus is 0.2 degrees wide and 0.5 degrees tall.
stim.units = 'deg'
Should shaders be used to render the stimulus (typically leave as True)
If the system support the use of OpenGL shader language then leaving this set to True is highly recommended. If shaders cannot be used then various operations will be slower (notably, changes to stimulus color or contrast)
a list of lists or a numpy array (Nx2) specifying xy positions of each vertex, relative to the centre of the field.
If you’re using Polygon, Circle or Rect, this shouldn’t be used.
Operations supported.
This determines the coordinates of the vertices for the current stimulus in pixels, accounting for size, ori, pos and units
Example, drawing same stimulus in two different windows and display simultaneously. Assuming that you have two windows and a stimulus (win1, win2 and stim):
stim.win = win1 # stimulus will be drawn in win1
stim.draw() # stimulus is now drawn to win1
stim.win = win2 # stimulus will be drawn in win2
stim.draw() # it is now drawn in win2
win1.flip(waitBlanking=False) # do not wait for next monitor update
win2.flip() # wait for vertical blanking.
Note that this just changes **default** window for stimulus.
You could also specify window-to-draw-to when drawing::
stim.draw(win1)
stim.draw(win2)