Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Touch Response function with Sketchpad

edited March 2014 in OpenSesame

I was wondering if there is a way to see the grid that you define in the touch response item. I wish to display some text in a sketchpad where a word is placed in each cell of the grid. I need to see this grid as so to place the words in each cell. Many thanks,

Comments

  • edited 10:23PM

    There is no way to visualize the grid used by the touch_response directly, but the logic is very simple: The display is divided into equally sized cells, where cell-width = screen-width / number-of-columns and cell-height = screen-height / number-of-rows. Using this formula you should be able to deduce where each cell is, right?

    If you want, you could also draw a simple grid using an inline_script, if that would help you to visualize things:

    from openexp.canvas import canvas
    
    n_col = 10
    n_row = 5
    w = self.get('width')
    h = self.get('height')
    
    # Draw a grid-like canvas
    my_canvas = canvas(exp)
    # Draw vertical lines to separate the columns
    for c in range(1, n_col):
        x = int(float(c)*w/n_col)
        my_canvas.line(x, 0, x, h)
    # Draw horizontal lines to separate the rows
    for r in range(1, n_row):
        y = int(float(r)*h/n_row)
        my_canvas.line(0, y, w, y)
    my_canvas.show()
    

    Cheers!
    Sebastiaan

  • edited 10:23PM

    Thanks for the code Sebastiaan. the grid appears for something like 200ms then disappears, though. would it be possible to define how long the grid is displayed for, in the python script?

    Many thanks!

  • edited 10:23PM

    Sorted. THanks Sebastiaan :) :)

Sign In or Register to comment.