bitcraftlab / p5.gui

p5.gui magically generates a graphical user interface for your p5.js sketches
https://bitcraftlab.github.io/p5.gui
MIT License
354 stars 91 forks source link

Example code to position a gui #17

Open ricardocanada opened 5 years ago

ricardocanada commented 5 years ago

39DEEEA5-B39C-48A1-B81B-2CE257B14F91 I am using p5.gui with QuickSettings in many of my OpenProcessing sketches. If you are interested, look for sketches 743514 and 743509, in which I use p5.GUI sliders to set hue, saturation and brightness for fullscreen gradients. It is a great timesaver. I agree with the idea that it would be nice to have a button element included. Up until now I have used checkboxes as buttons, but I am looking forward to using a user solution posted in Issues. I reread the p5.GUI information page several times to find out how to position a GUI, and tried the code suggested there:

let gui1 = p.createGui('My 1st GUI'); gui1.moveTo(50, 50); gui1.addGlobals('a', 'b', 'c');

It would not work. The console error was: TypeError: gui.moveTo is not a function. (In 'gui.moveTo(50, 50)', 'gui.moveTo' is undefined)

Then I happened to notice a different positioning method shown in one of the examples.

gui = createGui('p5.GUI').setPosition(width - 250, 120);

That one works perfectly, so I suggest using it, and error-checking the other method.

anugrahandi commented 4 years ago

Thanks.. did search from readme/documentation on move the GUI on the first run land me here. I use: gui = createGui('name of my GUI'); gui.setPosition(50,50);