class module_Config { width = 0 ; height = 0 ; content_node = null ; is_autobuild = true ; color = 1 ; background_rgba = 0 ; deg = 1 ; PALETTE = [ "000000", "FFFFFF","3388FF","33EEFF","33FF88","88FF33","FFEE33","FF8833","FF2211","FF3388","8866FF", "EEEEEE","2255CC","22BBCC","22CC55","55CC22","CCBB22","CC5522","CC1111","CC2255","5544CC", "DDDDDD","114499","118899","119944","449911","998811","994411","990000","991144","443399", "BBBBBB","113364","115566","116633","336611","665511","663311","661111","661133","332266", "999999","041A3A","042A3A","043A1A","1A3A00","3A2A04","3A1A04","3A0404","3A041A","1A113A", "777777","556688","558899","558866","668855","888855","886655","885555","885566","665588", "555555","88AACC","88BBCC","88CCBB","BBCC88","CCCC88","CCBB88","CC8888","CC88BB","BB88CC", "333333","BBCCFF","BBEEFF","BBFFEE","EEFFCC","FFFFBB","FFEEBB","FFCCCC","FFBBEE","EEBBFF", "222222","5566FF","33AAFF","33FFBB","66FF66","DDFF33","FFBB33","FF5522","FF2255","CC33CC", "111111","445566","778899","AABBCC","DDEEFF","665544","998877","CCBBAA","000000" ] ; constructor() { this.degree(true); this.content_node = µB.task_node.querySelector("ARTICLE") ; this.content_node.style.aspectRatio = µB.CONFIG.ratio ; if( µB.CONFIG.monitor == 0 ) µB.CONFIG.monitor = screen.height ; let aspect = µB.CONFIG.monitor / screen.height; let width = Math.round(screen.width * aspect) ; let height = Math.round(screen.height * aspect) ; let format = this.GetBestFormat(µB.CONFIG.ratio, width, height) ; this.width = format.width ; this.height = format.height ; } GetBestOrientation() { const portrait_size = this.GetBestFormat(µB.CONFIG.ratio); const landscape_size = getMaxSizeForRatio(1/µB.CONFIG.ratio); const portrait_area = portrait_size.width * portrait_size.height; const landscape_area = landscape_size.width * landscape_size.height; return landscape_area > portrait_area ? "landscape" : "portrait"; } GetBestFormat(ratio, target_width, target_height) { const avail_ratio = target_width / target_height ; let max_width, max_height; if( avail_ratio > ratio ) { max_height = target_height ; max_width = max_height * ratio; } else { max_width = target_width; max_height = max_width / ratio; } return { width: Math.round(max_width), height: Math.round(max_height) }; } GetEnum( value ) { let str = String(value); return str.trim().toLowerCase(); } Color2Hex24( color ) { let c = this.Color2Hex(color); return Number( "0x"+c.substring(1,7) ); } Color2Rgba( color ) { let hex = this.Color2Hex(color); let RGBA = {} ; RGBA.r = parseInt(hex.substring(1,3),16)/255 ; RGBA.g = parseInt(hex.substring(3,5),16)/255 ; RGBA.b = parseInt(hex.substring(5,7),16)/255 ; RGBA.a = parseInt(hex.substring(7,9),16)/255 ; return RGBA ; } Color2Hex( color ) { if( typeof color === 'string' && color.substring(0,1)=="#" ) { if( color.length == 4 || color.length == 5 ) { let r = color.substring(1,2); let g = color.substring(2,3); let b = color.substring(3,4); let a = color.length==5 ? color.substring(4,5) : "F"; return "#"+r+r+g+g+b+b+a+a; } else if( color.length == 7 || color.length == 9 ) { let r = color.substring(1,3); let g = color.substring(3,5); let b = color.substring(5,7); let a = color.length==9 ? color.substring(7,9) : "F"; return "#"+r+g+b+a; } } else if( this.PALETTE[color] ) { return "#"+this.PALETTE[color] + "FF" ; } return "#FF00FFFF" ; } Rgba2Hex(r, g, b, a) { r = Zero(MinMax(Math.floor(r*2.55),0,255).toString(16),2) ; g = Zero(MinMax(Math.floor(g*2.55),0,255).toString(16),2) ; b = Zero(MinMax(Math.floor(b*2.55),0,255).toString(16),2) ; a = Zero(MinMax(Math.floor(a*2.55),0,255).toString(16),2) ; return "#" + r + g + b + a ; } autobuild(mode) { this.is_autobuild = mode == 1 ? true : false ; Log( "AUTOBUILD="+this.is_autobuild); } background(color) { this.background_rgba = this.Color2Hex(color); this.content_node.style.backgroundColor = this.background_rgba ; } set_color(color) { this.color = color ; µB.$D2.SetColor(this.color); } rgb(r, g, b) { this.color = this.Rgba2Hex(r, g, b, 100) ; µB.$D2.SetColor(this.color); } rgba(r, g, b, a) { this.color = this.Rgba2Hex(r, g, b, a) ; µB.$D2.SetColor(this.color); } degree() { this.deg = Math.PI/180.0 ; } radian() { this.deg = 1 ; } /* autoupdate(mode) { this.is_autoupdate = mode; } */ screen_size_native() { this.screen_size(screen.width,screen.height); } screen_get_width() { return this.width ; } screen_get_height() { return this.height ; } screen_size(x, y) { this.width = x; this.height = y; µB.$Basic.Screen.Resize(x,y); µB.$D2.Resize(x, y); µB.$D3.Resize(x, y); } get_frame() { return µB.FPS.frame ; } get_calls() { return µB.$D3.$Renderer.info.render.calls ; } get_fps() { return Math.round(µB.FPS.average); } };