uil 4.0.0 → 4.0.4
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 +5 -1
- package/build/uil.js +33 -45
- package/build/uil.min.js +1 -1
- package/build/uil.module.js +45 -58
- package/package.json +6 -10
- package/examples/js/BufferGeometryUtils.js +0 -921
- package/examples/js/SimplexNoise.js +0 -324
- package/examples/js/controls/OrbitControls.js +0 -1215
- package/examples/js/controls/OrbitControls_.js +0 -1042
- package/examples/js/libs/sea3d.min.js +0 -373
- package/examples/js/libs/three.min.js +0 -6
- package/examples/js/math.js +0 -447
- package/examples/js/objects/Landscape.js +0 -778
- package/examples/js/objects/Lensflare.js +0 -372
- package/examples/js/objects/SuperSky.js +0 -297
- package/examples/js/objects/Water.js +0 -329
- package/src/Uil.js +0 -6
- package/src/Uil_dev.js +0 -15
- package/src/core/Gui.js +0 -807
- package/src/core/Proto.js +0 -679
- package/src/core/Roots.js +0 -864
- package/src/core/Tools.js +0 -830
- package/src/core/V2.js +0 -131
- package/src/core/add.js +0 -85
- package/src/polyfills.js +0 -85
- package/src/proto/Bool.js +0 -147
- package/src/proto/Button.js +0 -357
- package/src/proto/Circular.js +0 -230
- package/src/proto/Color.js +0 -411
- package/src/proto/Empty.js +0 -15
- package/src/proto/Fps.js +0 -327
- package/src/proto/Graph.js +0 -310
- package/src/proto/Grid.js +0 -297
- package/src/proto/Group.js +0 -430
- package/src/proto/Item.js +0 -120
- package/src/proto/Joystick.js +0 -241
- package/src/proto/Knob.js +0 -262
- package/src/proto/List.js +0 -789
- package/src/proto/Numeric.js +0 -417
- package/src/proto/Pad2D.js +0 -268
- package/src/proto/Rubric.js +0 -0
- package/src/proto/Select.js +0 -178
- package/src/proto/Selector.js +0 -13
- package/src/proto/Slide.js +0 -267
- package/src/proto/TextInput.js +0 -181
- package/src/proto/Title.js +0 -61
package/src/proto/Numeric.js
DELETED
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import { Proto } from '../core/Proto.js';
|
|
2
|
-
import { Tools } from '../core/Tools.js';
|
|
3
|
-
|
|
4
|
-
export class Numeric extends Proto {
|
|
5
|
-
|
|
6
|
-
constructor( o = {} ) {
|
|
7
|
-
|
|
8
|
-
super( o );
|
|
9
|
-
|
|
10
|
-
this.setTypeNumber( o );
|
|
11
|
-
|
|
12
|
-
this.allway = o.allway || false;
|
|
13
|
-
|
|
14
|
-
this.isDown = false;
|
|
15
|
-
|
|
16
|
-
this.value = [0];
|
|
17
|
-
this.multy = 1;
|
|
18
|
-
this.invmulty = 1;
|
|
19
|
-
this.isSingle = true;
|
|
20
|
-
this.isAngle = false;
|
|
21
|
-
this.isVector = false;
|
|
22
|
-
|
|
23
|
-
if( o.isAngle ){
|
|
24
|
-
this.isAngle = true;
|
|
25
|
-
this.multy = Tools.torad;
|
|
26
|
-
this.invmulty = Tools.todeg;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
this.isDrag = o.drag || false;
|
|
30
|
-
|
|
31
|
-
if( o.value !== undefined ){
|
|
32
|
-
if(!isNaN(o.value)){
|
|
33
|
-
this.value = [o.value];
|
|
34
|
-
} else if( o.value instanceof Array ){
|
|
35
|
-
this.value = o.value;
|
|
36
|
-
this.isSingle = false;
|
|
37
|
-
} else if( o.value instanceof Object ){
|
|
38
|
-
this.value = [];
|
|
39
|
-
if( o.value.x !== undefined ) this.value[0] = o.value.x;
|
|
40
|
-
if( o.value.y !== undefined ) this.value[1] = o.value.y;
|
|
41
|
-
if( o.value.z !== undefined ) this.value[2] = o.value.z;
|
|
42
|
-
if( o.value.w !== undefined ) this.value[3] = o.value.w;
|
|
43
|
-
this.isVector = true;
|
|
44
|
-
this.isSingle = false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.lng = this.value.length;
|
|
49
|
-
this.tmp = [];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.current = -1;
|
|
54
|
-
this.prev = { x:0, y:0, d:0, v:0 };
|
|
55
|
-
|
|
56
|
-
let cc = this.colors
|
|
57
|
-
|
|
58
|
-
// bg
|
|
59
|
-
this.c[2] = this.dom( 'div', this.css.basic + ' background:' + cc.select + '; top:4px; width:0px; height:' + (this.h-8) + 'px;' );
|
|
60
|
-
|
|
61
|
-
this.cMode = [];
|
|
62
|
-
|
|
63
|
-
let i = this.lng;
|
|
64
|
-
while(i--){
|
|
65
|
-
|
|
66
|
-
if(this.isAngle) this.value[i] = (this.value[i] * 180 / Math.PI).toFixed( this.precision );
|
|
67
|
-
this.c[3+i] = this.dom( 'div', this.css.txtselect + ' height:'+(this.h-4)+'px; color:' + cc.text + '; background:' + cc.back + '; borderColor:' + cc.border+'; border-radius:'+this.radius+'px;');
|
|
68
|
-
if(o.center) this.c[2+i].style.textAlign = 'center';
|
|
69
|
-
this.c[3+i].textContent = this.value[i];
|
|
70
|
-
this.c[3+i].style.color = this.colors.text;
|
|
71
|
-
this.c[3+i].isNum = true;
|
|
72
|
-
|
|
73
|
-
this.cMode[i] = 0;
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// selection
|
|
78
|
-
this.selectId = 3 + this.lng;
|
|
79
|
-
this.c[this.selectId] = this.dom( 'div', this.css.txtselect + 'position:absolute; top:4px; height:' + (this.h-8) + 'px; padding:0px 0px; width:0px; color:' + cc.textSelect + '; background:' + cc.select + '; border:none; border-radius:0px;');
|
|
80
|
-
|
|
81
|
-
// cursor
|
|
82
|
-
this.cursorId = 4 + this.lng;
|
|
83
|
-
this.c[ this.cursorId ] = this.dom( 'div', this.css.basic + 'top:4px; height:' + (this.h-8) + 'px; width:0px; background:'+cc.text+';' );
|
|
84
|
-
|
|
85
|
-
this.init();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
testZone ( e ) {
|
|
89
|
-
|
|
90
|
-
let l = this.local;
|
|
91
|
-
if( l.x === -1 && l.y === -1 ) return '';
|
|
92
|
-
|
|
93
|
-
let i = this.lng;
|
|
94
|
-
let t = this.tmp;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
while( i-- ){
|
|
98
|
-
if( l.x>t[i][0] && l.x<t[i][2] ) return i;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return '';
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/* mode: function ( n, name ) {
|
|
106
|
-
|
|
107
|
-
if( n === this.cMode[name] ) return false;
|
|
108
|
-
|
|
109
|
-
//let m;
|
|
110
|
-
|
|
111
|
-
/*switch(n){
|
|
112
|
-
|
|
113
|
-
case 0: m = this.colors.border; break;
|
|
114
|
-
case 1: m = this.colors.borderOver; break;
|
|
115
|
-
case 2: m = this.colors.borderSelect; break;
|
|
116
|
-
|
|
117
|
-
}*/
|
|
118
|
-
|
|
119
|
-
/* this.reset();
|
|
120
|
-
//this.c[name+2].style.borderColor = m;
|
|
121
|
-
this.cMode[name] = n;
|
|
122
|
-
|
|
123
|
-
return true;
|
|
124
|
-
|
|
125
|
-
},*/
|
|
126
|
-
|
|
127
|
-
// ----------------------
|
|
128
|
-
// EVENTS
|
|
129
|
-
// ----------------------
|
|
130
|
-
|
|
131
|
-
mousedown ( e ) {
|
|
132
|
-
|
|
133
|
-
let name = this.testZone( e );
|
|
134
|
-
|
|
135
|
-
if( !this.isDown ){
|
|
136
|
-
this.isDown = true;
|
|
137
|
-
if( name !== '' ){
|
|
138
|
-
this.current = name;
|
|
139
|
-
this.prev = { x:e.clientX, y:e.clientY, d:0, v: this.isSingle ? parseFloat(this.value) : parseFloat( this.value[ this.current ] ) };
|
|
140
|
-
this.setInput( this.c[ 3 + this.current ] );
|
|
141
|
-
}
|
|
142
|
-
return this.mousemove( e );
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return false;
|
|
146
|
-
/*
|
|
147
|
-
|
|
148
|
-
if( name === '' ) return false;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.current = name;
|
|
152
|
-
this.isDown = true;
|
|
153
|
-
|
|
154
|
-
this.prev = { x:e.clientX, y:e.clientY, d:0, v: this.isSingle ? parseFloat(this.value) : parseFloat( this.value[ this.current ] ) };
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return this.mode( 2, name );*/
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
mouseup ( e ) {
|
|
162
|
-
|
|
163
|
-
if( this.isDown ){
|
|
164
|
-
|
|
165
|
-
this.isDown = false;
|
|
166
|
-
//this.current = -1;
|
|
167
|
-
this.prev = { x:0, y:0, d:0, v:0 };
|
|
168
|
-
|
|
169
|
-
return this.mousemove( e );
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return false;
|
|
173
|
-
|
|
174
|
-
/*let name = this.testZone( e );
|
|
175
|
-
this.isDown = false;
|
|
176
|
-
|
|
177
|
-
if( this.current !== -1 ){
|
|
178
|
-
|
|
179
|
-
//let tm = this.current;
|
|
180
|
-
let td = this.prev.d;
|
|
181
|
-
|
|
182
|
-
this.current = -1;
|
|
183
|
-
this.prev = { x:0, y:0, d:0, v:0 };
|
|
184
|
-
|
|
185
|
-
if( !td ){
|
|
186
|
-
|
|
187
|
-
this.setInput( this.c[ 3 + name ] );
|
|
188
|
-
return true;//this.mode( 2, name );
|
|
189
|
-
|
|
190
|
-
} else {
|
|
191
|
-
return this.reset();//this.mode( 0, tm );
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
}*/
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
mousemove ( e ) {
|
|
199
|
-
|
|
200
|
-
let nup = false;
|
|
201
|
-
let x = 0;
|
|
202
|
-
|
|
203
|
-
let name = this.testZone( e );
|
|
204
|
-
|
|
205
|
-
if( name === '' ) this.cursor();
|
|
206
|
-
else{
|
|
207
|
-
if(!this.isDrag) this.cursor('text');
|
|
208
|
-
else this.cursor( this.current !== -1 ? 'move' : 'pointer' );
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if( this.isDrag ){
|
|
214
|
-
|
|
215
|
-
if( this.current !== -1 ){
|
|
216
|
-
|
|
217
|
-
this.prev.d += ( e.clientX - this.prev.x ) - ( e.clientY - this.prev.y );
|
|
218
|
-
|
|
219
|
-
let n = this.prev.v + ( this.prev.d * this.step);
|
|
220
|
-
|
|
221
|
-
this.value[ this.current ] = this.numValue(n);
|
|
222
|
-
this.c[ 3 + this.current ].textContent = this.value[this.current];
|
|
223
|
-
|
|
224
|
-
this.validate();
|
|
225
|
-
|
|
226
|
-
this.prev.x = e.clientX;
|
|
227
|
-
this.prev.y = e.clientY;
|
|
228
|
-
|
|
229
|
-
nup = true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
} else {
|
|
233
|
-
|
|
234
|
-
if( this.isDown ) x = e.clientX - this.zone.x -3;
|
|
235
|
-
if( this.current !== -1 ) x -= this.tmp[this.current][0]
|
|
236
|
-
return this.upInput( x, this.isDown );
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return nup;
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
//keydown: function ( e ) { return true; },
|
|
248
|
-
|
|
249
|
-
// ----------------------
|
|
250
|
-
|
|
251
|
-
reset () {
|
|
252
|
-
|
|
253
|
-
let nup = false;
|
|
254
|
-
//this.isDown = false;
|
|
255
|
-
|
|
256
|
-
//this.current = 0;
|
|
257
|
-
|
|
258
|
-
/* let i = this.lng;
|
|
259
|
-
while(i--){
|
|
260
|
-
if(this.cMode[i]!==0){
|
|
261
|
-
this.cMode[i] = 0;
|
|
262
|
-
//this.c[2+i].style.borderColor = this.colors.border;
|
|
263
|
-
nup = true;
|
|
264
|
-
}
|
|
265
|
-
}*/
|
|
266
|
-
|
|
267
|
-
return nup;
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
setValue ( v ) {
|
|
273
|
-
|
|
274
|
-
if( this.isVector ){
|
|
275
|
-
|
|
276
|
-
if( v.x !== undefined ) this.value[0] = v.x;
|
|
277
|
-
if( v.y !== undefined ) this.value[1] = v.y;
|
|
278
|
-
if( v.z !== undefined ) this.value[2] = v.z;
|
|
279
|
-
if( v.w !== undefined ) this.value[3] = v.w;
|
|
280
|
-
|
|
281
|
-
} else {
|
|
282
|
-
|
|
283
|
-
if( this.isSingle ) this.value = [v]
|
|
284
|
-
else this.value = v
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
this.update();
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
sameStr ( str ){
|
|
293
|
-
|
|
294
|
-
let i = this.value.length;
|
|
295
|
-
while(i--) this.c[ 3 + i ].textContent = str;
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
update ( up ) {
|
|
300
|
-
|
|
301
|
-
let i = this.value.length;
|
|
302
|
-
|
|
303
|
-
while(i--){
|
|
304
|
-
this.value[i] = this.numValue( this.value[i] * this.invmulty );
|
|
305
|
-
this.c[ 3 + i ].textContent = this.value[i];
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if( up ) this.send();
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
send ( v ) {
|
|
313
|
-
|
|
314
|
-
v = v || this.value;
|
|
315
|
-
|
|
316
|
-
this.isSend = true;
|
|
317
|
-
|
|
318
|
-
if( this.objectLink !== null ){
|
|
319
|
-
|
|
320
|
-
if( this.isVector ){
|
|
321
|
-
|
|
322
|
-
this.objectLink[ this.val ].fromArray( v );
|
|
323
|
-
|
|
324
|
-
/*this.objectLink[ this.val ].x = v[0];
|
|
325
|
-
this.objectLink[ this.val ].y = v[1];
|
|
326
|
-
this.objectLink[ this.val ].z = v[2];
|
|
327
|
-
if( v[3] ) this.objectLink[ this.val ].w = v[3];*/
|
|
328
|
-
|
|
329
|
-
} else {
|
|
330
|
-
this.objectLink[ this.val ] = v;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if( this.callback ) this.callback( v, this.val );
|
|
336
|
-
|
|
337
|
-
this.isSend = false;
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// ----------------------
|
|
343
|
-
// INPUT
|
|
344
|
-
// ----------------------
|
|
345
|
-
|
|
346
|
-
select ( c, e, w, t ) {
|
|
347
|
-
|
|
348
|
-
let s = this.s;
|
|
349
|
-
let d = this.current !== -1 ? this.tmp[this.current][0] + 5 : 0;
|
|
350
|
-
s[this.cursorId].width = '1px';
|
|
351
|
-
s[this.cursorId].left = ( d + c ) + 'px';
|
|
352
|
-
//s[2].left = ( d + e ) + 'px';
|
|
353
|
-
//s[2].width = w + 'px';
|
|
354
|
-
|
|
355
|
-
s[this.selectId].left = ( d + e ) + 'px';
|
|
356
|
-
s[this.selectId].width = w + 'px';
|
|
357
|
-
this.c[this.selectId].innerHTML = t
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
unselect () {
|
|
362
|
-
|
|
363
|
-
let s = this.s;
|
|
364
|
-
if(!s) return;
|
|
365
|
-
this.c[this.selectId].innerHTML = ''
|
|
366
|
-
s[this.selectId].width = 0 + 'px';
|
|
367
|
-
s[this.cursorId].width = 0 + 'px';
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
validate ( force ) {
|
|
372
|
-
|
|
373
|
-
let ar = [];
|
|
374
|
-
let i = this.lng;
|
|
375
|
-
|
|
376
|
-
if( this.allway ) force = true;
|
|
377
|
-
|
|
378
|
-
while(i--){
|
|
379
|
-
if(!isNaN( this.c[ 3 + i ].textContent )){
|
|
380
|
-
let nx = this.numValue( this.c[ 3 + i ].textContent );
|
|
381
|
-
this.c[ 3 + i ].textContent = nx;
|
|
382
|
-
this.value[i] = nx;
|
|
383
|
-
} else { // not number
|
|
384
|
-
this.c[ 3 + i ].textContent = this.value[i];
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
ar[i] = this.value[i] * this.multy;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if( !force ) return;
|
|
391
|
-
|
|
392
|
-
if( this.isSingle ) this.send( ar[0] );
|
|
393
|
-
else this.send( ar );
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// ----------------------
|
|
398
|
-
// REZISE
|
|
399
|
-
// ----------------------
|
|
400
|
-
|
|
401
|
-
rSize () {
|
|
402
|
-
|
|
403
|
-
super.rSize();
|
|
404
|
-
|
|
405
|
-
let w = Math.floor( ( this.sb + 5 ) / this.lng )-5;
|
|
406
|
-
let s = this.s;
|
|
407
|
-
let i = this.lng;
|
|
408
|
-
while(i--){
|
|
409
|
-
this.tmp[i] = [ Math.floor( this.sa + ( w * i )+( 5 * i )), w ];
|
|
410
|
-
this.tmp[i][2] = this.tmp[i][0] + this.tmp[i][1];
|
|
411
|
-
s[ 3 + i ].left = this.tmp[i][0] + 'px';
|
|
412
|
-
s[ 3 + i ].width = this.tmp[i][1] + 'px';
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
}
|
package/src/proto/Pad2D.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { Proto } from '../core/Proto.js';
|
|
2
|
-
import { Tools } from '../core/Tools.js';
|
|
3
|
-
import { V2 } from '../core/V2.js';
|
|
4
|
-
|
|
5
|
-
export class Pad2D extends Proto {
|
|
6
|
-
|
|
7
|
-
constructor( o = {} ) {
|
|
8
|
-
|
|
9
|
-
super( o );
|
|
10
|
-
|
|
11
|
-
this.autoWidth = false;
|
|
12
|
-
this.minw = this.w
|
|
13
|
-
this.diam = o.diam || this.w
|
|
14
|
-
|
|
15
|
-
//this.margin = 15;
|
|
16
|
-
this.pos = new V2(0,0);
|
|
17
|
-
this.maxPos = 90
|
|
18
|
-
|
|
19
|
-
this.model = o.stype || 0;
|
|
20
|
-
if( o.mode !== undefined ) this.model = o.mode;
|
|
21
|
-
|
|
22
|
-
this.min = o.min === undefined ? -1 : o.min;
|
|
23
|
-
this.max = o.max === undefined ? 1 : o.max;
|
|
24
|
-
|
|
25
|
-
this.range = (this.max - this.min)*0.5;
|
|
26
|
-
|
|
27
|
-
this.cmode = 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//console.log(this.range)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.precision = o.precision === undefined ? 2 : o.precision;
|
|
35
|
-
|
|
36
|
-
/*this.bounds = {};
|
|
37
|
-
this.bounds.x1 = o.x1 || -1;
|
|
38
|
-
this.bounds.x2 = o.x2 || 1;
|
|
39
|
-
this.bounds.y1 = o.y1 || -1;
|
|
40
|
-
this.bounds.y2 = o.y2 || 1;
|
|
41
|
-
|
|
42
|
-
this.lerpX = this.lerp( this.margin, this.w - this.margin , this.bounds.x1, this.bounds.x2 );
|
|
43
|
-
this.lerpY = this.lerp( this.margin, this.w - this.margin , this.bounds.y1, this.bounds.y2 );
|
|
44
|
-
|
|
45
|
-
this.alerpX = this.lerp( this.bounds.x1, this.bounds.x2, this.margin, this.w - this.margin );
|
|
46
|
-
this.alerpY = this.lerp( this.bounds.y1, this.bounds.y2, this.margin, this.w - this.margin );*/
|
|
47
|
-
|
|
48
|
-
this.value = ( Array.isArray( o.value ) && o.value.length == 2 ) ? o.value : [ 0, 0 ];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.h = o.h || this.w + 10;
|
|
52
|
-
this.top = 0;
|
|
53
|
-
|
|
54
|
-
this.c[0].style.width = this.w + 'px';
|
|
55
|
-
|
|
56
|
-
// Title
|
|
57
|
-
if( this.c[1] !== undefined ) { // with title
|
|
58
|
-
|
|
59
|
-
this.c[1].style.width = '100%';
|
|
60
|
-
this.c[1].style.justifyContent = 'center';
|
|
61
|
-
this.top = 10;
|
|
62
|
-
this.h += 10;
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let cc = this.colors
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Value
|
|
70
|
-
this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; top:'+ ( this.h - 20 ) + 'px; width:100%; color:' + cc.text );
|
|
71
|
-
this.c[2].textContent = this.value;
|
|
72
|
-
|
|
73
|
-
// Pad
|
|
74
|
-
|
|
75
|
-
let pad = this.getPad2d()
|
|
76
|
-
|
|
77
|
-
this.setSvg( pad, 'fill', cc.back, 0 )
|
|
78
|
-
this.setSvg( pad, 'fill', cc.button, 1 )
|
|
79
|
-
this.setSvg( pad, 'stroke', cc.back, 2 )
|
|
80
|
-
this.setSvg( pad, 'stroke', cc.back, 3 )
|
|
81
|
-
this.setSvg( pad, 'stroke', cc.text, 4 )
|
|
82
|
-
|
|
83
|
-
this.setSvg( pad, 'viewBox', '0 0 '+this.diam+' '+this.diam )
|
|
84
|
-
this.setCss( pad, { width:this.diam, height:this.diam, left:0, top:this.top })
|
|
85
|
-
|
|
86
|
-
this.c[3] = pad
|
|
87
|
-
|
|
88
|
-
this.init()
|
|
89
|
-
this.setValue()
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
testZone ( e ) {
|
|
94
|
-
|
|
95
|
-
let l = this.local;
|
|
96
|
-
|
|
97
|
-
if( l.x === -1 && l.y === -1 ) return '';
|
|
98
|
-
|
|
99
|
-
if( l.y <= this.c[ 1 ].offsetHeight ) return 'title';
|
|
100
|
-
else if ( l.y > this.h - this.c[ 2 ].offsetHeight ) return 'text';
|
|
101
|
-
else return 'pad';
|
|
102
|
-
|
|
103
|
-
/*if( ( l.x >= this.margin ) && ( l.x <= this.w - this.margin ) && ( l.y >= this.top + this.margin ) && ( l.y <= this.top + this.w - this.margin ) ) {
|
|
104
|
-
return 'pad';
|
|
105
|
-
}*/
|
|
106
|
-
|
|
107
|
-
//return '';
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
mouseup ( e ) {
|
|
112
|
-
|
|
113
|
-
this.isDown = false;
|
|
114
|
-
return this.mode(0);
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
mousedown ( e ) {
|
|
119
|
-
|
|
120
|
-
if ( this.testZone(e) === 'pad' ) {
|
|
121
|
-
this.isDown = true;
|
|
122
|
-
this.mousemove( e );
|
|
123
|
-
return this.mode(1);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
mousemove ( e ) {
|
|
129
|
-
|
|
130
|
-
if( !this.isDown ) return;
|
|
131
|
-
|
|
132
|
-
let x = (this.w*0.5) - ( e.clientX - this.zone.x )
|
|
133
|
-
let y = (this.diam*0.5) - ( e.clientY - this.zone.y - this.top )
|
|
134
|
-
let r = 256 / this.diam
|
|
135
|
-
|
|
136
|
-
x = -(x*r)
|
|
137
|
-
y = -(y*r)
|
|
138
|
-
|
|
139
|
-
x = Tools.clamp( x, -this.maxPos, this.maxPos )
|
|
140
|
-
y = Tools.clamp( y, -this.maxPos, this.maxPos )
|
|
141
|
-
|
|
142
|
-
//let x = e.clientX - this.zone.x;
|
|
143
|
-
//let y = e.clientY - this.zone.y - this.top;
|
|
144
|
-
|
|
145
|
-
/*if( x < this.margin ) x = this.margin;
|
|
146
|
-
if( x > this.w - this.margin ) x = this.w - this.margin;
|
|
147
|
-
if( y < this.margin ) y = this.margin;
|
|
148
|
-
if( y > this.w - this.margin ) y = this.w - this.margin;*/
|
|
149
|
-
|
|
150
|
-
//console.log(x,y)
|
|
151
|
-
|
|
152
|
-
this.setPos( [ x , y ] );
|
|
153
|
-
|
|
154
|
-
this.update( true );
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
mode ( mode ) {
|
|
159
|
-
|
|
160
|
-
if( this.cmode === mode ) return false;
|
|
161
|
-
|
|
162
|
-
let cc = this.colors
|
|
163
|
-
|
|
164
|
-
switch( mode ){
|
|
165
|
-
case 0: // base
|
|
166
|
-
|
|
167
|
-
this.s[2].color = cc.text;
|
|
168
|
-
this.setSvg( this.c[3], 'fill', cc.back, 0)
|
|
169
|
-
this.setSvg( this.c[3], 'fill', cc.button, 1)
|
|
170
|
-
this.setSvg( this.c[3], 'stroke', cc.back, 2)
|
|
171
|
-
this.setSvg( this.c[3], 'stroke', cc.back, 3)
|
|
172
|
-
this.setSvg( this.c[3], 'stroke', cc.text, 4 )
|
|
173
|
-
|
|
174
|
-
break;
|
|
175
|
-
case 1: // down
|
|
176
|
-
|
|
177
|
-
this.s[2].color = cc.textSelect;
|
|
178
|
-
this.setSvg( this.c[3], 'fill', cc.backoff, 0)
|
|
179
|
-
this.setSvg( this.c[3], 'fill', cc.overoff, 1)
|
|
180
|
-
this.setSvg( this.c[3], 'stroke', cc.backoff, 2)
|
|
181
|
-
this.setSvg( this.c[3], 'stroke', cc.backoff, 3)
|
|
182
|
-
this.setSvg( this.c[3], 'stroke', cc.textSelect, 4 )
|
|
183
|
-
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
this.cmode = mode;
|
|
188
|
-
return true;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
update ( up ) {
|
|
195
|
-
|
|
196
|
-
//if( up === undefined ) up = true;
|
|
197
|
-
|
|
198
|
-
this.c[2].textContent = this.value;
|
|
199
|
-
|
|
200
|
-
this.updateSVG();
|
|
201
|
-
|
|
202
|
-
if( up ) this.send();
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
updateSVG() {
|
|
207
|
-
|
|
208
|
-
if ( this.model == 1 ) {
|
|
209
|
-
|
|
210
|
-
this.setSvg( this.c[3], 'y1', this.pos.y, 2 );
|
|
211
|
-
this.setSvg( this.c[3], 'y2', this.pos.y, 2 );
|
|
212
|
-
|
|
213
|
-
this.setSvg( this.c[3], 'x1', this.pos.x, 3 );
|
|
214
|
-
this.setSvg( this.c[3], 'x2', this.pos.x, 3 );
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
this.setSvg( this.c[3], 'cx', this.pos.x, 4 );
|
|
219
|
-
this.setSvg( this.c[3], 'cy', this.pos.y, 4 );
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
setPos ( p ) {
|
|
224
|
-
|
|
225
|
-
//if( p === undefined ) p = [ this.w / 2, this.w / 2 ];
|
|
226
|
-
|
|
227
|
-
this.pos.set( p[0]+128 , p[1]+128 );
|
|
228
|
-
|
|
229
|
-
let r = 1/this.maxPos
|
|
230
|
-
|
|
231
|
-
this.value[0] = ((p[0]*r)*this.range).toFixed( this.precision );
|
|
232
|
-
this.value[1] = ((p[1]*r)*this.range).toFixed( this.precision );
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
setValue ( v, up = false ) {
|
|
237
|
-
|
|
238
|
-
if( v === undefined ) v = this.value;
|
|
239
|
-
|
|
240
|
-
/*if ( v[0] < this.bounds.x1 ) v[0] = this.bounds.x1;
|
|
241
|
-
if ( v[0] > this.bounds.x2 ) v[0] = this.bounds.x2;
|
|
242
|
-
if ( v[1] < this.bounds.y1 ) v[1] = this.bounds.y1;
|
|
243
|
-
if ( v[1] > this.bounds.y2 ) v[1] = this.bounds.y2;*/
|
|
244
|
-
|
|
245
|
-
this.value[0] = Math.min( this.max, Math.max( this.min, v[0] ) ).toFixed( this.precision ) * 1;
|
|
246
|
-
this.value[1] = Math.min( this.max, Math.max( this.min, v[1] ) ).toFixed( this.precision ) * 1;
|
|
247
|
-
|
|
248
|
-
this.pos.set( ((this.value[0]/this.range)*this.maxPos)+128 , ((this.value[1]/this.range)*this.maxPos)+128 )
|
|
249
|
-
|
|
250
|
-
//console.log(this.pos)
|
|
251
|
-
|
|
252
|
-
this.update( up );
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/*lerp( s1, s2, d1, d2, c = true ) {
|
|
257
|
-
|
|
258
|
-
let s = ( d2 - d1 ) / ( s2 - s1 );
|
|
259
|
-
|
|
260
|
-
return c ? ( v ) => {
|
|
261
|
-
return ( ( v < s1 ? s1 : v > s2 ? s2 : v ) - s1 ) * s + d1
|
|
262
|
-
} : ( v ) => {
|
|
263
|
-
return ( v - s1 ) * s + d1
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
}*/
|
|
267
|
-
|
|
268
|
-
}
|
package/src/proto/Rubric.js
DELETED
|
File without changes
|