perfect-gui 3.4.6 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,17 +14,15 @@ https://thibka.github.io/perfect-gui/public/
14
14
 
15
15
  ## Install
16
16
 
17
- ### NPM
18
17
  ```bash
19
18
  npm i perfect-gui
20
19
  ```
21
- ```javascript
22
- import GUI from 'perfect-gui';
23
- ```
24
20
 
25
21
  ## Usage
26
22
 
27
23
  ```javascript
24
+ import GUI from 'perfect-gui';
25
+
28
26
  const gui = new GUI();
29
27
 
30
28
  gui.button('Click me', callback);
@@ -45,17 +43,20 @@ const gui = new GUI({
45
43
  width: 250,
46
44
  // Width of the panel (in pixels).
47
45
  // Default is 290.
46
+
47
+ maxHeight: 500,
48
+ // Maximum height beyond which scrolling is necessary.
49
+ // Default is the smallest value between the height of the window and the height of the container.
48
50
 
49
51
  closed: false,
50
- // Defines whether the panel should be open or closed by default.
51
- // Default is false (open).
52
+ // Defines whether the panel should be closed by default.
53
+ // Default is false.
52
54
 
53
55
  position: 'bottom right',
54
56
  // Defines where to place the panel on screen.
55
- // Accepted values are 'top', 'bottom', 'left' and 'right'
56
- // in no particular order ('bottom right' = 'right bottom').
57
+ // Accepted values are 'top', 'bottom', 'left' and 'right' in no particular order ('bottom right' = 'right bottom').
57
58
  // If multiple instances have the same position, they will be stacked horizontally.
58
- // Default is 'top left'.
59
+ // Default is 'top right'.
59
60
 
60
61
  draggable: false,
61
62
  // Defines if the panel can be manually moved across the screen.
@@ -143,6 +144,14 @@ gui.vector2('Position', {
143
144
  });
144
145
  ```
145
146
  </td></tr>
147
+ <tr><td>color</td><td>
148
+
149
+ ```javascript
150
+ gui.color('Color', '#ff0000', color => {
151
+ console.log('Selected color:', color);
152
+ });
153
+ ```
154
+ </td></tr>
146
155
  <tr><td>folder</td><td>
147
156
 
148
157
  ```javascript
@@ -164,6 +173,6 @@ gui.toggleClose();
164
173
 
165
174
 
166
175
  ## To do
167
- - Color palette component
168
176
  - Vector2 drag & drop
169
- - Style list component
177
+ - Style list component
178
+ - Image button selection outline
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perfect-gui",
3
- "version": "3.4.6",
3
+ "version": "3.5.1",
4
4
  "description": "Nice and simple GUI for JavaScript.",
5
5
  "main": "src/index.js",
6
6
  "directories": {
package/src/index.js CHANGED
@@ -18,7 +18,7 @@ export default class GUI {
18
18
  }
19
19
 
20
20
  this.name = (options != undefined && typeof options.name == "string") ? options.name : '';
21
- this.color = options.color || null;
21
+ this.backgroundColor = options.color || null;
22
22
 
23
23
  if ( this instanceof GUI ) {
24
24
  if ( typeof GUI[GUI.instanceCounter] != 'number' ) {
@@ -73,7 +73,7 @@ export default class GUI {
73
73
  max-height: ${this.maxHeight}px;
74
74
  transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
75
75
  ${ this.screenCorner.y == 'top' ? '' : 'top: auto; bottom: 0;' }
76
- ${ this.color ? 'background: ' + this.color + ';' : '' }
76
+ ${ this.backgroundColor ? 'background: ' + this.backgroundColor + ';' : '' }
77
77
  }`);
78
78
 
79
79
  if (options.autoRepositioning != false) window.addEventListener('resize', this._handleResize.bind(this));
@@ -96,12 +96,12 @@ export default class GUI {
96
96
  }
97
97
 
98
98
  _parseScreenCorner(position) {
99
- let parsedPosition = {x: 'left', y: 'top'};
99
+ let parsedPosition = {x: 'right', y: 'top'};
100
100
 
101
101
  if (position == undefined) return parsedPosition;
102
- else if (typeof position != 'string') console.error('[perfect-gui] The position option must be a string.');
102
+ else if (typeof position != 'string') console.error('[perfect-gui] Position must be a string.');
103
103
 
104
- if (position.includes('right')) parsedPosition.x = 'right';
104
+ if (position.includes('left')) parsedPosition.x = 'left';
105
105
  if (position.includes('bottom')) parsedPosition.y = 'bottom';
106
106
 
107
107
  return parsedPosition;
@@ -142,6 +142,8 @@ export default class GUI {
142
142
  if (element.onchange) domElement.onchange = element.onchange;
143
143
  if (element.textContent) domElement.textContent = element.textContent;
144
144
  if (element.innerHTML) domElement.innerHTML = element.innerHTML;
145
+ if (element.type) domElement.type = element.type;
146
+ if (element.value) domElement.value = element.value;
145
147
  if (element.customAttributes) {
146
148
  for (var i in element.customAttributes) {
147
149
  domElement.setAttribute(i, element.customAttributes[i]);
@@ -167,7 +169,7 @@ export default class GUI {
167
169
  parent: this.wrapper,
168
170
  class: 'p-gui__header',
169
171
  textContent: this.name,
170
- inline: `${ this.color ? 'border-color: ' + this.color + ';' : ''}`
172
+ inline: `${ this.backgroundColor ? 'border-color: ' + this.backgroundColor + ';' : ''}`
171
173
  });
172
174
 
173
175
  this._createElement({
@@ -472,6 +474,28 @@ export default class GUI {
472
474
  });
473
475
  }
474
476
 
477
+ color(text, value, callback) {
478
+ const container = this._createElement({
479
+ el: 'div',
480
+ class: 'p-gui__color',
481
+ textContent: text,
482
+ });
483
+
484
+ const colorpicker = this._createElement({
485
+ parent: container,
486
+ el: 'input',
487
+ class: 'p-gui__color-picker',
488
+ type: 'color',
489
+ value
490
+ });
491
+
492
+ if (callback) {
493
+ colorpicker.addEventListener('input', () => {
494
+ callback(colorpicker.value);
495
+ });
496
+ }
497
+ }
498
+
475
499
  folder(options = {}) {
476
500
  let closed = typeof options.closed == 'boolean' ? options.closed : false;
477
501
  let name = options.name || '';
package/src/styles.js CHANGED
@@ -92,7 +92,8 @@ return /* css */`
92
92
  .p-gui__button,
93
93
  .p-gui__switch,
94
94
  .p-gui__list,
95
- .p-gui__vector2 {
95
+ .p-gui__vector2,
96
+ .p-gui__color {
96
97
  width: 100%;
97
98
  padding: 7px;
98
99
  font-size: 11px;
@@ -177,10 +178,6 @@ return /* css */`
177
178
  pointer-events: none;
178
179
  }
179
180
 
180
- .p-gui__list {
181
- cursor: default;
182
- }
183
-
184
181
  .p-gui__switch-checkbox {
185
182
  width: 5px;
186
183
  height: 5px;
@@ -199,7 +196,13 @@ return /* css */`
199
196
  box-shadow: 0 0 5px #00ff89;
200
197
  }
201
198
 
202
- .p-gui__list-dropdown {
199
+ .p-gui__list,
200
+ .p-gui__color {
201
+ cursor: default;
202
+ }
203
+
204
+ .p-gui__list-dropdown,
205
+ .p-gui__color-picker {
203
206
  position: absolute;
204
207
  right: 5px;
205
208
  top: 0;
@@ -209,6 +212,21 @@ return /* css */`
209
212
  cursor: pointer;
210
213
  }
211
214
 
215
+ .p-gui__color-picker {
216
+ -webkit-appearance: none;
217
+ padding: 0;
218
+ background-color: transparent;
219
+ height: 15px;
220
+ border: 1px solid #222222;
221
+ }
222
+
223
+ .p-gui__color-picker::-webkit-color-swatch-wrapper {
224
+ padding: 0;
225
+ }
226
+ .p-gui__color-picker::-webkit-color-swatch {
227
+ border: none;
228
+ }
229
+
212
230
  .p-gui__slider {
213
231
  width: 100%;
214
232
  margin-bottom: 8px;
@@ -11,7 +11,7 @@
11
11
  <body>
12
12
  <div class="wrapper">
13
13
  <h1>Perfect GUI API</h1>
14
-
14
+
15
15
  <h2>Basics</h2>
16
16
 
17
17
  <div id="container-1" class="container">
@@ -25,22 +25,17 @@
25
25
  <span style="color: #a6e22e">x</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">0</span>
26
26
  <span style="color: #f8f8f2">};</span>
27
27
 
28
- <span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">GUI</span><span style="color: #f8f8f2">({</span>
29
- <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;Basics&#39;</span>
30
- <span style="color: #f8f8f2">});</span>
28
+ <span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">GUI</span><span style="color: #f8f8f2">({</span> <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;Basics&#39;</span> <span style="color: #f8f8f2">});</span>
31
29
 
32
30
  <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">button</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Button&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #a6e22e">changeColor</span><span style="color: #f8f8f2">);</span>
33
31
 
34
- <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">slider</span><span style="color: #f8f8f2">({</span>
35
- <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;Slider (simple callback)&#39;</span><span style="color: #f8f8f2">,</span>
36
- <span style="color: #a6e22e">value</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">1</span><span style="color: #f8f8f2">,</span>
37
- <span style="color: #f8f8f2">},</span> <span style="color: #a6e22e">value</span> <span style="color: #f92672">=&gt;</span> <span style="color: #f8f8f2">{</span>
38
- <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">opacity</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">value</span>
39
- <span style="color: #f8f8f2">});</span>
32
+ <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">slider</span><span style="color: #f8f8f2">({</span> <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;Slider (simple callback)&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #a6e22e">value</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">1</span> <span style="color: #f8f8f2">},</span>
33
+ <span style="color: #a6e22e">value</span> <span style="color: #f92672">=&gt;</span> <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">opacity</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">value</span>
34
+ <span style="color: #f8f8f2">);</span>
40
35
 
41
36
  <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">slider</span><span style="color: #f8f8f2">({</span>
42
37
  <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;Slider 2 (object binding)&#39;</span><span style="color: #f8f8f2">,</span>
43
- <span style="color: #a6e22e">object</span><span style="color: #f92672">:</span> <span style="color: #a6e22e">position</span><span style="color: #f8f8f2">,</span>
38
+ <span style="color: #a6e22e">obj</span><span style="color: #f92672">:</span> <span style="color: #a6e22e">position</span><span style="color: #f8f8f2">,</span>
44
39
  <span style="color: #a6e22e">prop</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;x&#39;</span><span style="color: #f8f8f2">,</span>
45
40
  <span style="color: #a6e22e">min</span><span style="color: #f92672">:</span> <span style="color: #f92672">-</span><span style="color: #ae81ff">30</span><span style="color: #f8f8f2">,</span>
46
41
  <span style="color: #a6e22e">max</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">30</span><span style="color: #f8f8f2">,</span>
@@ -54,22 +49,19 @@
54
49
 
55
50
  <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">list</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;List&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">[</span><span style="color: #e6db74">&#39;red&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;pink&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;yellow&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;blue&#39;</span><span style="color: #f8f8f2">],</span> <span style="color: #a6e22e">item</span> <span style="color: #f92672">=&gt;</span> <span style="color: #f8f8f2">{</span>
56
51
  <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundColor</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">item</span><span style="color: #f8f8f2">;</span>
57
- <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundImage</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">&#39;none&#39;</span><span style="color: #f8f8f2">;</span>
58
52
  <span style="color: #f8f8f2">});</span>
59
53
 
60
- <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">image</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Image 1&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;path/to/image-1.jpg&#39;</span><span style="color: #f8f8f2">,</span>
61
- <span style="color: #a6e22e">evt</span> <span style="color: #f92672">=&gt;</span> <span style="color: #f8f8f2">{</span>
62
- <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundImage</span> <span style="color: #f92672">=</span> <span style="color: #960050; background-color: #1e0010">`</span><span style="color: #a6e22e">url</span><span style="color: #f8f8f2">(</span><span style="color: #a6e22e">$</span><span style="color: #f8f8f2">{</span><span style="color: #a6e22e">evt</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">path</span><span style="color: #f8f8f2">})</span><span style="color: #960050; background-color: #1e0010">`</span><span style="color: #f8f8f2">;</span>
63
- <span style="color: #f8f8f2">document.</span><span style="color: #a6e22e">querySelector</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;#container-1 .note&#39;</span><span style="color: #f8f8f2">).</span><span style="color: #a6e22e">textContent</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">&quot;Photo by Joel Filipe on Unsplash&quot;</span><span style="color: #f8f8f2">;</span>
64
- <span style="color: #f8f8f2">}</span>
65
- <span style="color: #f8f8f2">);</span>
54
+ <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">image</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Image 1&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;path/to/image-1.jpg&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #a6e22e">evt</span> <span style="color: #f92672">=&gt;</span> <span style="color: #f8f8f2">{</span>
55
+ <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundImage</span> <span style="color: #f92672">=</span> <span style="color: #960050; background-color: #1e0010">`</span><span style="color: #a6e22e">url</span><span style="color: #f8f8f2">(</span><span style="color: #a6e22e">$</span><span style="color: #f8f8f2">{</span><span style="color: #a6e22e">evt</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">path</span><span style="color: #f8f8f2">})</span><span style="color: #960050; background-color: #1e0010">`</span><span style="color: #f8f8f2">;</span>
56
+ <span style="color: #f8f8f2">});</span>
66
57
 
67
- <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">image</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Image 2&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;path/to/image-2.jpg&#39;</span><span style="color: #f8f8f2">,</span>
68
- <span style="color: #a6e22e">evt</span> <span style="color: #f92672">=&gt;</span> <span style="color: #f8f8f2">{</span>
69
- <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundImage</span> <span style="color: #f92672">=</span> <span style="color: #960050; background-color: #1e0010">`</span><span style="color: #a6e22e">url</span><span style="color: #f8f8f2">(</span><span style="color: #a6e22e">$</span><span style="color: #f8f8f2">{</span><span style="color: #a6e22e">evt</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">path</span><span style="color: #f8f8f2">})</span><span style="color: #960050; background-color: #1e0010">`</span><span style="color: #f8f8f2">;</span>
70
- <span style="color: #f8f8f2">document.</span><span style="color: #a6e22e">querySelector</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;#container-1 .note&#39;</span><span style="color: #f8f8f2">).</span><span style="color: #a6e22e">textContent</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">&quot;Photo by Milad Fakurian on Unsplash&quot;</span><span style="color: #f8f8f2">;</span>
71
- <span style="color: #f8f8f2">}</span>
72
- <span style="color: #f8f8f2">);</span>
58
+ <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">image</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Image 2&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;path/to/image-2.jpg&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #a6e22e">evt</span> <span style="color: #f92672">=&gt;</span> <span style="color: #f8f8f2">{</span>
59
+ <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundImage</span> <span style="color: #f92672">=</span> <span style="color: #960050; background-color: #1e0010">`</span><span style="color: #a6e22e">url</span><span style="color: #f8f8f2">(</span><span style="color: #a6e22e">$</span><span style="color: #f8f8f2">{</span><span style="color: #a6e22e">evt</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">path</span><span style="color: #f8f8f2">})</span><span style="color: #960050; background-color: #1e0010">`</span><span style="color: #f8f8f2">;</span>
60
+ <span style="color: #f8f8f2">});</span>
61
+
62
+ <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">color</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Color&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">&#39;#ff0000&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #a6e22e">color</span> <span style="color: #f92672">=&gt;</span> <span style="color: #f8f8f2">{</span>
63
+ <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundColor</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">color</span><span style="color: #f8f8f2">;</span>
64
+ <span style="color: #f8f8f2">});</span>
73
65
 
74
66
  <span style="color: #66d9ef">function</span> <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">{</span>
75
67
  <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">transform</span> <span style="color: #f92672">=</span> <span style="color: #960050; background-color: #1e0010">`</span><span style="color: #a6e22e">translateX</span><span style="color: #f8f8f2">(</span><span style="color: #a6e22e">$</span><span style="color: #f8f8f2">{</span><span style="color: #a6e22e">position</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">x</span><span style="color: #f8f8f2">}</span><span style="color: #a6e22e">px</span><span style="color: #f8f8f2">)</span><span style="color: #960050; background-color: #1e0010">`</span><span style="color: #f8f8f2">;</span>
@@ -77,7 +69,8 @@
77
69
  <span style="color: #f8f8f2">}</span>
78
70
 
79
71
  <span style="color: #a6e22e">loop</span><span style="color: #f8f8f2">();</span>
80
- </pre></div>
72
+ </pre></div>
73
+
81
74
  </div>
82
75
 
83
76
  <h2>Vectors</h2>
@@ -141,14 +134,14 @@
141
134
 
142
135
  <span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui_3</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">GUI</span><span style="color: #f8f8f2">({</span>
143
136
  <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;GUI 3&#39;</span><span style="color: #f8f8f2">,</span>
144
- <span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;top right&#39;</span>
137
+ <span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;top left&#39;</span>
145
138
  <span style="color: #f8f8f2">});</span>
146
139
 
147
140
  <span style="color: #a6e22e">gui_3</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">button</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Button&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=&gt;</span> <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundColor</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">getRandomColor</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">);</span>
148
141
 
149
142
  <span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui_4</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">GUI</span><span style="color: #f8f8f2">({</span>
150
143
  <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;GUI 4&#39;</span><span style="color: #f8f8f2">,</span>
151
- <span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;right bottom&#39;</span>
144
+ <span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;bottom right&#39;</span>
152
145
  <span style="color: #f8f8f2">});</span>
153
146
 
154
147
  <span style="color: #a6e22e">gui_4</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">button</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">&#39;Button&#39;</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=&gt;</span> <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">style</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">backgroundColor</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">getRandomColor</span><span style="color: #f8f8f2">()</span> <span style="color: #f8f8f2">);</span>
@@ -268,7 +261,8 @@
268
261
  <span style="color: #a6e22e">guis</span><span style="color: #f8f8f2">[</span><span style="color: #a6e22e">guis</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">length</span><span style="color: #f8f8f2">]</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">GUI</span><span style="color: #f8f8f2">({</span>
269
262
  <span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;Created GUI&#39;</span><span style="color: #f8f8f2">,</span>
270
263
  <span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">&#39;bottom left&#39;</span><span style="color: #f8f8f2">,</span>
271
- <span style="color: #a6e22e">width</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">150</span>
264
+ <span style="color: #a6e22e">width</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">150</span><span style="color: #f8f8f2">,</span>
265
+ <span style="color: #a6e22e">color</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">'red'</span>
272
266
  <span style="color: #f8f8f2">});</span>
273
267
  <span style="color: #f8f8f2">});</span>
274
268
 
@@ -25,8 +25,7 @@ export default function basics() {
25
25
  }
26
26
  );
27
27
 
28
- gui.slider({ name: 'Slider 2 (object binding)', obj: position, prop: 'x', min: -30, max: 30, step: .1 }
29
- );
28
+ gui.slider({ name: 'Slider 2 (object binding)', obj: position, prop: 'x', min: -30, max: 30, step: .1 });
30
29
 
31
30
  gui.toggle('Switch', true, state => {
32
31
  if ( state ) element.classList.remove('round');
@@ -34,8 +33,8 @@ export default function basics() {
34
33
  });
35
34
 
36
35
  gui.list('List', ['red', 'pink', 'yellow', 'blue'], item => {
37
- element.style.backgroundColor = item;
38
36
  element.style.backgroundImage = 'none';
37
+ element.style.backgroundColor = item;
39
38
  });
40
39
 
41
40
  gui.image('Image 1',
@@ -54,6 +53,11 @@ export default function basics() {
54
53
  }
55
54
  );
56
55
 
56
+ gui.color('Color', '#ff0000', color => {
57
+ element.style.backgroundImage = 'none';
58
+ element.style.backgroundColor = color;
59
+ });
60
+
57
61
  function loop() {
58
62
  element.style.transform = `translateX(${position.x}px)`;
59
63
  requestAnimationFrame(loop);
@@ -13,7 +13,6 @@ export default function()
13
13
  name: 'Control panel'
14
14
  });
15
15
 
16
-
17
16
  gui.button("Randomize color", () => {
18
17
  element.style.backgroundColor = get_random_color();
19
18
  });
@@ -62,5 +61,5 @@ export default function()
62
61
  x: {min: -10, max: 10, object: position, prop: 'x'},
63
62
  y: {min: -10, max: 10, object: position, prop: 'y'},
64
63
  }, () => {});
65
- gui2.button('Randomize', () => {});
64
+ gui2.color('Color', '#ffd170', () => {});
66
65
  }
@@ -16,7 +16,8 @@ export default function other() {
16
16
  container,
17
17
  name: 'Created GUI',
18
18
  position: 'bottom left',
19
- width: 150
19
+ width: 150,
20
+ color: 'red'
20
21
  });
21
22
  });
22
23
 
@@ -24,7 +24,7 @@ export default function multiple() {
24
24
 
25
25
  const gui_3 = new GUI({
26
26
  name: 'GUI 3',
27
- position: 'top right',
27
+ position: 'top left',
28
28
  container: '#container-2'
29
29
  });
30
30
 
@@ -94,7 +94,7 @@ pre {
94
94
  background-position: center;
95
95
  background-repeat: no-repeat;
96
96
  border: 1px solid black;
97
- transition: .1s transform ease, .3s border-radius ease, .3s background-color linear;
97
+ transition: .1s transform ease, .3s border-radius ease;
98
98
  }
99
99
 
100
100
  .element.round {