p5.touchgui
p5.touchgui copied to clipboard
Regenerate GUI after orientation change
@L05 Hello, thank you for this fantastic library!
I'm using it as a game controller on mobile devices, I'd like for the user to be able to rotate their screen and re-render the canvas to accommodate for the different aspect ratio. Is there a way to change the values of the button and joystick x,y,width,height properties after they have been created?
Thanks, Nic
Hey Nic!
If you store any of the elements as a variable when you create them, you should be able to set the position and height/width at any time. An example:
let gui;let b;function setup() { createCanvas(400, 400); gui = createGui(); b = createButton("Button", 50, 50);}function draw() { background(220); drawGui(); if(b.isPressed) { print(b.label + " is pressed."); } // Set the button width and height in the draw loop. b.w = 300; b.h = 150;}
Carlos Garcia Software Engineer / Media Artist //L05.is http://l05.is/
[image: L05-logo-small.png] https://L05.is
On Mon, Nov 2, 2020 at 11:40 AM Nic Stark [email protected] wrote:
@L05 https://github.com/L05 Hello, thank you for this fantastic library!
I'm using it as a game controller on mobile devices, I'd like for the user to be able to rotate their screen and re-render the canvas to accommodate for the different aspect ratio. Is there a way to change the values of the button and joystick x,y,width,height properties after they have been created?
Thanks, Nic
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/L05/p5.touchgui/issues/19, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6QI2Q3NGZSGI2NLCXFQD3SN4DLFANCNFSM4TH35XJA .
Thanks so much for the quick reply Carlos, that helped me get it working!
Best,
Nic
Nic Stark | Digital Design Portfolio Site | nicstark.com http://www.nicstark.com Tel | 802.884.0746
On Mon, Nov 2, 2020 at 11:14 PM L05 [email protected] wrote:
Hey Nic!
If you store any of the elements as a variable when you create them, you should be able to set the position and height/width at any time. An example:
let gui;let b;function setup() { createCanvas(400, 400); gui = createGui(); b = createButton("Button", 50, 50);}function draw() { background(220); drawGui(); if(b.isPressed) { print(b.label + " is pressed."); } // Set the button width and height in the draw loop. b.w = 300; b.h = 150;}
Carlos Garcia Software Engineer / Media Artist //L05.is http://l05.is/
[image: L05-logo-small.png] https://L05.is
On Mon, Nov 2, 2020 at 11:40 AM Nic Stark [email protected] wrote:
@L05 https://github.com/L05 Hello, thank you for this fantastic library!
I'm using it as a game controller on mobile devices, I'd like for the user to be able to rotate their screen and re-render the canvas to accommodate for the different aspect ratio. Is there a way to change the values of the button and joystick x,y,width,height properties after they have been created?
Thanks, Nic
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/L05/p5.touchgui/issues/19, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA6QI2Q3NGZSGI2NLCXFQD3SN4DLFANCNFSM4TH35XJA
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/L05/p5.touchgui/issues/19#issuecomment-720894846, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFJAYZCZVE2RK6NMS3A23DDSN57TLANCNFSM4TH35XJA .
Hey Carlos,
Hope I'm not a bother. I'm having some trouble setting a button label font. The font file loads fine and is rendered properly for p5 text but when setting it as the button label font the button.setStyle{font:myFont} is returning GuiObject.setStyle(): wrong data type for 'font' in object type 'button'.
I've tried loading both an otf and ttf font to the same effect.
Any idea what I could be doing wrong here?
Thanks,
Nic
Nic Stark | Digital Design Portfolio Site | nicstark.com http://www.nicstark.com Tel | 802.884.0746
On Tue, Nov 3, 2020 at 6:01 PM Nic Stark [email protected] wrote:
Thanks so much for the quick reply Carlos, that helped me get it working!
Best,
Nic
Nic Stark | Digital Design Portfolio Site | nicstark.com http://www.nicstark.com Tel | 802.884.0746
On Mon, Nov 2, 2020 at 11:14 PM L05 [email protected] wrote:
Hey Nic!
If you store any of the elements as a variable when you create them, you should be able to set the position and height/width at any time. An example:
let gui;let b;function setup() { createCanvas(400, 400); gui = createGui(); b = createButton("Button", 50, 50);}function draw() { background(220); drawGui(); if(b.isPressed) { print(b.label + " is pressed."); } // Set the button width and height in the draw loop. b.w = 300; b.h = 150;}
Carlos Garcia Software Engineer / Media Artist //L05.is http://l05.is/
[image: L05-logo-small.png] https://L05.is
On Mon, Nov 2, 2020 at 11:40 AM Nic Stark [email protected] wrote:
@L05 https://github.com/L05 Hello, thank you for this fantastic library!
I'm using it as a game controller on mobile devices, I'd like for the user to be able to rotate their screen and re-render the canvas to accommodate for the different aspect ratio. Is there a way to change the values of the button and joystick x,y,width,height properties after they have been created?
Thanks, Nic
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/L05/p5.touchgui/issues/19, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AA6QI2Q3NGZSGI2NLCXFQD3SN4DLFANCNFSM4TH35XJA
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/L05/p5.touchgui/issues/19#issuecomment-720894846, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFJAYZCZVE2RK6NMS3A23DDSN57TLANCNFSM4TH35XJA .