psychopy.visual.helpers.
pointInPolygon
(x, y, poly)[source]¶Determine if a point is inside a polygon; returns True if inside.
(x, y) is the point to test. poly is a list of 3 or more vertices as (x,y) pairs. If given an object, such as a ShapeStim, will try to use its vertices and position as the polygon.
Same as the .contains() method elsewhere.
psychopy.visual.helpers.
polygonsOverlap
(poly1, poly2)[source]¶Determine if two polygons intersect; can fail for very pointy polygons.
Accepts two polygons, as lists of vertices (x,y) pairs. If given an object with with (vertices + pos), will try to use that as the polygon.
Checks if any vertex of one polygon is inside the other polygon. Same as the .overlaps() method elsewhere.
Notes: |
---|
We implement special handling for the Line stimulus as it is not a proper polygon. We do not check for class instances because this would require importing of visual.Line, creating a circular import. Instead, we assume that a “polygon” with only two vertices is meant to specify a line. Pixels between the endpoints get interpolated before testing for overlap.
psychopy.visual.helpers.
groupFlipVert
(flipList, yReflect=0)[source]¶Reverses the vertical mirroring of all items in list flipList
.
Reverses the .flipVert status, vertical (y) positions, and angular
rotation (.ori). Flipping preserves the relations among the group’s
visual elements. The parameter yReflect
is the y-value of an
imaginary horizontal line around which to reflect the items;
default = 0 (screen center).
Typical usage is to call once prior to any display; call again to un-flip. Can be called with a list of all stim to be presented in a given routine.
Will flip a) all psychopy.visual.xyzStim that have a setFlipVert method, b) the y values of .vertices, and c) items in n x 2 lists that are mutable (i.e., list, np.array, no tuples): [[x1, y1], [x2, y2], …]