Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

canvas question


Hey guys,
I need some ideas on how to implement something that seems easy but yet eludes me. Basically, I want to show a map and when people click on a location to save its pixel coordinates. I've done the click and save part by recycling some code from another example and drawing a fixation point on the mouse location on the canvas (see attachment). The problem is that when I add the png for the map in the while loop that controls the mouse, things slow down a lot. This is of course to be expected as the png gets redrawn on the canvas all the time, but how should I do this instead? Basically, I want to display the map once and redraw the mouse continuously. I tried putting the map outside of the loop but I haven't manged to make the mouse update as it should. Any ideas?
Thanks in advance,
marios

Comments

  • sebastiaansebastiaan Posts: 2,701

    Hi Marios,

    First thought: Why don't you simply let the operating system draw the mouse cursor?

    my_mouse.show_cursor(True)
    

    That way you don't have to redraw the canvas over and over again. But if, for whatever reason, that is not an option, there are a few other things you could try to improve performance:

    • Set the timeout to 0, instead of 20
    • Change the backend to legacy, which is faster when it comes to stimulus rendering

    Cheers!
    Sebastiaan

    Thanked by 1mariosav

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • mariosavmariosav Posts: 29

    Thanks Sebastiaan! Initially I was thinking of doing mouse tracking so I went down this route. But, if I decide against it then I could just have the os draw the mouse. Good point. I'll also try the other things you suggested and see what happens. :)

Sign In or Register to comment.