Skip to content

Example code to position a gui #17

@ricardocanada

Description

@ricardocanada

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions