psychopy icon indicating copy to clipboard operation
psychopy copied to clipboard

Circle stim drawing issue

Open isolver opened this issue 5 years ago • 5 comments

This circle does not seem to draw anymore:

from psychopy import visual, event, core
win = visual.Window([600, 600], color='grey')

circle = visual.Circle(
            win,
            pos=(0, 0),
            lineWidth=3.0,
            lineColor=[255,0,0],
            colorSpace='rgb255',
            fillColor=[255,0,0],
            radius=50,
            units='pix',
            opacity=1.0,
            interpolate=False)

t = 0.0
while not event.getKeys():
    circle.draw()
    win.flip()

win.close()
core.quit()

isolver avatar Jan 28 '21 18:01 isolver

seems to have been fixed with latest color fixes.

isolver avatar Jan 31 '21 13:01 isolver

Hello, I am using PsychoPy 2022.1.2 standalone Windows app, and I think I face the same issue. The circle do not appear on the screen. Here is my code.

from psychopy import visual, core
from psychopy.visual import Circle

win = visual.Window((600, 600), monitor='testMonitor')
circ = Circle(win=win, radius=1, units="pix", fillColor="black")

for i in range(0,100):
    circ.radius = i*10
    circ.draw()
    win.flip()

win.close()
core.quit()

If I use older version of psychopy (the one I tested was 2020.2.5), the code works OK and the circle gets drawn on the screen. Has anyone encountered this issue?

tomomano avatar Mar 29 '22 06:03 tomomano

Confirmed this code no longer works.

A potential work-around for @tomomano is that the visual.Pie stimulus does still work - if you set it to start=0, end=360, it will display as full circle. https://www.psychopy.org/api/visual/pie.html

m-macaskill avatar Mar 29 '22 23:03 m-macaskill

@m-macaskill Thank you for confirming the bug and also sueggesting the workaround! I hope it gets fixed in the next release.

tomomano avatar Mar 30 '22 01:03 tomomano

The following code was used by me in a previous version (don't know which one, sorry) to demo unit changes, and it worked back then. Now it doesn't, namely the radius of the circles after the first one is tiny (not following the unit change). You can usually find the couple of pixels wide "circle" somewhere on screen. Press key after every circle draw. This does not work with Pie instead of Circle either, but it does work when switching to Rect.

from psychopy import visual, core, event
from numpy.random import uniform as runiform

white = [1, 1, 1]
grey = [0, 0, 0]
black = [-1, -1, -1]
orange = [1, 0, -1]

win = visual.Window(
    units = 'pix',      
    size = (800, 600),  
    fullscr = False,   
    color = white      
)

width, height = win.size
randXpos, randYpos = runiform(-1, 1, 2)
circleXpos = int(randXpos * (width / 2))
circleYpos = int(randYpos * (height / 2))
circ_rad = 50

circle_stim = visual.Circle(
    win = win,       
    units = 'pix',         
    radius = circ_rad,  
    lineColor = black,  
    fillColor = grey,  
    edges = 128    
)

circle_stim.pos = [circleXpos, circleYpos]
print('circle position (x, y) = (', circleXpos, ', ', circleYpos, ')')
circle_stim.draw()
win.flip()

circle_stim.units = 'norm'     
circle_stim.pos = runiform(-1, 1, 2)    
circle_stim.radius = 0.2   
circle_stim.fillColor = orange   
circle_stim.draw()
event.waitKeys()
win.flip()

circle_stim.units = 'height'    
rXp, rYp = runiform(-0.5, 0.5, 2)    
circle_stim.pos = [rXp * width / height, rYp]   
circle_stim.colorSpace = 'rgb255'   
circle_stim.fillColor = [255, 0, 255]   
circle_stim.draw()
event.waitKeys()
win.flip()

event.waitKeys()
win.close()
core.quit()

ibojak avatar Feb 15 '23 19:02 ibojak