Howdy, Stranger!

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

Supported by

Many items in search display

Hello there,

I'm creating an online visual-search experiment with a 12x8 stimulus grid. Maybe I'll make this grid even larger at some point.

For simplicity, let's assume all 96 items are identical, a simple dot, but their locations are jittered.

I would prefer to not have to create 96 variables that specify each dot's x and y position. Is there a way to iterate over a list in the sketchpad? Or at least access an indexed item in a list?

Or is there some other elegant way to display these items in a sketchpad?

Thanks in advance,

Jasper

Comments

  • Hi @JasperdeWaard ,


    Thanks for all your help on the forum! :)

    But no, sorry, I can't think of an easy solution to your question. (Assuming that you are using OSWeb and therefore can't make use of Canvas objects...)


    Maybe @sebastiaan or @eduard ?


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi Lotje,

    No problem, I enjoy it :)

    And yeah, I was afraid you would say that. For the time being, I think I'll just show the target on its own and use a background image for distraction.

    Cheers,

    Jasper

  • Hi Jasper,

    Well yeah, canvases don't work, but creating arrays, randomizing them and extract values from it to use in sketchpads does work.

    I won't be able to give you a complete script here, because I haven't done it myself (and have limited experience with javascript), but the general procedure should be following:

    1) Create an array with all the x s and y s that correspond to the grid coordinates. Depending on how you run your randomization, you might want to shuffle the list of coordinate pairs

    2) Add some random noise to each coordinate, to create that jitter effect you mentioned. Somehting like this, should do the trick:

    vars.x1 = vars.x1+parseInt(Math.random()*10) # adds a jitter of up to 10 pixels
    

    3) In the beginning of every trial, you have to extract as many values as you have coordinates and assign them to variables. If exp.set is implemented for osweb that can easily be done in a loop:

    # python syntax for simplicity, should be quite similar in js
    for i in range(length_of_coordinate_list):
        exp.set("x"+str(i),  coordinate_list[i][0])
        exp.set("y"+str(i), coordinate_list[i][1])
    

    If not supported, you might be able to do something like this:

    (vars.x1, vars.y1), (vars.x2, vars.y2), ... , (vars.xn, vars.yn) = coordinate_list

    Which is quite annoying to write, but at least you would only need to do it once. You can also try to combine this step with step 2).

    These variables can then be used in the sketchpad.

    4) You need to create one with all the dots you have in mind and set their x and y coordinates to corresponding variable (e.g. [x1] and [y1]).

    I am quite sure the operations you need to do to create the lists can be done in javascript.

    This discussion might further help in getting javascript inspiration. I suggest you give it a try and if you get stuck somewhere, you get back to us and we try to help. Yes?


    Good luck,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    Thanks for the detailed explanation! I think I understand the logic of it, and I agree that creating the list in javascript won't be the problem. I was just hoping to avoid the creation of 96 separate dots, each with its own x and y variables, but I guess it wouldn't be the end of the world :)

    Cheers,

    Jasper

  • Perhaps you can write a little script to write the script... ;-)

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • That sounds like a smart idea :)

  • Perhaps you can write a little script to write the script... ;-)

    That was going to be my suggestion too, yes. For example, the Python script below will generate 10 textline elements with their identities and positions defined in terms of variables. You can then copy-paste this into the script of a sketchpad . (So copy-paste the output of the Python script below, not the Python script itself!)

    lines = [
        f'draw textline center=1 color=white font_bold=no font_family=serif font_italic=no font_size=32 html=yes show_if=always text="[stim{i}_text]" x=[stim{i}_x] y=[stim{i}_y] z_index=0'
        for i in range(10)
    ]
    print('\n'.join(lines))
    


Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games