perfect-gui 2.5.2 → 2.6.0
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 +8 -3
- package/package.json +1 -1
- package/src/index.js +24 -16
- package/src/styles.js +5 -3
- package/test/build/bundle.js +1 -1
- package/test/build/index.html +150 -4
- package/test/build/main.css +83 -330
- package/test/package-lock.json +2331 -10957
- package/test/package.json +10 -22
- package/test/src/index.html +148 -2
- package/test/src/index.js +12 -174
- package/test/src/js/basics.js +49 -0
- package/test/src/js/folders.js +23 -0
- package/test/src/js/full_featured.js +84 -0
- package/test/src/js/getRandomColor.js +8 -0
- package/test/src/js/multiple.js +40 -0
- package/test/src/js/other.js +34 -0
- package/test/src/styles/main.scss +58 -3
- package/test/webpack.config.js +2 -38
package/test/package.json
CHANGED
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
3
|
-
"version": "
|
|
2
|
+
"name": "perfect-gui_example",
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "webpack.config.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"start": "webpack serve",
|
|
8
8
|
"build": "webpack --mode=production"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [],
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"html-webpack-plugin": "^3.2.0",
|
|
17
|
-
"image-webpack-loader": "^4.6.0",
|
|
14
|
+
"css-loader": "^6.7.1",
|
|
15
|
+
"html-webpack-plugin": "^5.5.0",
|
|
18
16
|
"json-loader": "^0.5.7",
|
|
19
|
-
"mini-css-extract-plugin": "^
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"webpack": "^4.
|
|
24
|
-
"webpack-cli": "^3.3.12",
|
|
25
|
-
"webpack-dev-server": "^3.11.0"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@babel/core": "^7.2.2",
|
|
29
|
-
"@babel/polyfill": "^7.2.5",
|
|
30
|
-
"@babel/preset-env": "^7.3.1",
|
|
31
|
-
"babel-loader": "^8.0.5",
|
|
32
|
-
"css-loader": "^2.1.1",
|
|
33
|
-
"normalize.css": "^8.0.1"
|
|
17
|
+
"mini-css-extract-plugin": "^2.6.1",
|
|
18
|
+
"style-loader": "^3.3.1",
|
|
19
|
+
"webpack": "^5.74.0",
|
|
20
|
+
"webpack-cli": "^4.10.0",
|
|
21
|
+
"webpack-dev-server": "^4.10.1"
|
|
34
22
|
}
|
|
35
23
|
}
|
package/test/src/index.html
CHANGED
|
@@ -9,8 +9,154 @@
|
|
|
9
9
|
</head>
|
|
10
10
|
|
|
11
11
|
<body>
|
|
12
|
-
<div
|
|
13
|
-
|
|
12
|
+
<div class="wrapper">
|
|
13
|
+
<h1>Perfect GUI API</h1>
|
|
14
|
+
|
|
15
|
+
<h2>Basics</h2>
|
|
16
|
+
|
|
17
|
+
<div id="container-1" class="container">
|
|
18
|
+
<div class="element"></div>
|
|
19
|
+
<p class="note"></p>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<!-- HTML generated using hilite.me --><div style="background: #272822; overflow:auto;width:auto;;"><pre style="margin: 0; line-height: 125%"><span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui_1</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
23
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'Basics'</span><span style="color: #f8f8f2">,</span>
|
|
24
|
+
<span style="color: #f8f8f2">});</span>
|
|
25
|
+
|
|
26
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Button'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
27
|
+
<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>
|
|
28
|
+
<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">'none'</span><span style="color: #f8f8f2">;</span>
|
|
29
|
+
<span style="color: #f8f8f2">});</span>
|
|
30
|
+
|
|
31
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addSlider</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Slider'</span><span style="color: #f8f8f2">,</span>
|
|
32
|
+
<span style="color: #f8f8f2">{</span> <span style="color: #a6e22e">min</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">0</span><span style="color: #f8f8f2">,</span> <span style="color: #a6e22e">max</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">2</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> <span style="color: #a6e22e">step</span><span style="color: #f92672">:</span> <span style="color: #f8f8f2">.</span><span style="color: #ae81ff">01</span> <span style="color: #f8f8f2">},</span>
|
|
33
|
+
<span style="color: #a6e22e">value</span> <span style="color: #f92672">=></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">transform</span> <span style="color: #f92672">=</span> <span style="color: #960050; background-color: #1e0010">`</span><span style="color: #a6e22e">scale</span><span style="color: #f8f8f2">(</span><span style="color: #a6e22e">$</span><span style="color: #f8f8f2">{</span> <span style="color: #a6e22e">value</span> <span style="color: #f8f8f2">})</span><span style="color: #960050; background-color: #1e0010">`</span>
|
|
34
|
+
<span style="color: #f8f8f2">);</span>
|
|
35
|
+
|
|
36
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addSwitch</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Switch'</span><span style="color: #f8f8f2">,</span> <span style="color: #66d9ef">true</span><span style="color: #f8f8f2">,</span> <span style="color: #a6e22e">state</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
37
|
+
<span style="color: #66d9ef">if</span> <span style="color: #f8f8f2">(</span> <span style="color: #a6e22e">state</span> <span style="color: #f8f8f2">)</span> <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">classList</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">remove</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'round'</span><span style="color: #f8f8f2">);</span>
|
|
38
|
+
<span style="color: #66d9ef">else</span> <span style="color: #a6e22e">element</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">classList</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">add</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'round'</span><span style="color: #f8f8f2">);</span>
|
|
39
|
+
<span style="color: #f8f8f2">});</span>
|
|
40
|
+
|
|
41
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addList</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'List'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">[</span><span style="color: #e6db74">'red'</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">'pink'</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">'yellow'</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">'blue'</span><span style="color: #f8f8f2">],</span> <span style="color: #a6e22e">item</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
42
|
+
<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>
|
|
43
|
+
<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">'none'</span><span style="color: #f8f8f2">;</span>
|
|
44
|
+
<span style="color: #f8f8f2">});</span>
|
|
45
|
+
|
|
46
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addImage</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Image 1'</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">'path/to/image-1.jpg'</span><span style="color: #f8f8f2">,</span>
|
|
47
|
+
<span style="color: #a6e22e">path</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
48
|
+
<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">path</span><span style="color: #f8f8f2">})</span><span style="color: #960050; background-color: #1e0010">`</span><span style="color: #f8f8f2">;</span>
|
|
49
|
+
<span style="color: #f8f8f2">document.</span><span style="color: #a6e22e">querySelector</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'#container-1 .note'</span><span style="color: #f8f8f2">).</span><span style="color: #a6e22e">textContent</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">"Photo by Joel Filipe on Unsplash"</span><span style="color: #f8f8f2">;</span>
|
|
50
|
+
<span style="color: #f8f8f2">}</span>
|
|
51
|
+
<span style="color: #f8f8f2">);</span>
|
|
52
|
+
|
|
53
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addImage</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Image 2'</span><span style="color: #f8f8f2">,</span> <span style="color: #e6db74">'path/to/image-2.jpg'</span><span style="color: #f8f8f2">,</span>
|
|
54
|
+
<span style="color: #a6e22e">path</span> <span style="color: #f92672">=></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">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">document.</span><span style="color: #a6e22e">querySelector</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'#container-1 .note'</span><span style="color: #f8f8f2">).</span><span style="color: #a6e22e">textContent</span> <span style="color: #f92672">=</span> <span style="color: #e6db74">"Photo by Milad Fakurian on Unsplash"</span><span style="color: #f8f8f2">;</span>
|
|
57
|
+
<span style="color: #f8f8f2">}</span>
|
|
58
|
+
<span style="color: #f8f8f2">);</span>
|
|
59
|
+
</pre></div>
|
|
60
|
+
|
|
61
|
+
<h2>Positioning</h2>
|
|
62
|
+
<p>GUI instances can be positioned in any corner of the screen / container.</p>
|
|
63
|
+
<p>When multiple instances share the same position (like GUI 1 and GUI 2 in the example below), they are stacked next to each other.</p>
|
|
64
|
+
<div id="container-2" class="container">
|
|
65
|
+
<div class="element"></div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<!-- HTML generated using hilite.me --><div style="background: #272822; overflow:auto;width:auto;;"><pre style="margin: 0; line-height: 125%"><span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui_1</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
69
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'GUI 1'</span><span style="color: #f8f8f2">,</span>
|
|
70
|
+
<span style="color: #a6e22e">width</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">200</span>
|
|
71
|
+
<span style="color: #f8f8f2">});</span>
|
|
72
|
+
|
|
73
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Buttons can handle multiple lines of text.'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
74
|
+
<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>
|
|
75
|
+
<span style="color: #f8f8f2">});</span>
|
|
76
|
+
|
|
77
|
+
<span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui_2</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
78
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'GUI 2'</span><span style="color: #f8f8f2">,</span>
|
|
79
|
+
<span style="color: #a6e22e">width</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">200</span>
|
|
80
|
+
<span style="color: #f8f8f2">});</span>
|
|
81
|
+
|
|
82
|
+
<span style="color: #a6e22e">gui_2</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Button'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></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>
|
|
83
|
+
|
|
84
|
+
<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">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
85
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'GUI 3'</span><span style="color: #f8f8f2">,</span>
|
|
86
|
+
<span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'top right'</span>
|
|
87
|
+
<span style="color: #f8f8f2">});</span>
|
|
88
|
+
|
|
89
|
+
<span style="color: #a6e22e">gui_3</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Button'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></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>
|
|
90
|
+
|
|
91
|
+
<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">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
92
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'GUI 4'</span><span style="color: #f8f8f2">,</span>
|
|
93
|
+
<span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'right bottom'</span>
|
|
94
|
+
<span style="color: #f8f8f2">});</span>
|
|
95
|
+
|
|
96
|
+
<span style="color: #a6e22e">gui_4</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Button'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></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>
|
|
97
|
+
</pre></div>
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<h2>Folders</h2>
|
|
101
|
+
Folders can be closed by default by setting the <i>open</i> parameter to <span class="code">false</span>.
|
|
102
|
+
<div id="container-3" class="container">
|
|
103
|
+
<div class="element"></div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<!-- HTML generated using hilite.me --><div style="background: #272822; overflow:auto;width:auto;;"><pre style="margin: 0; line-height: 125%"><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">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
107
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'Folders'</span>
|
|
108
|
+
<span style="color: #f8f8f2">});</span>
|
|
109
|
+
|
|
110
|
+
<span style="color: #66d9ef">let</span> <span style="color: #a6e22e">folder_1</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addFolder</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Folder 1'</span><span style="color: #f8f8f2">);</span>
|
|
111
|
+
|
|
112
|
+
<span style="color: #a6e22e">folder_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">"Random color"</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
113
|
+
<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>
|
|
114
|
+
<span style="color: #f8f8f2">});</span>
|
|
115
|
+
|
|
116
|
+
<span style="color: #66d9ef">let</span> <span style="color: #a6e22e">folder_2</span> <span style="color: #f92672">=</span> <span style="color: #a6e22e">gui</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addFolder</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Folder 2'</span><span style="color: #f8f8f2">,</span> <span style="color: #66d9ef">false</span><span style="color: #f8f8f2">);</span>
|
|
117
|
+
|
|
118
|
+
<span style="color: #a6e22e">folder_2</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">"Random color"</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
119
|
+
<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>
|
|
120
|
+
<span style="color: #f8f8f2">});</span>
|
|
121
|
+
</pre></div>
|
|
122
|
+
|
|
123
|
+
<h2>Other options</h2>
|
|
124
|
+
<p>GUI panels can be dragged around with the <span class="code">draggable</span> option.</p>
|
|
125
|
+
<p>They can also have a custom width, by using the <span class="code">width</span> option.</p>
|
|
126
|
+
<p>The <span class="code">toggleClose()</span> method can be used to open / close a GUI panel.</p>
|
|
127
|
+
<p>Just like folders, GUI panels can be closed by default by setting the <span class="code">close</span> option to <span class="code">true</span>.</p>
|
|
128
|
+
<div id="container-4" class="container">
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<!-- HTML generated using hilite.me --><div style="background: #272822; overflow:auto;width:auto;;"><pre style="margin: 0; line-height: 125%"><span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui_1</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
132
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'GUI 1 (drag me!)'</span><span style="color: #f8f8f2">,</span>
|
|
133
|
+
<span style="color: #a6e22e">width</span><span style="color: #f92672">:</span> <span style="color: #ae81ff">500</span><span style="color: #f8f8f2">,</span>
|
|
134
|
+
<span style="color: #a6e22e">draggable</span><span style="color: #f92672">:</span> <span style="color: #66d9ef">true</span>
|
|
135
|
+
<span style="color: #f8f8f2">});</span>
|
|
136
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'Custom width using the `width` option'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{});</span>
|
|
137
|
+
|
|
138
|
+
<span style="color: #66d9ef">const</span> <span style="color: #a6e22e">gui_2</span> <span style="color: #f92672">=</span> <span style="color: #66d9ef">new</span> <span style="color: #a6e22e">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
139
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'GUI 2 (drag me!)'</span><span style="color: #f8f8f2">,</span>
|
|
140
|
+
<span style="color: #a6e22e">close</span><span style="color: #f92672">:</span> <span style="color: #66d9ef">true</span><span style="color: #f8f8f2">,</span>
|
|
141
|
+
<span style="color: #a6e22e">draggable</span><span style="color: #f92672">:</span> <span style="color: #66d9ef">true</span><span style="color: #f8f8f2">,</span>
|
|
142
|
+
<span style="color: #a6e22e">position</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'bottom left'</span>
|
|
143
|
+
<span style="color: #f8f8f2">});</span>
|
|
144
|
+
|
|
145
|
+
<span style="color: #a6e22e">gui_2</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'gui_1.toggleClose();'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
146
|
+
<span style="color: #a6e22e">gui_1</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">toggleClose</span><span style="color: #f8f8f2">();</span>
|
|
147
|
+
<span style="color: #f8f8f2">});</span>
|
|
148
|
+
|
|
149
|
+
<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">perfectGUI</span><span style="color: #f8f8f2">({</span>
|
|
150
|
+
<span style="color: #a6e22e">name</span><span style="color: #f92672">:</span> <span style="color: #e6db74">'GUI 3 (closed)'</span><span style="color: #f8f8f2">,</span>
|
|
151
|
+
<span style="color: #a6e22e">closed</span><span style="color: #f92672">:</span> <span style="color: #66d9ef">true</span><span style="color: #f8f8f2">,</span>
|
|
152
|
+
<span style="color: #f8f8f2">});</span>
|
|
153
|
+
|
|
154
|
+
<span style="color: #a6e22e">gui_3</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">addButton</span><span style="color: #f8f8f2">(</span><span style="color: #e6db74">'gui_2.toggleClose();'</span><span style="color: #f8f8f2">,</span> <span style="color: #f8f8f2">()</span> <span style="color: #f92672">=></span> <span style="color: #f8f8f2">{</span>
|
|
155
|
+
<span style="color: #a6e22e">gui_2</span><span style="color: #f8f8f2">.</span><span style="color: #a6e22e">toggleClose</span><span style="color: #f8f8f2">();</span>
|
|
156
|
+
<span style="color: #f8f8f2">});</span>
|
|
157
|
+
</pre></div>
|
|
158
|
+
|
|
159
|
+
</div>
|
|
14
160
|
</body>
|
|
15
161
|
|
|
16
162
|
</html>
|
package/test/src/index.js
CHANGED
|
@@ -1,178 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './styles/main.scss';
|
|
2
|
+
import perfectGUI from '../../src/index';
|
|
3
|
+
//import full_featured_gui from './js/full_featured';
|
|
4
|
+
import basics from './js/basics';
|
|
5
|
+
import multiple from './js/multiple';
|
|
6
|
+
import folders from './js/folders';
|
|
7
|
+
import other from './js/other';
|
|
8
|
+
import getRandomColor from './js/getRandomColor';
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
import './styles/main.scss'
|
|
10
|
+
basics();
|
|
5
11
|
|
|
6
|
-
|
|
12
|
+
multiple();
|
|
7
13
|
|
|
8
|
-
|
|
14
|
+
folders();
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
name: "This is a basic panel",
|
|
12
|
-
draggable: true
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
gui_1.addImage(
|
|
16
|
-
'Background 1',
|
|
17
|
-
'https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1502&q=80',
|
|
18
|
-
() => {
|
|
19
|
-
document.body.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)`;
|
|
20
|
-
document.body.style.backgroundColor = `none`;
|
|
21
|
-
document.getElementById('note').textContent = "Photo by Joel Filipe on Unsplash";
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
gui_1.addImage(
|
|
25
|
-
'Background 2',
|
|
26
|
-
'https://images.unsplash.com/photo-1535370976884-f4376736ab06?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=564&q=80',
|
|
27
|
-
() => {
|
|
28
|
-
document.body.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)`;
|
|
29
|
-
document.body.style.backgroundColor = `none`;
|
|
30
|
-
document.getElementById('note').textContent = "Photo by Richard M. on Unsplash";
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
gui_1.addImage(
|
|
34
|
-
'Background 3',
|
|
35
|
-
'https://images.unsplash.com/photo-1524721696987-b9527df9e512?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1490&q=80',
|
|
36
|
-
() => {
|
|
37
|
-
document.body.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)`;
|
|
38
|
-
document.body.style.backgroundColor = `none`;
|
|
39
|
-
document.getElementById('note').textContent = "Photo by Cassi Josh on Unsplash";
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
gui_1.addImage(
|
|
43
|
-
'Background 3',
|
|
44
|
-
'https://images.unsplash.com/photo-1524721696987-b9527df9e512?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1490&q=80',
|
|
45
|
-
() => {
|
|
46
|
-
document.body.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)`;
|
|
47
|
-
document.body.style.backgroundColor = `none`;
|
|
48
|
-
document.getElementById('note').textContent = "Photo by Cassi Josh on Unsplash";
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
let folder = gui_1.addFolder('Some folder');
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
folder.addButton("Random element color", () => {
|
|
56
|
-
element.style.backgroundColor = get_random_color();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
folder.addImage(
|
|
60
|
-
'Background 1',
|
|
61
|
-
'https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1502&q=80',
|
|
62
|
-
() => {
|
|
63
|
-
document.body.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)`;
|
|
64
|
-
document.body.style.backgroundColor = `none`;
|
|
65
|
-
document.getElementById('note').textContent = "Photo by Joel Filipe on Unsplash";
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
folder.addImage(
|
|
70
|
-
'Background 1',
|
|
71
|
-
'https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1502&q=80',
|
|
72
|
-
() => {
|
|
73
|
-
document.body.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)`;
|
|
74
|
-
document.body.style.backgroundColor = `none`;
|
|
75
|
-
document.getElementById('note').textContent = "Photo by Joel Filipe on Unsplash";
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
folder.addImage(
|
|
80
|
-
'Background 1',
|
|
81
|
-
'https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1502&q=80',
|
|
82
|
-
() => {
|
|
83
|
-
document.body.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)`;
|
|
84
|
-
document.body.style.backgroundColor = `none`;
|
|
85
|
-
document.getElementById('note').textContent = "Photo by Joel Filipe on Unsplash";
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
folder.addImage(
|
|
89
|
-
'Background 1',
|
|
90
|
-
'https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1502&q=80',
|
|
91
|
-
() => {
|
|
92
|
-
document.body.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)`;
|
|
93
|
-
document.body.style.backgroundColor = `none`;
|
|
94
|
-
document.getElementById('note').textContent = "Photo by Joel Filipe on Unsplash";
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
gui_1.addButton("Random element color", () => {
|
|
99
|
-
element.style.backgroundColor = get_random_color();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
gui_1.addSlider("Scale", {min: .1, max: 2, value: 1, step: .01 }, (value) => {
|
|
103
|
-
element.style.transform = `scale(${value})`;
|
|
104
|
-
});
|
|
105
|
-
gui_1.addSlider("3-step border-radius", {min: 0, max: 50, value: 0, step: 25 }, (value) => {
|
|
106
|
-
element.style.borderRadius = `${value}%`;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
let folder2 = gui_1.addFolder('ok', false);
|
|
110
|
-
folder2.addButton("Random element color", () => {
|
|
111
|
-
element.style.backgroundColor = get_random_color();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
gui_1.addSwitch("Opacity switch", true, (state) => {
|
|
115
|
-
if (!state) element.style.opacity = .5;
|
|
116
|
-
else element.style.opacity = 1;
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
gui_1.addList('Select a color', ['red', 'pink', 'yellow', 'blue'], function(item) {
|
|
120
|
-
element.style.backgroundColor = item;
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
function get_random_color() {
|
|
124
|
-
var letters = '0123456789ABCDEF'.split('');
|
|
125
|
-
var color = '#';
|
|
126
|
-
for (var i = 0; i < 6; i++ ) {
|
|
127
|
-
color += letters[Math.round(Math.random() * 15)];
|
|
128
|
-
}
|
|
129
|
-
return color;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const gui_2 = new perfectGUI({
|
|
133
|
-
name: "This is one is closed",
|
|
134
|
-
width: 175,
|
|
135
|
-
closed: true,
|
|
136
|
-
draggable: true
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
let f = gui_2.addFolder("test");
|
|
140
|
-
|
|
141
|
-
f.addButton('ok', ()=>{});
|
|
142
|
-
|
|
143
|
-
gui_2.addButton("Toggle the first GUI", () => {
|
|
144
|
-
gui_1.toggleClose();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
gui_2.addButton("You can put a lot of text in a button if you want to.", () => {
|
|
148
|
-
element.style.backgroundColor = get_random_color();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const gui_3 = new perfectGUI({
|
|
152
|
-
name: "You can drag panels around...",
|
|
153
|
-
draggable: true
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
gui_3.addButton("...with the 'draggable' option.", () => {
|
|
157
|
-
element.style.backgroundColor = get_random_color();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const gui_4 = new perfectGUI({
|
|
161
|
-
name: "This panel is not draggable.",
|
|
162
|
-
position: 'top right',
|
|
163
|
-
draggable: false
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
gui_4.addButton("It's up to you.", ()=>{
|
|
167
|
-
element.style.backgroundColor = get_random_color();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const gui_5 = new perfectGUI({
|
|
171
|
-
name: "You can place the panels wherever you want",
|
|
172
|
-
position: 'right bottom',
|
|
173
|
-
width: 450
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
gui_5.addButton("And you can set their width, with the 'width' option.", () => {
|
|
177
|
-
|
|
178
|
-
});
|
|
16
|
+
other();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import perfectGUI from '../../../src/index';
|
|
2
|
+
import getRandomColor from './getRandomColor';
|
|
3
|
+
|
|
4
|
+
export default function basics() {
|
|
5
|
+
|
|
6
|
+
const element = document.querySelector('#container-1 .element');
|
|
7
|
+
|
|
8
|
+
const gui_1 = new perfectGUI({
|
|
9
|
+
name: 'Basics',
|
|
10
|
+
container: '#container-1'
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
gui_1.addButton('Button', () => {
|
|
14
|
+
element.style.backgroundColor = getRandomColor();
|
|
15
|
+
element.style.backgroundImage = 'none';
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
gui_1.addSlider('Slider',
|
|
19
|
+
{ min: 0, max: 2, value: 1, step: .01 },
|
|
20
|
+
value => element.style.transform = `scale(${ value })`
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
gui_1.addSwitch('Switch', true, state => {
|
|
24
|
+
if ( state ) element.classList.remove('round');
|
|
25
|
+
else element.classList.add('round');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
gui_1.addList('List', ['red', 'pink', 'yellow', 'blue'], item => {
|
|
29
|
+
element.style.backgroundColor = item;
|
|
30
|
+
element.style.backgroundImage = 'none';
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
gui_1.addImage('Image 1',
|
|
34
|
+
'https://images.unsplash.com/photo-1485254767195-60704c46702e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=512&q=80',
|
|
35
|
+
path => {
|
|
36
|
+
element.style.backgroundImage = `url(${path})`;
|
|
37
|
+
document.querySelector('#container-1 .note').textContent = "Photo by Joel Filipe on Unsplash";
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
gui_1.addImage('Image 2',
|
|
42
|
+
'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=512&q=80',
|
|
43
|
+
path => {
|
|
44
|
+
element.style.backgroundImage = `url(${path})`;
|
|
45
|
+
document.querySelector('#container-1 .note').textContent = "Photo by Milad Fakurian on Unsplash";
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import getRandomColor from './getRandomColor';
|
|
2
|
+
import perfectGUI from '../../../src/index';
|
|
3
|
+
|
|
4
|
+
export default function folders() {
|
|
5
|
+
const element = document.querySelector('#container-3 .element');
|
|
6
|
+
|
|
7
|
+
const gui = new perfectGUI({
|
|
8
|
+
name: 'Folders',
|
|
9
|
+
container: '#container-3'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
let folder_1 = gui.addFolder('Folder 1 (open)');
|
|
13
|
+
|
|
14
|
+
folder_1.addButton("Random color", () => {
|
|
15
|
+
element.style.backgroundColor = getRandomColor();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
let folder_2 = gui.addFolder('Folder 2 (closed)', { closed: true });
|
|
19
|
+
|
|
20
|
+
folder_2.addButton("Random color", () => {
|
|
21
|
+
element.style.backgroundColor = getRandomColor();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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.addImage(
|
|
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.addImage(
|
|
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.addImage(
|
|
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.addImage(
|
|
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.addFolder('Some folder');
|
|
47
|
+
|
|
48
|
+
folder.addButton("Random element color", () => {
|
|
49
|
+
element.style.backgroundColor = get_random_color();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
folder.addImage(
|
|
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.addButton("Random element color", () => {
|
|
63
|
+
element.style.backgroundColor = get_random_color();
|
|
64
|
+
});
|
|
65
|
+
full_featured_gui.addSlider("Scale", {min: .1, max: 2, value: 1, step: .01 }, (value) => {
|
|
66
|
+
element.style.transform = `scale(${value})`;
|
|
67
|
+
});
|
|
68
|
+
full_featured_gui.addSlider("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.addFolder('ok', false);
|
|
73
|
+
folder2.addButton("Random element color", () => {
|
|
74
|
+
element.style.backgroundColor = get_random_color();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
full_featured_gui.addSwitch("Opacity switch", true, (state) => {
|
|
78
|
+
if (!state) element.style.opacity = .5;
|
|
79
|
+
else element.style.opacity = 1;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
full_featured_gui.addList('Select a color', ['red', 'pink', 'yellow', 'blue'], function(item) {
|
|
83
|
+
element.style.backgroundColor = item;
|
|
84
|
+
});
|