# Review / Refactor / Example of p5 UI

**URL:** <https://discourse.processing.org/t/review-refactor-example-of-p5-ui/12838>\
**Category:** p5.js\
**Created:** [July 20, 2019, 11:09am UTC](https://discourse.processing.org/t/review-refactor-example-of-p5-ui/12838 "2019-07-20T11:09:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hellonearthis/32/3482_2.png) [@hellonearthis](https://discourse.processing.org/u/hellonearthis)\
**Post date:** [July 20, 2019, 11:09am UTC](https://discourse.processing.org/t/review-refactor-example-of-p5-ui/12838/1 "2019-07-20T11:09:40Z")

</div>

I’m working on a UI using p5.js you can see it [here in p5 webeditor](https://editor.p5js.org/hellonearthisman/sketches/aeiGRVtG3).

It is rendered from the game loop, but could be even driven using redraw() frunction.  
But I’m ok with it hogging the game loop for now.

No I don’t what to make ‘this’ and object oriented program and trying for a more functional design.  
I might be getting that wrong. My use of globals might frighten some people so yeah, warned.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/69c0655c7a378f7a60d2eb0b9e642a0840945943.jpeg)

---

<div class="post-metadata">

**Author:** ![hellonearthis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hellonearthis/32/3482_2.png) [@hellonearthis](https://discourse.processing.org/u/hellonearthis)\
**Post date:** [July 21, 2019, 3:20pm UTC](https://discourse.processing.org/t/review-refactor-example-of-p5-ui/12838/2 "2019-07-21T15:20:39Z")

</div>

For a website a game loop seems impractical, unless I make a state variable and check it in the draw() loop and only render stuff that’s changed.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [July 24, 2019, 8:53am UTC](https://discourse.processing.org/t/review-refactor-example-of-p5-ui/12838/3 "2019-07-24T08:53:43Z")

</div>

You mention what kinds of feedback you _don’t_ want: things about the main loop, global variables, object oriented design, or functional programming.

What kind of feedback _do_ you want?
