Hello everyone,
I try an experimental code in which the subject has to press the space bar [continuously] in order to produce more and more polygons and when the pressing stops, re-pressing will remove those polygons and so on.
Creating and displaying the polygons is based on the following code:
keys = kb.getKeys(['space', 'return'], waitRelease = False, clear=False)
for poly in Poly_List:
poly.setAutoDraw(True)
for thisKey in keys:
if thisKey == 'space' and space_func: #this func change the Space Operation from addition to substarction
polygon = visual.Polygon(
win=win, name='polygon',
edges=10000, size=(0.1),
ori=0.0, pos=(random()-0.5, random()-0.5),
lineWidth=1.0, colorSpace='rgb', lineColor='black', fillColor='black',
opacity=None, depth=0.0, interpolate=True)
overlap = False
for poly in Poly_List:
if customOverlaps(poly, polygon): #is they overlap
overlap = True
isInside = insideCircle(Base_Circle, polygon) #is they inside a Primary desirable area
if not overlap and isInside:
Poly_List.append(polygon)
Size_List.append(polygon.size) #get the size for statistics
core.wait(random()-0.9) # have some random time
Dur = thisKey.duration
space_func_minus() # shift the space operation from addition to substraction
And their removal is based on this code:
elif thisKey == 'space' and not space_func:
for i in Poly_List:
Poly_List.remove(i)
core.wait(random())
i.setAutoDraw(False)
Dur = thisKey.duration
space_func_plus()
My problem is that while the creation of the polygons is done one after the other continuously [more and more] - their removal is done once and in a certain amount of polygons
Do you have any idea how to arrange this? Thanks!