uil 4.0.0 → 4.0.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 +1 -1
- package/package.json +2 -5
- 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/Color.js
DELETED
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
import { Tools } from '../core/Tools.js';
|
|
2
|
-
import { Proto } from '../core/Proto.js';
|
|
3
|
-
import { V2 } from '../core/V2.js';
|
|
4
|
-
|
|
5
|
-
export class Color extends Proto {
|
|
6
|
-
|
|
7
|
-
constructor( o = {} ) {
|
|
8
|
-
|
|
9
|
-
super( o );
|
|
10
|
-
|
|
11
|
-
//this.autoHeight = true;
|
|
12
|
-
|
|
13
|
-
this.ctype = o.ctype || 'hex';
|
|
14
|
-
|
|
15
|
-
this.wfixe = 256;
|
|
16
|
-
|
|
17
|
-
this.cw = this.sb > 256 ? 256 : this.sb;
|
|
18
|
-
if(o.cw != undefined ) this.cw = o.cw;
|
|
19
|
-
|
|
20
|
-
// color up or down
|
|
21
|
-
this.side = o.side || 'down';
|
|
22
|
-
this.up = this.side === 'down' ? 0 : 1;
|
|
23
|
-
|
|
24
|
-
this.baseH = this.h;
|
|
25
|
-
|
|
26
|
-
this.offset = new V2();
|
|
27
|
-
this.decal = new V2();
|
|
28
|
-
this.pp = new V2();
|
|
29
|
-
|
|
30
|
-
this.c[2] = this.dom( 'div', this.css.txt + 'height:'+(this.h-4)+'px;' + 'border-radius:'+this.radius+'px; line-height:'+(this.h-8)+'px;' );
|
|
31
|
-
this.s[2] = this.c[2].style;
|
|
32
|
-
|
|
33
|
-
this.s[2].textShadow = 'none'
|
|
34
|
-
|
|
35
|
-
if( this.up ){
|
|
36
|
-
this.s[2].top = 'auto';
|
|
37
|
-
this.s[2].bottom = '2px';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//this.c[0].style.textAlign = 'center';
|
|
41
|
-
//this.c[0].style.flex = '1 0 auto'
|
|
42
|
-
|
|
43
|
-
this.c[3] = this.getColorRing();
|
|
44
|
-
this.c[3].style.visibility = 'hidden';
|
|
45
|
-
|
|
46
|
-
this.hsl = null;
|
|
47
|
-
this.value = '#ffffff';
|
|
48
|
-
if( o.value !== undefined ){
|
|
49
|
-
if( o.value instanceof Array ) this.value = Tools.rgbToHex( o.value );
|
|
50
|
-
else if(!isNaN(o.value)) this.value = Tools.hexToHtml( o.value );
|
|
51
|
-
else this.value = o.value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.bcolor = null;
|
|
55
|
-
this.isDown = false;
|
|
56
|
-
this.fistDown = false;
|
|
57
|
-
|
|
58
|
-
this.notext = o.notext || false
|
|
59
|
-
|
|
60
|
-
this.tr = 98;
|
|
61
|
-
this.tsl = Math.sqrt(3) * this.tr;
|
|
62
|
-
|
|
63
|
-
this.hue = 0;
|
|
64
|
-
this.d = 256;
|
|
65
|
-
|
|
66
|
-
this.setColor( this.value );
|
|
67
|
-
|
|
68
|
-
this.init();
|
|
69
|
-
|
|
70
|
-
if( o.open !== undefined ) this.open();
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
testZone ( mx, my ) {
|
|
75
|
-
|
|
76
|
-
let l = this.local;
|
|
77
|
-
if( l.x === -1 && l.y === -1 ) return '';
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if( this.up && this.isOpen ){
|
|
82
|
-
|
|
83
|
-
if( l.y > this.wfixe ) return 'title';
|
|
84
|
-
else return 'color';
|
|
85
|
-
|
|
86
|
-
} else {
|
|
87
|
-
|
|
88
|
-
if( l.y < this.baseH+2 ) return 'title';
|
|
89
|
-
else if( this.isOpen ) return 'color';
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// ----------------------
|
|
97
|
-
// EVENTS
|
|
98
|
-
// ----------------------
|
|
99
|
-
|
|
100
|
-
mouseup ( e ) {
|
|
101
|
-
|
|
102
|
-
this.isDown = false;
|
|
103
|
-
this.d = 256;
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
mousedown ( e ) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
let name = this.testZone( e.clientX, e.clientY );
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
//if( !name ) return;
|
|
114
|
-
if(name === 'title'){
|
|
115
|
-
if( !this.isOpen ) this.open();
|
|
116
|
-
else this.close();
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if( name === 'color' ){
|
|
122
|
-
|
|
123
|
-
this.isDown = true;
|
|
124
|
-
this.fistDown = true
|
|
125
|
-
this.mousemove( e );
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
mousemove ( e ) {
|
|
130
|
-
|
|
131
|
-
let name = this.testZone( e.clientX, e.clientY );
|
|
132
|
-
|
|
133
|
-
let off, d, hue, sat, lum, rad, x, y, rr, T = Tools;
|
|
134
|
-
|
|
135
|
-
if( name === 'title' ) this.cursor('pointer');
|
|
136
|
-
|
|
137
|
-
if( name === 'color' ){
|
|
138
|
-
|
|
139
|
-
off = this.offset;
|
|
140
|
-
off.x = e.clientX - ( this.zone.x + this.decal.x + this.mid );
|
|
141
|
-
off.y = e.clientY - ( this.zone.y + this.decal.y + this.mid );
|
|
142
|
-
d = off.length() * this.ratio;
|
|
143
|
-
rr = off.angle();
|
|
144
|
-
if(rr < 0) rr += 2 * T.PI;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if ( d < 128 ) this.cursor('crosshair');
|
|
148
|
-
else if( !this.isDown ) this.cursor()
|
|
149
|
-
|
|
150
|
-
if( this.isDown ){
|
|
151
|
-
|
|
152
|
-
if( this.fistDown ){
|
|
153
|
-
this.d = d;
|
|
154
|
-
this.fistDown = false;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if ( this.d < 128 ) {
|
|
158
|
-
|
|
159
|
-
if ( this.d > this.tr ) { // outside hue
|
|
160
|
-
|
|
161
|
-
hue = ( rr + T.pi90 ) / T.TwoPI;
|
|
162
|
-
this.hue = (hue + 1) % 1;
|
|
163
|
-
this.setHSL([(hue + 1) % 1, this.hsl[1], this.hsl[2]]);
|
|
164
|
-
|
|
165
|
-
} else { // triangle
|
|
166
|
-
|
|
167
|
-
x = off.x * this.ratio;
|
|
168
|
-
y = off.y * this.ratio;
|
|
169
|
-
|
|
170
|
-
let rr = (this.hue * T.TwoPI) + T.PI;
|
|
171
|
-
if(rr < 0) rr += 2 * T.PI;
|
|
172
|
-
|
|
173
|
-
rad = Math.atan2(-y, x);
|
|
174
|
-
if(rad < 0) rad += 2 * T.PI;
|
|
175
|
-
|
|
176
|
-
let rad0 = ( rad + T.pi90 + T.TwoPI + rr ) % (T.TwoPI),
|
|
177
|
-
rad1 = rad0 % ((2/3) * T.PI) - (T.pi60),
|
|
178
|
-
a = 0.5 * this.tr,
|
|
179
|
-
b = Math.tan(rad1) * a,
|
|
180
|
-
r = Math.sqrt(x*x + y*y),
|
|
181
|
-
maxR = Math.sqrt(a*a + b*b);
|
|
182
|
-
|
|
183
|
-
if( r > maxR ) {
|
|
184
|
-
let dx = Math.tan(rad1) * r;
|
|
185
|
-
let rad2 = Math.atan(dx / maxR);
|
|
186
|
-
if(rad2 > T.pi60) rad2 = T.pi60;
|
|
187
|
-
else if( rad2 < -T.pi60 ) rad2 = -T.pi60;
|
|
188
|
-
|
|
189
|
-
rad += rad2 - rad1;
|
|
190
|
-
|
|
191
|
-
rad0 = (rad + T.pi90 + T.TwoPI + rr) % (T.TwoPI),
|
|
192
|
-
rad1 = rad0 % ((2/3) * T.PI) - (T.pi60);
|
|
193
|
-
b = Math.tan(rad1) * a;
|
|
194
|
-
r = maxR = Math.sqrt(a*a + b*b);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
lum = ((Math.sin(rad0) * r) / this.tsl) + 0.5;
|
|
198
|
-
|
|
199
|
-
let w = 1 - (Math.abs(lum - 0.5) * 2);
|
|
200
|
-
sat = (((Math.cos(rad0) * r) + (this.tr / 2)) / (1.5 * this.tr)) / w;
|
|
201
|
-
sat = T.clamp( sat, 0, 1 );
|
|
202
|
-
|
|
203
|
-
this.setHSL([this.hsl[0], sat, lum]);
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// ----------------------
|
|
213
|
-
|
|
214
|
-
setHeight () {
|
|
215
|
-
|
|
216
|
-
this.h = this.isOpen ? this.wfixe + this.baseH + 5 : this.baseH;
|
|
217
|
-
this.s[0].height = this.h + 'px';
|
|
218
|
-
this.zone.h = this.h;
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
parentHeight ( t ) {
|
|
223
|
-
|
|
224
|
-
if ( this.group !== null ) this.group.calc( t );
|
|
225
|
-
else if ( this.isUI ) this.main.calc( t );
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
open () {
|
|
230
|
-
|
|
231
|
-
super.open();
|
|
232
|
-
|
|
233
|
-
this.setHeight();
|
|
234
|
-
|
|
235
|
-
if( this.up ) this.zone.y -= this.wfixe + 5;
|
|
236
|
-
|
|
237
|
-
let t = this.h - this.baseH;
|
|
238
|
-
|
|
239
|
-
this.s[3].visibility = 'visible';
|
|
240
|
-
//this.s[3].display = 'block';
|
|
241
|
-
this.parentHeight( t );
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
close () {
|
|
246
|
-
|
|
247
|
-
super.close();
|
|
248
|
-
|
|
249
|
-
if( this.up ) this.zone.y += this.wfixe + 5;
|
|
250
|
-
|
|
251
|
-
let t = this.h - this.baseH;
|
|
252
|
-
|
|
253
|
-
this.setHeight();
|
|
254
|
-
|
|
255
|
-
this.s[3].visibility = 'hidden';
|
|
256
|
-
//this.s[3].display = 'none';
|
|
257
|
-
this.parentHeight( -t );
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
update ( up ) {
|
|
262
|
-
|
|
263
|
-
let cc = Tools.rgbToHex( Tools.hslToRgb([ this.hsl[0], 1, 0.5 ]) );
|
|
264
|
-
|
|
265
|
-
this.moveMarkers();
|
|
266
|
-
|
|
267
|
-
this.value = this.bcolor;
|
|
268
|
-
|
|
269
|
-
this.setSvg( this.c[3], 'fill', cc, 2, 0 );
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this.s[2].background = this.bcolor;
|
|
273
|
-
if(!this.notext) this.c[2].textContent = Tools.htmlToHex( this.bcolor );
|
|
274
|
-
|
|
275
|
-
this.invert = Tools.findDeepInver( this.rgb );
|
|
276
|
-
this.s[2].color = this.invert ? '#fff' : '#000';
|
|
277
|
-
|
|
278
|
-
if(!up) return;
|
|
279
|
-
|
|
280
|
-
if( this.ctype === 'array' ) this.send( this.rgb );
|
|
281
|
-
if( this.ctype === 'rgb' ) this.send( Tools.htmlRgb( this.rgb ) );
|
|
282
|
-
if( this.ctype === 'hex' ) this.send( Tools.htmlToHex( this.value ) );
|
|
283
|
-
if( this.ctype === 'html' ) this.send();
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
setValue ( v ){
|
|
288
|
-
|
|
289
|
-
if( v instanceof Array ) this.value = Tools.rgbToHex( v );
|
|
290
|
-
else if(!isNaN(v)) this.value = Tools.hexToHtml( v );
|
|
291
|
-
else this.value = v;
|
|
292
|
-
|
|
293
|
-
this.setColor( this.value )
|
|
294
|
-
this.update();
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
setColor ( color ) {
|
|
299
|
-
|
|
300
|
-
let unpack = Tools.unpack(color);
|
|
301
|
-
if (this.bcolor !== color && unpack) {
|
|
302
|
-
|
|
303
|
-
this.bcolor = color;
|
|
304
|
-
this.rgb = unpack;
|
|
305
|
-
this.hsl = Tools.rgbToHsl( this.rgb );
|
|
306
|
-
|
|
307
|
-
this.hue = this.hsl[0];
|
|
308
|
-
|
|
309
|
-
this.update();
|
|
310
|
-
}
|
|
311
|
-
return this;
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
setHSL ( hsl ) {
|
|
316
|
-
|
|
317
|
-
this.hsl = hsl;
|
|
318
|
-
this.rgb = Tools.hslToRgb( hsl );
|
|
319
|
-
this.bcolor = Tools.rgbToHex( this.rgb );
|
|
320
|
-
this.update( true );
|
|
321
|
-
return this;
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
moveMarkers () {
|
|
326
|
-
|
|
327
|
-
let p = this.pp;
|
|
328
|
-
let T = Tools;
|
|
329
|
-
|
|
330
|
-
let c1 = this.invert ? '#fff' : '#000';
|
|
331
|
-
let a = this.hsl[0] * T.TwoPI;
|
|
332
|
-
let third = (2/3) * T.PI;
|
|
333
|
-
let r = this.tr;
|
|
334
|
-
let h = this.hsl[0];
|
|
335
|
-
let s = this.hsl[1];
|
|
336
|
-
let l = this.hsl[2];
|
|
337
|
-
|
|
338
|
-
let angle = ( a - T.pi90 ) * T.todeg;
|
|
339
|
-
|
|
340
|
-
h = - a + T.pi90;
|
|
341
|
-
|
|
342
|
-
let hx = Math.cos(h) * r;
|
|
343
|
-
let hy = -Math.sin(h) * r;
|
|
344
|
-
let sx = Math.cos(h - third) * r;
|
|
345
|
-
let sy = -Math.sin(h - third) * r;
|
|
346
|
-
let vx = Math.cos(h + third) * r;
|
|
347
|
-
let vy = -Math.sin(h + third) * r;
|
|
348
|
-
let mx = (sx + vx) / 2, my = (sy + vy) / 2;
|
|
349
|
-
a = (1 - 2 * Math.abs(l - .5)) * s;
|
|
350
|
-
let x = sx + (vx - sx) * l + (hx - mx) * a;
|
|
351
|
-
let y = sy + (vy - sy) * l + (hy - my) * a;
|
|
352
|
-
|
|
353
|
-
p.set( x, y ).addScalar(128);
|
|
354
|
-
|
|
355
|
-
//let ff = (1-l)*255;
|
|
356
|
-
// this.setSvg( this.c[3], 'stroke', 'rgb('+ff+','+ff+','+ff+')', 3 );
|
|
357
|
-
|
|
358
|
-
this.setSvg( this.c[3], 'transform', 'rotate('+angle+' )', 2 );
|
|
359
|
-
|
|
360
|
-
this.setSvg( this.c[3], 'cx', p.x, 3 );
|
|
361
|
-
this.setSvg( this.c[3], 'cy', p.y, 3 );
|
|
362
|
-
|
|
363
|
-
this.setSvg( this.c[3], 'stroke', this.invert ? '#fff' : '#000', 2, 3 );
|
|
364
|
-
this.setSvg( this.c[3], 'stroke', this.invert ? '#fff' : '#000', 3 );
|
|
365
|
-
this.setSvg( this.c[3], 'fill',this.bcolor, 3 );
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
rSize () {
|
|
370
|
-
|
|
371
|
-
//Proto.prototype.rSize.call( this );
|
|
372
|
-
super.rSize();
|
|
373
|
-
|
|
374
|
-
let s = this.s;
|
|
375
|
-
|
|
376
|
-
s[2].width = this.sb + 'px';
|
|
377
|
-
s[2].left = this.sa + 'px';
|
|
378
|
-
|
|
379
|
-
this.rSizeColor( this.cw );
|
|
380
|
-
|
|
381
|
-
this.decal.x = Math.floor((this.w - this.wfixe) * 0.5);
|
|
382
|
-
//s[3].left = this.decal.x + 'px';
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
rSizeColor ( w ) {
|
|
387
|
-
|
|
388
|
-
if( w === this.wfixe ) return;
|
|
389
|
-
|
|
390
|
-
this.wfixe = w;
|
|
391
|
-
|
|
392
|
-
let s = this.s;
|
|
393
|
-
|
|
394
|
-
//this.decal.x = Math.floor((this.w - this.wfixe) * 0.5);
|
|
395
|
-
this.decal.y = this.side === 'up' ? 2 : this.baseH + 2;
|
|
396
|
-
this.mid = Math.floor( this.wfixe * 0.5 );
|
|
397
|
-
|
|
398
|
-
this.setSvg( this.c[3], 'viewBox', '0 0 '+ this.wfixe + ' '+ this.wfixe );
|
|
399
|
-
s[3].width = this.wfixe + 'px';
|
|
400
|
-
s[3].height = this.wfixe + 'px';
|
|
401
|
-
//s[3].left = this.decal.x + 'px';
|
|
402
|
-
s[3].top = this.decal.y + 'px';
|
|
403
|
-
|
|
404
|
-
this.ratio = 256 / this.wfixe;
|
|
405
|
-
this.square = 1 / (60*(this.wfixe/256));
|
|
406
|
-
this.setHeight();
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|