uil 1.0.1 → 4.0.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 +57 -0
- package/build/uil.js +7040 -4199
- package/build/uil.min.js +6 -4
- package/build/uil.module.js +7200 -2761
- package/examples/js/BufferGeometryUtils.js +921 -0
- package/examples/js/SimplexNoise.js +324 -0
- package/examples/js/controls/OrbitControls.js +1215 -0
- package/examples/js/controls/OrbitControls_.js +1042 -0
- package/examples/js/libs/sea3d.min.js +373 -0
- package/examples/js/libs/three.min.js +6 -0
- package/examples/js/math.js +447 -0
- package/examples/js/objects/Landscape.js +778 -0
- package/examples/js/objects/Lensflare.js +372 -0
- package/examples/js/objects/SuperSky.js +297 -0
- package/examples/js/objects/Water.js +329 -0
- package/package.json +56 -54
- package/src/Uil.js +2 -17
- package/src/Uil_dev.js +15 -0
- package/src/core/Gui.js +601 -299
- package/src/core/Proto.js +490 -220
- package/src/core/Roots.js +864 -0
- package/src/core/Tools.js +591 -140
- package/src/core/V2.js +131 -0
- package/src/core/add.js +52 -57
- package/src/proto/Bool.js +117 -52
- package/src/proto/Button.js +286 -146
- package/src/proto/Circular.js +162 -130
- package/src/proto/Color.js +331 -289
- package/src/proto/Empty.js +15 -0
- package/src/proto/Fps.js +232 -159
- package/src/proto/Graph.js +310 -0
- package/src/proto/Grid.js +297 -0
- package/src/proto/Group.js +334 -160
- package/src/proto/Item.js +120 -0
- package/src/proto/Joystick.js +159 -185
- package/src/proto/Knob.js +210 -91
- package/src/proto/List.js +661 -249
- package/src/proto/Numeric.js +329 -162
- package/src/proto/Pad2D.js +268 -0
- package/src/proto/Rubric.js +0 -0
- package/src/proto/Select.js +178 -0
- package/src/proto/Selector.js +13 -0
- package/src/proto/Slide.js +191 -185
- package/src/proto/TextInput.js +149 -59
- package/src/proto/Title.js +40 -31
package/src/proto/Circular.js
CHANGED
|
@@ -1,198 +1,230 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Proto } from '../core/Proto.js';
|
|
2
|
+
import { Tools } from '../core/Tools.js';
|
|
3
|
+
import { V2 } from '../core/V2.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export class Circular extends Proto {
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
constructor( o = {} ) {
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
this.autoWidth = false;
|
|
9
|
+
super( o )
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
this.isCyclic = o.cyclic || false
|
|
12
|
+
this.model = o.stype || 0
|
|
13
|
+
if( o.mode !== undefined ) this.model = o.mode
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
this.autoWidth = false
|
|
16
|
+
this.minw = this.w
|
|
17
|
+
this.diam = o.diam || this.w
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
this.setTypeNumber( o )
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.width = (this.radius*2)+20;
|
|
21
|
+
this.twoPi = Tools.TwoPI
|
|
22
|
+
this.pi90 = Tools.pi90
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
this.width = o.width;
|
|
23
|
-
this.radius = ~~ (this.width-20)*0.5;
|
|
24
|
-
}
|
|
24
|
+
this.offset = new V2()
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
this.radius = ~~ (this.width-20)*0.5;
|
|
29
|
-
}*/
|
|
26
|
+
this.h = o.h || this.w + 10
|
|
27
|
+
this.top = 0
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
this.h = o.height || (this.height + 40);
|
|
29
|
+
this.c[0].style.width = this.w +'px'
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
if(this.c[1] !== undefined) {
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
this.c[1].style.width = '100%'
|
|
34
|
+
this.c[1].style.justifyContent = 'center'
|
|
35
|
+
this.top = 10
|
|
36
|
+
this.h += 10
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
if(this.c[1] !== undefined) {
|
|
41
40
|
|
|
42
|
-
this.c[1].style.width = this.width +'px';
|
|
43
|
-
this.c[1].style.textAlign = 'center';
|
|
44
|
-
this.top = 20;
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
this.percent = 0
|
|
43
|
+
this.cmode = 0
|
|
44
|
+
let cc = this.colors
|
|
45
|
+
|
|
46
|
+
this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+(this.h-20)+'px; width:100%; color:'+ cc.text )
|
|
47
|
+
|
|
48
|
+
// svg
|
|
49
|
+
|
|
50
|
+
this.c[3] = this.getCircular()
|
|
51
|
+
|
|
52
|
+
this.setSvg( this.c[3], 'stroke', cc.back, 0 )
|
|
53
|
+
this.setSvg( this.c[3], 'd', this.makePath(), 1 )
|
|
54
|
+
this.setSvg( this.c[3], 'stroke', cc.text, 1 )
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
this.setSvg( this.c[3], 'viewBox', '0 0 '+this.diam+' '+this.diam )
|
|
57
|
+
this.setCss( this.c[3], { width:this.diam, height:this.diam, left:0, top:this.top })
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.c[4] = Tools.dom( 'path', Tools.css.basic + 'left:10px; top:'+this.top+'px; width:'+this.w+'px; height:'+this.height+'px;', { d:this.makePath(), fill:this.fontColor });
|
|
53
|
-
this.c[5] = Tools.dom( 'circle', Tools.css.basic + 'left:10px; top:'+this.top+'px; width:'+this.w+'px; height:'+this.height+'px;', { cx:this.radius, cy:this.radius, r:this.radius*0.5, fill:this.buttonColor, 'stroke-width':1, stroke:Tools.colors.stroke });
|
|
59
|
+
this.init()
|
|
60
|
+
this.update()
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
}
|
|
56
63
|
|
|
57
|
-
|
|
64
|
+
mode ( mode ) {
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
if( this.cmode === mode ) return false;
|
|
60
67
|
|
|
61
|
-
|
|
68
|
+
let cc = this.colors
|
|
69
|
+
let color
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
switch( mode ){
|
|
72
|
+
case 0: // base
|
|
65
73
|
|
|
66
|
-
|
|
74
|
+
this.s[2].color = cc.text;
|
|
75
|
+
this.setSvg( this.c[3], 'stroke', cc.back, 0);
|
|
76
|
+
color = this.model > 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.text;
|
|
77
|
+
this.setSvg( this.c[3], 'stroke', color, 1 );
|
|
78
|
+
|
|
79
|
+
break;
|
|
80
|
+
case 1: // down
|
|
67
81
|
|
|
68
|
-
|
|
82
|
+
this.s[2].color = cc.textOver;
|
|
83
|
+
this.setSvg( this.c[3], 'stroke', cc.backoff, 0);
|
|
84
|
+
color = this.model > 0 ? Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) ) : cc.textOver
|
|
85
|
+
this.setSvg( this.c[3], 'stroke', color, 1 );
|
|
86
|
+
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
69
89
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case 'mousedown': this.down( e ); break;
|
|
73
|
-
case 'mouseout': this.out( e ); break;
|
|
90
|
+
this.cmode = mode;
|
|
91
|
+
return true;
|
|
74
92
|
|
|
75
|
-
case 'mouseup': this.up( e ); break;
|
|
76
|
-
case 'mousemove': this.move( e ); break;
|
|
77
93
|
}
|
|
78
94
|
|
|
79
|
-
|
|
95
|
+
reset () {
|
|
96
|
+
|
|
97
|
+
this.isDown = false;
|
|
98
|
+
|
|
99
|
+
}
|
|
80
100
|
|
|
81
|
-
|
|
101
|
+
testZone ( e ) {
|
|
82
102
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
case 1: // over
|
|
90
|
-
this.s[2].color = this.colorPlus;
|
|
91
|
-
Tools.setSvg( this.c[3], 'fill','rgba(0,0,0,0.6)');
|
|
92
|
-
Tools.setSvg( this.c[4], 'fill', this.colorPlus );
|
|
93
|
-
break;
|
|
103
|
+
let l = this.local;
|
|
104
|
+
if( l.x === -1 && l.y === -1 ) return '';
|
|
105
|
+
|
|
106
|
+
if( l.y <= this.c[ 1 ].offsetHeight ) return 'title';
|
|
107
|
+
else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text';
|
|
108
|
+
else return 'circular';
|
|
94
109
|
|
|
95
110
|
}
|
|
96
|
-
}
|
|
97
111
|
|
|
98
|
-
|
|
112
|
+
// ----------------------
|
|
113
|
+
// EVENTS
|
|
114
|
+
// ----------------------
|
|
99
115
|
|
|
100
|
-
|
|
101
|
-
this.mode(1);
|
|
116
|
+
mouseup ( e ) {
|
|
102
117
|
|
|
103
|
-
|
|
118
|
+
this.isDown = false;
|
|
119
|
+
this.sendEnd();
|
|
120
|
+
return this.mode(0);
|
|
104
121
|
|
|
105
|
-
|
|
122
|
+
}
|
|
106
123
|
|
|
107
|
-
|
|
108
|
-
if(this.isDown) return;
|
|
109
|
-
this.mode(0);
|
|
124
|
+
mousedown ( e ) {
|
|
110
125
|
|
|
111
|
-
|
|
126
|
+
this.isDown = true;
|
|
127
|
+
this.old = this.value;
|
|
128
|
+
this.oldr = null;
|
|
129
|
+
this.mousemove( e );
|
|
130
|
+
return this.mode(1);
|
|
112
131
|
|
|
113
|
-
|
|
132
|
+
}
|
|
114
133
|
|
|
115
|
-
|
|
116
|
-
document.removeEventListener( 'mouseup', this, false );
|
|
117
|
-
document.removeEventListener( 'mousemove', this, false );
|
|
134
|
+
mousemove ( e ) {
|
|
118
135
|
|
|
119
|
-
|
|
120
|
-
else this.mode(0);
|
|
136
|
+
if( !this.isDown ) return;
|
|
121
137
|
|
|
122
|
-
|
|
138
|
+
//console.log('over')
|
|
123
139
|
|
|
124
|
-
|
|
140
|
+
let off = this.offset;
|
|
141
|
+
off.x = (this.w*0.5) - ( e.clientX - this.zone.x );
|
|
142
|
+
off.y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top );
|
|
125
143
|
|
|
126
|
-
|
|
144
|
+
this.r = off.angle() - this.pi90;
|
|
145
|
+
this.r = (((this.r%this.twoPi)+this.twoPi)%this.twoPi);
|
|
127
146
|
|
|
128
|
-
|
|
129
|
-
document.addEventListener( 'mouseup', this, false );
|
|
130
|
-
document.addEventListener( 'mousemove', this, false );
|
|
147
|
+
if( this.oldr !== null ){
|
|
131
148
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.oldr = null;
|
|
135
|
-
this.move( e );
|
|
149
|
+
let dif = this.r - this.oldr;
|
|
150
|
+
this.r = Math.abs(dif) > Math.PI ? this.oldr : this.r;
|
|
136
151
|
|
|
137
|
-
|
|
152
|
+
if( dif > 6 ) this.r = 0;
|
|
153
|
+
if( dif < -6 ) this.r = this.twoPi;
|
|
138
154
|
|
|
139
|
-
|
|
155
|
+
}
|
|
140
156
|
|
|
141
|
-
|
|
157
|
+
let steps = 1 / this.twoPi;
|
|
158
|
+
let value = this.r * steps;
|
|
142
159
|
|
|
143
|
-
|
|
144
|
-
var y = this.radius - (e.clientY - this.rect.top);
|
|
160
|
+
let n = ( ( this.range * value ) + this.min ) - this.old;
|
|
145
161
|
|
|
146
|
-
|
|
147
|
-
|
|
162
|
+
if(n >= this.step || n <= this.step){
|
|
163
|
+
n = ~~ ( n / this.step );
|
|
164
|
+
this.value = this.numValue( this.old + ( n * this.step ) );
|
|
165
|
+
this.update( true );
|
|
166
|
+
this.old = this.value;
|
|
167
|
+
this.oldr = this.r;
|
|
168
|
+
}
|
|
148
169
|
|
|
149
|
-
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
wheel ( e ) {
|
|
150
173
|
|
|
151
|
-
|
|
152
|
-
this.r = Math.abs(dif) > Math.PI ? this.oldr : this.r;
|
|
174
|
+
let name = this.testZone( e );
|
|
153
175
|
|
|
154
|
-
if(
|
|
155
|
-
|
|
176
|
+
if( name === 'circular' ) {
|
|
177
|
+
|
|
178
|
+
let v = this.value - this.step * e.delta;
|
|
179
|
+
|
|
180
|
+
if ( v > this.max ) {
|
|
181
|
+
v = this.isCyclic ? this.min : this.max;
|
|
182
|
+
} else if ( v < this.min ) {
|
|
183
|
+
v = this.isCyclic ? this.max : this.min;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
this.setValue( v );
|
|
187
|
+
this.old = v;
|
|
188
|
+
this.update( true );
|
|
189
|
+
|
|
190
|
+
return true;
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
156
194
|
|
|
157
195
|
}
|
|
158
196
|
|
|
159
|
-
|
|
160
|
-
var value = this.r * steps;
|
|
197
|
+
// ----------------------
|
|
161
198
|
|
|
162
|
-
|
|
199
|
+
makePath () {
|
|
200
|
+
|
|
201
|
+
let r = 40;
|
|
202
|
+
let d = 24;
|
|
203
|
+
let a = this.percent * this.twoPi - 0.001;
|
|
204
|
+
let x2 = (r + r * Math.sin(a)) + d;
|
|
205
|
+
let y2 = (r - r * Math.cos(a)) + d;
|
|
206
|
+
let big = a > Math.PI ? 1 : 0;
|
|
207
|
+
return "M " + (r+d) + "," + d + " A " + r + "," + r + " 0 " + big + " 1 " + x2 + "," + y2;
|
|
163
208
|
|
|
164
|
-
if(n >= this.step || n <= this.step){
|
|
165
|
-
n = ~~ ( n / this.step );
|
|
166
|
-
this.value = this.numValue( this.old + ( n * this.step ) );
|
|
167
|
-
this.update( true );
|
|
168
|
-
this.old = this.value;
|
|
169
|
-
this.oldr = this.r;
|
|
170
209
|
}
|
|
171
210
|
|
|
172
|
-
|
|
211
|
+
update ( up ) {
|
|
173
212
|
|
|
174
|
-
|
|
213
|
+
this.c[2].textContent = this.value;
|
|
214
|
+
this.percent = ( this.value - this.min ) / this.range;
|
|
175
215
|
|
|
176
|
-
|
|
177
|
-
//var start = 0;
|
|
178
|
-
var end = this.percent * this.twoPi - 0.001;
|
|
179
|
-
//var x1 = r + r * Math.sin(start);
|
|
180
|
-
//var y1 = r - r * Math.cos(start);
|
|
181
|
-
var x2 = r + r * Math.sin(end);
|
|
182
|
-
var y2 = r - r * Math.cos(end);
|
|
183
|
-
//var big = end - start > Math.PI ? 1 : 0;
|
|
184
|
-
var big = end > Math.PI ? 1 : 0;
|
|
185
|
-
return "M " + r + "," + r + " L " + r + "," + 0 + " A " + r + "," + r + " 0 " + big + " 1 " + x2 + "," + y2 + " Z";
|
|
216
|
+
this.setSvg( this.c[3], 'd', this.makePath(), 1 );
|
|
186
217
|
|
|
187
|
-
|
|
218
|
+
if ( this.model > 0 ) {
|
|
188
219
|
|
|
189
|
-
|
|
220
|
+
let cc = this.colors
|
|
221
|
+
let color = Tools.pack( Tools.lerpColor( Tools.unpack( Tools.ColorLuma( cc.text, -0.75) ), Tools.unpack( cc.text ), this.percent ) );
|
|
222
|
+
this.setSvg( this.c[3], 'stroke', color, 1 );
|
|
223
|
+
|
|
224
|
+
}
|
|
190
225
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if( up ) this.send();
|
|
195
|
-
|
|
196
|
-
};
|
|
226
|
+
if( up ) this.send();
|
|
227
|
+
|
|
228
|
+
}
|
|
197
229
|
|
|
198
|
-
|
|
230
|
+
}
|