# Create circle that helps to direct mouse to center of screen

OS Win10
PsychoPy version 2020.1.3
**Standard Standalone? yes
What are you trying to achieve?:
I’m building a visuomotor rotation experiment. I managed to build a trial using different routines and some code inside the routines. Now I need to create the beginning of the trial, where a circle indicates the distance of the cursor from the center of the screen (where participants need to get to start the trial). So the cursor is not visible but there is this circle that gets bigger and smaller depending on the cursor’s radial distance to the center of the screen. (The idea here is that participants don’t know the exact position of the cursor but are able to navigate to the center)

What did you try to make it work?:
So I did create a large circle around the center. But after this I’m lost. I have no idea how I can vary the size of this circle depending on the cursor position… I have seen posts about resetting the mouse position and I saw that there is the “event mouse” but none of these are really what I need. If there is anyone with any idea on where to start even I’d be forever thankful!

Here’s one way to do it:

First let’s add a polygon component for the circle:

Now let’s add a mouse component for user input:

Lastly we need a custom code component (it’s under `Custom``Code` in the right-hand list of components)

Here’s the code - note that it’s in the “Each Frame” tab.

``````xcoord, ycoord = my_mouse.getPos()
dist_centre = (xcoord**2 + ycoord**2)**(1/2)
my_polygon.size = (dist_centre*100, dist_centre*100)
``````

A little bit of Pythagoras’ goes a long way

Note that you’ll probably want to adjust the polygon’s position (it’s in the centre, the way I’ve done it) as well as the scaling factor for determining the circle’s size based on the cursor’s coordinates. So change 100 to whatever you want in `my_polygon.size = (dist_centre*100, dist_centre*100)`.

Edit: All three components I described above must be in the same routine, of course.