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.
Files changed (46) hide show
  1. package/README.md +5 -1
  2. package/build/uil.js +33 -45
  3. package/build/uil.min.js +1 -1
  4. package/build/uil.module.js +45 -58
  5. package/package.json +6 -10
  6. package/examples/js/BufferGeometryUtils.js +0 -921
  7. package/examples/js/SimplexNoise.js +0 -324
  8. package/examples/js/controls/OrbitControls.js +0 -1215
  9. package/examples/js/controls/OrbitControls_.js +0 -1042
  10. package/examples/js/libs/sea3d.min.js +0 -373
  11. package/examples/js/libs/three.min.js +0 -6
  12. package/examples/js/math.js +0 -447
  13. package/examples/js/objects/Landscape.js +0 -778
  14. package/examples/js/objects/Lensflare.js +0 -372
  15. package/examples/js/objects/SuperSky.js +0 -297
  16. package/examples/js/objects/Water.js +0 -329
  17. package/src/Uil.js +0 -6
  18. package/src/Uil_dev.js +0 -15
  19. package/src/core/Gui.js +0 -807
  20. package/src/core/Proto.js +0 -679
  21. package/src/core/Roots.js +0 -864
  22. package/src/core/Tools.js +0 -830
  23. package/src/core/V2.js +0 -131
  24. package/src/core/add.js +0 -85
  25. package/src/polyfills.js +0 -85
  26. package/src/proto/Bool.js +0 -147
  27. package/src/proto/Button.js +0 -357
  28. package/src/proto/Circular.js +0 -230
  29. package/src/proto/Color.js +0 -411
  30. package/src/proto/Empty.js +0 -15
  31. package/src/proto/Fps.js +0 -327
  32. package/src/proto/Graph.js +0 -310
  33. package/src/proto/Grid.js +0 -297
  34. package/src/proto/Group.js +0 -430
  35. package/src/proto/Item.js +0 -120
  36. package/src/proto/Joystick.js +0 -241
  37. package/src/proto/Knob.js +0 -262
  38. package/src/proto/List.js +0 -789
  39. package/src/proto/Numeric.js +0 -417
  40. package/src/proto/Pad2D.js +0 -268
  41. package/src/proto/Rubric.js +0 -0
  42. package/src/proto/Select.js +0 -178
  43. package/src/proto/Selector.js +0 -13
  44. package/src/proto/Slide.js +0 -267
  45. package/src/proto/TextInput.js +0 -181
  46. package/src/proto/Title.js +0 -61
package/src/core/Tools.js DELETED
@@ -1,830 +0,0 @@
1
- /**
2
- * @author lth / https://github.com/lo-th
3
- */
4
-
5
- import { Roots } from './Roots.js';
6
-
7
- const T = {
8
-
9
- transition: 0.2,
10
-
11
- frag: document.createDocumentFragment(),
12
-
13
- colorRing: null,
14
- joystick_0: null,
15
- joystick_1: null,
16
- circular: null,
17
- knob: null,
18
- pad2d: null,
19
-
20
- svgns: "http://www.w3.org/2000/svg",
21
- links: "http://www.w3.org/1999/xlink",
22
- htmls: "http://www.w3.org/1999/xhtml",
23
-
24
- DOM_SIZE: [ 'height', 'width', 'top', 'left', 'bottom', 'right', 'margin-left', 'margin-right', 'margin-top', 'margin-bottom'],
25
- SVG_TYPE_D: [ 'pattern', 'defs', 'transform', 'stop', 'animate', 'radialGradient', 'linearGradient', 'animateMotion', 'use', 'filter', 'feColorMatrix' ],
26
- SVG_TYPE_G: [ 'svg', 'rect', 'circle', 'path', 'polygon', 'text', 'g', 'line', 'foreignObject' ],
27
-
28
- PI: Math.PI,
29
- TwoPI: Math.PI*2,
30
- pi90: Math.PI * 0.5,
31
- pi60: Math.PI/3,
32
-
33
- torad: Math.PI / 180,
34
- todeg: 180 / Math.PI,
35
-
36
- clamp: function (v, min, max) {
37
-
38
- v = v < min ? min : v;
39
- v = v > max ? max : v;
40
- return v;
41
-
42
- },
43
-
44
- size: { w: 240, h: 20, p: 30, s: 8 },
45
-
46
- // ----------------------
47
- // COLOR
48
- // ----------------------
49
-
50
- defineColor: function( o, cc = T.colors ) {
51
-
52
- let color = { ...cc }
53
-
54
- let textChange = ['fontFamily', 'fontWeight', 'fontShadow', 'fontSize' ]
55
- let changeText = false
56
-
57
- if( o.font ) o.fontFamily = o.font
58
- if( o.shadow ) o.fontShadow = o.shadow
59
- if( o.weight ) o.fontWeight = o.weight
60
-
61
- if( o.fontColor ) o.text = o.fontColor
62
- if( o.color ) o.text = o.color
63
-
64
- if( o.text ){
65
- color.text = o.text
66
- if( !o.fontColor && !o.color ){
67
- color.title = T.ColorLuma( o.text, -0.25 )
68
- color.titleoff = T.ColorLuma( o.text, -0.5 )
69
- }
70
- color.textOver = T.ColorLuma( o.text, 0.25 )
71
- color.textSelect = T.ColorLuma( o.text, 0.5 )
72
- }
73
-
74
- if( o.button ){
75
- color.button = o.button
76
- color.border = T.ColorLuma( o.button, 0.1 )
77
- color.overoff = T.ColorLuma( o.button, 0.2 )
78
- }
79
-
80
- if( o.select ){
81
- color.select = o.select
82
- color.over = T.ColorLuma( o.select, -0.1 )
83
- }
84
-
85
- if( o.itemBg ) o.back = o.itemBg
86
-
87
- if( o.back ){
88
- color.back = o.back
89
- color.backoff = T.ColorLuma( o.back, -0.1 )
90
- }
91
-
92
- if( o.fontSelect ) color.textSelect = o.fontSelect
93
- if( o.groupBorder ) color.gborder = o.groupBorder
94
-
95
- if( o.transparent ) o.bg = 'none'
96
- if( o.bg ) color.background = color.backgroundOver = o.bg
97
- if( o.bgOver ) color.backgroundOver = o.bgOver
98
-
99
- for( let m in color ){
100
- if(o[m]) color[m] = o[m]
101
- }
102
-
103
- for( let m in o ){
104
- if( textChange.indexOf(m) !== -1 ) changeText = true
105
- }
106
-
107
- if( changeText ) T.defineText( color )
108
-
109
- return color
110
-
111
- },
112
-
113
- colors: {
114
-
115
- content:'none',
116
- background: 'rgba(50,50,50,0.3)',
117
- backgroundOver: 'rgba(50,50,50,0.4)',
118
-
119
- title : '#CCC',
120
- titleoff : '#BBB',
121
- text : '#DDD',
122
- textOver : '#EEE',
123
- textSelect : '#FFF',
124
-
125
- //inputBg: 'rgba(0,0,0,0.25)',
126
- //itemBg:'rgba(0,0,0,0.25)',
127
-
128
- back:'rgba(0,0,0,0.2)',
129
- backoff:'rgba(0,0,0,0.3)',
130
- //inputOver: 'rgba(0,0,0,0.2)',
131
-
132
- // input and button border
133
- border : '#4c4c4c',
134
- borderSize : 1,
135
- gborder : 'none',
136
-
137
- button : '#3c3c3c',
138
- overoff : '#5c5c5c',
139
- over : '#024699',
140
- select : '#308AFF',
141
- action: '#FF3300',
142
-
143
-
144
- //fontFamily: 'Tahoma',
145
- fontFamily: 'Consolas,monaco,monospace',
146
- fontWeight: 'normal',
147
- fontShadow: '#000',
148
- fontSize:12,
149
-
150
-
151
- radius:4,
152
- hide: 'rgba(0,0,0,0)',
153
-
154
- },
155
-
156
- // style css
157
-
158
- css : {
159
-
160
- //unselect: '-o-user-select:none; -ms-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -moz-user-select:none;',
161
- basic: 'position:absolute; pointer-events:none; box-sizing:border-box; margin:0; padding:0; overflow:hidden; ' + '-o-user-select:none; -ms-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -moz-user-select:none;',
162
- button:'display:flex; justify-content:center; align-items:center; text-align:center;',
163
-
164
- /*txt: T.css.basic + 'font-family:'+ T.colors.fontFamily +'; font-size:'+T.colors.fontSize+'px; color:'+T.colors.text+'; padding:2px 10px; left:0; top:2px; height:16px; width:100px; overflow:hidden; white-space: nowrap;',
165
- txtselect: T.css.txt + 'display:flex; justify-content:left; align-items:center; text-align:left;' +'padding:2px 5px; border:1px dashed ' + T.colors.border + '; background:'+ T.colors.txtselectbg+';',
166
- item: T.css.txt + 'position:relative; background:rgba(0,0,0,0.2); margin-bottom:1px;',*/
167
- },
168
-
169
- // svg path
170
-
171
- svgs: {
172
-
173
- group:'M 7 7 L 7 8 8 8 8 7 7 7 M 5 7 L 5 8 6 8 6 7 5 7 M 3 7 L 3 8 4 8 4 7 3 7 M 7 5 L 7 6 8 6 8 5 7 5 M 6 6 L 6 5 5 5 5 6 6 6 M 7 3 L 7 4 8 4 8 3 7 3 M 6 4 L 6 3 5 3 5 4 6 4 M 3 5 L 3 6 4 6 4 5 3 5 M 3 3 L 3 4 4 4 4 3 3 3 Z',
174
- arrow:'M 3 8 L 8 5 3 2 3 8 Z',
175
- arrowDown:'M 5 8 L 8 3 2 3 5 8 Z',
176
- arrowUp:'M 5 2 L 2 7 8 7 5 2 Z',
177
-
178
- solid:'M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 Z',
179
- body:'M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 M 5 4 L 4 5 4 10 9 10 10 9 10 4 5 4 Z',
180
- vehicle:'M 13 6 L 11 1 3 1 1 6 1 13 3 13 3 11 11 11 11 13 13 13 13 6 M 2.4 6 L 4 2 10 2 11.6 6 2.4 6 M 12 8 L 12 10 10 10 10 8 12 8 M 4 8 L 4 10 2 10 2 8 4 8 Z',
181
- articulation:'M 13 9 L 12 9 9 2 9 1 5 1 5 2 2 9 1 9 1 13 5 13 5 9 4 9 6 5 8 5 10 9 9 9 9 13 13 13 13 9 Z',
182
- character:'M 13 4 L 12 3 9 4 5 4 2 3 1 4 5 6 5 8 4 13 6 13 7 9 8 13 10 13 9 8 9 6 13 4 M 6 1 L 6 3 8 3 8 1 6 1 Z',
183
- terrain:'M 13 8 L 12 7 Q 9.06 -3.67 5.95 4.85 4.04 3.27 2 7 L 1 8 7 13 13 8 M 3 8 Q 3.78 5.420 5.4 6.6 5.20 7.25 5 8 L 7 8 Q 8.39 -0.16 11 8 L 7 11 3 8 Z',
184
- joint:'M 7.7 7.7 Q 8 7.45 8 7 8 6.6 7.7 6.3 7.45 6 7 6 6.6 6 6.3 6.3 6 6.6 6 7 6 7.45 6.3 7.7 6.6 8 7 8 7.45 8 7.7 7.7 M 3.35 8.65 L 1 11 3 13 5.35 10.65 Q 6.1 11 7 11 8.28 11 9.25 10.25 L 7.8 8.8 Q 7.45 9 7 9 6.15 9 5.55 8.4 5 7.85 5 7 5 6.54 5.15 6.15 L 3.7 4.7 Q 3 5.712 3 7 3 7.9 3.35 8.65 M 10.25 9.25 Q 11 8.28 11 7 11 6.1 10.65 5.35 L 13 3 11 1 8.65 3.35 Q 7.9 3 7 3 5.7 3 4.7 3.7 L 6.15 5.15 Q 6.54 5 7 5 7.85 5 8.4 5.55 9 6.15 9 7 9 7.45 8.8 7.8 L 10.25 9.25 Z',
185
- ray:'M 9 11 L 5 11 5 12 9 12 9 11 M 12 5 L 11 5 11 9 12 9 12 5 M 11.5 10 Q 10.9 10 10.45 10.45 10 10.9 10 11.5 10 12.2 10.45 12.55 10.9 13 11.5 13 12.2 13 12.55 12.55 13 12.2 13 11.5 13 10.9 12.55 10.45 12.2 10 11.5 10 M 9 10 L 10 9 2 1 1 2 9 10 Z',
186
- collision:'M 11 12 L 13 10 10 7 13 4 11 2 7.5 5.5 9 7 7.5 8.5 11 12 M 3 2 L 1 4 4 7 1 10 3 12 8 7 3 2 Z',
187
- map:'M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z',
188
- material:'M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z',
189
- texture:'M 13 4 L 13 1 1 1 1 4 5 4 5 13 9 13 9 4 13 4 Z',
190
- object:'M 10 1 L 7 4 4 1 1 1 1 13 4 13 4 5 7 8 10 5 10 13 13 13 13 1 10 1 Z',
191
- none:'M 9 5 L 5 5 5 9 9 9 9 5 Z',
192
- cursor:'M 4 7 L 1 10 1 12 2 13 4 13 7 10 9 14 14 0 0 5 4 7 Z',
193
-
194
- },
195
-
196
-
197
- getImput: function(){
198
-
199
- return Roots.input ? true : false
200
-
201
- },
202
-
203
- setStyle : function ( data ){
204
-
205
- for ( var o in data ){
206
- if( T.colors[o] ) T.colors[o] = data[o];
207
- }
208
-
209
- T.setText();
210
-
211
- },
212
-
213
- // ----------------------
214
- // custom text
215
- // ----------------------
216
-
217
- defineText: function( o ){
218
-
219
- T.setText( o.fontSize, o.text, o.fontFamily, o.fontShadow, o.fontWeight )
220
-
221
- },
222
-
223
- setText: function( size, color, font, shadow, weight ){
224
-
225
- let cc = T.colors;
226
-
227
- if( font === undefined ) font = cc.fontFamily
228
- if( size === undefined ) size = cc.fontSize
229
- if( shadow === undefined ) shadow = cc.fontShadow
230
- if( weight === undefined ) weight = cc.fontWeight
231
- if( color === undefined ) color = cc.text
232
-
233
-
234
- let align = 'display:flex; justify-content:left; align-items:center; text-align:left;'
235
-
236
- T.css.txt = T.css.basic + align + 'font-family:'+ font +'; font-weight:'+weight+'; font-size:'+size+'px; color:'+cc.text+'; padding:0px 10px; left:0; top:2px; height:16px; width:100px; overflow:hidden; white-space: nowrap;';
237
- if( shadow !== 'none' ) T.css.txt += ' text-shadow: 1px 1px 1px '+shadow+';';
238
-
239
- T.css.txtselect = T.css.txt + 'padding:0px 4px; border:1px dashed ' + cc.border + ';';
240
- //T.css.item = T.css.txt + ' position:relative; margin-bottom:1px; '//display:block; padding:4px 4px;';//
241
- T.css.item = T.css.txt + ' position:relative; margin-bottom:1px; display:block; padding:2px 4px;';//
242
-
243
- },
244
-
245
-
246
- // note
247
-
248
- //https://developer.mozilla.org/fr/docs/Web/CSS/css_flexible_box_layout/aligning_items_in_a_flex_container
249
-
250
- /*cloneColor: function () {
251
-
252
- let cc = Object.assign({}, T.colors );
253
- return cc;
254
-
255
- },*/
256
-
257
- // intern function
258
-
259
- cloneCss: function () {
260
-
261
- //let cc = Object.assign({}, T.css );
262
- return { ...T.css };
263
-
264
- },
265
-
266
- clone: function ( o ) {
267
-
268
- return o.cloneNode( true );
269
-
270
- },
271
-
272
- setSvg: function( dom, type, value, id, id2 ){
273
-
274
- if( id === -1 ) dom.setAttributeNS( null, type, value );
275
- else if( id2 !== undefined ) dom.childNodes[ id || 0 ].childNodes[ id2 || 0 ].setAttributeNS( null, type, value );
276
- else dom.childNodes[ id || 0 ].setAttributeNS( null, type, value );
277
-
278
- },
279
-
280
- setCss: function( dom, css ){
281
-
282
- for( let r in css ){
283
- if( T.DOM_SIZE.indexOf(r) !== -1 ) dom.style[r] = css[r] + 'px';
284
- else dom.style[r] = css[r];
285
- }
286
-
287
- },
288
-
289
- set: function( g, o ){
290
-
291
- for( let att in o ){
292
- if( att === 'txt' ) g.textContent = o[ att ];
293
- if( att === 'link' ) g.setAttributeNS( T.links, 'xlink:href', o[ att ] );
294
- else g.setAttributeNS( null, att, o[ att ] );
295
- }
296
-
297
- },
298
-
299
- get: function( dom, id ){
300
-
301
- if( id === undefined ) return dom; // root
302
- else if( !isNaN( id ) ) return dom.childNodes[ id ]; // first child
303
- else if( id instanceof Array ){
304
- if(id.length === 2) return dom.childNodes[ id[0] ].childNodes[ id[1] ];
305
- if(id.length === 3) return dom.childNodes[ id[0] ].childNodes[ id[1] ].childNodes[ id[2] ];
306
- }
307
-
308
- },
309
-
310
- dom : function ( type, css, obj, dom, id ) {
311
-
312
- type = type || 'div';
313
-
314
- if( T.SVG_TYPE_D.indexOf(type) !== -1 || T.SVG_TYPE_G.indexOf(type) !== -1 ){ // is svg element
315
-
316
- if( type ==='svg' ){
317
-
318
- dom = document.createElementNS( T.svgns, 'svg' );
319
- T.set( dom, obj );
320
-
321
- /* } else if ( type === 'use' ) {
322
-
323
- dom = document.createElementNS( T.svgns, 'use' );
324
- T.set( dom, obj );
325
- */
326
- } else {
327
- // create new svg if not def
328
- if( dom === undefined ) dom = document.createElementNS( T.svgns, 'svg' );
329
- T.addAttributes( dom, type, obj, id );
330
-
331
- }
332
-
333
- } else { // is html element
334
-
335
- if( dom === undefined ) dom = document.createElementNS( T.htmls, type );
336
- else dom = dom.appendChild( document.createElementNS( T.htmls, type ) );
337
-
338
- }
339
-
340
- if( css ) dom.style.cssText = css;
341
-
342
- if( id === undefined ) return dom;
343
- else return dom.childNodes[ id || 0 ];
344
-
345
- },
346
-
347
- addAttributes : function( dom, type, o, id ){
348
-
349
- let g = document.createElementNS( T.svgns, type );
350
- T.set( g, o );
351
- T.get( dom, id ).appendChild( g );
352
- if( T.SVG_TYPE_G.indexOf(type) !== -1 ) g.style.pointerEvents = 'none';
353
- return g;
354
-
355
- },
356
-
357
- clear : function( dom ){
358
-
359
- T.purge( dom );
360
- while (dom.firstChild) {
361
- if ( dom.firstChild.firstChild ) T.clear( dom.firstChild );
362
- dom.removeChild( dom.firstChild );
363
- }
364
-
365
- },
366
-
367
- purge : function ( dom ) {
368
-
369
- let a = dom.attributes, i, n;
370
- if (a) {
371
- i = a.length;
372
- while(i--){
373
- n = a[i].name;
374
- if (typeof dom[n] === 'function') dom[n] = null;
375
- }
376
- }
377
- a = dom.childNodes;
378
- if (a) {
379
- i = a.length;
380
- while(i--){
381
- T.purge( dom.childNodes[i] );
382
- }
383
- }
384
-
385
- },
386
-
387
- // ----------------------
388
- // SVG Effects function
389
- // ----------------------
390
-
391
- addSVGGlowEffect: function () {
392
-
393
- if ( document.getElementById( 'UILGlow') !== null ) return;
394
-
395
- let svgFilter = T.initUILEffects();
396
-
397
- let filter = T.addAttributes( svgFilter, 'filter', { id: 'UILGlow', x: '-20%', y: '-20%', width: '140%', height: '140%' } );
398
- T.addAttributes( filter, 'feGaussianBlur', { in: 'SourceGraphic', stdDeviation: '3', result: 'uilBlur' } );
399
- let feMerge = T.addAttributes( filter, 'feMerge', { } );
400
-
401
- for( let i = 0; i <= 3; i++ ) {
402
-
403
- T.addAttributes( feMerge, 'feMergeNode', { in: 'uilBlur' } );
404
-
405
- }
406
-
407
- T.addAttributes( feMerge, 'feMergeNode', { in: 'SourceGraphic' } );
408
-
409
- },
410
-
411
- initUILEffects: function () {
412
-
413
- let svgFilter = document.getElementById( 'UILSVGEffects');
414
-
415
- if ( svgFilter === null ) {
416
-
417
- svgFilter = T.dom( 'svg', undefined , { id: 'UILSVGEffects', width: '0', height: '0' } );
418
- document.body.appendChild( svgFilter );
419
-
420
- }
421
-
422
- return svgFilter;
423
-
424
- },
425
-
426
- // ----------------------
427
- // Color function
428
- // ----------------------
429
-
430
- ColorLuma : function ( hex, l ) {
431
-
432
- if( hex === 'n' ) hex = '#000';
433
-
434
- // validate hex string
435
- hex = String(hex).replace(/[^0-9a-f]/gi, '');
436
- if (hex.length < 6) {
437
- hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2];
438
- }
439
- l = l || 0;
440
-
441
- // convert to decimal and change luminosity
442
- let rgb = "#", c, i;
443
- for (i = 0; i < 3; i++) {
444
- c = parseInt(hex.substr(i*2,2), 16);
445
- c = Math.round(Math.min(Math.max(0, c + (c * l)), 255)).toString(16);
446
- rgb += ("00"+c).substr(c.length);
447
- }
448
-
449
- return rgb;
450
-
451
- },
452
-
453
- findDeepInver: function ( c ) {
454
-
455
- return (c[0] * 0.3 + c[1] * .59 + c[2] * .11) <= 0.6;
456
-
457
- },
458
-
459
- lerpColor: function( c1, c2, factor ) {
460
- let newColor = {};
461
- for ( let i = 0; i < 3; i++ ) {
462
- newColor[i] = c1[ i ] + ( c2[ i ] - c1[ i ] ) * factor;
463
- }
464
- return newColor;
465
- },
466
-
467
- hexToHtml: function ( v ) {
468
- v = v === undefined ? 0x000000 : v;
469
- return "#" + ("000000" + v.toString(16)).substr(-6);
470
-
471
- },
472
-
473
- htmlToHex: function ( v ) {
474
-
475
- return v.toUpperCase().replace("#", "0x");
476
-
477
- },
478
-
479
- u255: function (c, i) {
480
-
481
- return parseInt(c.substring(i, i + 2), 16) / 255;
482
-
483
- },
484
-
485
- u16: function ( c, i ) {
486
-
487
- return parseInt(c.substring(i, i + 1), 16) / 15;
488
-
489
- },
490
-
491
- unpack: function( c ){
492
-
493
- if (c.length == 7) return [ T.u255(c, 1), T.u255(c, 3), T.u255(c, 5) ];
494
- else if (c.length == 4) return [ T.u16(c,1), T.u16(c,2), T.u16(c,3) ];
495
-
496
- },
497
-
498
- p255: function ( c ) {
499
- let h = Math.round( ( c * 255 ) ).toString( 16 );
500
- if ( h.length < 2 ) h = '0' + h;
501
- return h;
502
- },
503
-
504
- pack: function ( c ) {
505
-
506
- return '#' + T.p255( c[ 0 ] ) + T.p255( c[ 1 ] ) + T.p255( c[ 2 ] );
507
-
508
- },
509
-
510
- htmlRgb: function( c ){
511
-
512
- return 'rgb(' + Math.round(c[0] * 255) + ','+ Math.round(c[1] * 255) + ','+ Math.round(c[2] * 255) + ')';
513
-
514
- },
515
-
516
- pad: function( n ){
517
- if(n.length == 1)n = '0' + n;
518
- return n;
519
- },
520
-
521
- rgbToHex : function( c ){
522
-
523
- let r = Math.round(c[0] * 255).toString(16);
524
- let g = Math.round(c[1] * 255).toString(16);
525
- let b = Math.round(c[2] * 255).toString(16);
526
- return '#' + T.pad(r) + T.pad(g) + T.pad(b);
527
-
528
- // return '#' + ( '000000' + ( ( c[0] * 255 ) << 16 ^ ( c[1] * 255 ) << 8 ^ ( c[2] * 255 ) << 0 ).toString( 16 ) ).slice( - 6 );
529
-
530
- },
531
-
532
- hueToRgb: function( p, q, t ){
533
-
534
- if ( t < 0 ) t += 1;
535
- if ( t > 1 ) t -= 1;
536
- if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;
537
- if ( t < 1 / 2 ) return q;
538
- if ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );
539
- return p;
540
-
541
- },
542
-
543
- rgbToHsl: function ( c ) {
544
-
545
- let r = c[0], g = c[1], b = c[2], min = Math.min(r, g, b), max = Math.max(r, g, b), delta = max - min, h = 0, s = 0, l = (min + max) / 2;
546
- if (l > 0 && l < 1) s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
547
- if (delta > 0) {
548
- if (max == r && max != g) h += (g - b) / delta;
549
- if (max == g && max != b) h += (2 + (b - r) / delta);
550
- if (max == b && max != r) h += (4 + (r - g) / delta);
551
- h /= 6;
552
- }
553
- return [ h, s, l ];
554
-
555
- },
556
-
557
- hslToRgb: function ( c ) {
558
-
559
- let p, q, h = c[0], s = c[1], l = c[2];
560
-
561
- if ( s === 0 ) return [ l, l, l ];
562
- else {
563
- q = l <= 0.5 ? l * (s + 1) : l + s - ( l * s );
564
- p = l * 2 - q;
565
- return [ T.hueToRgb(p, q, h + 0.33333), T.hueToRgb(p, q, h), T.hueToRgb(p, q, h - 0.33333) ];
566
- }
567
-
568
- },
569
-
570
- // ----------------------
571
- // SVG MODEL
572
- // ----------------------
573
-
574
- makeGradiant: function ( type, settings, parent, colors ) {
575
-
576
- T.dom( type, null, settings, parent, 0 );
577
-
578
- let n = parent.childNodes[0].childNodes.length - 1, c;
579
-
580
- for( let i = 0; i < colors.length; i++ ){
581
-
582
- c = colors[i];
583
- //T.dom( 'stop', null, { offset:c[0]+'%', style:'stop-color:'+c[1]+'; stop-opacity:'+c[2]+';' }, parent, [0,n] );
584
- T.dom( 'stop', null, { offset:c[0]+'%', 'stop-color':c[1], 'stop-opacity':c[2] }, parent, [0,n] );
585
-
586
- }
587
-
588
- },
589
-
590
- /*makeGraph: function () {
591
-
592
- let w = 128;
593
- let radius = 34;
594
- let svg = T.dom( 'svg', T.css.basic , { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } );
595
- T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':4, fill:'none', 'stroke-linecap':'butt' }, svg );//0
596
- //T.dom( 'rect', '', { x:10, y:10, width:108, height:108, stroke:'rgba(0,0,0,0.3)', 'stroke-width':2 , fill:'none'}, svg );//1
597
- //T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:T.colors.button, stroke:'rgba(0,0,0,0.3)', 'stroke-width':8 }, svg );//0
598
-
599
- //T.dom( 'circle', '', { cx:64, cy:64, r:radius+7, stroke:'rgba(0,0,0,0.3)', 'stroke-width':7 , fill:'none'}, svg );//2
600
- //T.dom( 'path', '', { d:'', stroke:'rgba(255,255,255,0.3)', 'stroke-width':2, fill:'none', 'stroke-linecap':'round', 'stroke-opacity':0.5 }, svg );//3
601
- T.graph = svg;
602
-
603
- },*/
604
-
605
- makePad: function ( model ) {
606
-
607
- let ww = 256
608
- let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+ww+' '+ww, width:ww, height:ww, preserveAspectRatio:'none' } );
609
- let w = 200;
610
- let d = (ww-w)*0.5, m = 20;
611
- Tools.dom( 'rect', '', { x: d, y: d, width: w, height: w, fill:T.colors.back }, svg ); // 0
612
- Tools.dom( 'rect', '', { x: d+m*0.5, y: d+m*0.5, width: w - m , height: w - m, fill:T.colors.button }, svg ); // 1
613
- // Pointer
614
- Tools.dom( 'line', '', { x1: d+(m*0.5), y1: ww *0.5, x2: d+(w-m*0.5), y2: ww * 0.5, stroke:T.colors.back, 'stroke-width': 2 }, svg ); // 2
615
- Tools.dom( 'line', '', { x1: ww * 0.5, x2: ww * 0.5, y1: d+(m*0.5), y2: d+(w-m*0.5), stroke:T.colors.back, 'stroke-width': 2 }, svg ); // 3
616
- Tools.dom( 'circle', '', { cx: ww * 0.5, cy: ww * 0.5, r:5, stroke: T.colors.text, 'stroke-width': 5, fill:'none' }, svg ); // 4
617
- T.pad2d = svg;
618
-
619
- },
620
-
621
- makeKnob: function ( model ) {
622
-
623
- let w = 128;
624
- let radius = 34;
625
- let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } );
626
- T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:T.colors.button, stroke:'rgba(0,0,0,0.3)', 'stroke-width':8 }, svg );//0
627
- T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':4, fill:'none', 'stroke-linecap':'round' }, svg );//1
628
- T.dom( 'circle', '', { cx:64, cy:64, r:radius+7, stroke:'rgba(0,0,0,0.1)', 'stroke-width':7 , fill:'none'}, svg );//2
629
- T.dom( 'path', '', { d:'', stroke:'rgba(255,255,255,0.3)', 'stroke-width':2, fill:'none', 'stroke-linecap':'round', 'stroke-opacity':0.5 }, svg );//3
630
- T.knob = svg;
631
-
632
- },
633
-
634
- makeCircular: function ( model ) {
635
-
636
- let w = 128;
637
- let radius = 40;
638
- let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } );
639
- T.dom( 'circle', '', { cx:64, cy:64, r:radius, stroke:'rgba(0,0,0,0.1)', 'stroke-width':10, fill:'none' }, svg );//0
640
- T.dom( 'path', '', { d:'', stroke:T.colors.text, 'stroke-width':7, fill:'none', 'stroke-linecap':'butt' }, svg );//1
641
- T.circular = svg;
642
-
643
- },
644
-
645
- makeJoystick: function ( model ) {
646
-
647
- //+' background:#f00;'
648
-
649
- let w = 128, ccc;
650
- let radius = Math.floor((w-30)*0.5);
651
- let innerRadius = Math.floor(radius*0.6);
652
- let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } );
653
- T.dom( 'defs', null, {}, svg );
654
- T.dom( 'g', null, {}, svg );
655
-
656
- if( model === 0 ){
657
-
658
-
659
-
660
- // gradian background
661
- ccc = [ [40, 'rgb(0,0,0)', 0.3], [80, 'rgb(0,0,0)', 0], [90, 'rgb(50,50,50)', 0.4], [100, 'rgb(50,50,50)', 0] ];
662
- T.makeGradiant( 'radialGradient', { id:'grad', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc );
663
-
664
- // gradian shadow
665
- ccc = [ [60, 'rgb(0,0,0)', 0.5], [100, 'rgb(0,0,0)', 0] ];
666
- T.makeGradiant( 'radialGradient', { id:'gradS', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc );
667
-
668
- // gradian stick
669
- let cc0 = ['rgb(40,40,40)', 'rgb(48,48,48)', 'rgb(30,30,30)'];
670
- let cc1 = ['rgb(1,90,197)', 'rgb(3,95,207)', 'rgb(0,65,167)'];
671
-
672
- ccc = [ [30, cc0[0], 1], [60, cc0[1], 1], [80, cc0[1], 1], [100, cc0[2], 1] ];
673
- T.makeGradiant( 'radialGradient', { id:'gradIn', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc );
674
-
675
- ccc = [ [30, cc1[0], 1], [60, cc1[1], 1], [80, cc1[1], 1], [100, cc1[2], 1] ];
676
- T.makeGradiant( 'radialGradient', { id:'gradIn2', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc );
677
-
678
- // graph
679
-
680
- T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:'url(#grad)' }, svg );//2
681
- T.dom( 'circle', '', { cx:64+5, cy:64+10, r:innerRadius+10, fill:'url(#gradS)' }, svg );//3
682
- T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius, fill:'url(#gradIn)' }, svg );//4
683
-
684
- T.joystick_0 = svg;
685
-
686
- } else {
687
- // gradian shadow
688
- ccc = [ [69, 'rgb(0,0,0)', 0],[70, 'rgb(0,0,0)', 0.3], [100, 'rgb(0,0,0)', 0] ];
689
- T.makeGradiant( 'radialGradient', { id:'gradX', cx:'50%', cy:'50%', r:'50%', fx:'50%', fy:'50%' }, svg, ccc );
690
-
691
- T.dom( 'circle', '', { cx:64, cy:64, r:radius, fill:'none', stroke:'rgba(100,100,100,0.25)', 'stroke-width':'4' }, svg );//2
692
- T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius+14, fill:'url(#gradX)' }, svg );//3
693
- T.dom( 'circle', '', { cx:64, cy:64, r:innerRadius, fill:'none', stroke:'rgb(100,100,100)', 'stroke-width':'4' }, svg );//4
694
-
695
- T.joystick_1 = svg;
696
- }
697
-
698
-
699
-
700
- },
701
-
702
- makeColorRing: function () {
703
-
704
- let w = 256;
705
- let svg = T.dom( 'svg', T.css.basic + 'position:relative;', { viewBox:'0 0 '+w+' '+w, width:w, height:w, preserveAspectRatio:'none' } );
706
- T.dom( 'defs', null, {}, svg );
707
- T.dom( 'g', null, {}, svg );
708
-
709
- let s = 30;//stroke
710
- let r =( w-s )*0.5;
711
- let mid = w*0.5;
712
- let n = 24, nudge = 8 / r / n * Math.PI, a1 = 0, d1;
713
- let am, tan, d2, a2, ar, i, j, path, ccc;
714
- let color = [];
715
-
716
- for ( i = 0; i <= n; ++i) {
717
-
718
- d2 = i / n;
719
- a2 = d2 * T.TwoPI;
720
- am = (a1 + a2) * 0.5;
721
- tan = 1 / Math.cos((a2 - a1) * 0.5);
722
-
723
- ar = [
724
- Math.sin(a1), -Math.cos(a1),
725
- Math.sin(am) * tan, -Math.cos(am) * tan,
726
- Math.sin(a2), -Math.cos(a2)
727
- ];
728
-
729
- color[1] = T.rgbToHex( T.hslToRgb([d2, 1, 0.5]) );
730
-
731
- if (i > 0) {
732
-
733
- j = 6;
734
- while(j--){
735
- ar[j] = ((ar[j]*r)+mid).toFixed(2);
736
- }
737
-
738
- path = ' M' + ar[0] + ' ' + ar[1] + ' Q' + ar[2] + ' ' + ar[3] + ' ' + ar[4] + ' ' + ar[5];
739
-
740
- ccc = [ [0,color[0],1], [100,color[1],1] ];
741
- T.makeGradiant( 'linearGradient', { id:'G'+i, x1:ar[0], y1:ar[1], x2:ar[4], y2:ar[5], gradientUnits:"userSpaceOnUse" }, svg, ccc );
742
-
743
- T.dom( 'path', '', { d:path, 'stroke-width':s, stroke:'url(#G'+i+')', 'stroke-linecap':"butt" }, svg, 1 );
744
-
745
- }
746
- a1 = a2 - nudge;
747
- color[0] = color[1];
748
- d1 = d2;
749
- }
750
-
751
- let br = (128 - s ) + 2;
752
- let bw = 60;
753
-
754
- let tw = 84.90;
755
-
756
- // black / white
757
- ccc = [ [0, '#FFFFFF', 1], [50, '#FFFFFF', 0], [50, '#000000', 0], [100, '#000000', 1] ];
758
- T.makeGradiant( 'linearGradient', { id:'GL0', x1:0, y1:mid-tw, x2:0, y2:mid+tw, gradientUnits:"userSpaceOnUse" }, svg, ccc );
759
-
760
- ccc = [ [0, '#7f7f7f', 1], [50, '#7f7f7f', 0.5], [100, '#7f7f7f', 0] ];
761
- T.makeGradiant( 'linearGradient', { id:'GL1', x1:mid-49.05, y1:0, x2:mid+98, y2:0, gradientUnits:"userSpaceOnUse" }, svg, ccc );
762
-
763
- T.dom( 'g', null, { 'transform-origin': '128px 128px', 'transform':'rotate(0)' }, svg );//2
764
- T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'red' }, svg, 2 );// 2,0
765
- T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'url(#GL1)','stroke-width':1, stroke:'url(#GL1)' }, svg, 2 );//2,1
766
- T.dom( 'polygon', '', { points:'78.95 43.1 78.95 212.85 226 128', fill:'url(#GL0)','stroke-width':1, stroke:'url(#GL0)' }, svg, 2 );//2,2
767
- T.dom( 'path', '', { d:'M 255.75 136.5 Q 256 132.3 256 128 256 123.7 255.75 119.5 L 241 128 255.75 136.5 Z', fill:'none','stroke-width':2, stroke:'#000' }, svg, 2 );//2,3
768
- //T.dom( 'circle', '', { cx:128+113, cy:128, r:6, 'stroke-width':3, stroke:'#000', fill:'none' }, svg, 2 );//2.3
769
-
770
- T.dom( 'circle', '', { cx:128, cy:128, r:6, 'stroke-width':2, stroke:'#000', fill:'none' }, svg );//3
771
-
772
- T.colorRing = svg;
773
-
774
- },
775
-
776
- icon: function ( type, color, w ){
777
-
778
- w = w || 40;
779
- //color = color || '#DEDEDE';
780
- let viewBox = '0 0 256 256';
781
- //let viewBox = '0 0 '+ w +' '+ w;
782
- let t = ["<svg xmlns='"+T.svgns+"' version='1.1' xmlns:xlink='"+T.htmls+"' style='pointer-events:none;' preserveAspectRatio='xMinYMax meet' x='0px' y='0px' width='"+w+"px' height='"+w+"px' viewBox='"+viewBox+"'><g>"];
783
- switch(type){
784
- case 'logo':
785
- t[1]="<path id='logoin' fill='"+color+"' stroke='none' d='"+T.logoFill_d+"'/>";
786
- break;
787
- case 'neo':
788
- t[1]="<path id='logoin' fill='"+color+"' stroke='none' d='"+T.logo_neo+"'/>";
789
- break;
790
- case 'github':
791
- t[1]="<path id='logoin' fill='"+color+"' stroke='none' d='"+T.logo_github+"'/>";
792
- break;
793
- case 'save':
794
- t[1]="<path stroke='"+color+"' stroke-width='4' stroke-linejoin='round' stroke-linecap='round' fill='none' d='M 26.125 17 L 20 22.95 14.05 17 M 20 9.95 L 20 22.95'/><path stroke='"+color;
795
- t[1]+="' stroke-width='2.5' stroke-linejoin='round' stroke-linecap='round' fill='none' d='M 32.6 23 L 32.6 25.5 Q 32.6 28.5 29.6 28.5 L 10.6 28.5 Q 7.6 28.5 7.6 25.5 L 7.6 23'/>";
796
- break;
797
- }
798
- t[2] = "</g></svg>";
799
- return t.join("\n");
800
-
801
- },
802
-
803
- logoFill_d:`
804
- M 171 150.75 L 171 33.25 155.5 33.25 155.5 150.75 Q 155.5 162.2 147.45 170.2 139.45 178.25 128 178.25 116.6 178.25 108.55 170.2 100.5 162.2 100.5 150.75
805
- L 100.5 33.25 85 33.25 85 150.75 Q 85 168.65 97.55 181.15 110.15 193.75 128 193.75 145.9 193.75 158.4 181.15 171 168.65 171 150.75
806
- M 200 33.25 L 184 33.25 184 150.8 Q 184 174.1 167.6 190.4 151.3 206.8 128 206.8 104.75 206.8 88.3 190.4 72 174.1 72 150.8 L 72 33.25 56 33.25 56 150.75
807
- Q 56 180.55 77.05 201.6 98.2 222.75 128 222.75 157.8 222.75 178.9 201.6 200 180.55 200 150.75 L 200 33.25 Z
808
- `,
809
-
810
- logo_github:`
811
- M 180.5 70 Q 186.3 82.4 181.55 96.55 196.5 111.5 189.7 140.65 183.65 168.35 146 172.7 152.5 178.7 152.55 185.9 L 152.55 218.15 Q 152.84 224.56 159.15 223.3
812
- 159.21 223.3 159.25 223.3 181.14 216.25 198.7 198.7 228 169.4 228 128 228 86.6 198.7 57.3 169.4 28 128 28 86.6 28 57.3 57.3 28 86.6 28 128 28 169.4 57.3 198.7 74.85
813
- 216.25 96.75 223.3 96.78 223.3 96.8 223.3 103.16 224.54 103.45 218.15 L 103.45 200 Q 82.97 203.1 75.1 196.35 69.85 191.65 68.4 185.45 64.27 177.055 59.4 174.15 49.20
814
- 166.87 60.8 167.8 69.85 169.61 75.7 180 81.13 188.09 90 188.55 98.18 188.86 103.45 185.9 103.49 178.67 110 172.7 72.33 168.33 66.3 140.65 59.48 111.49 74.45 96.55 69.7
815
- 82.41 75.5 70 84.87 68.74 103.15 80 115.125 76.635 128 76.85 140.85 76.65 152.85 80 171.1 68.75 180.5 70 Z
816
- `,
817
-
818
- logo_neo:`
819
- M 219 52 L 206 52 206 166 Q 206 183.4 193.75 195.65 181.4 208 164 208 146.6 208 134.35 195.65 122 183.4 122 166 L 122 90 Q 122 77.6 113.15 68.85 104.4 60 92 60 79.55
820
- 60 70.75 68.85 62 77.6 62 90 L 62 204 75 204 75 90 Q 75 83 79.95 78 84.95 73 92 73 99 73 104 78 109 83 109 90 L 109 166 Q 109 188.8 125.15 204.85 141.2 221 164 221
821
- 186.75 221 202.95 204.85 219 188.8 219 166 L 219 52 M 194 52 L 181 52 181 166 Q 181 173 176.05 178 171.05 183 164 183 157 183 152 178 147 173 147 166 L 147 90 Q 147
822
- 67.2 130.85 51.15 114.8 35 92 35 69.25 35 53.05 51.15 37 67.2 37 90 L 37 204 50 204 50 90 Q 50 72.6 62.25 60.35 74.6 48 92 48 109.4 48 121.65 60.35 134 72.6 134 90 L
823
- 134 166 Q 134 178.4 142.85 187.15 151.6 196 164 196 176.45 196 185.25 187.15 194 178.4 194 166 L 194 52 Z
824
- `,
825
-
826
- }
827
-
828
- T.setText();
829
-
830
- export const Tools = T;