Constructor
new GUIForP5()
Constructs the GUI, creates the main div, and sets up theming and layout.
- Source:
Members
isTypingText :boolean
Tracks whether typing is happening within the GUI.
This is used to prevent keyPressed()
actions (like randomization)
while typing.
Type:
- boolean
- Source:
Methods
addController(controller, doAddToRandomizerAsopt) → {Controller}
Adds a controller to the GUI and optionally to the randomizer.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
controller |
Controller | ||
doAddToRandomizerAs |
boolean |
<optional> |
- Source:
Returns:
- Type
- Controller
addDivider() → {Divider}
Adds a divider (horizontal rule) to the GUI.
- Source:
Returns:
- Type
- Divider
addField(field) → {Field}
Adds a field (GUI element) to the GUI.
Parameters:
Name | Type | Description |
---|---|---|
field |
Field |
- Source:
Returns:
- Type
- Field
addHTMLToNewField(html, classNameopt) → {Field}
Adds an HTML string as a new field.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
html |
string | |||
className |
string |
<optional> |
'' |
- Source:
Returns:
- Type
- Field
addImage(url, altText, doAlignCenteropt) → {GUIImage}
Adds an image to the GUI.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string | |||
altText |
string | |||
doAlignCenter |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- GUIImage
addLabel(labelText) → {Label}
Adds a label to the GUI.
Parameters:
Name | Type | Description |
---|---|---|
labelText |
string |
- Source:
Returns:
- Type
- Label
addP5CatalystLogo() → {Field}
Adds the p5Catalyst logo as a field.
- Source:
Returns:
- Type
- Field
addTitle(hSize, titleText, doAlignCenteropt) → {Title}
Adds a title (heading) to the GUI.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
hSize |
number | Heading size (e.g., 1 for h1, 2 for h2). |
||
titleText |
string | |||
doAlignCenter |
boolean |
<optional> |
false |
- Source:
Returns:
- Type
- Title
createDarkModeButton()
Creates and adds a button for toggling light/dark mode.
- Source:
getController(name) → {Controller|undefined}
Gets a controller by name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
- Source:
Returns:
- Type
- Controller | undefined
getControllers(names) → {Array.<Controller>}
Gets multiple controllers by an array of names.
Parameters:
Name | Type | Description |
---|---|---|
names |
Array.<string> |
- Source:
Returns:
- Type
- Array.<Controller>
getState() → {Array.<{name: string, value: any}>}
Gets the current state of all controllers with values.
- Source:
Returns:
- Type
- Array.<{name: string, value: any}>
hasName(name) → {boolean}
Checks if a controller with the given name exists.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
- Source:
Returns:
- Type
- boolean
loadLightDarkMode()
Loads the light/dark mode setting from localStorage and applies it.
- Source:
restoreState(state)
Restores the state of controllers from a saved state.
Parameters:
Name | Type | Description |
---|---|---|
state |
Array.<{name: string, value: any}> |
- Source:
setAutoLightDarkMode()
Sets the GUI to automatically match the system's light/dark mode.
- Source:
setDarkMode()
Sets the GUI to dark mode.
- Source:
setLeft()
Moves the GUI to the left side of the main container.
- Source:
setLightMode()
Sets the GUI to light mode.
- Source:
setRight()
Moves the GUI to the right side of the main container.
- Source:
setup()
Calls setup on all controllers.
- Source:
toggleLightDarkMode()
Cycles between light, dark, and auto light/dark modes.
- Source:
toggleSide()
Toggles the GUI between left and right sides.
- Source: