Create geometric (vector) shapes by defining vertex locations.
Shapes can be outlines or filled, by setting lineRGB and fillRGB to rgb triplets, or None. They can also be rotated (stim.setOri(__)) and translated (stim.setPos(__)) like any other stimulus.
NB for now the fill of objects is performed using glBegin(GL_POLYGON) and that is limited to convex shapes. With concavities you get unpredictable results (e.g. add a fill color to the arrow stim below). To create concavities, you can combine multiple shapes, or stick to just outlines. (If anyone wants to rewrite ShapeStim to use glu tesselators that would be great!)
| Parameters : |
lineColor :
fillColor :
|
|---|
Determines if a point x,y is inside the extent of the stimulus.
Can accept: a) two args, x and y; b) one arg, as a point (x,y) that is list-like; or c) an object with a getPos() method that returns x,y, such as a mouse. Returns True if the point is within the area defined by vertices. This handles complex shapes, including concavities and self-crossings.
Note that, if your stimulus uses a mask (such as a Gaussian blob) then this is not accounted for by the contains method; the extent of the stmulus is determined purely by the size, pos and orientation settings (and by the vertices for shape stimuli).
See coder demo, shapeContains.py
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.
Determines if this stimulus intersects another one. If polygon is another stimulus instance, then the vertices and location of that stimulus will be used as the polygon. Overlap detection is only approximate; it can fail with pointy shapes. Returns True if the two shapes overlap.
Note that, if your stimulus uses a mask (such as a Gaussian blob) then this is not accounted for by the overlaps method; the extent of the stimulus is determined purely by the size, pos, and orientation settings (and by the vertices for shape stimuli).
See coder demo, shapeContains.py
Add or remove a stimulus from the list of stimuli that will be automatically drawn on each flip. You do NOT need to call this on every frame flip!
| Parameters : |
|
|---|
Turn on (or off) autoLogging for this stimulus. When autologging is enabled it can be overridden for an individual set() operation using the log=False argument.
| Parameters : |
|
|---|
For ShapeStim use setLineColor() or setFillColor()
” Set the contrast of the stimulus.
| Parameters : |
|---|
The contrast of the stimulus:
# 0.0 to 1.0 decreases contrast #Here
# 1.0 means unchanged
# 0.0 to -1.0 inverts with decreased contrast
# -1.0 means exactly inverted.
# >1.0 increases contrast. (See warning below)
# <-1.0 inverts with increased contrast (See warning below)
WARNING. Setting contrast below -1 or above 1 will produce strange results if this forces the stimulus to blacker-than-black or whiter-than-white.
operation : one of ‘+’,’-‘,’*’,’/’, or ‘’ for no operation (simply replace value)
DEPRECATED since v1.60.05: Please use setColor
Sets the color of the shape fill. See psychopy.visual.GratingStim.setColor() 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 setFillColor()
DEPRECATED since v1.60.05: Please use setColor
Sets the color of the shape edge. See psychopy.visual.GratingStim.setColor() for further details of how to use this function.
DEPRECATED since v1.60.05: Please use setLineColor()
Set the opacity of the stimulus. :parameters: newOpacity: float between 0 (transparent) and 1 (opaque).
operation: one of ‘+’,’-‘,’*’,’/’, or ‘’ for no operation (simply replace value)
Set the stimulus orientation in degrees
Set the stimulus position in the specified (or inherited) units
DEPRECATED since v1.60.05: Please use setColor
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.
Set this stimulus to use shaders if possible.
Set the xy values of the vertices (relative to the centre of the field). Values should be: