perfect-gui 3.4.4 → 3.4.6

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
@@ -7,7 +7,7 @@ Features:
7
7
  - easy positioning
8
8
  - draggable panels
9
9
 
10
- <img src="https://raw.githubusercontent.com/thibka/thibka.github.io/master/perfect-gui/_data/capture.png" width="464"/>
10
+ <img src="https://raw.githubusercontent.com/thibka/thibka.github.io/master/perfect-gui/_data/capture.png" width="580"/>
11
11
 
12
12
  ## Demo
13
13
  https://thibka.github.io/perfect-gui/public/
@@ -61,7 +61,7 @@ const gui = new GUI({
61
61
  // Defines if the panel can be manually moved across the screen.
62
62
  // Default is false.
63
63
 
64
- autoRepositioning: true
64
+ autoRepositioning: true,
65
65
  // If set to true, the panel position will be reset when the screen is resized.
66
66
  // If a panel has been dragged, it won't be be affected.
67
67
  // Default is true.
@@ -77,15 +77,13 @@ const gui = new GUI({
77
77
  <tr><td>button</td><td>
78
78
 
79
79
  ```javascript
80
- gui.button('Click me!', () => {
81
- ...
82
- });
80
+ gui.button('Click me!', callback);
83
81
  ```
84
82
  </td></tr>
85
83
  <tr><td>image</td><td>
86
84
 
87
85
  ```javascript
88
- gui.image('Click this', 'path/to/image', () => {
86
+ gui.image('Click this', 'path/to/image', (path) => {
89
87
  ...
90
88
  });
91
89
  ```
@@ -166,4 +164,6 @@ gui.toggleClose();
166
164
 
167
165
 
168
166
  ## To do
169
- - Adding color palette component
167
+ - Color palette component
168
+ - Vector2 drag & drop
169
+ - Style list component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perfect-gui",
3
- "version": "3.4.4",
3
+ "version": "3.4.6",
4
4
  "description": "Nice and simple GUI for JavaScript.",
5
5
  "main": "src/index.js",
6
6
  "directories": {
package/src/index.js CHANGED
@@ -246,13 +246,14 @@ export default class GUI {
246
246
  value: 'number'
247
247
  }, params);
248
248
  } else {
249
+ object = params.obj || params.object;
250
+ prop = params.prop || params.property;
251
+
249
252
  this._checkMandatoryParams({
250
253
  object: 'object',
251
254
  prop: 'string'
252
- }, params);
255
+ }, {object, prop});
253
256
 
254
- object = params.object;
255
- prop = params.prop;
256
257
  propReferenceIndex = this.propReferences.push(object[prop]) - 1;
257
258
  isObject = true;
258
259
  }
@@ -399,12 +400,12 @@ export default class GUI {
399
400
  const minY = data.y.min ?? 0;
400
401
  const maxY = data.y.max ?? 1;
401
402
 
402
- const objectX = data.x.object;
403
- const propX = data.x.prop;
403
+ const objectX = data.x.obj || data.x.object;
404
+ const propX = data.x.prop || data.x.property;
404
405
  const propXReferenceIndex = this.propReferences.push(objectX[propX]) - 1;
405
406
 
406
- const objectY = data.y.object;
407
- const propY = data.y.prop;
407
+ const objectY = data.y.obj || data.y.object;
408
+ const propY = data.y.prop || data.y.property;
408
409
  const propYReferenceIndex = this.propReferences.push(objectY[propY]) - 1;
409
410
 
410
411
  this.imageContainer = null;
package/src/styles.js CHANGED
@@ -18,7 +18,7 @@ return /* css */`
18
18
  font-family: Verdana, Arial, sans-serif;
19
19
  width: 290px;
20
20
  overflow: auto;
21
- box-shadow: 0 0 10px black;
21
+ box-shadow: 0 0 5px black;
22
22
  box-sizing: border-box;
23
23
  z-index: 99999;
24
24
  user-select: none;
@@ -75,7 +75,7 @@ return /* css */`
75
75
  width: calc(33.33% - 10px);
76
76
  aspect-ratio: 1 / 1;
77
77
  background-size: cover;
78
- margin: 5px 5px 19px 5px;
78
+ margin: 1px 5px 19px 5px;
79
79
  cursor: pointer;
80
80
  position: relative;
81
81
  }
@@ -184,7 +184,7 @@ return /* css */`
184
184
  .p-gui__switch-checkbox {
185
185
  width: 5px;
186
186
  height: 5px;
187
- background-color: #343434;
187
+ background-color: rgba(0, 0, 0, .5);
188
188
  position: absolute;
189
189
  top: 0;
190
190
  right: 8px;
package/test/src/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import './styles/main.scss';
2
- import perfectGUI from '../../src/index';
3
- //import full_featured_gui from './js/full_featured';
2
+ //import demo from './js/demo';
4
3
  import basics from './js/basics';
5
4
  import vectors from './js/vectors';
6
5
  import multiple from './js/multiple';
@@ -8,6 +7,8 @@ import folders from './js/folders';
8
7
  import other from './js/other';
9
8
  import kill_create from './js/kill_create';
10
9
 
10
+ //demo();
11
+
11
12
  basics();
12
13
 
13
14
  vectors();
@@ -11,6 +11,7 @@ export default function basics() {
11
11
  const gui = new GUI({
12
12
  name: 'Basics',
13
13
  container: '#container-1',
14
+ draggable: true
14
15
  });
15
16
 
16
17
  gui.button('Button', () => {
@@ -24,7 +25,7 @@ export default function basics() {
24
25
  }
25
26
  );
26
27
 
27
- gui.slider({ name: 'Slider 2 (object binding)', object: position, prop: 'x', min: -30, max: 30, step: .1 }
28
+ gui.slider({ name: 'Slider 2 (object binding)', obj: position, prop: 'x', min: -30, max: 30, step: .1 }
28
29
  );
29
30
 
30
31
  gui.toggle('Switch', true, state => {
@@ -0,0 +1,66 @@
1
+ // <div id="container-0" class="container" style="height: 800px; border-radius: 0;"></div>
2
+
3
+ import GUI from '../../../src/index';
4
+
5
+ export default function()
6
+ {
7
+ const element = document.querySelector('#container-0 .element');
8
+ const note = document.querySelector('#container-0 .note');
9
+
10
+ const gui = new GUI({
11
+ draggable: true,
12
+ container: '#container-0',
13
+ name: 'Control panel'
14
+ });
15
+
16
+
17
+ gui.button("Randomize color", () => {
18
+ element.style.backgroundColor = get_random_color();
19
+ });
20
+ gui.slider({name: 'Intensity', min: .1, max: 2, value: .75, step: .01 }, (value) => {
21
+ element.style.transform = `scale(${value})`;
22
+ });
23
+ gui.slider({name: 'Scale', min: 0, max: 50, value: 25, step: 25 }, (value) => {
24
+ element.style.borderRadius = `${value}%`;
25
+ });
26
+
27
+ let folder1 = gui.folder({name: 'Texture'});
28
+
29
+ folder1.image(
30
+ 'The officer',
31
+ require('../img/DALL·E-2022-11-13-20.11.16---portrait-of-a-squirrel-in-an-officier-suit,-style-of-a-Rembrandt-painting.jpg'),
32
+ () => {}
33
+ );
34
+ folder1.image(
35
+ 'Weird dream',
36
+ require('../img/DALL·E-2022-11-13-20.11.52---a-blonde-girl-riding-a-whale-in-the-style-of-hopper.jpg'),
37
+ () => {}
38
+ );
39
+ folder1.image(
40
+ 'Friends',
41
+ require('../img/DALL·E-2022-11-13-20.13.55---1-blonde-haired-girl-with-her-orange-cat,-watching-the-whales-in-Tadoussac,-Canada.-In-the-style-of-an-oil-painting..jpg'),
42
+ () => {}
43
+ );
44
+
45
+ let folder2 = gui.folder({name: 'Normals', closed: true});
46
+ folder2.button("Random element color", () => {});
47
+
48
+ gui.toggle("Rim light", true, (state) => {});
49
+
50
+ gui.toggle("Direct light", false, (state) => {});
51
+
52
+ gui.list('Preset', ['Atomic', 'pink', 'yellow', 'blue'], function(item) {});
53
+
54
+
55
+ let position = { x: 2, y: 1};
56
+ const gui2 = new GUI({
57
+ draggable: true,
58
+ container: '#container-0',
59
+ name: 'Position panel'
60
+ });
61
+ gui2.vector2('Position', {
62
+ x: {min: -10, max: 10, object: position, prop: 'x'},
63
+ y: {min: -10, max: 10, object: position, prop: 'y'},
64
+ }, () => {});
65
+ gui2.button('Randomize', () => {});
66
+ }
Binary file
@@ -1,84 +0,0 @@
1
-
2
-
3
- const full_featured_gui = new perfectGUI({
4
- name: "This is a basic panel",
5
- draggable: true,
6
- container: '#container-1'
7
- });
8
-
9
- full_featured_gui.image(
10
- 'Background 1',
11
- 'https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=768&q=80',
12
- () => {
13
- full_featured_gui.container.style.backgroundImage = `url(https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1502&q=80)`;
14
- full_featured_gui.container.style.backgroundColor = `none`;
15
- document.getElementById('note').textContent = "Photo by Joel Filipe on Unsplash";
16
- }
17
- );
18
- full_featured_gui.image(
19
- 'Background 2',
20
- 'https://images.unsplash.com/photo-1535370976884-f4376736ab06?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=768&q=80',
21
- () => {
22
- full_featured_gui.container.style.backgroundImage = `url(https://images.unsplash.com/photo-1535370976884-f4376736ab06?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=564&q=80)`;
23
- full_featured_gui.container.style.backgroundColor = `none`;
24
- document.getElementById('note').textContent = "Photo by Richard M. on Unsplash";
25
- }
26
- );
27
- full_featured_gui.image(
28
- 'Background 3',
29
- 'https://images.unsplash.com/photo-1524721696987-b9527df9e512?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=768&q=80',
30
- () => {
31
- full_featured_gui.container.style.backgroundImage = `url(https://images.unsplash.com/photo-1524721696987-b9527df9e512?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1490&q=80)`;
32
- full_featured_gui.container.style.backgroundColor = `none`;
33
- document.getElementById('note').textContent = "Photo by Cassi Josh on Unsplash";
34
- }
35
- );
36
- full_featured_gui.image(
37
- 'Background 4',
38
- 'https://images.unsplash.com/photo-1574169208507-84376144848b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=768&q=80',
39
- () => {
40
- full_featured_gui.container.style.backgroundImage = `url(https://images.unsplash.com/photo-1574169208507-84376144848b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=768&q=80)`;
41
- full_featured_gui.container.style.backgroundColor = `none`;
42
- document.getElementById('note').textContent = "Photo by United States Geological Survey on Unsplash";
43
- }
44
- );
45
-
46
- let folder = full_featured_gui.folder('Some folder');
47
-
48
- folder.button("Random element color", () => {
49
- element.style.backgroundColor = get_random_color();
50
- });
51
-
52
- folder.image(
53
- 'Background 5',
54
- 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1024&q=80',
55
- () => {
56
- full_featured_gui.container.style.backgroundImage = `url(https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1024&q=80)`;
57
- full_featured_gui.container.style.backgroundColor = `none`;
58
- document.getElementById('note').textContent = "Photo by Milad Fakurian on Unsplash";
59
- }
60
- );
61
-
62
- full_featured_gui.button("Random element color", () => {
63
- element.style.backgroundColor = get_random_color();
64
- });
65
- full_featured_gui.slider("Scale", {min: .1, max: 2, value: 1, step: .01 }, (value) => {
66
- element.style.transform = `scale(${value})`;
67
- });
68
- full_featured_gui.slider("3-step border-radius", {min: 0, max: 50, value: 0, step: 25 }, (value) => {
69
- element.style.borderRadius = `${value}%`;
70
- });
71
-
72
- let folder2 = full_featured_gui.folder('ok', false);
73
- folder2.button("Random element color", () => {
74
- element.style.backgroundColor = get_random_color();
75
- });
76
-
77
- full_featured_gui.toggle("Opacity switch", true, (state) => {
78
- if (!state) element.style.opacity = .5;
79
- else element.style.opacity = 1;
80
- });
81
-
82
- full_featured_gui.list('Select a color', ['red', 'pink', 'yellow', 'blue'], function(item) {
83
- element.style.backgroundColor = item;
84
- });