How to set the initial location of the canva relative to screen display ?

edited December 2015 in How To...

Hello guys !

I think the title says it all : I'm working on a widget that auto run when the pc boots, and I really need to be able to control where it's gonna pop ( and why not if you guys now, if possible to lock it in place ).

After some research on google I found the " frame.setLocation(x,y) " command but it doesn't seem to work. Do I need a specific library loaded before using this ?

Thanks anyone for help =)


  • edited December 2015 Answer ✓

    Though frame variable still exists in P3, many of its features were gone! :(
    However, new variable surface replaced some of its functionalities.
    And it can be grabbed w/ getSurface() "getter" method too. B-)

    size(600, 400);
    background((color) random(#000000));
    surface.setLocation(displayWidth - width >> 1, displayHeight - height >> 1);
  • edited December 2015

    Wow GoTo are you some kind of Processing god of some sort ? I may build a small temple to honor you xD

    This is exactly what I was looking for. How come I can't find anything about the surface variable in the processing reference ? I'm sure it's built in since my app is on an offline system.

    Thanks again for your quick answer =)

  • edited December 2015

    How come I can't find anything about the surface variable in the processing reference?

    Lotsa Processing's goodies deliberately stay outta its "official" reference page unfortunately. 8-|

    Can you believe "they" even had @ Deprecated both displayWidth & displayHeight in P3?! :O)

  • That's a shame !

    I just learnt about the "deprecation" thing. I can understand why they would discourage coders from using out of date commands to force them into better alternative. But why would you do it if there's no alternative. Sure it might not work 100% but since "they" don't provide alternative I think it should be in the reference, under a "use at your own risk" section or something ^^. Especially since it's still usable.

    its "official" reference page

    Does this mean there's some kind of dark corner where Processing outlaws trade illegal recipes ? :p

  • I couldn't figure out why frame.setLocation would not work. Then I changed it to surface.setLocationand that worked perfectly. Thank you!

Sign In or Register to comment.