The GUI controls used by the Creative Environment Creenv. Vanilla JS, lightweight, customizable
npm install @creenv/guijs
// the config
var config = {
strength: 13,
background: new Color(255,25,255,0.8), // can also be a string, ex: #efef17
isGlowActive: false,
textToDisplay: "test"
};
var userControls = {
object: config,
controls: [
[
"a folder name",
{
property: "strength",
min: 0, max: 150, step: 30,
callback: val => { console.log("number updated: "+val); }
},
{
property: "background" // we leave full control to the user here
}
],
[
"another folder",
{
property: "isGlowActive",
callback: val => { console.log("boolean changed: "+val) }
},
{
property: "textToDisplay"
}
]
]
}
var gui = new GUI(userControls);
`
aaaaand... BOOM:
[ici image]
As simple as that. Now, whenver you'll want to get the values of the config variable, they will match the one provided by the user.
What you need to know
There are a few things you need to know about the GUI if you want to use it wisely.
$3
The controls object must match a specific structure, otherwise it won't be transformed into the desired UI.
`js
// the controls variable is an object, it must have at least 2 properties :
let controls = {
// the variable, an object in which the properties are stored
object: yourConfigObject,
// an array with all the controls, in which all items follow a schema
controls: [
// if the item is an object, it will be considered as a controller
{
// a controller must have a "property" property. it will match the name of the
// property in the config object, see the example above. must be a string
property: "propertyName",
/**
* depending on the type of the property, the controller will either be:
* string: input text
* boolean: checkbox
* string, css color format: color picker
* number: slider
* it's automatic. look at the example above
/
// everything else is optional. look at the controls property below to learn
// about the controllers properties you can use
}
]
}
``