Howdy, Stranger!

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

Supported by

[open] backup a canvas for later reuse

edited June 2015 in OpenSesame

Hello again,

how can I code this with Opensesame?

--copy the content of "mySketchpad"  to  myCanvas
--  draw a text over  myCanvas
--  show myCanvas for 2000ms
--  copy  myCanvas to a "temporary"  myBackupCanvas
--  draw other text over  myCanvas
--  show myCanvas for 2000ms
--  copy the   myBackupCanvas  over myCanvas 
--  show   myCanvas for 2000ms

I tried something like this:

from openexp.canvas import canvas

myCanvas=offline_canvas()
myBackupCanvas=offline_canvas()
myCanvas.copy(exp.items["mySketchpad"].canvas)
myCanvas.text("some new text",y=400)
myCanvas.show()
self.time(2000)
myBackupCanvas.copy(myCanvas)   # make a backup copy 
myCanvas.text("other new text",y=800)
myCanvas.show()
self.time(2000)
myCanvas.copy(myBackupCanvas)
myCanvas.show()   # ------------ remark here
self.sleep(2000)

I would expect to see the backupCanvas at the end but instead I see a blank screen, like if the canvas was not copied and it was at its default init (blank)

thanks

Comments

  • edited 1:00AM

    hmmmm..
    changing to psychopy or plegacy backend seems to work, but I'm not willing to switch to those backeds after coding 90% of my LARGE experiment for 'expyriment' :(

  • edited 1:00AM

    I found out that:

    mycanvas= canvas(exp)
    mycanvas.copy(exp.items["mySketchpad"].canvas)
    mycanvas.line(0,0,0,0)    # ---   draw a simple dot
    mycanvas.show()
    

    do works, in the meaning that I can see my sketchpad copied.

    If I don't draw something I don't see anything into the "mycanvas" while I always thought that the simple copy operation was sufficient to have "something" new into my canvas (which I guess is empty (balnk? null?) when initiatiated.

    am I wrong?

    thanks!

  • edited 1:00AM

    Hi,

    I haven't used the copy function before, but usually you just simply do something like:

      exp.mycanvas=self.offline_canvas()
      exp.mycanvas.text("this is a text")
    
      exp.mycopycanvas = exp.mycanvas
    

    And you can also organize your code such that the initial text is drawn onto two canvases. The second text you only draw on the first canvas; and afterwards you display the second canvas again.

    Cheers,

    Josh

  • edited 1:00AM

    hmmm.. that was an option I also though, but after I tried these lines the "mycopycanvas" is empty (if I add another exp.mycopycanvas.show()


    at the moment the "copy" works only if I add other object to the copied canvas (now I am adding an 'invisible' line)

  • edited 1:00AM

    Hi,

    As is mentioned here, you have to initialize also the canvas to which you're copying. So, try this code:

    mycanvas=self.offline_canvas()
    mycanvas.text("this is a text",y=100)
    
    mycopycanvas = self.offline_canvas() # that line is the main difference
    mycopycanvas.copy(mycanvas)  
    mycopycanvas.text("this is another text",y=500)
    mycanvas.show()
    self.sleep(1000)
    mycopycanvas.show()
    
    self.sleep(1000)
    

    As a side note, as long as you use your canvas only in inline_scripts it is not necessary any more to add the prefix exp. in front of it. Any variables that are defined in inline_scripts are globally available in all inline_scripts (regardless of prep or run phase)

    simple copy operation was sufficient to have "something" new into my canvas which I guess is empty (balnk? null?) when initiatiated.

    As far as I can see, a copied canvas should be identical with the original canvas. So it shouldn't be necessary to draw something in order to see something on it (of course assuming that the original canvas wasn't empty).

    If you want to copy a sketchpad-canvas, you should use the self.copy_sketchpad('my_sketchpad') of the inline_scriptobject. Unfortunately, it doesn't work for me...No clue why.

    Hope this cleared things up a bit.

    Eduard

    Buy Me A Coffee

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