Hello! I’m trying to draw a pacman or pie shape (e.g., removing 1/4 of the entire circle like this). I’ve been searching for an answer but had no luck so far. Is there a way to specify such a property of a circle using a function like visual.Circle()? Thanks in advance!
Reading through this thread might help:
I’m so sorry for the late reply! I’ll read the thread and try solving the problem!
Thank you so much for your time and kindness.
Thanks to Michael’s help, I was able to draw a pacman shape using the codes below.
#specifying the screen height/width ratio to correct circle's distortion wide = 1920 high = 1200 display = 0 visual_angle = 1.5 win = visual.Window(fullscr=True, screen = 0, allowGUI=False, waitBlanking=True) win_ratio = high/wide circle_size = round(0.18*(1/2.5),2)*visual_angle wedge = visual.RadialStim(win, tex='None', color=1, size=[circle_size*win_ratio, circle_size], angularRes=360, visibleWedge=[0, 270], interpolate=False, autoLog=False, ori=0) wedge.draw() win.flip()
The next thing I have to do is to rotate the pacman shape (wedge). The first thing I tried was to change the starting and ending angles in visibleWedge=[0, 270]. However, it does not work when the ending angle is passed 360. For example, if I entered something like visibleWedge=[135, 405] to rotate the figure 135 degrees, I will get this shape which is not what I want.
On the other hand, when I try to rotate the wedge by entering ori=135, the whole shape gets distorted like this due to the screen height/width ratio.
I would very much appreciate it if anyone could suggest any possible ways to solve this dilemma – i.e., to rotate the pacman shape without distortion. Thank you so much for your time and kindness.
Well done on solving this. To rotate the PacMan, you should indeed just create the stimulus once and then simply alter its
.ori attribute as required.
I would guess that the distortion you are seeing is due to using the default “norm” units system for your window and stimuli. This means that both the height and width of the monitor are scaled to equal 2.0. You can instead use “height” units if you want normalised coordinates that account for the aspect ratio of the display. i.e. the height of the window is still scaled to 2.0, but the width is scaled relative to that (generally a larger value) so that stimuli with equal dimensions display as circles/squares rather than as ellipses/rectangles. Or you can use explicit units like pixels, degrees, cm, etc:
Thank you so much for your further help! Correcting the unit worked perfectly I put the revised line for everyone’s reference.
wedge = visual.RadialStim(win, tex='None', color=1, units='height', size=[circle_size, circle_size], angularRes=360, visibleWedge=[0, 270], interpolate=False, autoLog=False, ori=135)
I truly appreciate your kindness!
I’m sorry, now I have an additional question.
If I want to draw an open circle like this, what is the best way to do it?
wedge = visual.RadialStim(win, tex='None', color=1, units='height', size=[0.5, 0.5], angularRes=360, visibleWedge=[0, 270], interpolate=False, autoLog=False, ori=135) circle = visual.Circle(win, units='height', size=[0.4, 0.4], fillColor=0)
I would very much appreciate it if you could share some possible tip. Thank you so much for your time!
I guess you should also set the
lineColor attribute of your circle stimulus.
Thank you so much for your reply! It worked perfectly