Howdy, Stranger!

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

Supported by

[solved] Using "show if" in sketchpads

edited June 2013 in OpenSesame

Hi,

I have a simple problem, I'm trying to set up an element on a sketchpad that should be shown only sometimes but I can't seem to get the syntax correct. Can you help me with this please?

draw rect 245 22 86 35 fill=1 penwidth=3 color=0 show_if="[Task]=Lum"

There are two main issues... First the color was originally in the #0000 format and that had the effect of commenting out the show if statement. Second, I'm not sure how to use quotations in the [Task] = Lum part.

Thanks

Comments

  • edited 6:58AM

    Sorry for reposting but I forgot to include that I would like to include the color of the rectangle en RGB system so how can I include that in that kind of syntax?

  • edited 6:58AM

    Also... I wan tot calculate the natural logarithm of a number I tried using math.log, but didn't work...

  • edited May 2013

    On your first issue: you are using the quotations and brackets correctly; quotations might be added around the Lum part (i.e. show_if="[Task] = 'Lum'"), but this shouldn't be necessary.

    On your colour issue: even if it seems as though your code is being commented out, it should still work. So I'm pretty puzzled why your syntax proved incorrect. Could you perhaps post the entire sketchpad script? And elaborate a bit on why it did not work? (e.g.: an error message, or a description of any unwanted behaviour).

    EDIT: the natural logarithm may be calculated the easiest via numpy's log function, which uses e as it's base (if you want 10 as your base, use log10). In code:

    # first we import numpy, so we may use it's functions
    import numpy
    
    # now we're set to do some log calculations
    some_value = numpy.log(some_other_value)
    

    Cheers!

  • edited 6:58AM

    Thanks I got everything working (including the color) but now I need to use RGB code to make several shades of gray following a formula... How can I do that?

    Also, I drew some lines on the sketchpad, and calculate other lines using pixel count. Will these work when I present them in other computers with possibly different setups (like resolution)?

  • edited 6:58AM

    I need to use RGB code to make several shades of gray following a formula... How can I do that?

    The #XXXXXX notation is RGB in disguise: It's three RGB values in hexadecimal notation (so 00 - FF, which corresponds to 0 to 255 in decimal notation) in a row. To convert a tuple of three 0 - 255 values to this hexadecimal notation, you can use Python string formatting:

    color = 255, 0, 0 # Corresponds to red
    hexColor = '#%.2X%.2X%.2X' % color
    print '%s is the same as %s' % (color, hexColor)
    

    See here:

    Also, I drew some lines on the sketchpad, and calculate other lines using pixel count. Will these work when I present them in other computers with possibly different setups (like resolution)?

    Yes, the relative proportions will be preserved.

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