// Generated by Haxe 3.4.2 (function ($hx_exports, $global) { "use strict"; $hx_exports["kha"] = $hx_exports["kha"] || {}; $hx_exports["kha"]["input"] = $hx_exports["kha"]["input"] || {}; ;$hx_exports["kha"]["_Color"] = $hx_exports["kha"]["_Color"] || {}; var $hxClasses = {},$estr = function() { return js_Boot.__string_rec(this,''); }; function $extend(from, fields) { function Inherit() {} Inherit.prototype = from; var proto = new Inherit(); for (var name in fields) proto[name] = fields[name]; if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; return proto; } var EReg = function(r,opt) { this.r = new RegExp(r,opt.split("u").join("")); }; $hxClasses["EReg"] = EReg; EReg.__name__ = true; EReg.prototype = { r: null ,match: function(s) { if(this.r.global) { this.r.lastIndex = 0; } this.r.m = this.r.exec(s); this.r.s = s; return this.r.m != null; } ,matched: function(n) { if(this.r.m != null && n >= 0 && n < this.r.m.length) { return this.r.m[n]; } else { throw new js__$Boot_HaxeError("EReg::matched"); } } ,__class__: EReg }; var Elements = function(canvas) { this.drag = false; this.handleradio = zui_Handle.global.nest(4,null); this.handlewin = zui_Handle.global.nest(0,null); this.selectedElem = -1; this.bg = null; this.initialized = false; this.canvas = canvas; var _onDrop = $bind(this,this.onDrop); document.ondragover = document.ondrop = (ev) => { ev.preventDefault() } document.body.ondrop = (ev) => { _onDrop(ev.dataTransfer.files[0].path); ev.preventDefault() } ; kha_Assets.loadEverything($bind(this,this.loadingFinished)); }; $hxClasses["Elements"] = Elements; Elements.__name__ = true; Elements.prototype = { ui: null ,cui: null ,initialized: null ,bg: null ,canvas: null ,onDrop: function(file) { var _gthis = this; kha_LoaderImpl.loadImageFromDescription({ files : [file]},function(image) { var s = file.split("/"); var name = s[s.length - 1]; var asset = { name : name, file : file, image : image}; _gthis.canvas.assets.push(asset); }); } ,loadingFinished: function() { this.initialized = true; var t = Reflect.copy(zui_Themes.dark); t.FILL_WINDOW_BG = true; this.ui = new zui_Zui({ font : kha_Assets.fonts.DroidSans, theme : t}); this.cui = new zui_Zui({ font : kha_Assets.fonts.DroidSans, autoNotifyInput : false}); } ,makeElem: function(type) { var name = ""; var height = 100; if(type == 0) { name = "Text"; height = 48; } else if(type == 2) { name = "Button"; } else if(type == 1) { name = "Image"; } var elem = { id : 0, type : type, name : name, event : "", x : 0, y : 0, width : 150, height : height, text : name, asset : "", color : 16777215, anchor : 0, children : []}; return elem; } ,selectedElem: null ,handlewin: null ,handleradio: null ,render: function(framebuffer) { if(!this.initialized) { return; } if(this.bg == null) { var w = kha_System.windowWidth(); var h = kha_System.windowHeight(); this.bg = kha_Image.createRenderTarget(w,h); this.bg.get_g2().begin(true,-15461356); var _g1 = 0; var _g = (h / 40 | 0) + 1; while(_g1 < _g) { var i = _g1++; this.bg.get_g2().set_color(-13619152); this.bg.get_g2().drawLine(0,i * 40,w,i * 40); this.bg.get_g2().set_color(-14671840); this.bg.get_g2().drawLine(0,i * 40 + 20,w,i * 40 + 20); } var _g11 = 0; var _g2 = (w / 40 | 0) + 1; while(_g11 < _g2) { var i1 = _g11++; this.bg.get_g2().set_color(-13619152); this.bg.get_g2().drawLine(i1 * 40,0,i1 * 40,h); this.bg.get_g2().set_color(-14671840); this.bg.get_g2().drawLine(i1 * 40 + 20,0,i1 * 40 + 20,h); } this.bg.get_g2().set_color(-1); var tmp = kha_System.windowWidth() - this.canvas.width; this.canvas.x = tmp - 20; this.canvas.y = 40; this.bg.get_g2().drawRect(this.canvas.x,this.canvas.y,this.canvas.width,this.canvas.height,1.0); this.bg.get_g2().end(); } var g = framebuffer.get_g2(); g.begin(); g.drawImage(this.bg,0,0); g.set_font(kha_Assets.fonts.DroidSans); g.set_fontSize(40); var title = this.canvas.name + ", " + this.canvas.width + "x" + this.canvas.height; var titlew = g.get_font().width(40,title); var titleh = g.get_font().height(40); g.set_color(-1); g.drawString(title,kha_System.windowWidth() - titlew - 30,kha_System.windowHeight() - titleh - 10); zui_Canvas.draw(this.cui,this.canvas,g); if(this.selectedElem >= 0 && this.selectedElem < this.canvas.elements.length) { var elem = this.canvas.elements[this.selectedElem]; g.set_color(-1); g.drawRect(this.canvas.x + elem.x,this.canvas.y + elem.y,elem.width,elem.height,1); } g.end(); this.ui.begin(g); if(this.ui.window(this.handlewin,0,0,240,640,false)) { if(this.ui.panel(zui_Handle.global.nest(1,{ selected : true}),"CANVAS")) { if(this.ui.button("Save")) { var fs = require('fs'); fs.writeFileSync(Main.prefs.path, JSON.stringify(this.canvas)); } var tmp1 = this.ui; var tmp2 = zui_Handle.global.nest(2,{ text : this.canvas.name}); this.canvas.name = tmp1.textInput(tmp2,"Name",2); } this.ui.separator(); if(this.ui.panel(zui_Handle.global.nest(3,{ selected : true}),"TREE")) { this.ui.row([0.333333333333333315,0.333333333333333315,0.333333333333333315]); if(this.ui.button("Text")) { var elem1 = this.makeElem(0); this.canvas.elements.push(elem1); this.handleradio.position = this.canvas.elements.length - 1; } if(this.ui.button("Image")) { var elem2 = this.makeElem(1); this.canvas.elements.push(elem2); this.handleradio.position = this.canvas.elements.length - 1; } if(this.ui.button("Button")) { var elem3 = this.makeElem(2); this.canvas.elements.push(elem3); this.handleradio.position = this.canvas.elements.length - 1; } var i2 = 0; var _g3 = 0; var _g12 = this.canvas.elements; while(_g3 < _g12.length) { var elem4 = _g12[_g3]; ++_g3; if(this.ui.radio(this.handleradio,i2++,elem4.name)) { this.selectedElem = i2 - 1; } } if(this.canvas.elements.length > 0) { if(this.ui.button("Remove")) { this.canvas.elements.splice(this.selectedElem,1); if(this.selectedElem <= this.canvas.elements.length) { this.selectedElem--; this.handleradio.position = this.selectedElem; } } } } this.ui.separator(); if(this.ui.panel(zui_Handle.global.nest(5,{ selected : true}),"PROPERTIES")) { var i3 = this.selectedElem; if(i3 >= 0) { var elem5 = this.canvas.elements[i3]; this.ui.row([0.5,0.5]); elem5.name = this.ui.textInput(zui_Handle.global.nest(6,null).nest(i3,{ text : elem5.name}),"Name",2); elem5.text = this.ui.textInput(zui_Handle.global.nest(7,null).nest(i3,{ text : elem5.text}),"Text",2); this.ui.row([0.5,0.5]); elem5.event = this.ui.textInput(zui_Handle.global.nest(8,null).nest(i3,{ text : elem5.event}),"Event",2); elem5.asset = this.ui.textInput(zui_Handle.global.nest(9,null).nest(i3,{ text : elem5.asset}),"Asset",2); this.ui.row([0.5,0.5]); var handlex = elem5.x + ""; var handlex1 = zui_Handle.global.nest(10,null).nest(i3,{ text : handlex}); var handley = elem5.y + ""; var handley1 = zui_Handle.global.nest(11,null).nest(i3,{ text : handley}); handlex1.text = elem5.x + ""; handley1.text = elem5.y + ""; var strx = this.ui.textInput(handlex1,"X",2); var stry = this.ui.textInput(handley1,"Y",2); elem5.x = parseFloat(strx); elem5.y = parseFloat(stry); this.ui.row([0.5,0.5]); var strw = elem5.width + ""; var strw1 = this.ui.textInput(zui_Handle.global.nest(12,null).nest(i3,{ text : strw}),"Width",2); var strh = elem5.height + ""; var strh1 = this.ui.textInput(zui_Handle.global.nest(13,null).nest(i3,{ text : strh}),"Height",2); elem5.width = parseFloat(strw1) | 0; elem5.height = parseFloat(strh1) | 0; this.ui.row([0.5,0.5]); var strcol = this.ui.textInput(zui_Handle.global.nest(14,null).nest(i3,{ text : "#ffffff"}),"Color",2); var stranch = elem5.anchor + ""; var stranch1 = this.ui.textInput(zui_Handle.global.nest(15,null).nest(i3,{ text : stranch}),"Anchor",2); elem5.color = kha__$Color_Color_$Impl_$.fromString(strcol); elem5.anchor = parseFloat(stranch1) | 0; } } this.ui.separator(); if(this.ui.panel(zui_Handle.global.nest(16,{ selected : true}),"ASSETS")) { if(this.canvas.assets.length > 0) { var _g13 = 0; var _g4 = this.canvas.assets.length; while(_g13 < _g4) { var i4 = _g13++; var asset = this.canvas.assets[i4]; this.ui.image(asset.image); asset.name = this.ui.textInput(zui_Handle.global.nest(17,null).nest(i4,{ text : asset.name}),"Name",2); } } else { this.ui.text("Drag & drop assets here"); } } } this.ui.end(); } ,drag: null ,update: function() { if(!this.initialized) { return; } if(this.selectedElem >= 0 && this.selectedElem < this.canvas.elements.length) { var elem = this.canvas.elements[this.selectedElem]; if(this.ui.inputStarted && this.ui.inputX > this.canvas.x + elem.x && this.ui.inputX < this.canvas.x + elem.x + elem.width && this.ui.inputY > this.canvas.y + elem.y && this.ui.inputY < this.canvas.y + elem.y + elem.height) { this.drag = true; } if(this.ui.inputReleased && this.drag) { this.drag = false; } if(this.drag) { this.handlewin.redraws = 2; elem.x += this.ui.inputDX; elem.y += this.ui.inputDY; } } } ,__class__: Elements }; var HxOverrides = function() { }; $hxClasses["HxOverrides"] = HxOverrides; HxOverrides.__name__ = true; HxOverrides.strDate = function(s) { var _g = s.length; switch(_g) { case 8: var k = s.split(":"); var d = new Date(); d["setTime"](0); d["setUTCHours"](k[0]); d["setUTCMinutes"](k[1]); d["setUTCSeconds"](k[2]); return d; case 10: var k1 = s.split("-"); return new Date(k1[0],k1[1] - 1,k1[2],0,0,0); case 19: var k2 = s.split(" "); var y = k2[0].split("-"); var t = k2[1].split(":"); return new Date(y[0],y[1] - 1,y[2],t[0],t[1],t[2]); default: throw new js__$Boot_HaxeError("Invalid date format : " + s); } }; HxOverrides.cca = function(s,index) { var x = s.charCodeAt(index); if(x != x) { return undefined; } return x; }; HxOverrides.substr = function(s,pos,len) { if(len == null) { len = s.length; } else if(len < 0) { if(pos == 0) { len = s.length + len; } else { return ""; } } return s.substr(pos,len); }; HxOverrides.remove = function(a,obj) { var i = a.indexOf(obj); if(i == -1) { return false; } a.splice(i,1); return true; }; HxOverrides.iter = function(a) { return { cur : 0, arr : a, hasNext : function() { return this.cur < this.arr.length; }, next : function() { return this.arr[this.cur++]; }}; }; var Lambda = function() { }; $hxClasses["Lambda"] = Lambda; Lambda.__name__ = true; Lambda.array = function(it) { var a = []; var i = $iterator(it)(); while(i.hasNext()) { var i1 = i.next(); a.push(i1); } return a; }; var List = function() { this.length = 0; }; $hxClasses["List"] = List; List.__name__ = true; List.prototype = { h: null ,q: null ,length: null ,add: function(item) { var x = new _$List_ListNode(item,null); if(this.h == null) { this.h = x; } else { this.q.next = x; } this.q = x; this.length++; } ,remove: function(v) { var prev = null; var l = this.h; while(l != null) { if(l.item == v) { if(prev == null) { this.h = l.next; } else { prev.next = l.next; } if(this.q == l) { this.q = prev; } this.length--; return true; } prev = l; l = l.next; } return false; } ,iterator: function() { return new _$List_ListIterator(this.h); } ,__class__: List }; var _$List_ListNode = function(item,next) { this.item = item; this.next = next; }; $hxClasses["_List.ListNode"] = _$List_ListNode; _$List_ListNode.__name__ = true; _$List_ListNode.prototype = { item: null ,next: null ,__class__: _$List_ListNode }; var _$List_ListIterator = function(head) { this.head = head; }; $hxClasses["_List.ListIterator"] = _$List_ListIterator; _$List_ListIterator.__name__ = true; _$List_ListIterator.prototype = { head: null ,hasNext: function() { return this.head != null; } ,next: function() { var val = this.head.item; this.head = this.head.next; return val; } ,__class__: _$List_ListIterator }; var Main = function() { }; $hxClasses["Main"] = Main; Main.__name__ = true; Main.main = function() { kha_System.init({ title : "ArmorUI", width : 1240, height : 640},Main.initialized); }; Main.initialized = function() { kha_LoaderImpl.loadBlobFromDescription({ files : ["prefs.json"]},function(blob) { Main.prefs = JSON.parse(blob.toString()); kha_LoaderImpl.loadBlobFromDescription({ files : [Main.prefs.path]},function(cblob) { var raw = JSON.parse(cblob.toString()); var inst = new Elements(raw); kha_System.notifyOnRender($bind(inst,inst.render)); kha_Scheduler.addTimeTask($bind(inst,inst.update),0,0.0166666666666666664); }); }); }; Math.__name__ = true; var Reflect = function() { }; $hxClasses["Reflect"] = Reflect; Reflect.__name__ = true; Reflect.field = function(o,field) { try { return o[field]; } catch( e ) { return null; } }; Reflect.fields = function(o) { var a = []; if(o != null) { var hasOwnProperty = Object.prototype.hasOwnProperty; for( var f in o ) { if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) { a.push(f); } } } return a; }; Reflect.isFunction = function(f) { if(typeof(f) == "function") { return !(f.__name__ || f.__ename__); } else { return false; } }; Reflect.copy = function(o) { var o2 = { }; var _g = 0; var _g1 = Reflect.fields(o); while(_g < _g1.length) { var f = _g1[_g]; ++_g; o2[f] = Reflect.field(o,f); } return o2; }; var Std = function() { }; $hxClasses["Std"] = Std; Std.__name__ = true; Std.string = function(s) { return js_Boot.__string_rec(s,""); }; Std.parseInt = function(x) { var v = parseInt(x,10); if(v == 0 && (HxOverrides.cca(x,1) == 120 || HxOverrides.cca(x,1) == 88)) { v = parseInt(x); } if(isNaN(v)) { return null; } return v; }; var StringTools = function() { }; $hxClasses["StringTools"] = StringTools; StringTools.__name__ = true; StringTools.endsWith = function(s,end) { var elen = end.length; var slen = s.length; if(slen >= elen) { return HxOverrides.substr(s,slen - elen,elen) == end; } else { return false; } }; var Type = function() { }; $hxClasses["Type"] = Type; Type.__name__ = true; Type.resolveClass = function(name) { var cl = $hxClasses[name]; if(cl == null || !cl.__name__) { return null; } return cl; }; Type.resolveEnum = function(name) { var e = $hxClasses[name]; if(e == null || !e.__ename__) { return null; } return e; }; Type.createEmptyInstance = function(cl) { function empty() {}; empty.prototype = cl.prototype; return new empty(); }; Type.createEnum = function(e,constr,params) { var f = Reflect.field(e,constr); if(f == null) { throw new js__$Boot_HaxeError("No such constructor " + constr); } if(Reflect.isFunction(f)) { if(params == null) { throw new js__$Boot_HaxeError("Constructor " + constr + " need parameters"); } return f.apply(e,params); } if(params != null && params.length != 0) { throw new js__$Boot_HaxeError("Constructor " + constr + " does not need parameters"); } return f; }; Type.createEnumIndex = function(e,index,params) { var c = e.__constructs__[index]; if(c == null) { throw new js__$Boot_HaxeError(index + " is not a valid enum constructor index"); } return Type.createEnum(e,c,params); }; Type.getInstanceFields = function(c) { var a = []; for(var i in c.prototype) a.push(i); HxOverrides.remove(a,"__class__"); HxOverrides.remove(a,"__properties__"); return a; }; var _$UInt_UInt_$Impl_$ = {}; $hxClasses["_UInt.UInt_Impl_"] = _$UInt_UInt_$Impl_$; _$UInt_UInt_$Impl_$.__name__ = true; _$UInt_UInt_$Impl_$.gt = function(a,b) { var aNeg = a < 0; var bNeg = b < 0; if(aNeg != bNeg) { return aNeg; } else { return a > b; } }; _$UInt_UInt_$Impl_$.gte = function(a,b) { var aNeg = a < 0; var bNeg = b < 0; if(aNeg != bNeg) { return aNeg; } else { return a >= b; } }; _$UInt_UInt_$Impl_$.toFloat = function(this1) { var $int = this1; if($int < 0) { return 4294967296.0 + $int; } else { return $int + 0.0; } }; var haxe_IMap = function() { }; $hxClasses["haxe.IMap"] = haxe_IMap; haxe_IMap.__name__ = true; haxe_IMap.prototype = { iterator: null ,__class__: haxe_IMap }; var haxe__$Int64__$_$_$Int64 = function(high,low) { this.high = high; this.low = low; }; $hxClasses["haxe._Int64.___Int64"] = haxe__$Int64__$_$_$Int64; haxe__$Int64__$_$_$Int64.__name__ = true; haxe__$Int64__$_$_$Int64.prototype = { high: null ,low: null ,__class__: haxe__$Int64__$_$_$Int64 }; var haxe_Log = function() { }; $hxClasses["haxe.Log"] = haxe_Log; haxe_Log.__name__ = true; haxe_Log.trace = function(v,infos) { js_Boot.__trace(v,infos); }; var haxe__$Unserializer_DefaultResolver = function() { }; $hxClasses["haxe._Unserializer.DefaultResolver"] = haxe__$Unserializer_DefaultResolver; haxe__$Unserializer_DefaultResolver.__name__ = true; haxe__$Unserializer_DefaultResolver.prototype = { resolveClass: function(name) { return Type.resolveClass(name); } ,resolveEnum: function(name) { return Type.resolveEnum(name); } ,__class__: haxe__$Unserializer_DefaultResolver }; var haxe_Unserializer = function(buf) { this.buf = buf; this.length = buf.length; this.pos = 0; this.scache = []; this.cache = []; var r = haxe_Unserializer.DEFAULT_RESOLVER; if(r == null) { r = new haxe__$Unserializer_DefaultResolver(); haxe_Unserializer.DEFAULT_RESOLVER = r; } this.resolver = r; }; $hxClasses["haxe.Unserializer"] = haxe_Unserializer; haxe_Unserializer.__name__ = true; haxe_Unserializer.initCodes = function() { var codes = []; var _g1 = 0; var _g = haxe_Unserializer.BASE64.length; while(_g1 < _g) { var i = _g1++; codes[haxe_Unserializer.BASE64.charCodeAt(i)] = i; } return codes; }; haxe_Unserializer.run = function(v) { return new haxe_Unserializer(v).unserialize(); }; haxe_Unserializer.prototype = { buf: null ,pos: null ,length: null ,cache: null ,scache: null ,resolver: null ,readDigits: function() { var k = 0; var s = false; var fpos = this.pos; while(true) { var c = this.buf.charCodeAt(this.pos); if(c != c) { break; } if(c == 45) { if(this.pos != fpos) { break; } s = true; this.pos++; continue; } if(c < 48 || c > 57) { break; } k = k * 10 + (c - 48); this.pos++; } if(s) { k *= -1; } return k; } ,readFloat: function() { var p1 = this.pos; while(true) { var c = this.buf.charCodeAt(this.pos); if(c != c) { break; } if(c >= 43 && c < 58 || c == 101 || c == 69) { this.pos++; } else { break; } } return parseFloat(HxOverrides.substr(this.buf,p1,this.pos - p1)); } ,unserializeObject: function(o) { while(true) { if(this.pos >= this.length) { throw new js__$Boot_HaxeError("Invalid object"); } if(this.buf.charCodeAt(this.pos) == 103) { break; } var k = this.unserialize(); if(typeof(k) != "string") { throw new js__$Boot_HaxeError("Invalid object key"); } var v = this.unserialize(); o[k] = v; } this.pos++; } ,unserializeEnum: function(edecl,tag) { if(this.buf.charCodeAt(this.pos++) != 58) { throw new js__$Boot_HaxeError("Invalid enum format"); } var nargs = this.readDigits(); if(nargs == 0) { return Type.createEnum(edecl,tag); } var args = []; while(nargs-- > 0) args.push(this.unserialize()); return Type.createEnum(edecl,tag,args); } ,unserialize: function() { var _g = this.buf.charCodeAt(this.pos++); switch(_g) { case 65: var name = this.unserialize(); var cl = this.resolver.resolveClass(name); if(cl == null) { throw new js__$Boot_HaxeError("Class not found " + name); } return cl; case 66: var name1 = this.unserialize(); var e = this.resolver.resolveEnum(name1); if(e == null) { throw new js__$Boot_HaxeError("Enum not found " + name1); } return e; case 67: var name2 = this.unserialize(); var cl1 = this.resolver.resolveClass(name2); if(cl1 == null) { throw new js__$Boot_HaxeError("Class not found " + name2); } var o = Type.createEmptyInstance(cl1); this.cache.push(o); o.hxUnserialize(this); if(this.buf.charCodeAt(this.pos++) != 103) { throw new js__$Boot_HaxeError("Invalid custom data"); } return o; case 77: var h = new haxe_ds_ObjectMap(); this.cache.push(h); var buf = this.buf; while(this.buf.charCodeAt(this.pos) != 104) { var s = this.unserialize(); h.set(s,this.unserialize()); } this.pos++; return h; case 82: var n = this.readDigits(); if(n < 0 || n >= this.scache.length) { throw new js__$Boot_HaxeError("Invalid string reference"); } return this.scache[n]; case 97: var buf1 = this.buf; var a = []; this.cache.push(a); while(true) { var c = this.buf.charCodeAt(this.pos); if(c == 104) { this.pos++; break; } if(c == 117) { this.pos++; var n1 = this.readDigits(); a[a.length + n1 - 1] = null; } else { a.push(this.unserialize()); } } return a; case 98: var h1 = new haxe_ds_StringMap(); this.cache.push(h1); var buf2 = this.buf; while(this.buf.charCodeAt(this.pos) != 104) { var s1 = this.unserialize(); var value = this.unserialize(); if(__map_reserved[s1] != null) { h1.setReserved(s1,value); } else { h1.h[s1] = value; } } this.pos++; return h1; case 99: var name3 = this.unserialize(); var cl2 = this.resolver.resolveClass(name3); if(cl2 == null) { throw new js__$Boot_HaxeError("Class not found " + name3); } var o1 = Type.createEmptyInstance(cl2); this.cache.push(o1); this.unserializeObject(o1); return o1; case 100: return this.readFloat(); case 102: return false; case 105: return this.readDigits(); case 106: var name4 = this.unserialize(); var edecl = this.resolver.resolveEnum(name4); if(edecl == null) { throw new js__$Boot_HaxeError("Enum not found " + name4); } this.pos++; var index = this.readDigits(); var tag = edecl.__constructs__.slice()[index]; if(tag == null) { throw new js__$Boot_HaxeError("Unknown enum index " + name4 + "@" + index); } var e1 = this.unserializeEnum(edecl,tag); this.cache.push(e1); return e1; case 107: return NaN; case 108: var l = new List(); this.cache.push(l); var buf3 = this.buf; while(this.buf.charCodeAt(this.pos) != 104) l.add(this.unserialize()); this.pos++; return l; case 109: return -Infinity; case 110: return null; case 111: var o2 = { }; this.cache.push(o2); this.unserializeObject(o2); return o2; case 112: return Infinity; case 113: var h2 = new haxe_ds_IntMap(); this.cache.push(h2); var buf4 = this.buf; var c1 = this.buf.charCodeAt(this.pos++); while(c1 == 58) { var i = this.readDigits(); var value1 = this.unserialize(); h2.h[i] = value1; c1 = this.buf.charCodeAt(this.pos++); } if(c1 != 104) { throw new js__$Boot_HaxeError("Invalid IntMap format"); } return h2; case 114: var n2 = this.readDigits(); if(n2 < 0 || n2 >= this.cache.length) { throw new js__$Boot_HaxeError("Invalid reference"); } return this.cache[n2]; case 115: var len = this.readDigits(); var buf5 = this.buf; if(this.buf.charCodeAt(this.pos++) != 58 || this.length - this.pos < len) { throw new js__$Boot_HaxeError("Invalid bytes length"); } var codes = haxe_Unserializer.CODES; if(codes == null) { codes = haxe_Unserializer.initCodes(); haxe_Unserializer.CODES = codes; } var i1 = this.pos; var rest = len & 3; var size = (len >> 2) * 3 + (rest >= 2 ? rest - 1 : 0); var max = i1 + (len - rest); var bytes = new haxe_io_Bytes(new ArrayBuffer(size)); var bpos = 0; while(i1 < max) { var c11 = codes[buf5.charCodeAt(i1++)]; var c2 = codes[buf5.charCodeAt(i1++)]; bytes.b[bpos++] = (c11 << 2 | c2 >> 4) & 255; var c3 = codes[buf5.charCodeAt(i1++)]; bytes.b[bpos++] = (c2 << 4 | c3 >> 2) & 255; var c4 = codes[buf5.charCodeAt(i1++)]; bytes.b[bpos++] = (c3 << 6 | c4) & 255; } if(rest >= 2) { var c12 = codes[buf5.charCodeAt(i1++)]; var c21 = codes[buf5.charCodeAt(i1++)]; bytes.b[bpos++] = (c12 << 2 | c21 >> 4) & 255; if(rest == 3) { var c31 = codes[buf5.charCodeAt(i1++)]; bytes.b[bpos++] = (c21 << 4 | c31 >> 2) & 255; } } this.pos += len; this.cache.push(bytes); return bytes; case 116: return true; case 118: var d; if(this.buf.charCodeAt(this.pos) >= 48 && this.buf.charCodeAt(this.pos) <= 57 && this.buf.charCodeAt(this.pos + 1) >= 48 && this.buf.charCodeAt(this.pos + 1) <= 57 && this.buf.charCodeAt(this.pos + 2) >= 48 && this.buf.charCodeAt(this.pos + 2) <= 57 && this.buf.charCodeAt(this.pos + 3) >= 48 && this.buf.charCodeAt(this.pos + 3) <= 57 && this.buf.charCodeAt(this.pos + 4) == 45) { d = HxOverrides.strDate(HxOverrides.substr(this.buf,this.pos,19)); this.pos += 19; } else { var t = this.readFloat(); d = new Date(t); } this.cache.push(d); return d; case 119: var name5 = this.unserialize(); var edecl1 = this.resolver.resolveEnum(name5); if(edecl1 == null) { throw new js__$Boot_HaxeError("Enum not found " + name5); } var e2 = this.unserializeEnum(edecl1,this.unserialize()); this.cache.push(e2); return e2; case 120: throw js__$Boot_HaxeError.wrap(this.unserialize()); break; case 121: var len1 = this.readDigits(); if(this.buf.charCodeAt(this.pos++) != 58 || this.length - this.pos < len1) { throw new js__$Boot_HaxeError("Invalid string length"); } var s2 = HxOverrides.substr(this.buf,this.pos,len1); this.pos += len1; s2 = decodeURIComponent(s2.split("+").join(" ")); this.scache.push(s2); return s2; case 122: return 0; default: } this.pos--; throw new js__$Boot_HaxeError("Invalid char " + this.buf.charAt(this.pos) + " at position " + this.pos); } ,__class__: haxe_Unserializer }; var haxe_io_Bytes = function(data) { this.length = data.byteLength; this.b = new Uint8Array(data); this.b.bufferValue = data; data.hxBytes = this; data.bytes = this.b; }; $hxClasses["haxe.io.Bytes"] = haxe_io_Bytes; haxe_io_Bytes.__name__ = true; haxe_io_Bytes.ofString = function(s) { var a = []; var i = 0; while(i < s.length) { var c = s.charCodeAt(i++); if(55296 <= c && c <= 56319) { c = c - 55232 << 10 | s.charCodeAt(i++) & 1023; } if(c <= 127) { a.push(c); } else if(c <= 2047) { a.push(192 | c >> 6); a.push(128 | c & 63); } else if(c <= 65535) { a.push(224 | c >> 12); a.push(128 | c >> 6 & 63); a.push(128 | c & 63); } else { a.push(240 | c >> 18); a.push(128 | c >> 12 & 63); a.push(128 | c >> 6 & 63); a.push(128 | c & 63); } } return new haxe_io_Bytes(new Uint8Array(a).buffer); }; haxe_io_Bytes.ofData = function(b) { var hb = b.hxBytes; if(hb != null) { return hb; } return new haxe_io_Bytes(b); }; haxe_io_Bytes.prototype = { length: null ,b: null ,data: null ,blit: function(pos,src,srcpos,len) { if(pos < 0 || srcpos < 0 || len < 0 || pos + len > this.length || srcpos + len > src.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } if(srcpos == 0 && len == src.b.byteLength) { this.b.set(src.b,pos); } else { this.b.set(src.b.subarray(srcpos,srcpos + len),pos); } } ,sub: function(pos,len) { if(pos < 0 || len < 0 || pos + len > this.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } return new haxe_io_Bytes(this.b.buffer.slice(pos + this.b.byteOffset,pos + this.b.byteOffset + len)); } ,getDouble: function(pos) { if(this.data == null) { this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength); } return this.data.getFloat64(pos,true); } ,getFloat: function(pos) { if(this.data == null) { this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength); } return this.data.getFloat32(pos,true); } ,setDouble: function(pos,v) { if(this.data == null) { this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength); } this.data.setFloat64(pos,v,true); } ,setFloat: function(pos,v) { if(this.data == null) { this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength); } this.data.setFloat32(pos,v,true); } ,getUInt16: function(pos) { if(this.data == null) { this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength); } return this.data.getUint16(pos,true); } ,getInt32: function(pos) { if(this.data == null) { this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength); } return this.data.getInt32(pos,true); } ,setInt32: function(pos,v) { if(this.data == null) { this.data = new DataView(this.b.buffer,this.b.byteOffset,this.b.byteLength); } this.data.setInt32(pos,v,true); } ,getString: function(pos,len) { if(pos < 0 || len < 0 || pos + len > this.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } var s = ""; var b = this.b; var fcc = String.fromCharCode; var i = pos; var max = pos + len; while(i < max) { var c = b[i++]; if(c < 128) { if(c == 0) { break; } s += fcc(c); } else if(c < 224) { s += fcc((c & 63) << 6 | b[i++] & 127); } else if(c < 240) { var c2 = b[i++]; s += fcc((c & 31) << 12 | (c2 & 127) << 6 | b[i++] & 127); } else { var c21 = b[i++]; var c3 = b[i++]; var u = (c & 15) << 18 | (c21 & 127) << 12 | (c3 & 127) << 6 | b[i++] & 127; s += fcc((u >> 10) + 55232); s += fcc(u & 1023 | 56320); } } return s; } ,toString: function() { return this.getString(0,this.length); } ,__class__: haxe_io_Bytes }; var haxe_crypto_Base64 = function() { }; $hxClasses["haxe.crypto.Base64"] = haxe_crypto_Base64; haxe_crypto_Base64.__name__ = true; haxe_crypto_Base64.encode = function(bytes,complement) { if(complement == null) { complement = true; } var str = new haxe_crypto_BaseCode(haxe_crypto_Base64.BYTES).encodeBytes(bytes).toString(); if(complement) { var _g = bytes.length % 3; switch(_g) { case 1: str += "=="; break; case 2: str += "="; break; default: } } return str; }; var haxe_crypto_BaseCode = function(base) { var len = base.length; var nbits = 1; while(len > 1 << nbits) ++nbits; if(nbits > 8 || len != 1 << nbits) { throw new js__$Boot_HaxeError("BaseCode : base length must be a power of two."); } this.base = base; this.nbits = nbits; }; $hxClasses["haxe.crypto.BaseCode"] = haxe_crypto_BaseCode; haxe_crypto_BaseCode.__name__ = true; haxe_crypto_BaseCode.prototype = { base: null ,nbits: null ,encodeBytes: function(b) { var nbits = this.nbits; var base = this.base; var size = b.length * 8 / nbits | 0; var out = new haxe_io_Bytes(new ArrayBuffer(size + (b.length * 8 % nbits == 0 ? 0 : 1))); var buf = 0; var curbits = 0; var mask = (1 << nbits) - 1; var pin = 0; var pout = 0; while(pout < size) { while(curbits < nbits) { curbits += 8; buf <<= 8; buf |= b.b[pin++]; } curbits -= nbits; out.b[pout++] = base.b[buf >> curbits & mask] & 255; } if(curbits > 0) { out.b[pout++] = base.b[buf << nbits - curbits & mask] & 255; } return out; } ,__class__: haxe_crypto_BaseCode }; var haxe_ds_IntMap = function() { this.h = { }; }; $hxClasses["haxe.ds.IntMap"] = haxe_ds_IntMap; haxe_ds_IntMap.__name__ = true; haxe_ds_IntMap.__interfaces__ = [haxe_IMap]; haxe_ds_IntMap.prototype = { h: null ,keys: function() { var a = []; for( var key in this.h ) if(this.h.hasOwnProperty(key)) { a.push(key | 0); } return HxOverrides.iter(a); } ,iterator: function() { return { ref : this.h, it : this.keys(), hasNext : function() { return this.it.hasNext(); }, next : function() { var i = this.it.next(); return this.ref[i]; }}; } ,__class__: haxe_ds_IntMap }; var haxe_ds_ObjectMap = function() { this.h = { __keys__ : { }}; }; $hxClasses["haxe.ds.ObjectMap"] = haxe_ds_ObjectMap; haxe_ds_ObjectMap.__name__ = true; haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap]; haxe_ds_ObjectMap.prototype = { h: null ,set: function(key,value) { var id = key.__id__ || (key.__id__ = ++haxe_ds_ObjectMap.count); this.h[id] = value; this.h.__keys__[id] = key; } ,keys: function() { var a = []; for( var key in this.h.__keys__ ) { if(this.h.hasOwnProperty(key)) { a.push(this.h.__keys__[key]); } } return HxOverrides.iter(a); } ,iterator: function() { return { ref : this.h, it : this.keys(), hasNext : function() { return this.it.hasNext(); }, next : function() { var i = this.it.next(); return this.ref[i.__id__]; }}; } ,__class__: haxe_ds_ObjectMap }; var haxe_ds__$StringMap_StringMapIterator = function(map,keys) { this.map = map; this.keys = keys; this.index = 0; this.count = keys.length; }; $hxClasses["haxe.ds._StringMap.StringMapIterator"] = haxe_ds__$StringMap_StringMapIterator; haxe_ds__$StringMap_StringMapIterator.__name__ = true; haxe_ds__$StringMap_StringMapIterator.prototype = { map: null ,keys: null ,index: null ,count: null ,hasNext: function() { return this.index < this.count; } ,next: function() { var _this = this.map; var key = this.keys[this.index++]; if(__map_reserved[key] != null) { return _this.getReserved(key); } else { return _this.h[key]; } } ,__class__: haxe_ds__$StringMap_StringMapIterator }; var haxe_ds_StringMap = function() { this.h = { }; }; $hxClasses["haxe.ds.StringMap"] = haxe_ds_StringMap; haxe_ds_StringMap.__name__ = true; haxe_ds_StringMap.__interfaces__ = [haxe_IMap]; haxe_ds_StringMap.prototype = { h: null ,rh: null ,setReserved: function(key,value) { if(this.rh == null) { this.rh = { }; } this.rh["$" + key] = value; } ,getReserved: function(key) { if(this.rh == null) { return null; } else { return this.rh["$" + key]; } } ,existsReserved: function(key) { if(this.rh == null) { return false; } return this.rh.hasOwnProperty("$" + key); } ,arrayKeys: function() { var out = []; for( var key in this.h ) { if(this.h.hasOwnProperty(key)) { out.push(key); } } if(this.rh != null) { for( var key in this.rh ) { if(key.charCodeAt(0) == 36) { out.push(key.substr(1)); } } } return out; } ,iterator: function() { return new haxe_ds__$StringMap_StringMapIterator(this,this.arrayKeys()); } ,__class__: haxe_ds_StringMap }; var haxe_io_BytesBuffer = function() { this.b = []; }; $hxClasses["haxe.io.BytesBuffer"] = haxe_io_BytesBuffer; haxe_io_BytesBuffer.__name__ = true; haxe_io_BytesBuffer.prototype = { b: null ,getBytes: function() { var bytes = new haxe_io_Bytes(new Uint8Array(this.b).buffer); this.b = null; return bytes; } ,__class__: haxe_io_BytesBuffer }; var haxe_io_Input = function() { }; $hxClasses["haxe.io.Input"] = haxe_io_Input; haxe_io_Input.__name__ = true; haxe_io_Input.prototype = { bigEndian: null ,readByte: function() { throw new js__$Boot_HaxeError("Not implemented"); } ,readBytes: function(s,pos,len) { var k = len; var b = s.b; if(pos < 0 || len < 0 || pos + len > s.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } try { while(k > 0) { b[pos] = this.readByte(); ++pos; --k; } } catch( eof ) { if (eof instanceof js__$Boot_HaxeError) eof = eof.val; if( js_Boot.__instanceof(eof,haxe_io_Eof) ) { } else throw(eof); } return len - k; } ,readFullBytes: function(s,pos,len) { while(len > 0) { var k = this.readBytes(s,pos,len); if(k == 0) { throw new js__$Boot_HaxeError(haxe_io_Error.Blocked); } pos += k; len -= k; } } ,read: function(nbytes) { var s = new haxe_io_Bytes(new ArrayBuffer(nbytes)); var p = 0; while(nbytes > 0) { var k = this.readBytes(s,p,nbytes); if(k == 0) { throw new js__$Boot_HaxeError(haxe_io_Error.Blocked); } p += k; nbytes -= k; } return s; } ,readInt32: function() { var ch1 = this.readByte(); var ch2 = this.readByte(); var ch3 = this.readByte(); var ch4 = this.readByte(); if(this.bigEndian) { return ch4 | ch3 << 8 | ch2 << 16 | ch1 << 24; } else { return ch1 | ch2 << 8 | ch3 << 16 | ch4 << 24; } } ,readString: function(len) { var b = new haxe_io_Bytes(new ArrayBuffer(len)); this.readFullBytes(b,0,len); return b.toString(); } ,__class__: haxe_io_Input }; var haxe_io_BytesInput = function(b,pos,len) { if(pos == null) { pos = 0; } if(len == null) { len = b.length - pos; } if(pos < 0 || len < 0 || pos + len > b.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } this.b = b.b; this.pos = pos; this.len = len; this.totlen = len; }; $hxClasses["haxe.io.BytesInput"] = haxe_io_BytesInput; haxe_io_BytesInput.__name__ = true; haxe_io_BytesInput.__super__ = haxe_io_Input; haxe_io_BytesInput.prototype = $extend(haxe_io_Input.prototype,{ b: null ,pos: null ,len: null ,totlen: null ,set_position: function(p) { if(p < 0) { p = 0; } else if(p > this.totlen) { p = this.totlen; } this.len = this.totlen - p; return this.pos = p; } ,readByte: function() { if(this.len == 0) { throw new js__$Boot_HaxeError(new haxe_io_Eof()); } this.len--; return this.b[this.pos++]; } ,readBytes: function(buf,pos,len) { if(pos < 0 || len < 0 || pos + len > buf.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } if(this.len == 0 && len > 0) { throw new js__$Boot_HaxeError(new haxe_io_Eof()); } if(this.len < len) { len = this.len; } var b1 = this.b; var b2 = buf.b; var _g1 = 0; var _g = len; while(_g1 < _g) { var i = _g1++; b2[pos + i] = b1[this.pos + i]; } this.pos += len; this.len -= len; return len; } ,__class__: haxe_io_BytesInput }); var haxe_io_Output = function() { }; $hxClasses["haxe.io.Output"] = haxe_io_Output; haxe_io_Output.__name__ = true; haxe_io_Output.prototype = { bigEndian: null ,writeByte: function(c) { throw new js__$Boot_HaxeError("Not implemented"); } ,writeBytes: function(s,pos,len) { if(pos < 0 || len < 0 || pos + len > s.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } var b = s.b; var k = len; while(k > 0) { this.writeByte(b[pos]); ++pos; --k; } return len; } ,write: function(s) { var l = s.length; var p = 0; while(l > 0) { var k = this.writeBytes(s,p,l); if(k == 0) { throw new js__$Boot_HaxeError(haxe_io_Error.Blocked); } p += k; l -= k; } } ,writeFloat: function(x) { this.writeInt32(haxe_io_FPHelper.floatToI32(x)); } ,writeInt32: function(x) { if(this.bigEndian) { this.writeByte(x >>> 24); this.writeByte(x >> 16 & 255); this.writeByte(x >> 8 & 255); this.writeByte(x & 255); } else { this.writeByte(x & 255); this.writeByte(x >> 8 & 255); this.writeByte(x >> 16 & 255); this.writeByte(x >>> 24); } } ,__class__: haxe_io_Output }; var haxe_io_BytesOutput = function() { this.b = new haxe_io_BytesBuffer(); }; $hxClasses["haxe.io.BytesOutput"] = haxe_io_BytesOutput; haxe_io_BytesOutput.__name__ = true; haxe_io_BytesOutput.__super__ = haxe_io_Output; haxe_io_BytesOutput.prototype = $extend(haxe_io_Output.prototype,{ b: null ,writeByte: function(c) { this.b.b.push(c); } ,writeBytes: function(buf,pos,len) { var _this = this.b; if(pos < 0 || len < 0 || pos + len > buf.length) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } var b1 = _this.b; var b2 = buf.b; var _g1 = pos; var _g = pos + len; while(_g1 < _g) { var i = _g1++; _this.b.push(b2[i]); } return len; } ,getBytes: function() { return this.b.getBytes(); } ,__class__: haxe_io_BytesOutput }); var haxe_io_Eof = function() { }; $hxClasses["haxe.io.Eof"] = haxe_io_Eof; haxe_io_Eof.__name__ = true; haxe_io_Eof.prototype = { toString: function() { return "Eof"; } ,__class__: haxe_io_Eof }; var haxe_io_Error = $hxClasses["haxe.io.Error"] = { __ename__ : true, __constructs__ : ["Blocked","Overflow","OutsideBounds","Custom"] }; haxe_io_Error.Blocked = ["Blocked",0]; haxe_io_Error.Blocked.toString = $estr; haxe_io_Error.Blocked.__enum__ = haxe_io_Error; haxe_io_Error.Overflow = ["Overflow",1]; haxe_io_Error.Overflow.toString = $estr; haxe_io_Error.Overflow.__enum__ = haxe_io_Error; haxe_io_Error.OutsideBounds = ["OutsideBounds",2]; haxe_io_Error.OutsideBounds.toString = $estr; haxe_io_Error.OutsideBounds.__enum__ = haxe_io_Error; haxe_io_Error.Custom = function(e) { var $x = ["Custom",3,e]; $x.__enum__ = haxe_io_Error; $x.toString = $estr; return $x; }; var haxe_io_FPHelper = function() { }; $hxClasses["haxe.io.FPHelper"] = haxe_io_FPHelper; haxe_io_FPHelper.__name__ = true; haxe_io_FPHelper.i32ToFloat = function(i) { var sign = 1 - (i >>> 31 << 1); var exp = i >>> 23 & 255; var sig = i & 8388607; if(sig == 0 && exp == 0) { return 0.0; } return sign * (1 + Math.pow(2,-23) * sig) * Math.pow(2,exp - 127); }; haxe_io_FPHelper.floatToI32 = function(f) { if(f == 0) { return 0; } var af = f < 0 ? -f : f; var exp = Math.floor(Math.log(af) / 0.6931471805599453); if(exp < -127) { exp = -127; } else if(exp > 128) { exp = 128; } var sig = Math.round((af / Math.pow(2,exp) - 1) * 8388608); if(sig == 8388608 && exp < 128) { sig = 0; ++exp; } return (f < 0 ? -2147483648 : 0) | exp + 127 << 23 | sig; }; haxe_io_FPHelper.i64ToDouble = function(low,high) { var sign = 1 - (high >>> 31 << 1); var exp = (high >> 20 & 2047) - 1023; var sig = (high & 1048575) * 4294967296. + (low >>> 31) * 2147483648. + (low & 2147483647); if(sig == 0 && exp == -1023) { return 0.0; } return sign * (1.0 + Math.pow(2,-52) * sig) * Math.pow(2,exp); }; haxe_io_FPHelper.doubleToI64 = function(v) { var i64 = haxe_io_FPHelper.i64tmp; if(v == 0) { i64.low = 0; i64.high = 0; } else if(!isFinite(v)) { if(v > 0) { i64.low = 0; i64.high = 2146435072; } else { i64.low = 0; i64.high = -1048576; } } else { var av = v < 0 ? -v : v; var exp = Math.floor(Math.log(av) / 0.6931471805599453); var sig = Math.round((av / Math.pow(2,exp) - 1) * 4503599627370496.); var sig_l = sig | 0; var sig_h = sig / 4294967296.0 | 0; i64.low = sig_l; i64.high = (v < 0 ? -2147483648 : 0) | exp + 1023 << 20 | sig_h; } return i64; }; var haxe_io__$UInt8Array_UInt8Array_$Impl_$ = {}; $hxClasses["haxe.io._UInt8Array.UInt8Array_Impl_"] = haxe_io__$UInt8Array_UInt8Array_$Impl_$; haxe_io__$UInt8Array_UInt8Array_$Impl_$.__name__ = true; haxe_io__$UInt8Array_UInt8Array_$Impl_$.fromBytes = function(bytes,bytePos,length) { if(bytePos == null) { bytePos = 0; } if(length == null) { length = bytes.length - bytePos; } return new Uint8Array(bytes.b.bufferValue,bytePos,length); }; var js__$Boot_HaxeError = function(val) { Error.call(this); this.val = val; this.message = String(val); if(Error.captureStackTrace) { Error.captureStackTrace(this,js__$Boot_HaxeError); } }; $hxClasses["js._Boot.HaxeError"] = js__$Boot_HaxeError; js__$Boot_HaxeError.__name__ = true; js__$Boot_HaxeError.wrap = function(val) { if((val instanceof Error)) { return val; } else { return new js__$Boot_HaxeError(val); } }; js__$Boot_HaxeError.__super__ = Error; js__$Boot_HaxeError.prototype = $extend(Error.prototype,{ val: null ,__class__: js__$Boot_HaxeError }); var js_Boot = function() { }; $hxClasses["js.Boot"] = js_Boot; js_Boot.__name__ = true; js_Boot.__unhtml = function(s) { return s.split("&").join("&").split("<").join("<").split(">").join(">"); }; js_Boot.__trace = function(v,i) { var msg = i != null ? i.fileName + ":" + i.lineNumber + ": " : ""; msg += js_Boot.__string_rec(v,""); if(i != null && i.customParams != null) { var _g = 0; var _g1 = i.customParams; while(_g < _g1.length) { var v1 = _g1[_g]; ++_g; msg += "," + js_Boot.__string_rec(v1,""); } } var d; var tmp; if(typeof(document) != "undefined") { d = document.getElementById("haxe:trace"); tmp = d != null; } else { tmp = false; } if(tmp) { d.innerHTML += js_Boot.__unhtml(msg) + "
"; } else if(typeof console != "undefined" && console.log != null) { console.log(msg); } }; js_Boot.getClass = function(o) { if((o instanceof Array) && o.__enum__ == null) { return Array; } else { var cl = o.__class__; if(cl != null) { return cl; } var name = js_Boot.__nativeClassName(o); if(name != null) { return js_Boot.__resolveNativeClass(name); } return null; } }; js_Boot.__string_rec = function(o,s) { if(o == null) { return "null"; } if(s.length >= 5) { return "<...>"; } var t = typeof(o); if(t == "function" && (o.__name__ || o.__ename__)) { t = "object"; } switch(t) { case "function": return ""; case "object": if(o instanceof Array) { if(o.__enum__) { if(o.length == 2) { return o[0]; } var str = o[0] + "("; s += "\t"; var _g1 = 2; var _g = o.length; while(_g1 < _g) { var i = _g1++; if(i != 2) { str += "," + js_Boot.__string_rec(o[i],s); } else { str += js_Boot.__string_rec(o[i],s); } } return str + ")"; } var l = o.length; var i1; var str1 = "["; s += "\t"; var _g11 = 0; var _g2 = l; while(_g11 < _g2) { var i2 = _g11++; str1 += (i2 > 0 ? "," : "") + js_Boot.__string_rec(o[i2],s); } str1 += "]"; return str1; } var tostr; try { tostr = o.toString; } catch( e ) { return "???"; } if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") { var s2 = o.toString(); if(s2 != "[object Object]") { return s2; } } var k = null; var str2 = "{\n"; s += "\t"; var hasp = o.hasOwnProperty != null; for( var k in o ) { if(hasp && !o.hasOwnProperty(k)) { continue; } if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") { continue; } if(str2.length != 2) { str2 += ", \n"; } str2 += s + k + " : " + js_Boot.__string_rec(o[k],s); } s = s.substring(1); str2 += "\n" + s + "}"; return str2; case "string": return o; default: return String(o); } }; js_Boot.__interfLoop = function(cc,cl) { if(cc == null) { return false; } if(cc == cl) { return true; } var intf = cc.__interfaces__; if(intf != null) { var _g1 = 0; var _g = intf.length; while(_g1 < _g) { var i = _g1++; var i1 = intf[i]; if(i1 == cl || js_Boot.__interfLoop(i1,cl)) { return true; } } } return js_Boot.__interfLoop(cc.__super__,cl); }; js_Boot.__instanceof = function(o,cl) { if(cl == null) { return false; } switch(cl) { case Array: if((o instanceof Array)) { return o.__enum__ == null; } else { return false; } break; case Bool: return typeof(o) == "boolean"; case Dynamic: return true; case Float: return typeof(o) == "number"; case Int: if(typeof(o) == "number") { return (o|0) === o; } else { return false; } break; case String: return typeof(o) == "string"; default: if(o != null) { if(typeof(cl) == "function") { if(o instanceof cl) { return true; } if(js_Boot.__interfLoop(js_Boot.getClass(o),cl)) { return true; } } else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) { if(o instanceof cl) { return true; } } } else { return false; } if(cl == Class ? o.__name__ != null : false) { return true; } if(cl == Enum ? o.__ename__ != null : false) { return true; } return o.__enum__ == cl; } }; js_Boot.__cast = function(o,t) { if(js_Boot.__instanceof(o,t)) { return o; } else { throw new js__$Boot_HaxeError("Cannot cast " + Std.string(o) + " to " + Std.string(t)); } }; js_Boot.__nativeClassName = function(o) { var name = js_Boot.__toStr.call(o).slice(8,-1); if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") { return null; } return name; }; js_Boot.__isNativeObj = function(o) { return js_Boot.__nativeClassName(o) != null; }; js_Boot.__resolveNativeClass = function(name) { return $global[name]; }; var js_html_compat_ArrayBuffer = function(a) { if((a instanceof Array) && a.__enum__ == null) { this.a = a; this.byteLength = a.length; } else { var len = a; this.a = []; var _g1 = 0; var _g = len; while(_g1 < _g) { var i = _g1++; this.a[i] = 0; } this.byteLength = len; } }; $hxClasses["js.html.compat.ArrayBuffer"] = js_html_compat_ArrayBuffer; js_html_compat_ArrayBuffer.__name__ = true; js_html_compat_ArrayBuffer.sliceImpl = function(begin,end) { var u = new Uint8Array(this,begin,end == null ? null : end - begin); var result = new ArrayBuffer(u.byteLength); var resultArray = new Uint8Array(result); resultArray.set(u); return result; }; js_html_compat_ArrayBuffer.prototype = { byteLength: null ,a: null ,slice: function(begin,end) { return new js_html_compat_ArrayBuffer(this.a.slice(begin,end)); } ,__class__: js_html_compat_ArrayBuffer }; var js_html_compat_DataView = function(buffer,byteOffset,byteLength) { this.buf = buffer; this.offset = byteOffset == null ? 0 : byteOffset; this.length = byteLength == null ? buffer.byteLength - this.offset : byteLength; if(this.offset < 0 || this.length < 0 || this.offset + this.length > buffer.byteLength) { throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds); } this.byteLength = this.length; this.byteOffset = this.offset; this.buffer = this.buf; }; $hxClasses["js.html.compat.DataView"] = js_html_compat_DataView; js_html_compat_DataView.__name__ = true; js_html_compat_DataView.prototype = { buf: null ,offset: null ,length: null ,byteLength: null ,byteOffset: null ,buffer: null ,getInt8: function(byteOffset) { var v = this.buf.a[this.offset + byteOffset]; if(v >= 128) { return v - 256; } else { return v; } } ,getUint8: function(byteOffset) { return this.buf.a[this.offset + byteOffset]; } ,getInt16: function(byteOffset,littleEndian) { var v = this.getUint16(byteOffset,littleEndian); if(v >= 32768) { return v - 65536; } else { return v; } } ,getUint16: function(byteOffset,littleEndian) { if(littleEndian) { return this.buf.a[this.offset + byteOffset] | this.buf.a[this.offset + byteOffset + 1] << 8; } else { return this.buf.a[this.offset + byteOffset] << 8 | this.buf.a[this.offset + byteOffset + 1]; } } ,getInt32: function(byteOffset,littleEndian) { var p = this.offset + byteOffset; var a = this.buf.a[p++]; var b = this.buf.a[p++]; var c = this.buf.a[p++]; var d = this.buf.a[p++]; if(littleEndian) { return a | b << 8 | c << 16 | d << 24; } else { return d | c << 8 | b << 16 | a << 24; } } ,getUint32: function(byteOffset,littleEndian) { var v = this.getInt32(byteOffset,littleEndian); if(v < 0) { return v + 4294967296.; } else { return v; } } ,getFloat32: function(byteOffset,littleEndian) { return haxe_io_FPHelper.i32ToFloat(this.getInt32(byteOffset,littleEndian)); } ,getFloat64: function(byteOffset,littleEndian) { var a = this.getInt32(byteOffset,littleEndian); var b = this.getInt32(byteOffset + 4,littleEndian); return haxe_io_FPHelper.i64ToDouble(littleEndian ? a : b,littleEndian ? b : a); } ,setInt8: function(byteOffset,value) { this.buf.a[byteOffset + this.offset] = value < 0 ? value + 128 & 255 : value & 255; } ,setUint8: function(byteOffset,value) { this.buf.a[byteOffset + this.offset] = value & 255; } ,setInt16: function(byteOffset,value,littleEndian) { this.setUint16(byteOffset,value < 0 ? value + 65536 : value,littleEndian); } ,setUint16: function(byteOffset,value,littleEndian) { var p = byteOffset + this.offset; if(littleEndian) { this.buf.a[p] = value & 255; this.buf.a[p++] = value >> 8 & 255; } else { this.buf.a[p++] = value >> 8 & 255; this.buf.a[p] = value & 255; } } ,setInt32: function(byteOffset,value,littleEndian) { this.setUint32(byteOffset,value,littleEndian); } ,setUint32: function(byteOffset,value,littleEndian) { var p = byteOffset + this.offset; if(littleEndian) { this.buf.a[p++] = value & 255; this.buf.a[p++] = value >> 8 & 255; this.buf.a[p++] = value >> 16 & 255; this.buf.a[p++] = value >>> 24; } else { this.buf.a[p++] = value >>> 24; this.buf.a[p++] = value >> 16 & 255; this.buf.a[p++] = value >> 8 & 255; this.buf.a[p++] = value & 255; } } ,setFloat32: function(byteOffset,value,littleEndian) { this.setUint32(byteOffset,haxe_io_FPHelper.floatToI32(value),littleEndian); } ,setFloat64: function(byteOffset,value,littleEndian) { var i64 = haxe_io_FPHelper.doubleToI64(value); if(littleEndian) { this.setUint32(byteOffset,i64.low); this.setUint32(byteOffset,i64.high); } else { this.setUint32(byteOffset,i64.high); this.setUint32(byteOffset,i64.low); } } ,__class__: js_html_compat_DataView }; var js_html_compat_Float32Array = function() { }; $hxClasses["js.html.compat.Float32Array"] = js_html_compat_Float32Array; js_html_compat_Float32Array.__name__ = true; js_html_compat_Float32Array._new = function(arg1,offset,length) { var arr; if(typeof(arg1) == "number") { arr = []; var _g1 = 0; var _g = arg1; while(_g1 < _g) { var i = _g1++; arr[i] = 0; } arr.byteLength = arr.length << 2; arr.byteOffset = 0; var _g2 = []; var _g21 = 0; var _g11 = arr.length << 2; while(_g21 < _g11) { var i1 = _g21++; _g2.push(0); } arr.buffer = new js_html_compat_ArrayBuffer(_g2); } else if(js_Boot.__instanceof(arg1,js_html_compat_ArrayBuffer)) { var buffer = arg1; if(offset == null) { offset = 0; } if(length == null) { length = buffer.byteLength - offset >> 2; } arr = []; var _g12 = 0; var _g3 = length; while(_g12 < _g3) { var i2 = _g12++; var val = buffer.a[offset++] | buffer.a[offset++] << 8 | buffer.a[offset++] << 16 | buffer.a[offset++] << 24; arr.push(haxe_io_FPHelper.i32ToFloat(val)); } arr.byteLength = arr.length << 2; arr.byteOffset = offset; arr.buffer = buffer; } else if((arg1 instanceof Array) && arg1.__enum__ == null) { arr = arg1.slice(); var buffer1 = []; var _g4 = 0; while(_g4 < arr.length) { var f = arr[_g4]; ++_g4; var i3 = haxe_io_FPHelper.floatToI32(f); buffer1.push(i3 & 255); buffer1.push(i3 >> 8 & 255); buffer1.push(i3 >> 16 & 255); buffer1.push(i3 >>> 24); } arr.byteLength = arr.length << 2; arr.byteOffset = 0; arr.buffer = new js_html_compat_ArrayBuffer(buffer1); } else { throw new js__$Boot_HaxeError("TODO " + Std.string(arg1)); } arr.subarray = js_html_compat_Float32Array._subarray; arr.set = js_html_compat_Float32Array._set; return arr; }; js_html_compat_Float32Array._set = function(arg,offset) { if(js_Boot.__instanceof(arg.buffer,js_html_compat_ArrayBuffer)) { var a = arg; if(arg.byteLength + offset > this.byteLength) { throw new js__$Boot_HaxeError("set() outside of range"); } var _g1 = 0; var _g = arg.byteLength; while(_g1 < _g) { var i = _g1++; this[i + offset] = a[i]; } } else if((arg instanceof Array) && arg.__enum__ == null) { var a1 = arg; if(a1.length + offset > this.byteLength) { throw new js__$Boot_HaxeError("set() outside of range"); } var _g11 = 0; var _g2 = a1.length; while(_g11 < _g2) { var i1 = _g11++; this[i1 + offset] = a1[i1]; } } else { throw new js__$Boot_HaxeError("TODO"); } }; js_html_compat_Float32Array._subarray = function(start,end) { var a = js_html_compat_Float32Array._new(this.slice(start,end)); a.byteOffset = start * 4; return a; }; var js_html_compat_Uint8Array = function() { }; $hxClasses["js.html.compat.Uint8Array"] = js_html_compat_Uint8Array; js_html_compat_Uint8Array.__name__ = true; js_html_compat_Uint8Array._new = function(arg1,offset,length) { var arr; if(typeof(arg1) == "number") { arr = []; var _g1 = 0; var _g = arg1; while(_g1 < _g) { var i = _g1++; arr[i] = 0; } arr.byteLength = arr.length; arr.byteOffset = 0; arr.buffer = new js_html_compat_ArrayBuffer(arr); } else if(js_Boot.__instanceof(arg1,js_html_compat_ArrayBuffer)) { var buffer = arg1; if(offset == null) { offset = 0; } if(length == null) { length = buffer.byteLength - offset; } if(offset == 0) { arr = buffer.a; } else { arr = buffer.a.slice(offset,offset + length); } arr.byteLength = arr.length; arr.byteOffset = offset; arr.buffer = buffer; } else if((arg1 instanceof Array) && arg1.__enum__ == null) { arr = arg1.slice(); arr.byteLength = arr.length; arr.byteOffset = 0; arr.buffer = new js_html_compat_ArrayBuffer(arr); } else { throw new js__$Boot_HaxeError("TODO " + Std.string(arg1)); } arr.subarray = js_html_compat_Uint8Array._subarray; arr.set = js_html_compat_Uint8Array._set; return arr; }; js_html_compat_Uint8Array._set = function(arg,offset) { if(js_Boot.__instanceof(arg.buffer,js_html_compat_ArrayBuffer)) { var a = arg; if(arg.byteLength + offset > this.byteLength) { throw new js__$Boot_HaxeError("set() outside of range"); } var _g1 = 0; var _g = arg.byteLength; while(_g1 < _g) { var i = _g1++; this[i + offset] = a[i]; } } else if((arg instanceof Array) && arg.__enum__ == null) { var a1 = arg; if(a1.length + offset > this.byteLength) { throw new js__$Boot_HaxeError("set() outside of range"); } var _g11 = 0; var _g2 = a1.length; while(_g11 < _g2) { var i1 = _g11++; this[i1 + offset] = a1[i1]; } } else { throw new js__$Boot_HaxeError("TODO"); } }; js_html_compat_Uint8Array._subarray = function(start,end) { var a = js_html_compat_Uint8Array._new(this.slice(start,end)); a.byteOffset = start; return a; }; var kha__$Assets_ImageList = function() { this.names = []; }; $hxClasses["kha._Assets.ImageList"] = kha__$Assets_ImageList; kha__$Assets_ImageList.__name__ = true; kha__$Assets_ImageList.prototype = { names: null ,__class__: kha__$Assets_ImageList }; var kha__$Assets_SoundList = function() { this.names = []; }; $hxClasses["kha._Assets.SoundList"] = kha__$Assets_SoundList; kha__$Assets_SoundList.__name__ = true; kha__$Assets_SoundList.prototype = { names: null ,__class__: kha__$Assets_SoundList }; var kha__$Assets_BlobList = function() { this.names = []; }; $hxClasses["kha._Assets.BlobList"] = kha__$Assets_BlobList; kha__$Assets_BlobList.__name__ = true; kha__$Assets_BlobList.prototype = { names: null ,__class__: kha__$Assets_BlobList }; var kha__$Assets_FontList = function() { this.names = ["DroidSans"]; this.DroidSansDescription = { files : ["DroidSans.ttf"], type : "font", name : "DroidSans"}; this.DroidSansName = "DroidSans"; this.DroidSans = null; }; $hxClasses["kha._Assets.FontList"] = kha__$Assets_FontList; kha__$Assets_FontList.__name__ = true; kha__$Assets_FontList.prototype = { DroidSans: null ,DroidSansName: null ,DroidSansDescription: null ,DroidSansLoad: function(done) { kha_Assets.loadFont("DroidSans",function(font) { done(); }); } ,DroidSansUnload: function() { this.DroidSans.unload(); this.DroidSans = null; } ,names: null ,__class__: kha__$Assets_FontList }; var kha__$Assets_VideoList = function() { this.names = []; }; $hxClasses["kha._Assets.VideoList"] = kha__$Assets_VideoList; kha__$Assets_VideoList.__name__ = true; kha__$Assets_VideoList.prototype = { names: null ,__class__: kha__$Assets_VideoList }; var kha_Assets = function() { }; $hxClasses["kha.Assets"] = kha_Assets; kha_Assets.__name__ = true; kha_Assets.loadEverything = function(callback) { var fileCount = 0; var _g = 0; var _g1 = Type.getInstanceFields(kha__$Assets_BlobList); while(_g < _g1.length) { var blob = _g1[_g]; ++_g; if(StringTools.endsWith(blob,"Load")) { fileCount += 1; } } var _g2 = 0; var _g11 = Type.getInstanceFields(kha__$Assets_ImageList); while(_g2 < _g11.length) { var image = _g11[_g2]; ++_g2; if(StringTools.endsWith(image,"Load")) { fileCount += 1; } } var _g3 = 0; var _g12 = Type.getInstanceFields(kha__$Assets_SoundList); while(_g3 < _g12.length) { var sound = _g12[_g3]; ++_g3; if(StringTools.endsWith(sound,"Load")) { fileCount += 1; } } var _g4 = 0; var _g13 = Type.getInstanceFields(kha__$Assets_FontList); while(_g4 < _g13.length) { var font = _g13[_g4]; ++_g4; if(StringTools.endsWith(font,"Load")) { fileCount += 1; } } var _g5 = 0; var _g14 = Type.getInstanceFields(kha__$Assets_VideoList); while(_g5 < _g14.length) { var video = _g14[_g5]; ++_g5; if(StringTools.endsWith(video,"Load")) { fileCount += 1; } } if(fileCount == 0) { callback(); return; } var filesLeft = fileCount; var _g6 = 0; var _g15 = Type.getInstanceFields(kha__$Assets_BlobList); while(_g6 < _g15.length) { var blob1 = _g15[_g6]; ++_g6; if(StringTools.endsWith(blob1,"Load")) { (Reflect.field(kha_Assets.blobs,blob1))(function() { filesLeft -= 1; kha_Assets.progress = 1 - filesLeft / fileCount; if(filesLeft == 0) { callback(); } }); } } var _g7 = 0; var _g16 = Type.getInstanceFields(kha__$Assets_ImageList); while(_g7 < _g16.length) { var image1 = _g16[_g7]; ++_g7; if(StringTools.endsWith(image1,"Load")) { (Reflect.field(kha_Assets.images,image1))(function() { filesLeft -= 1; kha_Assets.progress = 1 - filesLeft / fileCount; if(filesLeft == 0) { callback(); } }); } } var _g8 = 0; var _g17 = Type.getInstanceFields(kha__$Assets_SoundList); while(_g8 < _g17.length) { var sound1 = [_g17[_g8]]; ++_g8; if(StringTools.endsWith(sound1[0],"Load")) { (Reflect.field(kha_Assets.sounds,sound1[0]))((function(sound2) { return function() { var sound3 = Reflect.field(kha_Assets.sounds,sound2[0].substring(0,sound2[0].length - 4)); sound3.uncompress((function() { return function() { filesLeft -= 1; kha_Assets.progress = 1 - filesLeft / fileCount; if(filesLeft == 0) { callback(); } }; })()); }; })(sound1)); } } var _g9 = 0; var _g18 = Type.getInstanceFields(kha__$Assets_FontList); while(_g9 < _g18.length) { var font1 = _g18[_g9]; ++_g9; if(StringTools.endsWith(font1,"Load")) { (Reflect.field(kha_Assets.fonts,font1))(function() { filesLeft -= 1; kha_Assets.progress = 1 - filesLeft / fileCount; if(filesLeft == 0) { callback(); } }); } } var _g10 = 0; var _g19 = Type.getInstanceFields(kha__$Assets_VideoList); while(_g10 < _g19.length) { var video1 = _g19[_g10]; ++_g10; if(StringTools.endsWith(video1,"Load")) { (Reflect.field(kha_Assets.videos,video1))(function() { filesLeft -= 1; kha_Assets.progress = 1 - filesLeft / fileCount; if(filesLeft == 0) { callback(); } }); } } }; kha_Assets.loadImage = function(name,done) { var description = Reflect.field(kha_Assets.images,name + "Description"); kha_LoaderImpl.loadImageFromDescription(description,function(image) { kha_Assets.images[name] = image; done(image); }); }; kha_Assets.loadImageFromPath = function(path,readable,done) { var description = { files : [path], readable : readable}; kha_LoaderImpl.loadImageFromDescription(description,done); }; kha_Assets.get_imageFormats = function() { return kha_LoaderImpl.getImageFormats(); }; kha_Assets.loadBlob = function(name,done) { var description = Reflect.field(kha_Assets.blobs,name + "Description"); kha_LoaderImpl.loadBlobFromDescription(description,function(blob) { kha_Assets.blobs[name] = blob; done(blob); }); }; kha_Assets.loadBlobFromPath = function(path,done) { var description = { files : [path]}; kha_LoaderImpl.loadBlobFromDescription(description,done); }; kha_Assets.loadSound = function(name,done) { var description = Reflect.field(kha_Assets.sounds,name + "Description"); kha_LoaderImpl.loadSoundFromDescription(description,function(sound) { kha_Assets.sounds[name] = sound; done(sound); }); return; }; kha_Assets.loadSoundFromPath = function(path,done) { var description = { files : [path]}; kha_LoaderImpl.loadSoundFromDescription(description,done); return; }; kha_Assets.get_soundFormats = function() { return kha_LoaderImpl.getSoundFormats(); }; kha_Assets.loadFont = function(name,done) { var description = Reflect.field(kha_Assets.fonts,name + "Description"); kha_LoaderImpl.loadFontFromDescription(description,function(font) { kha_Assets.fonts[name] = font; done(font); }); return; }; kha_Assets.loadFontFromPath = function(path,done) { var description = { files : [path]}; kha_LoaderImpl.loadFontFromDescription(description,done); return; }; kha_Assets.get_fontFormats = function() { return ["ttf"]; }; kha_Assets.loadVideo = function(name,done) { var description = Reflect.field(kha_Assets.videos,name + "Description"); kha_LoaderImpl.loadVideoFromDescription(description,function(video) { kha_Assets.videos[name] = video; done(video); }); return; }; kha_Assets.loadVideoFromPath = function(path,done) { var description = { files : [path]}; kha_LoaderImpl.loadVideoFromDescription(description,done); return; }; kha_Assets.get_videoFormats = function() { return kha_LoaderImpl.getVideoFormats(); }; var kha_Canvas = function() { }; $hxClasses["kha.Canvas"] = kha_Canvas; kha_Canvas.__name__ = true; kha_Canvas.prototype = { get_width: null ,get_height: null ,get_g1: null ,get_g2: null ,get_g4: null ,width: null ,height: null ,g1: null ,g2: null ,g4: null ,__class__: kha_Canvas }; var kha_Resource = function() { }; $hxClasses["kha.Resource"] = kha_Resource; kha_Resource.__name__ = true; kha_Resource.prototype = { unload: null ,__class__: kha_Resource }; var kha_Image = function() { }; $hxClasses["kha.Image"] = kha_Image; kha_Image.__name__ = true; kha_Image.__interfaces__ = [kha_Resource,kha_Canvas]; kha_Image.create = function(width,height,format,usage) { if(format == null) { format = kha_graphics4_TextureFormat.RGBA32; } if(usage == null) { usage = kha_graphics4_Usage.StaticUsage; } if(kha_SystemImpl.gl == null) { return new kha_CanvasImage(width,height,format,false); } else { return new kha_WebGLImage(width,height,format,false,0); } }; kha_Image.create3D = function(width,height,depth,format,usage) { return null; }; kha_Image.createRenderTarget = function(width,height,format,depthStencil,antiAliasingSamples,contextId) { if(contextId == null) { contextId = 0; } if(antiAliasingSamples == null) { antiAliasingSamples = 1; } if(depthStencil == null) { depthStencil = 0; } if(format == null) { format = kha_graphics4_TextureFormat.RGBA32; } if(kha_SystemImpl.gl == null) { return new kha_CanvasImage(width,height,format,true); } else { return new kha_WebGLImage(width,height,format,true,depthStencil); } }; kha_Image.fromImage = function(image,readable) { if(kha_SystemImpl.gl == null) { var img = new kha_CanvasImage(image.width,image.height,kha_graphics4_TextureFormat.RGBA32,false); img.image = image; img.createTexture(); return img; } else { var img1 = new kha_WebGLImage(image.width,image.height,kha_graphics4_TextureFormat.RGBA32,false,0); img1.image = image; img1.createTexture(); return img1; } }; kha_Image.fromBytes = function(bytes,width,height,format,usage) { if(format == null) { format = kha_graphics4_TextureFormat.RGBA32; } if(usage == null) { usage = kha_graphics4_Usage.StaticUsage; } if(kha_SystemImpl.gl != null) { var img = new kha_WebGLImage(width,height,format,false,0); img.image = img.bytesToArray(bytes); img.createTexture(); return img; } return null; }; kha_Image.fromEncodedBytes = function(bytes,fileExtention,doneCallback,errorCallback,readable) { if(readable == null) { readable = false; } var dataUrl = "data:image;base64," + haxe_crypto_Base64.encode(bytes); var imageElement = js_Boot.__cast(window.document.createElement("img") , HTMLImageElement); imageElement.onload = function() { var tmp = kha_Image.fromImage(imageElement,readable); doneCallback(tmp); }; imageElement.onerror = function() { errorCallback("Image was not created"); }; imageElement.src = dataUrl; }; kha_Image.fromVideo = function(video) { if(kha_SystemImpl.gl == null) { var img = new kha_CanvasImage(video.element.videoWidth,video.element.videoHeight,kha_graphics4_TextureFormat.RGBA32,false); img.video = video.element; img.createTexture(); return img; } else { var img1 = new kha_WebGLImage(video.element.videoWidth,video.element.videoHeight,kha_graphics4_TextureFormat.RGBA32,false,0); img1.video = video.element; img1.createTexture(); return img1; } }; kha_Image.get_maxSize = function() { if(kha_SystemImpl.gl == null) { return 8192; } else { return kha_SystemImpl.gl.getParameter(3379); } }; kha_Image.get_nonPow2Supported = function() { return kha_SystemImpl.gl != null; }; kha_Image.prototype = { isOpaque: function(x,y) { return false; } ,at: function(x,y) { return -16777216; } ,unload: function() { } ,lock: function(level) { if(level == null) { level = 0; } return null; } ,unlock: function() { } ,getPixels: function() { return null; } ,generateMipmaps: function(levels) { } ,setMipmaps: function(mipmaps) { } ,setDepthStencilFrom: function(image) { } ,clear: function(x,y,z,width,height,depth,color) { } ,width: null ,get_width: function() { return 0; } ,height: null ,get_height: function() { return 0; } ,depth: null ,get_depth: function() { return 1; } ,realWidth: null ,get_realWidth: function() { return 0; } ,realHeight: null ,get_realHeight: function() { return 0; } ,g1: null ,get_g1: function() { return null; } ,g2: null ,get_g2: function() { return null; } ,g4: null ,get_g4: function() { return null; } ,__class__: kha_Image }; var kha_CanvasImage = function(width,height,format,renderTarget) { this.g2canvas = null; this.myWidth = width; this.myHeight = height; this.format = format; this.renderTarget = renderTarget; this.image = null; this.video = null; if(renderTarget) { this.createTexture(); } }; $hxClasses["kha.CanvasImage"] = kha_CanvasImage; kha_CanvasImage.__name__ = true; kha_CanvasImage.init = function() { var canvas = window.document.createElement("canvas"); if(canvas != null) { kha_CanvasImage.context = canvas.getContext("2d"); canvas.width = 2048; canvas.height = 2048; kha_CanvasImage.context.globalCompositeOperation = "copy"; } }; kha_CanvasImage.upperPowerOfTwo = function(v) { --v; v |= v >>> 1; v |= v >>> 2; v |= v >>> 4; v |= v >>> 8; v |= v >>> 16; return ++v; }; kha_CanvasImage.__super__ = kha_Image; kha_CanvasImage.prototype = $extend(kha_Image.prototype,{ image: null ,video: null ,data: null ,myWidth: null ,myHeight: null ,format: null ,renderTarget: null ,frameBuffer: null ,graphics1: null ,g2canvas: null ,get_g1: function() { if(this.graphics1 == null) { this.graphics1 = new kha_graphics2_Graphics1(this); } return this.graphics1; } ,get_g2: function() { if(this.g2canvas == null) { var canvas = window.document.createElement("canvas"); this.image = canvas; var context = canvas.getContext("2d"); canvas.width = this.get_width(); canvas.height = this.get_height(); this.g2canvas = new kha_js_CanvasGraphics(context); } return this.g2canvas; } ,get_g4: function() { return null; } ,get_width: function() { return this.myWidth; } ,get_height: function() { return this.myHeight; } ,get_realWidth: function() { return this.myWidth; } ,get_realHeight: function() { return this.myHeight; } ,isOpaque: function(x,y) { if(this.data == null) { if(kha_CanvasImage.context == null) { return true; } else { this.createImageData(); } } return this.data.data[y * (this.image.width | 0) * 4 + x * 4 + 3] != 0; } ,at: function(x,y) { if(this.data == null) { if(kha_CanvasImage.context == null) { return -16777216; } else { this.createImageData(); } } return kha__$Color_Color_$Impl_$._new(this.data.data[y * (this.image.width | 0) * 4 + x * 4]); } ,createImageData: function() { kha_CanvasImage.context.strokeStyle = "rgba(0,0,0,0)"; kha_CanvasImage.context.fillStyle = "rgba(0,0,0,0)"; kha_CanvasImage.context.fillRect(0,0,this.image.width,this.image.height); kha_CanvasImage.context.drawImage(this.image,0,0,this.image.width,this.image.height,0,0,this.image.width,this.image.height); this.data = kha_CanvasImage.context.getImageData(0,0,this.image.width,this.image.height); } ,texture: null ,createTexture: function() { if(kha_SystemImpl.gl == null) { return; } this.texture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(3553,this.texture); kha_SystemImpl.gl.texParameteri(3553,10240,9729); kha_SystemImpl.gl.texParameteri(3553,10241,9729); kha_SystemImpl.gl.texParameteri(3553,10242,33071); kha_SystemImpl.gl.texParameteri(3553,10243,33071); if(this.renderTarget) { this.frameBuffer = kha_SystemImpl.gl.createFramebuffer(); kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null); kha_SystemImpl.gl.framebufferTexture2D(36160,36064,3553,this.texture,0); kha_SystemImpl.gl.bindFramebuffer(36160,null); } else if(this.video != null) { kha_SystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.video); } else { kha_SystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.image); } kha_SystemImpl.gl.bindTexture(3553,null); } ,set: function(stage) { kha_SystemImpl.gl.activeTexture(33984 + stage); kha_SystemImpl.gl.bindTexture(3553,this.texture); if(this.video != null) { kha_SystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.video); } } ,bytes: null ,lock: function(level) { if(level == null) { level = 0; } this.bytes = new haxe_io_Bytes(new ArrayBuffer(this.format == kha_graphics4_TextureFormat.RGBA32 ? 4 * this.get_width() * this.get_height() : this.get_width() * this.get_height())); return this.bytes; } ,unlock: function() { if(kha_SystemImpl.gl != null) { this.texture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(3553,this.texture); kha_SystemImpl.gl.texParameteri(3553,10240,9729); kha_SystemImpl.gl.texParameteri(3553,10241,9729); kha_SystemImpl.gl.texParameteri(3553,10242,33071); kha_SystemImpl.gl.texParameteri(3553,10243,33071); kha_SystemImpl.gl.texImage2D(3553,0,6409,this.get_width(),this.get_height(),0,6409,5121,new Uint8Array(this.bytes.b.bufferValue)); if(kha_SystemImpl.gl.getError() == 1282) { var rgbaBytes = new haxe_io_Bytes(new ArrayBuffer(this.get_width() * this.get_height() * 4)); var _g1 = 0; var _g = this.get_height(); while(_g1 < _g) { var y = _g1++; var _g3 = 0; var _g2 = this.get_width(); while(_g3 < _g2) { var x = _g3++; var _this = this.bytes; var pos = y * this.get_width() + x; var value = _this.b[pos]; var pos1 = y * this.get_width() * 4 + x * 4; rgbaBytes.b[pos1] = value & 255; var pos2 = y * this.get_width() * 4 + x * 4 + 1; rgbaBytes.b[pos2] = value & 255; var pos3 = y * this.get_width() * 4 + x * 4 + 2; rgbaBytes.b[pos3] = value & 255; var pos4 = y * this.get_width() * 4 + x * 4 + 3; rgbaBytes.b[pos4] = 255; } } kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,new Uint8Array(rgbaBytes.b.bufferValue)); } kha_SystemImpl.gl.bindTexture(3553,null); this.bytes = null; } } ,unload: function() { this.image = null; this.video = null; this.data = null; } ,__class__: kha_CanvasImage }); var kha__$Color_Color_$Impl_$ = $hx_exports["kha"]["_Color"]["Color_Impl_"] = {}; $hxClasses["kha._Color.Color_Impl_"] = kha__$Color_Color_$Impl_$; kha__$Color_Color_$Impl_$.__name__ = true; kha__$Color_Color_$Impl_$.fromValue = function(value) { return kha__$Color_Color_$Impl_$._new(value); }; kha__$Color_Color_$Impl_$.fromBytes = function(r,g,b,a) { if(a == null) { a = 255; } return kha__$Color_Color_$Impl_$._new(a << 24 | r << 16 | g << 8 | b); }; kha__$Color_Color_$Impl_$.fromFloats = function(r,g,b,a) { if(a == null) { a = 1; } return kha__$Color_Color_$Impl_$._new((a * 255 | 0) << 24 | (r * 255 | 0) << 16 | (g * 255 | 0) << 8 | (b * 255 | 0)); }; kha__$Color_Color_$Impl_$.fromString = function(value) { if((value.length == 7 || value.length == 9) && value.charCodeAt(0) == 35) { var colorValue = Std.parseInt("0x" + HxOverrides.substr(value,1,null)); if(value.length == 7) { colorValue += -16777216; } return kha__$Color_Color_$Impl_$._new(colorValue); } else { throw new js__$Boot_HaxeError("Invalid Color string: '" + value + "'"); } }; kha__$Color_Color_$Impl_$._new = function(value) { var this1 = value; return this1; }; kha__$Color_Color_$Impl_$.get_value = function(this1) { return this1; }; kha__$Color_Color_$Impl_$.set_value = function(this1,value) { this1 = value; return this1; }; kha__$Color_Color_$Impl_$.get_Rb = function(this1) { return (this1 & 16711680) >>> 16; }; kha__$Color_Color_$Impl_$.get_Gb = function(this1) { return (this1 & 65280) >>> 8; }; kha__$Color_Color_$Impl_$.get_Bb = function(this1) { return this1 & 255; }; kha__$Color_Color_$Impl_$.get_Ab = function(this1) { return this1 >>> 24; }; kha__$Color_Color_$Impl_$.set_Rb = function(this1,i) { this1 = this1 >>> 24 << 24 | i << 16 | (this1 & 65280) >>> 8 << 8 | this1 & 255; return i; }; kha__$Color_Color_$Impl_$.set_Gb = function(this1,i) { this1 = this1 >>> 24 << 24 | (this1 & 16711680) >>> 16 << 16 | i << 8 | this1 & 255; return i; }; kha__$Color_Color_$Impl_$.set_Bb = function(this1,i) { this1 = this1 >>> 24 << 24 | (this1 & 16711680) >>> 16 << 16 | (this1 & 65280) >>> 8 << 8 | i; return i; }; kha__$Color_Color_$Impl_$.set_Ab = function(this1,i) { this1 = i << 24 | (this1 & 16711680) >>> 16 << 16 | (this1 & 65280) >>> 8 << 8 | this1 & 255; return i; }; kha__$Color_Color_$Impl_$.get_R = function(this1) { return ((this1 & 16711680) >>> 16) * 0.00392156862745098; }; kha__$Color_Color_$Impl_$.get_G = function(this1) { return ((this1 & 65280) >>> 8) * 0.00392156862745098; }; kha__$Color_Color_$Impl_$.get_B = function(this1) { return (this1 & 255) * 0.00392156862745098; }; kha__$Color_Color_$Impl_$.get_A = function(this1) { return (this1 >>> 24) * 0.00392156862745098; }; kha__$Color_Color_$Impl_$.set_R = function(this1,f) { this1 = ((this1 >>> 24) * 0.00392156862745098 * 255 | 0) << 24 | (f * 255 | 0) << 16 | (((this1 & 65280) >>> 8) * 0.00392156862745098 * 255 | 0) << 8 | ((this1 & 255) * 0.00392156862745098 * 255 | 0); return f; }; kha__$Color_Color_$Impl_$.set_G = function(this1,f) { this1 = ((this1 >>> 24) * 0.00392156862745098 * 255 | 0) << 24 | (((this1 & 16711680) >>> 16) * 0.00392156862745098 * 255 | 0) << 16 | (f * 255 | 0) << 8 | ((this1 & 255) * 0.00392156862745098 * 255 | 0); return f; }; kha__$Color_Color_$Impl_$.set_B = function(this1,f) { this1 = ((this1 >>> 24) * 0.00392156862745098 * 255 | 0) << 24 | (((this1 & 16711680) >>> 16) * 0.00392156862745098 * 255 | 0) << 16 | (((this1 & 65280) >>> 8) * 0.00392156862745098 * 255 | 0) << 8 | (f * 255 | 0); return f; }; kha__$Color_Color_$Impl_$.set_A = function(this1,f) { this1 = (f * 255 | 0) << 24 | (((this1 & 16711680) >>> 16) * 0.00392156862745098 * 255 | 0) << 16 | (((this1 & 65280) >>> 8) * 0.00392156862745098 * 255 | 0) << 8 | ((this1 & 255) * 0.00392156862745098 * 255 | 0); return f; }; var kha_CompilerDefines = function() { }; $hxClasses["kha.CompilerDefines"] = kha_CompilerDefines; kha_CompilerDefines.__name__ = true; var kha_EnvironmentVariables = function() { }; $hxClasses["kha.EnvironmentVariables"] = kha_EnvironmentVariables; kha_EnvironmentVariables.__name__ = true; kha_EnvironmentVariables.prototype = { getVariable: function(name) { return ""; } ,__class__: kha_EnvironmentVariables }; var kha_Font = function() { }; $hxClasses["kha.Font"] = kha_Font; kha_Font.__name__ = true; kha_Font.__interfaces__ = [kha_Resource]; kha_Font.prototype = { height: null ,width: null ,baseline: null ,__class__: kha_Font }; var kha_FontStyle = function(bold,italic,underlined) { this.bold = bold; this.italic = italic; this.underlined = underlined; }; $hxClasses["kha.FontStyle"] = kha_FontStyle; kha_FontStyle.__name__ = true; kha_FontStyle.prototype = { bold: null ,italic: null ,underlined: null ,getBold: function() { return this.bold; } ,getItalic: function() { return this.italic; } ,getUnderlined: function() { return this.underlined; } ,__class__: kha_FontStyle }; var kha_Framebuffer = function(windowId,g1,g2,g4) { this.windowId = windowId; this.graphics1 = g1; this.graphics2 = g2; this.graphics4 = g4; }; $hxClasses["kha.Framebuffer"] = kha_Framebuffer; kha_Framebuffer.__name__ = true; kha_Framebuffer.__interfaces__ = [kha_Canvas]; kha_Framebuffer.prototype = { windowId: null ,graphics1: null ,graphics2: null ,graphics4: null ,init: function(g1,g2,g4) { this.graphics1 = g1; this.graphics2 = g2; this.graphics4 = g4; } ,g1: null ,get_g1: function() { return this.graphics1; } ,g2: null ,get_g2: function() { return this.graphics2; } ,g4: null ,get_g4: function() { return this.graphics4; } ,width: null ,get_width: function() { return kha_System.windowWidth(this.windowId); } ,height: null ,get_height: function() { return kha_System.windowHeight(this.windowId); } ,__class__: kha_Framebuffer }; var kha_Key = $hxClasses["kha.Key"] = { __ename__ : true, __constructs__ : ["BACKSPACE","TAB","ENTER","SHIFT","CTRL","ALT","CHAR","ESC","DEL","UP","DOWN","LEFT","RIGHT","BACK"] }; kha_Key.BACKSPACE = ["BACKSPACE",0]; kha_Key.BACKSPACE.toString = $estr; kha_Key.BACKSPACE.__enum__ = kha_Key; kha_Key.TAB = ["TAB",1]; kha_Key.TAB.toString = $estr; kha_Key.TAB.__enum__ = kha_Key; kha_Key.ENTER = ["ENTER",2]; kha_Key.ENTER.toString = $estr; kha_Key.ENTER.__enum__ = kha_Key; kha_Key.SHIFT = ["SHIFT",3]; kha_Key.SHIFT.toString = $estr; kha_Key.SHIFT.__enum__ = kha_Key; kha_Key.CTRL = ["CTRL",4]; kha_Key.CTRL.toString = $estr; kha_Key.CTRL.__enum__ = kha_Key; kha_Key.ALT = ["ALT",5]; kha_Key.ALT.toString = $estr; kha_Key.ALT.__enum__ = kha_Key; kha_Key.CHAR = ["CHAR",6]; kha_Key.CHAR.toString = $estr; kha_Key.CHAR.__enum__ = kha_Key; kha_Key.ESC = ["ESC",7]; kha_Key.ESC.toString = $estr; kha_Key.ESC.__enum__ = kha_Key; kha_Key.DEL = ["DEL",8]; kha_Key.DEL.toString = $estr; kha_Key.DEL.__enum__ = kha_Key; kha_Key.UP = ["UP",9]; kha_Key.UP.toString = $estr; kha_Key.UP.__enum__ = kha_Key; kha_Key.DOWN = ["DOWN",10]; kha_Key.DOWN.toString = $estr; kha_Key.DOWN.__enum__ = kha_Key; kha_Key.LEFT = ["LEFT",11]; kha_Key.LEFT.toString = $estr; kha_Key.LEFT.__enum__ = kha_Key; kha_Key.RIGHT = ["RIGHT",12]; kha_Key.RIGHT.toString = $estr; kha_Key.RIGHT.__enum__ = kha_Key; kha_Key.BACK = ["BACK",13]; kha_Key.BACK.toString = $estr; kha_Key.BACK.__enum__ = kha_Key; var kha_AlignedQuad = function() { }; $hxClasses["kha.AlignedQuad"] = kha_AlignedQuad; kha_AlignedQuad.__name__ = true; kha_AlignedQuad.prototype = { x0: null ,y0: null ,s0: null ,t0: null ,x1: null ,y1: null ,s1: null ,t1: null ,xadvance: null ,__class__: kha_AlignedQuad }; var kha_KravurImage = function(size,ascent,descent,lineGap,width,height,chars,pixels) { this.mySize = size; this.width = width; this.height = height; this.chars = chars; this.baseline = ascent; var _g = 0; while(_g < chars.length) { var $char = chars[_g]; ++_g; $char.yoff += this.baseline; } this.texture = kha_Image.create(width,height,kha_graphics4_TextureFormat.L8); var bytes = this.texture.lock(); var pos = 0; var _g1 = 0; var _g2 = height; while(_g1 < _g2) { var y = _g1++; var _g3 = 0; var _g21 = width; while(_g3 < _g21) { var x = _g3++; var v = pixels.readU8(pos); bytes.b[pos] = v & 255; ++pos; } } this.texture.unlock(); }; $hxClasses["kha.KravurImage"] = kha_KravurImage; kha_KravurImage.__name__ = true; kha_KravurImage.prototype = { mySize: null ,chars: null ,texture: null ,width: null ,height: null ,baseline: null ,getTexture: function() { return this.texture; } ,getBakedQuad: function(char_index,xpos,ypos) { if(char_index >= this.chars.length) { return null; } var ipw = 1.0 / this.width; var iph = 1.0 / this.height; var b = this.chars[char_index]; if(b == null) { return null; } var round_x = Math.round(xpos + b.xoff); var round_y = Math.round(ypos + b.yoff); var q = new kha_AlignedQuad(); q.x0 = round_x; q.y0 = round_y; q.x1 = round_x + b.x1 - b.x0; q.y1 = round_y + b.y1 - b.y0; q.s0 = b.x0 * ipw; q.t0 = b.y0 * iph; q.s1 = b.x1 * ipw; q.t1 = b.y1 * iph; q.xadvance = b.xadvance; return q; } ,getCharWidth: function(charIndex) { if(charIndex < 32) { return 0; } if(charIndex - 32 >= this.chars.length) { return 0; } return this.chars[charIndex - 32].xadvance; } ,getHeight: function() { return this.mySize; } ,stringWidth: function(string) { var str = new String(string); var width = 0; var _g1 = 0; var _g = str.length; while(_g1 < _g) { var c = _g1++; width += this.getCharWidth(HxOverrides.cca(str,c)); } return width; } ,getBaselinePosition: function() { return this.baseline; } ,__class__: kha_KravurImage }; var kha_Kravur = function(blob) { this.images = new haxe_ds_IntMap(); this.blob = blob; }; $hxClasses["kha.Kravur"] = kha_Kravur; kha_Kravur.__name__ = true; kha_Kravur.__interfaces__ = [kha_Font]; kha_Kravur.prototype = { blob: null ,images: null ,_get: function(fontSize,glyphs) { if(!this.images.h.hasOwnProperty(fontSize)) { if(glyphs == null) { glyphs = []; var _g = 32; while(_g < 256) { var i = _g++; glyphs.push(i); } } var width = 64; var height = 32; var length = glyphs.length; var this1 = new Array(length); var baked = this1; var _g1 = 0; var _g2 = baked.length; while(_g1 < _g2) { var i1 = _g1++; baked[i1] = new kha_graphics2_truetype_Stbtt_$bakedchar(); } var pixels = null; var status = -1; while(status < 0) { if(height < width) { height *= 2; } else { width *= 2; } pixels = kha_internal_BytesBlob.alloc(width * height); status = kha_graphics2_truetype_StbTruetype.stbtt_BakeFontBitmap(this.blob,0,fontSize,pixels,width,height,glyphs,baked); } var info = new kha_graphics2_truetype_Stbtt_$fontinfo(); kha_graphics2_truetype_StbTruetype.stbtt_InitFont(info,this.blob,0); var metrics = kha_graphics2_truetype_StbTruetype.stbtt_GetFontVMetrics(info); var scale = kha_graphics2_truetype_StbTruetype.stbtt_ScaleForPixelHeight(info,fontSize); var ascent = Math.round(metrics.ascent * scale); var descent = Math.round(metrics.descent * scale); var lineGap = Math.round(metrics.lineGap * scale); var image = new kha_KravurImage(fontSize | 0,ascent,descent,lineGap,width,height,baked,pixels); this.images.h[fontSize] = image; return image; } return this.images.h[fontSize]; } ,height: function(fontSize) { return this._get(fontSize).getHeight(); } ,width: function(fontSize,str) { return this._get(fontSize).stringWidth(str); } ,baseline: function(fontSize) { return this._get(fontSize).getBaselinePosition(); } ,unload: function() { this.blob = null; this.images = null; } ,__class__: kha_Kravur }; var kha_LoaderImpl = function() { }; $hxClasses["kha.LoaderImpl"] = kha_LoaderImpl; kha_LoaderImpl.__name__ = true; kha_LoaderImpl.getImageFormats = function() { return ["png","jpg","hdr"]; }; kha_LoaderImpl.loadImageFromDescription = function(desc,done) { var readable = Object.prototype.hasOwnProperty.call(desc,"readable") && desc.readable; if(StringTools.endsWith(desc.files[0],".hdr")) { kha_LoaderImpl.loadBlobFromDescription(desc,function(blob) { var hdrImage = kha_internal_HdrFormat.parse(blob.toBytes()); var tmp = kha_Image.fromBytes(haxe_io_Bytes.ofData(hdrImage.data.buffer),hdrImage.width,hdrImage.height,kha_graphics4_TextureFormat.RGBA128,readable ? kha_graphics4_Usage.DynamicUsage : kha_graphics4_Usage.StaticUsage); done(tmp); }); } else { var img = window.document.createElement("img"); img.onload = function(event) { var tmp1 = kha_Image.fromImage(img,readable); done(tmp1); }; img.src = desc.files[0]; img.crossOrigin = ""; } }; kha_LoaderImpl.getSoundFormats = function() { var element = window.document.createElement("audio"); var formats = []; if(element.canPlayType("audio/mp4") != "") { formats.push("mp4"); } if(kha_SystemImpl._hasWebAudio || element.canPlayType("audio/ogg") != "") { formats.push("ogg"); } return formats; }; kha_LoaderImpl.loadSoundFromDescription = function(desc,done) { if(kha_SystemImpl._hasWebAudio) { var element = window.document.createElement("audio"); if(element.canPlayType("audio/mp4") != "") { var _g1 = 0; var _g = desc.files.length; while(_g1 < _g) { var i = _g1++; var file = desc.files[i]; if(StringTools.endsWith(file,".mp4")) { new kha_js_WebAudioSound(file,done); return; } } } var _g11 = 0; var _g2 = desc.files.length; while(_g11 < _g2) { var i1 = _g11++; var file1 = desc.files[i1]; if(StringTools.endsWith(file1,".ogg")) { new kha_js_WebAudioSound(file1,done); return; } } } else if(kha_SystemImpl.mobile) { var element1 = window.document.createElement("audio"); if(element1.canPlayType("audio/mp4") != "") { var _g12 = 0; var _g3 = desc.files.length; while(_g12 < _g3) { var i2 = _g12++; var file2 = desc.files[i2]; if(StringTools.endsWith(file2,".mp4")) { new kha_js_MobileWebAudioSound(file2,done); return; } } } var _g13 = 0; var _g4 = desc.files.length; while(_g13 < _g4) { var i3 = _g13++; var file3 = desc.files[i3]; if(StringTools.endsWith(file3,".ogg")) { new kha_js_MobileWebAudioSound(file3,done); return; } } } else { new kha_js_Sound(desc.files,done); } }; kha_LoaderImpl.getVideoFormats = function() { return ["mp4","webm"]; }; kha_LoaderImpl.loadVideoFromDescription = function(desc,done) { var video = new kha_js_Video(desc.files,done); }; kha_LoaderImpl.loadBlobFromDescription = function(desc,done) { var request = new XMLHttpRequest(); request.open("GET",desc.files[0],true); request.responseType = "arraybuffer"; request.onreadystatechange = function() { if(request.readyState != 4) { return; } if(request.status >= 200 && request.status < 400 || request.status == 0 && request.statusText == "") { var bytes = null; var arrayBuffer = request.response; if(arrayBuffer != null) { var byteArray = new Uint8Array(arrayBuffer); bytes = haxe_io_Bytes.ofData(byteArray); } else if(request.responseBody != null) { var data = VBArray(request.responseBody).toArray(); bytes = new haxe_io_Bytes(new ArrayBuffer(data.length)); var _g1 = 0; var _g = data.length; while(_g1 < _g) { var i = _g1++; bytes.b[i] = data[i] & 255; } } else { haxe_Log.trace("Error loading " + desc.files[0],{ fileName : "LoaderImpl.hx", lineNumber : 144, className : "kha.LoaderImpl", methodName : "loadBlobFromDescription"}); window.console.log("loadBlob failed"); } done(new kha_internal_BytesBlob(bytes)); } else { haxe_Log.trace("Error loading " + desc.files[0],{ fileName : "LoaderImpl.hx", lineNumber : 150, className : "kha.LoaderImpl", methodName : "loadBlobFromDescription"}); window.console.log("loadBlob failed"); } }; request.send(null); }; kha_LoaderImpl.loadFontFromDescription = function(desc,done) { kha_LoaderImpl.loadBlobFromDescription(desc,function(blob) { if(kha_SystemImpl.gl == null) { done(new kha_js_Font(new kha_Kravur(blob))); } else { done(new kha_Kravur(blob)); } }); }; var kha_Rotation = function(center,angle) { this.center = center; this.angle = angle; }; $hxClasses["kha.Rotation"] = kha_Rotation; kha_Rotation.__name__ = true; kha_Rotation.prototype = { center: null ,angle: null ,__class__: kha_Rotation }; var kha_TimeTask = function() { }; $hxClasses["kha.TimeTask"] = kha_TimeTask; kha_TimeTask.__name__ = true; kha_TimeTask.prototype = { task: null ,start: null ,period: null ,duration: null ,next: null ,id: null ,groupId: null ,active: null ,paused: null ,__class__: kha_TimeTask }; var kha_FrameTask = function(task,priority,id) { this.task = task; this.priority = priority; this.id = id; this.active = true; this.paused = false; }; $hxClasses["kha.FrameTask"] = kha_FrameTask; kha_FrameTask.__name__ = true; kha_FrameTask.prototype = { task: null ,priority: null ,id: null ,active: null ,paused: null ,__class__: kha_FrameTask }; var kha_Scheduler = function() { }; $hxClasses["kha.Scheduler"] = kha_Scheduler; kha_Scheduler.__name__ = true; kha_Scheduler.init = function() { kha_Scheduler.deltas = []; var _g1 = 0; var _g = kha_Scheduler.DIF_COUNT; while(_g1 < _g) { var i = _g1++; kha_Scheduler.deltas[i] = 0; } kha_Scheduler.stopped = true; kha_Scheduler.frame_tasks_sorted = true; kha_Scheduler.current = kha_Scheduler.realTime(); kha_Scheduler.lastTime = kha_Scheduler.realTime(); kha_Scheduler.currentFrameTaskId = 0; kha_Scheduler.currentTimeTaskId = 0; kha_Scheduler.currentGroupId = 0; kha_Scheduler.timeTasks = []; kha_Scheduler.pausedTimeTasks = []; kha_Scheduler.outdatedTimeTasks = []; kha_Scheduler.timeTasksScratchpad = []; kha_Scheduler.frameTasks = []; kha_Scheduler.toDeleteFrame = []; }; kha_Scheduler.start = function(restartTimers) { if(restartTimers == null) { restartTimers = false; } kha_Scheduler.vsync = kha_System.get_vsync(); var hz = kha_System.get_refreshRate(); if(hz >= 57 && hz <= 63) { hz = 60; } kha_Scheduler.onedifhz = 1.0 / hz; kha_Scheduler.stopped = false; kha_Scheduler.resetTime(); kha_Scheduler.lastTime = kha_Scheduler.realTime() - kha_Scheduler.startTime; var _g1 = 0; var _g = kha_Scheduler.DIF_COUNT; while(_g1 < _g) { var i = _g1++; kha_Scheduler.deltas[i] = 0; } if(restartTimers) { var _g2 = 0; var _g11 = kha_Scheduler.timeTasks; while(_g2 < _g11.length) { var timeTask = _g11[_g2]; ++_g2; timeTask.paused = false; } var _g3 = 0; var _g12 = kha_Scheduler.frameTasks; while(_g3 < _g12.length) { var frameTask = _g12[_g3]; ++_g3; frameTask.paused = false; } } }; kha_Scheduler.stop = function() { kha_Scheduler.stopped = true; }; kha_Scheduler.isStopped = function() { return kha_Scheduler.stopped; }; kha_Scheduler.warpTimeTasks = function(time,tasks) { var _g = 0; while(_g < tasks.length) { var timeTask = tasks[_g]; ++_g; if(timeTask.start >= time) { timeTask.next = timeTask.start; } else if(timeTask.period > 0) { var sinceStart = time - timeTask.start; var times = Math.ceil(sinceStart / timeTask.period); timeTask.next = timeTask.start + times * timeTask.period; } } }; kha_Scheduler.back = function(time) { if(time >= kha_Scheduler.lastTime) { return; } kha_Scheduler.current = time; kha_Scheduler.lastTime = time; kha_Scheduler.warpTimeTasks(time,kha_Scheduler.outdatedTimeTasks); kha_Scheduler.warpTimeTasks(time,kha_Scheduler.timeTasks); var _g = 0; var _g1 = kha_Scheduler.outdatedTimeTasks; while(_g < _g1.length) { var task = _g1[_g]; ++_g; if(task.next >= time) { kha_Scheduler.timeTasksScratchpad.push(task); } } var _g2 = 0; var _g11 = kha_Scheduler.timeTasksScratchpad; while(_g2 < _g11.length) { var task1 = _g11[_g2]; ++_g2; HxOverrides.remove(kha_Scheduler.outdatedTimeTasks,task1); } var _g3 = 0; var _g12 = kha_Scheduler.timeTasksScratchpad; while(_g3 < _g12.length) { var task2 = _g12[_g3]; ++_g3; kha_Scheduler.insertSorted(kha_Scheduler.timeTasks,task2); } while(kha_Scheduler.timeTasksScratchpad.length > 0) HxOverrides.remove(kha_Scheduler.timeTasksScratchpad,kha_Scheduler.timeTasksScratchpad[0]); var _g4 = 0; var _g13 = kha_Scheduler.outdatedTimeTasks; while(_g4 < _g13.length) { var task3 = _g13[_g4]; ++_g4; if(task3.next < time - 1.0) { kha_Scheduler.timeTasksScratchpad.push(task3); } } var _g5 = 0; var _g14 = kha_Scheduler.timeTasksScratchpad; while(_g5 < _g14.length) { var task4 = _g14[_g5]; ++_g5; HxOverrides.remove(kha_Scheduler.outdatedTimeTasks,task4); } while(kha_Scheduler.timeTasksScratchpad.length > 0) HxOverrides.remove(kha_Scheduler.timeTasksScratchpad,kha_Scheduler.timeTasksScratchpad[0]); }; kha_Scheduler.executeFrame = function() { var now = kha_Scheduler.realTime() - kha_Scheduler.startTime; var delta = now - kha_Scheduler.lastTime; var frameEnd = kha_Scheduler.current; if(delta < 0) { return; } if(delta > kha_Scheduler.maxframetime) { kha_Scheduler.startTime += delta - kha_Scheduler.maxframetime; delta = kha_Scheduler.maxframetime; frameEnd += delta; } else if(kha_Scheduler.vsync) { var realdif = kha_Scheduler.onedifhz; while(realdif < delta - kha_Scheduler.onedifhz) realdif += kha_Scheduler.onedifhz; delta = realdif; var _g1 = 0; var _g = kha_Scheduler.DIF_COUNT - 2; while(_g1 < _g) { var i = _g1++; delta += kha_Scheduler.deltas[i]; kha_Scheduler.deltas[i] = kha_Scheduler.deltas[i + 1]; } delta += kha_Scheduler.deltas[kha_Scheduler.DIF_COUNT - 2]; delta /= kha_Scheduler.DIF_COUNT; kha_Scheduler.deltas[kha_Scheduler.DIF_COUNT - 2] = realdif; frameEnd += delta; } else { var _g11 = 0; var _g2 = kha_Scheduler.DIF_COUNT - 1; while(_g11 < _g2) { var i1 = _g11++; kha_Scheduler.deltas[i1] = kha_Scheduler.deltas[i1 + 1]; } kha_Scheduler.deltas[kha_Scheduler.DIF_COUNT - 1] = delta; var next = 0; var _g12 = 0; var _g3 = kha_Scheduler.DIF_COUNT; while(_g12 < _g3) { var i2 = _g12++; next += kha_Scheduler.deltas[i2]; } next /= kha_Scheduler.DIF_COUNT; frameEnd += next; } kha_Scheduler.lastTime = frameEnd; if(!kha_Scheduler.stopped) { kha_Scheduler.current = frameEnd; } var _g4 = 0; var _g13 = kha_Scheduler.pausedTimeTasks; while(_g4 < _g13.length) { var pausedTask = _g13[_g4]; ++_g4; pausedTask.next += delta; } if(kha_Scheduler.stopped) { var _g5 = 0; var _g14 = kha_Scheduler.timeTasks; while(_g5 < _g14.length) { var timeTask = _g14[_g5]; ++_g5; timeTask.next += delta; } } while(kha_Scheduler.timeTasks.length > 0) { kha_Scheduler.activeTimeTask = kha_Scheduler.timeTasks[0]; if(kha_Scheduler.activeTimeTask.next <= frameEnd) { kha_Scheduler.activeTimeTask.next += kha_Scheduler.activeTimeTask.period; HxOverrides.remove(kha_Scheduler.timeTasks,kha_Scheduler.activeTimeTask); if(kha_Scheduler.activeTimeTask.active && kha_Scheduler.activeTimeTask.task()) { if(kha_Scheduler.activeTimeTask.period > 0 && (kha_Scheduler.activeTimeTask.duration == 0 || kha_Scheduler.activeTimeTask.duration >= kha_Scheduler.activeTimeTask.start + kha_Scheduler.activeTimeTask.next)) { kha_Scheduler.insertSorted(kha_Scheduler.timeTasks,kha_Scheduler.activeTimeTask); } else { kha_Scheduler.archiveTimeTask(kha_Scheduler.activeTimeTask,frameEnd); } } else { kha_Scheduler.activeTimeTask.active = false; kha_Scheduler.archiveTimeTask(kha_Scheduler.activeTimeTask,frameEnd); } } else { break; } } kha_Scheduler.activeTimeTask = null; kha_Scheduler.sortFrameTasks(); var _g6 = 0; var _g15 = kha_Scheduler.frameTasks; while(_g6 < _g15.length) { var frameTask = _g15[_g6]; ++_g6; if(!kha_Scheduler.stopped && !frameTask.paused && frameTask.active) { if(!frameTask.task()) { frameTask.active = false; } } } var _g7 = 0; var _g16 = kha_Scheduler.frameTasks; while(_g7 < _g16.length) { var frameTask1 = _g16[_g7]; ++_g7; if(!frameTask1.active) { kha_Scheduler.toDeleteFrame.push(frameTask1); } } while(kha_Scheduler.toDeleteFrame.length > 0) HxOverrides.remove(kha_Scheduler.frameTasks,kha_Scheduler.toDeleteFrame.pop()); }; kha_Scheduler.archiveTimeTask = function(timeTask,frameEnd) { }; kha_Scheduler.time = function() { return kha_Scheduler.current; }; kha_Scheduler.realTime = function() { return kha_System.get_time(); }; kha_Scheduler.resetTime = function() { var now = kha_System.get_time(); var dif = now - kha_Scheduler.startTime; kha_Scheduler.startTime = now; var _g = 0; var _g1 = kha_Scheduler.timeTasks; while(_g < _g1.length) { var timeTask = _g1[_g]; ++_g; timeTask.start -= dif; timeTask.next -= dif; } var _g11 = 0; var _g2 = kha_Scheduler.DIF_COUNT; while(_g11 < _g2) { var i = _g11++; kha_Scheduler.deltas[i] = 0; } kha_Scheduler.current = 0; kha_Scheduler.lastTime = 0; }; kha_Scheduler.addBreakableFrameTask = function(task,priority) { kha_Scheduler.frameTasks.push(new kha_FrameTask(task,priority,++kha_Scheduler.currentFrameTaskId)); kha_Scheduler.frame_tasks_sorted = false; return kha_Scheduler.currentFrameTaskId; }; kha_Scheduler.addFrameTask = function(task,priority) { return kha_Scheduler.addBreakableFrameTask(function() { task(); return true; },priority); }; kha_Scheduler.pauseFrameTask = function(id,paused) { var _g = 0; var _g1 = kha_Scheduler.frameTasks; while(_g < _g1.length) { var frameTask = _g1[_g]; ++_g; if(frameTask.id == id) { frameTask.paused = paused; break; } } }; kha_Scheduler.removeFrameTask = function(id) { var _g = 0; var _g1 = kha_Scheduler.frameTasks; while(_g < _g1.length) { var frameTask = _g1[_g]; ++_g; if(frameTask.id == id) { frameTask.active = false; break; } } }; kha_Scheduler.generateGroupId = function() { return ++kha_Scheduler.currentGroupId; }; kha_Scheduler.addBreakableTimeTaskToGroup = function(groupId,task,start,period,duration) { if(duration == null) { duration = 0; } if(period == null) { period = 0; } var t = new kha_TimeTask(); t.active = true; t.task = task; t.id = ++kha_Scheduler.currentTimeTaskId; t.groupId = groupId; t.start = kha_Scheduler.current + start; t.period = 0; if(period != 0) { t.period = period; } t.duration = 0; if(duration != 0) { t.duration = t.start + duration; } t.next = t.start; kha_Scheduler.insertSorted(kha_Scheduler.timeTasks,t); return t.id; }; kha_Scheduler.addTimeTaskToGroup = function(groupId,task,start,period,duration) { if(duration == null) { duration = 0; } if(period == null) { period = 0; } return kha_Scheduler.addBreakableTimeTaskToGroup(groupId,function() { task(); return true; },start,period,duration); }; kha_Scheduler.addBreakableTimeTask = function(task,start,period,duration) { if(duration == null) { duration = 0; } if(period == null) { period = 0; } return kha_Scheduler.addBreakableTimeTaskToGroup(0,task,start,period,duration); }; kha_Scheduler.addTimeTask = function(task,start,period,duration) { if(duration == null) { duration = 0; } if(period == null) { period = 0; } return kha_Scheduler.addTimeTaskToGroup(0,task,start,period,duration); }; kha_Scheduler.getTimeTask = function(id) { if(kha_Scheduler.activeTimeTask != null && kha_Scheduler.activeTimeTask.id == id) { return kha_Scheduler.activeTimeTask; } var _g = 0; var _g1 = kha_Scheduler.timeTasks; while(_g < _g1.length) { var timeTask = _g1[_g]; ++_g; if(timeTask.id == id) { return timeTask; } } var _g2 = 0; var _g11 = kha_Scheduler.pausedTimeTasks; while(_g2 < _g11.length) { var timeTask1 = _g11[_g2]; ++_g2; if(timeTask1.id == id) { return timeTask1; } } return null; }; kha_Scheduler.pauseTimeTask = function(id,paused) { var timeTask = kha_Scheduler.getTimeTask(id); if(timeTask != null) { kha_Scheduler.pauseRunningTimeTask(timeTask,paused); } if(kha_Scheduler.activeTimeTask != null && kha_Scheduler.activeTimeTask.id == id) { kha_Scheduler.activeTimeTask.paused = paused; } }; kha_Scheduler.pauseRunningTimeTask = function(timeTask,paused) { timeTask.paused = paused; if(paused) { HxOverrides.remove(kha_Scheduler.timeTasks,timeTask); kha_Scheduler.pausedTimeTasks.push(timeTask); } else { kha_Scheduler.insertSorted(kha_Scheduler.timeTasks,timeTask); HxOverrides.remove(kha_Scheduler.pausedTimeTasks,timeTask); } }; kha_Scheduler.pauseTimeTasks = function(groupId,paused) { var _g = 0; var _g1 = kha_Scheduler.timeTasks; while(_g < _g1.length) { var timeTask = _g1[_g]; ++_g; if(timeTask.groupId == groupId) { kha_Scheduler.pauseRunningTimeTask(timeTask,paused); } } if(kha_Scheduler.activeTimeTask != null && kha_Scheduler.activeTimeTask.groupId == groupId) { kha_Scheduler.activeTimeTask.paused = paused; } }; kha_Scheduler.removeTimeTask = function(id) { var timeTask = kha_Scheduler.getTimeTask(id); if(timeTask != null) { timeTask.active = false; HxOverrides.remove(kha_Scheduler.timeTasks,timeTask); } }; kha_Scheduler.removeTimeTasks = function(groupId) { var _g = 0; var _g1 = kha_Scheduler.timeTasks; while(_g < _g1.length) { var timeTask = _g1[_g]; ++_g; if(timeTask.groupId == groupId) { timeTask.active = false; kha_Scheduler.timeTasksScratchpad.push(timeTask); } } var _g2 = 0; var _g11 = kha_Scheduler.timeTasksScratchpad; while(_g2 < _g11.length) { var timeTask1 = _g11[_g2]; ++_g2; HxOverrides.remove(kha_Scheduler.timeTasks,timeTask1); } while(kha_Scheduler.timeTasksScratchpad.length > 0) HxOverrides.remove(kha_Scheduler.timeTasksScratchpad,kha_Scheduler.timeTasksScratchpad[0]); if(kha_Scheduler.activeTimeTask != null && kha_Scheduler.activeTimeTask.groupId == groupId) { kha_Scheduler.activeTimeTask.active = false; } }; kha_Scheduler.numTasksInSchedule = function() { return kha_Scheduler.timeTasks.length + kha_Scheduler.frameTasks.length; }; kha_Scheduler.insertSorted = function(list,task) { var _g1 = 0; var _g = list.length; while(_g1 < _g) { var i = _g1++; if(list[i].next > task.next) { list.splice(i,0,task); return; } } list.push(task); }; kha_Scheduler.sortFrameTasks = function() { if(kha_Scheduler.frame_tasks_sorted) { return; } kha_Scheduler.frameTasks.sort(function(a,b) { if(a.priority > b.priority) { return 1; } else if(a.priority < b.priority) { return -1; } else { return 0; } }); kha_Scheduler.frame_tasks_sorted = true; }; var kha_ScreenRotation = $hxClasses["kha.ScreenRotation"] = { __ename__ : true, __constructs__ : ["RotationNone","Rotation90","Rotation180","Rotation270"] }; kha_ScreenRotation.RotationNone = ["RotationNone",0]; kha_ScreenRotation.RotationNone.toString = $estr; kha_ScreenRotation.RotationNone.__enum__ = kha_ScreenRotation; kha_ScreenRotation.Rotation90 = ["Rotation90",1]; kha_ScreenRotation.Rotation90.toString = $estr; kha_ScreenRotation.Rotation90.__enum__ = kha_ScreenRotation; kha_ScreenRotation.Rotation180 = ["Rotation180",2]; kha_ScreenRotation.Rotation180.toString = $estr; kha_ScreenRotation.Rotation180.__enum__ = kha_ScreenRotation; kha_ScreenRotation.Rotation270 = ["Rotation270",3]; kha_ScreenRotation.Rotation270.toString = $estr; kha_ScreenRotation.Rotation270.__enum__ = kha_ScreenRotation; var kha_Shaders = function() { }; $hxClasses["kha.Shaders"] = kha_Shaders; kha_Shaders.__name__ = true; kha_Shaders.init = function() { var blobs = []; var _g = 0; while(_g < 3) { var i = _g++; var data = Reflect.field(kha_Shaders,"painter_colored_fragData" + i); var bytes = haxe_Unserializer.run(data); blobs.push(kha_internal_BytesBlob.fromBytes(bytes)); } kha_Shaders.painter_colored_frag = new kha_graphics4_FragmentShader(blobs,["painter-colored.frag.essl","painter-colored-relaxed.frag.essl","painter-colored-webgl2.frag.essl"]); var blobs1 = []; var _g1 = 0; while(_g1 < 3) { var i1 = _g1++; var data1 = Reflect.field(kha_Shaders,"painter_colored_vertData" + i1); var bytes1 = haxe_Unserializer.run(data1); blobs1.push(kha_internal_BytesBlob.fromBytes(bytes1)); } kha_Shaders.painter_colored_vert = new kha_graphics4_VertexShader(blobs1,["painter-colored.vert.essl","painter-colored-relaxed.vert.essl","painter-colored-webgl2.vert.essl"]); var blobs2 = []; var _g2 = 0; while(_g2 < 3) { var i2 = _g2++; var data2 = Reflect.field(kha_Shaders,"painter_image_fragData" + i2); var bytes2 = haxe_Unserializer.run(data2); blobs2.push(kha_internal_BytesBlob.fromBytes(bytes2)); } kha_Shaders.painter_image_frag = new kha_graphics4_FragmentShader(blobs2,["painter-image.frag.essl","painter-image-relaxed.frag.essl","painter-image-webgl2.frag.essl"]); var blobs3 = []; var _g3 = 0; while(_g3 < 3) { var i3 = _g3++; var data3 = Reflect.field(kha_Shaders,"painter_image_vertData" + i3); var bytes3 = haxe_Unserializer.run(data3); blobs3.push(kha_internal_BytesBlob.fromBytes(bytes3)); } kha_Shaders.painter_image_vert = new kha_graphics4_VertexShader(blobs3,["painter-image.vert.essl","painter-image-relaxed.vert.essl","painter-image-webgl2.vert.essl"]); var blobs4 = []; var _g4 = 0; while(_g4 < 3) { var i4 = _g4++; var data4 = Reflect.field(kha_Shaders,"painter_text_fragData" + i4); var bytes4 = haxe_Unserializer.run(data4); blobs4.push(kha_internal_BytesBlob.fromBytes(bytes4)); } kha_Shaders.painter_text_frag = new kha_graphics4_FragmentShader(blobs4,["painter-text.frag.essl","painter-text-relaxed.frag.essl","painter-text-webgl2.frag.essl"]); var blobs5 = []; var _g5 = 0; while(_g5 < 3) { var i5 = _g5++; var data5 = Reflect.field(kha_Shaders,"painter_text_vertData" + i5); var bytes5 = haxe_Unserializer.run(data5); blobs5.push(kha_internal_BytesBlob.fromBytes(bytes5)); } kha_Shaders.painter_text_vert = new kha_graphics4_VertexShader(blobs5,["painter-text.vert.essl","painter-text-relaxed.vert.essl","painter-text-webgl2.vert.essl"]); var blobs6 = []; var _g6 = 0; while(_g6 < 3) { var i6 = _g6++; var data6 = Reflect.field(kha_Shaders,"painter_video_fragData" + i6); var bytes6 = haxe_Unserializer.run(data6); blobs6.push(kha_internal_BytesBlob.fromBytes(bytes6)); } kha_Shaders.painter_video_frag = new kha_graphics4_FragmentShader(blobs6,["painter-video.frag.essl","painter-video-relaxed.frag.essl","painter-video-webgl2.frag.essl"]); var blobs7 = []; var _g7 = 0; while(_g7 < 3) { var i7 = _g7++; var data7 = Reflect.field(kha_Shaders,"painter_video_vertData" + i7); var bytes7 = haxe_Unserializer.run(data7); blobs7.push(kha_internal_BytesBlob.fromBytes(bytes7)); } kha_Shaders.painter_video_vert = new kha_graphics4_VertexShader(blobs7,["painter-video.vert.essl","painter-video-relaxed.vert.essl","painter-video-webgl2.vert.essl"]); }; var kha_Sound = function() { }; $hxClasses["kha.Sound"] = kha_Sound; kha_Sound.__name__ = true; kha_Sound.__interfaces__ = [kha_Resource]; kha_Sound.prototype = { compressedData: null ,uncompressedData: null ,uncompress: function(done) { var output = new haxe_io_BytesOutput(); var header = kha_audio2_ogg_vorbis_Reader.readAll(this.compressedData,output,true); var soundBytes = output.getBytes(); var count = soundBytes.length / 4 | 0; if(header.channel == 1) { var this1 = new Array(count * 2); this.uncompressedData = this1; var _g1 = 0; var _g = count; while(_g1 < _g) { var i = _g1++; this.uncompressedData[i * 2] = soundBytes.getFloat(i * 4); this.uncompressedData[i * 2 + 1] = soundBytes.getFloat(i * 4); } } else { var this2 = new Array(count); this.uncompressedData = this2; var _g11 = 0; var _g2 = count; while(_g11 < _g2) { var i1 = _g11++; this.uncompressedData[i1] = soundBytes.getFloat(i1 * 4); } } this.compressedData = null; done(); } ,unload: function() { this.compressedData = null; this.uncompressedData = null; } ,__class__: kha_Sound }; var kha_System = function() { }; $hxClasses["kha.System"] = kha_System; kha_System.__name__ = true; kha_System.init = function(options,callback) { if(options.title == null) { options.title = "Kha"; } if(options.width == null) { options.width = 800; } if(options.height == null) { options.height = 600; } if(options.samplesPerPixel == null) { options.samplesPerPixel = 1; } if(options.vSync == null) { options.vSync = true; } if(options.windowMode == null) { options.windowMode = kha_WindowMode.Window; } kha_System.theTitle = options.title; kha_SystemImpl.init(options,callback); }; kha_System.initEx = function(title,options,windowCallback,callback) { kha_System.theTitle = title; kha_SystemImpl.initEx(title,options,windowCallback,callback); }; kha_System.get_title = function() { return kha_System.theTitle; }; kha_System.notifyOnRender = function(listener,id) { if(id == null) { id = 0; } while(id >= kha_System.renderListeners.length) kha_System.renderListeners.push([]); kha_System.renderListeners[id].push(listener); }; kha_System.removeRenderListener = function(listener,id) { if(id == null) { id = 0; } HxOverrides.remove(kha_System.renderListeners[id],listener); }; kha_System.notifyOnApplicationState = function(foregroundListener,resumeListener,pauseListener,backgroundListener,shutdownListener) { if(foregroundListener != null) { kha_System.foregroundListeners.push(foregroundListener); } if(resumeListener != null) { kha_System.resumeListeners.push(resumeListener); } if(pauseListener != null) { kha_System.pauseListeners.push(pauseListener); } if(backgroundListener != null) { kha_System.backgroundListeners.push(backgroundListener); } if(shutdownListener != null) { kha_System.shutdownListeners.push(shutdownListener); } }; kha_System.render = function(id,framebuffer) { if(kha_System.renderListeners.length == 0) { return; } var _g = 0; var _g1 = kha_System.renderListeners[id]; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(framebuffer); } }; kha_System.foreground = function() { var _g = 0; var _g1 = kha_System.foregroundListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(); } }; kha_System.resume = function() { var _g = 0; var _g1 = kha_System.resumeListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(); } }; kha_System.pause = function() { var _g = 0; var _g1 = kha_System.pauseListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(); } }; kha_System.background = function() { var _g = 0; var _g1 = kha_System.backgroundListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(); } }; kha_System.shutdown = function() { var _g = 0; var _g1 = kha_System.shutdownListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(); } }; kha_System.get_time = function() { return kha_SystemImpl.getTime(); }; kha_System.windowWidth = function(windowId) { if(windowId == null) { windowId = 0; } return kha_SystemImpl.windowWidth(windowId); }; kha_System.windowHeight = function(windowId) { if(windowId == null) { windowId = 0; } return kha_SystemImpl.windowHeight(windowId); }; kha_System.screenDpi = function() { return kha_SystemImpl.screenDpi(); }; kha_System.get_screenRotation = function() { return kha_SystemImpl.getScreenRotation(); }; kha_System.get_vsync = function() { return kha_SystemImpl.getVsync(); }; kha_System.get_refreshRate = function() { return kha_SystemImpl.getRefreshRate(); }; kha_System.get_systemId = function() { return kha_SystemImpl.getSystemId(); }; kha_System.requestShutdown = function() { kha_SystemImpl.requestShutdown(); }; kha_System.changeResolution = function(width,height) { kha_SystemImpl.changeResolution(width,height); }; kha_System.loadUrl = function(url) { kha_SystemImpl.loadUrl(url); }; var kha_GamepadStates = function() { this.axes = []; this.buttons = []; }; $hxClasses["kha.GamepadStates"] = kha_GamepadStates; kha_GamepadStates.__name__ = true; kha_GamepadStates.prototype = { axes: null ,buttons: null ,__class__: kha_GamepadStates }; var kha_SystemImpl = function() { }; $hxClasses["kha.SystemImpl"] = kha_SystemImpl; kha_SystemImpl.__name__ = true; kha_SystemImpl.initPerformanceTimer = function() { if(window.performance != null && ($_=window.performance,$bind($_,$_.now)) != null) { kha_SystemImpl.performance = window.performance; } else { kha_SystemImpl.performance = window.Date; } }; kha_SystemImpl.errorHandler = function(message,source,lineno,colno,error) { window.console.error(error.stack); return true; }; kha_SystemImpl.init = function(options,callback) { kha_SystemImpl.options = options; kha_SystemImpl.mobile = kha_SystemImpl.isMobile(); kha_SystemImpl.chrome = kha_SystemImpl.isChrome(); kha_SystemImpl.init2(); callback(); }; kha_SystemImpl.initEx = function(title,options,windowCallback,callback) { haxe_Log.trace("initEx is not supported on the html5 target, running init() with first window options",{ fileName : "SystemImpl.hx", lineNumber : 86, className : "kha.SystemImpl", methodName : "initEx"}); kha_SystemImpl.init({ title : title, width : options[0].width, height : options[0].height},callback); if(windowCallback != null) { windowCallback(0); } }; kha_SystemImpl.isMobile = function() { var agent = window.navigator.userAgent; if(agent.indexOf("Android") >= 0 || agent.indexOf("webOS") >= 0 || agent.indexOf("iPhone") >= 0 || agent.indexOf("iPad") >= 0 || agent.indexOf("iPod") >= 0 || agent.indexOf("BlackBerry") >= 0 || agent.indexOf("Windows Phone") >= 0) { return true; } else { return false; } }; kha_SystemImpl.isChrome = function() { var agent = window.navigator.userAgent; if(agent.indexOf("Chrome") >= 0) { return true; } else { return false; } }; kha_SystemImpl.windowWidth = function(windowId) { if(windowId == null) { windowId = 0; } if(kha_SystemImpl.khanvas.width == 0 && kha_SystemImpl.options.width != null) { return kha_SystemImpl.options.width; } else { return kha_SystemImpl.khanvas.width; } }; kha_SystemImpl.windowHeight = function(windowId) { if(windowId == null) { windowId = 0; } if(kha_SystemImpl.khanvas.height == 0 && kha_SystemImpl.options.height != null) { return kha_SystemImpl.options.height; } else { return kha_SystemImpl.khanvas.height; } }; kha_SystemImpl.screenDpi = function() { var dpiElement = window.document.createElement("div"); dpiElement.style.position = "absolute"; dpiElement.style.width = "1in"; dpiElement.style.height = "1in"; dpiElement.style.left = "-100%"; dpiElement.style.top = "-100%"; window.document.body.appendChild(dpiElement); var dpi = dpiElement.offsetHeight; dpiElement.remove(); return dpi; }; kha_SystemImpl.setCanvas = function(canvas) { kha_SystemImpl.khanvas = canvas; }; kha_SystemImpl.getScreenRotation = function() { return kha_ScreenRotation.RotationNone; }; kha_SystemImpl.getTime = function() { return kha_SystemImpl.performance.now() / 1000; }; kha_SystemImpl.getVsync = function() { return true; }; kha_SystemImpl.getRefreshRate = function() { return 60; }; kha_SystemImpl.getSystemId = function() { return "HTML5"; }; kha_SystemImpl.requestShutdown = function() { window.close(); }; kha_SystemImpl.init2 = function(backbufferFormat) { haxe_Log.trace = js_Boot.__trace; kha_SystemImpl.keyboard = new kha_input_Keyboard(); kha_SystemImpl.mouse = new kha_input_MouseImpl(); kha_SystemImpl.surface = new kha_input_Surface(); kha_SystemImpl.gamepads = []; kha_SystemImpl.gamepadStates = []; var _g = 0; while(_g < 4) { var i = _g++; kha_SystemImpl.gamepads[i] = new kha_input_Gamepad(i); kha_SystemImpl.gamepadStates[i] = new kha_GamepadStates(); } kha_SystemImpl.pressedKeys = []; var _g1 = 0; while(_g1 < 256) { var i1 = _g1++; kha_SystemImpl.pressedKeys.push(false); } var _g2 = 0; while(_g2 < 256) { var i2 = _g2++; kha_SystemImpl.pressedKeys.push(null); } kha_CanvasImage.init(); kha_SystemImpl.initPerformanceTimer(); kha_Scheduler.init(); kha_SystemImpl.loadFinished(); kha_EnvironmentVariables.instance = new kha_js_EnvironmentVariables(); }; kha_SystemImpl.getMouse = function(num) { if(num != 0) { return null; } return kha_SystemImpl.mouse; }; kha_SystemImpl.getKeyboard = function(num) { if(num != 0) { return null; } return kha_SystemImpl.keyboard; }; kha_SystemImpl.checkGamepad = function(pad) { var _g1 = 0; var _g = pad.axes.length; while(_g1 < _g) { var i = _g1++; if(pad.axes[i] != null) { if(kha_SystemImpl.gamepadStates[pad.index].axes[i] != pad.axes[i]) { var axis = pad.axes[i]; if(i % 2 == 1) { axis = -axis; } kha_SystemImpl.gamepadStates[pad.index].axes[i] = axis; kha_SystemImpl.gamepads[pad.index].sendAxisEvent(i,axis); } } } var _g11 = 0; var _g2 = pad.buttons.length; while(_g11 < _g2) { var i1 = _g11++; if(pad.buttons[i1] != null) { if(kha_SystemImpl.gamepadStates[pad.index].buttons[i1] != pad.buttons[i1].value) { kha_SystemImpl.gamepadStates[pad.index].buttons[i1] = pad.buttons[i1].value; kha_SystemImpl.gamepads[pad.index].sendButtonEvent(i1,pad.buttons[i1].value); } } } if(pad.axes.length <= 4 && pad.buttons.length > 7) { kha_SystemImpl.gamepadStates[pad.index].axes[4] = pad.buttons[6].value; kha_SystemImpl.gamepads[pad.index].sendAxisEvent(4,pad.buttons[6].value); kha_SystemImpl.gamepadStates[pad.index].axes[5] = pad.buttons[7].value; kha_SystemImpl.gamepads[pad.index].sendAxisEvent(5,pad.buttons[7].value); } }; kha_SystemImpl.loadFinished = function() { var canvas = kha_SystemImpl.khanvas; if(canvas == null) { canvas = window.document.getElementById(kha_CompilerDefines.canvas_id); } canvas.style.cursor = "default"; var gl = false; try { kha_SystemImpl.gl = canvas.getContext("webgl2",{ alpha : false, antialias : kha_SystemImpl.options.samplesPerPixel > 1, stencil : true, preserveDrawingBuffer : true}); kha_SystemImpl.gl.pixelStorei(37441,1); kha_SystemImpl.halfFloat = { HALF_FLOAT_OES : 5131}; kha_SystemImpl.depthTexture = { UNSIGNED_INT_24_8_WEBGL : 34042}; kha_SystemImpl.drawBuffers = { COLOR_ATTACHMENT0_WEBGL : 36064}; kha_SystemImpl.elementIndexUint = true; kha_SystemImpl.gl.getExtension("EXT_color_buffer_float"); kha_SystemImpl.gl.getExtension("OES_texture_float_linear"); kha_SystemImpl.gl.getExtension("OES_texture_half_float_linear"); kha_SystemImpl.anisotropicFilter = kha_SystemImpl.gl.getExtension("EXT_texture_filter_anisotropic"); if(kha_SystemImpl.anisotropicFilter == null) { kha_SystemImpl.anisotropicFilter = kha_SystemImpl.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); } gl = true; kha_SystemImpl.gl2 = true; kha_Shaders.init(); } catch( e ) { haxe_Log.trace("Could not initialize WebGL 2, falling back to WebGL.",{ fileName : "SystemImpl.hx", lineNumber : 302, className : "kha.SystemImpl", methodName : "loadFinished"}); } if(!kha_SystemImpl.gl2) { try { kha_SystemImpl.gl = canvas.getContext("experimental-webgl",{ alpha : false, antialias : kha_SystemImpl.options.samplesPerPixel > 1, stencil : true, preserveDrawingBuffer : true}); if(kha_SystemImpl.gl != null) { kha_SystemImpl.gl.pixelStorei(37441,1); kha_SystemImpl.gl.getExtension("OES_texture_float"); kha_SystemImpl.gl.getExtension("OES_texture_float_linear"); kha_SystemImpl.halfFloat = kha_SystemImpl.gl.getExtension("OES_texture_half_float"); kha_SystemImpl.gl.getExtension("OES_texture_half_float_linear"); kha_SystemImpl.depthTexture = kha_SystemImpl.gl.getExtension("WEBGL_depth_texture"); kha_SystemImpl.gl.getExtension("EXT_shader_texture_lod"); kha_SystemImpl.gl.getExtension("OES_standard_derivatives"); kha_SystemImpl.anisotropicFilter = kha_SystemImpl.gl.getExtension("EXT_texture_filter_anisotropic"); if(kha_SystemImpl.anisotropicFilter == null) { kha_SystemImpl.anisotropicFilter = kha_SystemImpl.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic"); } kha_SystemImpl.drawBuffers = kha_SystemImpl.gl.getExtension("WEBGL_draw_buffers"); kha_SystemImpl.elementIndexUint = kha_SystemImpl.gl.getExtension("OES_element_index_uint"); gl = true; kha_Shaders.init(); } } catch( e1 ) { haxe_Log.trace("Could not initialize WebGL, falling back to Canvas.",{ fileName : "SystemImpl.hx", lineNumber : 326, className : "kha.SystemImpl", methodName : "loadFinished"}); } } kha_SystemImpl.setCanvas(canvas); if(gl) { var g4 = gl ? new kha_js_graphics4_Graphics() : null; kha_SystemImpl.frame = new kha_Framebuffer(0,null,null,g4); kha_SystemImpl.frame.init(new kha_graphics2_Graphics1(kha_SystemImpl.frame),new kha_js_graphics4_Graphics2(kha_SystemImpl.frame),g4); } else { var g2 = new kha_js_CanvasGraphics(canvas.getContext("2d")); kha_SystemImpl.frame = new kha_Framebuffer(0,null,g2,null); kha_SystemImpl.frame.init(new kha_graphics2_Graphics1(kha_SystemImpl.frame),g2,null); } if(!kha_SystemImpl.mobile && kha_audio2_Audio._init()) { kha_SystemImpl._hasWebAudio = true; kha_audio2_Audio1._init(); } else if(kha_SystemImpl.mobile) { kha_SystemImpl._hasWebAudio = false; kha_js_MobileWebAudio._init(); kha_audio2_Audio1 = kha_js_MobileWebAudio; } else { kha_SystemImpl._hasWebAudio = false; kha_js_AudioElementAudio._compile(); kha_audio2_Audio1 = kha_js_AudioElementAudio; } kha_vr_VrInterface.instance = new kha_js_vr_VrInterface(); kha_Scheduler.start(); var $window = window; var requestAnimationFrame = $window.requestAnimationFrame; if(requestAnimationFrame == null) { requestAnimationFrame = $window.mozRequestAnimationFrame; } if(requestAnimationFrame == null) { requestAnimationFrame = $window.webkitRequestAnimationFrame; } if(requestAnimationFrame == null) { requestAnimationFrame = $window.msRequestAnimationFrame; } var animate = null; animate = function(timestamp) { var window1 = window; if(requestAnimationFrame == null) { window1.setTimeout(animate,16.6666666666666679); } else { requestAnimationFrame(animate); } var sysGamepads = kha_SystemImpl.getGamepads(); if(sysGamepads != null) { var _g1 = 0; var _g = sysGamepads.length; while(_g1 < _g) { var i = _g1++; var pad = sysGamepads[i]; if(pad != null) { kha_SystemImpl.checkGamepad(pad); } } } kha_Scheduler.executeFrame(); if(canvas.getContext) { var displayWidth = canvas.clientWidth; var displayHeight = canvas.clientHeight; if(canvas.width != displayWidth || canvas.height != displayHeight) { canvas.width = displayWidth; canvas.height = displayHeight; } kha_System.render(0,kha_SystemImpl.frame); if(kha_SystemImpl.gl != null) { kha_SystemImpl.gl.clearColor(1,1,1,1); kha_SystemImpl.gl.colorMask(false,false,false,true); kha_SystemImpl.gl.clear(16384); kha_SystemImpl.gl.colorMask(true,true,true,true); } } }; var animate1 = animate; if(requestAnimationFrame == null) { $window.setTimeout(animate1,16.6666666666666679); } else { requestAnimationFrame(animate1); } if(canvas.getAttribute("tabindex") == null) { canvas.setAttribute("tabindex","0"); } canvas.focus(); canvas.oncontextmenu = function(event) { event.stopPropagation(); event.preventDefault(); }; canvas.onmousedown = kha_SystemImpl.mouseDown; canvas.onmousemove = kha_SystemImpl.mouseMove; if(kha_SystemImpl.keyboard != null) { canvas.onkeydown = kha_SystemImpl.keyDown; canvas.onkeyup = kha_SystemImpl.keyUp; } canvas.onblur = kha_SystemImpl.onBlur; canvas.onfocus = kha_SystemImpl.onFocus; canvas.onmousewheel = canvas.onwheel = kha_SystemImpl.mouseWheel; canvas.onmouseleave = kha_SystemImpl.mouseLeave; canvas.addEventListener("wheel mousewheel",kha_SystemImpl.mouseWheel,false); canvas.addEventListener("touchstart",kha_SystemImpl.touchDown,false); canvas.addEventListener("touchend",kha_SystemImpl.touchUp,false); canvas.addEventListener("touchmove",kha_SystemImpl.touchMove,false); window.addEventListener("unload",kha_SystemImpl.unload); }; kha_SystemImpl.lockMouse = function() { if(($_=kha_SystemImpl.khanvas,$bind($_,$_.requestPointerLock))) { kha_SystemImpl.khanvas.requestPointerLock(); } else if(kha_SystemImpl.khanvas.mozRequestPointerLock) { kha_SystemImpl.khanvas.mozRequestPointerLock(); } else if(kha_SystemImpl.khanvas.webkitRequestPointerLock) { kha_SystemImpl.khanvas.webkitRequestPointerLock(); } }; kha_SystemImpl.unlockMouse = function() { if(document.exitPointerLock) { document.exitPointerLock(); } else if(document.mozExitPointerLock) { document.mozExitPointerLock(); } else if(document.webkitExitPointerLock) { document.webkitExitPointerLock(); } }; kha_SystemImpl.canLockMouse = function() { return 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; }; kha_SystemImpl.isMouseLocked = function() { return document.pointerLockElement === kha_Sys.khanvas || document.mozPointerLockElement === kha_Sys.khanvas || document.webkitPointerLockElement === kha_Sys.khanvas; }; kha_SystemImpl.notifyOfMouseLockChange = function(func,error) { window.document.addEventListener("pointerlockchange",func,false); window.document.addEventListener("mozpointerlockchange",func,false); window.document.addEventListener("webkitpointerlockchange",func,false); window.document.addEventListener("pointerlockerror",error,false); window.document.addEventListener("mozpointerlockerror",error,false); window.document.addEventListener("webkitpointerlockerror",error,false); }; kha_SystemImpl.removeFromMouseLockChange = function(func,error) { window.document.removeEventListener("pointerlockchange",func,false); window.document.removeEventListener("mozpointerlockchange",func,false); window.document.removeEventListener("webkitpointerlockchange",func,false); window.document.removeEventListener("pointerlockerror",error,false); window.document.removeEventListener("mozpointerlockerror",error,false); window.document.removeEventListener("webkitpointerlockerror",error,false); }; kha_SystemImpl.unload = function(_) { }; kha_SystemImpl.setMouseXY = function(event) { var rect = kha_SystemImpl.khanvas.getBoundingClientRect(); var borderWidth = kha_SystemImpl.khanvas.clientLeft; var borderHeight = kha_SystemImpl.khanvas.clientTop; kha_SystemImpl.mouseX = (event.clientX - rect.left - borderWidth) * kha_SystemImpl.khanvas.width / (rect.width - 2 * borderWidth) | 0; kha_SystemImpl.mouseY = (event.clientY - rect.top - borderHeight) * kha_SystemImpl.khanvas.height / (rect.height - 2 * borderHeight) | 0; }; kha_SystemImpl.unlockSoundOnIOS = function() { if(!kha_SystemImpl.mobile || kha_SystemImpl.iosSoundEnabled) { return; } var buffer = kha_js_MobileWebAudio._context.createBuffer(1,1,22050); var source = kha_js_MobileWebAudio._context.createBufferSource(); source.buffer = buffer; source.connect(kha_js_MobileWebAudio._context.destination); if(source.noteOn) { source.noteOn(0); } kha_SystemImpl.iosSoundEnabled = true; }; kha_SystemImpl.mouseLeave = function() { kha_SystemImpl.mouse.sendLeaveEvent(0); }; kha_SystemImpl.mouseWheel = function(event) { kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.unlockSoundOnIOS(); event.preventDefault(); if(event.deltaMode == 0) { if(event.deltaY < 0) { kha_SystemImpl.mouse.sendWheelEvent(0,-1); } else if(event.deltaY > 0) { kha_SystemImpl.mouse.sendWheelEvent(0,1); } kha_SystemImpl.insideInputEvent = false; return false; } if(event.deltaMode == 1) { kha_SystemImpl.minimumScroll = Math.min(kha_SystemImpl.minimumScroll,Math.abs(event.deltaY)) | 0; kha_SystemImpl.mouse.sendWheelEvent(0,event.deltaY / kha_SystemImpl.minimumScroll | 0); kha_SystemImpl.insideInputEvent = false; return false; } kha_SystemImpl.insideInputEvent = false; return false; }; kha_SystemImpl.mouseDown = function(event) { kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.unlockSoundOnIOS(); kha_SystemImpl.setMouseXY(event); if(event.which == 1) { if(event.ctrlKey) { kha_SystemImpl.leftMouseCtrlDown = true; kha_SystemImpl.mouse.sendDownEvent(0,1,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); } else { kha_SystemImpl.leftMouseCtrlDown = false; kha_SystemImpl.mouse.sendDownEvent(0,0,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); } if(($_=kha_SystemImpl.khanvas,$bind($_,$_.setCapture)) != null) { kha_SystemImpl.khanvas.setCapture(); } kha_SystemImpl.khanvas.ownerDocument.addEventListener("mouseup",kha_SystemImpl.mouseLeftUp); } else if(event.which == 2) { kha_SystemImpl.mouse.sendDownEvent(0,2,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); kha_SystemImpl.khanvas.ownerDocument.addEventListener("mouseup",kha_SystemImpl.mouseMiddleUp); } else if(event.which == 3) { kha_SystemImpl.mouse.sendDownEvent(0,1,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); kha_SystemImpl.khanvas.ownerDocument.addEventListener("mouseup",kha_SystemImpl.mouseRightUp); } kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.mouseLeftUp = function(event) { kha_SystemImpl.unlockSoundOnIOS(); if(event.which != 1) { return; } kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.khanvas.ownerDocument.removeEventListener("mouseup",kha_SystemImpl.mouseLeftUp); if(($_=kha_SystemImpl.khanvas,$bind($_,$_.releaseCapture)) != null) { kha_SystemImpl.khanvas.ownerDocument.releaseCapture(); } if(kha_SystemImpl.leftMouseCtrlDown) { kha_SystemImpl.mouse.sendUpEvent(0,1,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); } else { kha_SystemImpl.mouse.sendUpEvent(0,0,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); } kha_SystemImpl.leftMouseCtrlDown = false; kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.mouseMiddleUp = function(event) { kha_SystemImpl.unlockSoundOnIOS(); if(event.which != 2) { return; } kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.khanvas.ownerDocument.removeEventListener("mouseup",kha_SystemImpl.mouseMiddleUp); kha_SystemImpl.mouse.sendUpEvent(0,2,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.mouseRightUp = function(event) { kha_SystemImpl.unlockSoundOnIOS(); if(event.which != 3) { return; } kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.khanvas.ownerDocument.removeEventListener("mouseup",kha_SystemImpl.mouseRightUp); kha_SystemImpl.mouse.sendUpEvent(0,1,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY); kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.mouseMove = function(event) { kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.unlockSoundOnIOS(); var lastMouseX = kha_SystemImpl.mouseX; var lastMouseY = kha_SystemImpl.mouseY; kha_SystemImpl.setMouseXY(event); var movementX = event.movementX; var movementY = event.movementY; if(event.movementX == null) { if(event.mozMovementX != null) { movementX = event.mozMovementX; } else if(event.webkitMovementX != null) { movementX = event.webkitMovementX; } else { movementX = kha_SystemImpl.mouseX - lastMouseX; } if(event.mozMovementY != null) { movementY = event.mozMovementY; } else if(event.webkitMovementY != null) { movementY = event.webkitMovementY; } else { movementY = kha_SystemImpl.mouseY - lastMouseY; } } kha_SystemImpl.mouse.sendMoveEvent(0,kha_SystemImpl.mouseX,kha_SystemImpl.mouseY,movementX,movementY); kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.setTouchXY = function(touch) { var rect = kha_SystemImpl.khanvas.getBoundingClientRect(); var borderWidth = kha_SystemImpl.khanvas.clientLeft; var borderHeight = kha_SystemImpl.khanvas.clientTop; kha_SystemImpl.touchX = (touch.clientX - rect.left - borderWidth) * kha_SystemImpl.khanvas.width / (rect.width - 2 * borderWidth) | 0; kha_SystemImpl.touchY = (touch.clientY - rect.top - borderHeight) * kha_SystemImpl.khanvas.height / (rect.height - 2 * borderHeight) | 0; }; kha_SystemImpl.touchDown = function(event) { kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.unlockSoundOnIOS(); event.stopPropagation(); event.preventDefault(); var _g = 0; var _g1 = event.changedTouches; while(_g < _g1.length) { var touch = _g1[_g]; ++_g; kha_SystemImpl.setTouchXY(touch); kha_SystemImpl.mouse.sendDownEvent(0,0,kha_SystemImpl.touchX,kha_SystemImpl.touchY); kha_SystemImpl.surface.sendTouchStartEvent(touch.identifier,kha_SystemImpl.touchX,kha_SystemImpl.touchY); } kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.touchUp = function(event) { kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.unlockSoundOnIOS(); var _g = 0; var _g1 = event.changedTouches; while(_g < _g1.length) { var touch = _g1[_g]; ++_g; kha_SystemImpl.setTouchXY(touch); kha_SystemImpl.mouse.sendUpEvent(0,0,kha_SystemImpl.touchX,kha_SystemImpl.touchY); kha_SystemImpl.surface.sendTouchEndEvent(touch.identifier,kha_SystemImpl.touchX,kha_SystemImpl.touchY); } kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.touchMove = function(event) { kha_SystemImpl.insideInputEvent = true; kha_SystemImpl.unlockSoundOnIOS(); var index = 0; var _g = 0; var _g1 = event.changedTouches; while(_g < _g1.length) { var touch = _g1[_g]; ++_g; kha_SystemImpl.setTouchXY(touch); if(index == 0) { var movementX = kha_SystemImpl.touchX - kha_SystemImpl.lastFirstTouchX; var movementY = kha_SystemImpl.touchY - kha_SystemImpl.lastFirstTouchY; kha_SystemImpl.lastFirstTouchX = kha_SystemImpl.touchX; kha_SystemImpl.lastFirstTouchY = kha_SystemImpl.touchY; kha_SystemImpl.mouse.sendMoveEvent(0,kha_SystemImpl.touchX,kha_SystemImpl.touchY,movementX,movementY); } kha_SystemImpl.surface.sendMoveEvent(touch.identifier,kha_SystemImpl.touchX,kha_SystemImpl.touchY); ++index; } kha_SystemImpl.insideInputEvent = false; }; kha_SystemImpl.onBlur = function() { kha_System.background(); }; kha_SystemImpl.onFocus = function() { kha_System.foreground(); }; kha_SystemImpl.keycodeToChar = function(key,keycode,shift) { if(key != null) { if(key.length == 1) { return key; } switch(key) { case "Add": return "+"; case "Divide": return "/"; case "Multiply": return "*"; case "Subtract": return "-"; } } switch(keycode) { case 48: if(shift) { return "="; } else { return "0"; } break; case 49: if(shift) { return "!"; } else { return "1"; } break; case 50: if(shift) { return "\""; } else { return "2"; } break; case 51: if(shift) { return "§"; } else { return "3"; } break; case 52: if(shift) { return "$"; } else { return "4"; } break; case 53: if(shift) { return "%"; } else { return "5"; } break; case 54: if(shift) { return "&"; } else { return "6"; } break; case 55: if(shift) { return "/"; } else { return "7"; } break; case 56: if(shift) { return "("; } else { return "8"; } break; case 57: if(shift) { return ")"; } else { return "9"; } break; case 106: return "*"; case 107: return "+"; case 109: return "-"; case 111: return "/"; case 187: if(shift) { return "*"; } else { return "+"; } break; case 188: if(shift) { return ";"; } else { return ","; } break; case 189: if(shift) { return "_"; } else { return "-"; } break; case 190: if(shift) { return ":"; } else { return "."; } break; case 191: if(shift) { return "'"; } else { return "#"; } break; case 212: if(shift) { return "`"; } else { return "´"; } break; case 219: if(shift) { return "?"; } else { return "ß"; } break; case 226: if(shift) { return ">"; } else { return "<"; } break; } if(keycode >= 96 && keycode <= 105) { return String.fromCharCode(-48 + keycode); } if(keycode >= 65 && keycode <= 90) { if(shift) { return String.fromCharCode(keycode); } else { return String.fromCharCode(keycode - 65 + 97); } } return String.fromCharCode(keycode); }; kha_SystemImpl.keyDown = function(event) { event.stopPropagation(); if(kha_SystemImpl.pressedKeys[event.keyCode]) { event.preventDefault(); return; } kha_SystemImpl.pressedKeys[event.keyCode] = true; var _g = event.keyCode; switch(_g) { case 8: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.BACKSPACE,""); event.preventDefault(); break; case 9: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.TAB,""); event.preventDefault(); break; case 13: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.ENTER,""); event.preventDefault(); break; case 16: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.SHIFT,""); event.preventDefault(); break; case 17: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.CTRL,""); event.preventDefault(); break; case 18: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.ALT,""); event.preventDefault(); break; case 27: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.ESC,""); event.preventDefault(); break; case 32: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.CHAR," "); event.preventDefault(); break; case 37: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.LEFT,""); event.preventDefault(); break; case 38: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.UP,""); event.preventDefault(); break; case 39: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.RIGHT,""); event.preventDefault(); break; case 40: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.DOWN,""); event.preventDefault(); break; case 46: kha_SystemImpl.keyboard.sendDownEvent(kha_Key.DEL,""); event.preventDefault(); break; default: if(!event.altKey) { var $char = kha_SystemImpl.keycodeToChar(event.key,event.keyCode,event.shiftKey); kha_SystemImpl.keyboard.sendDownEvent(kha_Key.CHAR,$char); } } }; kha_SystemImpl.keyUp = function(event) { event.preventDefault(); event.stopPropagation(); kha_SystemImpl.pressedKeys[event.keyCode] = false; var _g = event.keyCode; switch(_g) { case 8: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.BACKSPACE,""); break; case 9: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.TAB,""); break; case 13: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.ENTER,""); break; case 16: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.SHIFT,""); break; case 17: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.CTRL,""); break; case 18: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.ALT,""); break; case 27: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.ESC,""); break; case 32: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.CHAR," "); break; case 37: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.LEFT,""); break; case 38: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.UP,""); break; case 39: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.RIGHT,""); break; case 40: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.DOWN,""); break; case 46: kha_SystemImpl.keyboard.sendUpEvent(kha_Key.DEL,""); break; default: if(!event.altKey) { var $char = kha_SystemImpl.keycodeToChar(event.key,event.keyCode,event.shiftKey); kha_SystemImpl.keyboard.sendUpEvent(kha_Key.CHAR,$char); } } }; kha_SystemImpl.canSwitchFullscreen = function() { return 'fullscreenElement ' in document || 'mozFullScreenElement' in document || 'webkitFullscreenElement' in document || 'msFullscreenElement' in document ; }; kha_SystemImpl.isFullscreen = function() { return document.fullscreenElement === this.khanvas || document.mozFullScreenElement === this.khanvas || document.webkitFullscreenElement === this.khanvas || document.msFullscreenElement === this.khanvas ; }; kha_SystemImpl.requestFullscreen = function() { if(($_=kha_SystemImpl.khanvas,$bind($_,$_.requestFullscreen))) { kha_SystemImpl.khanvas.requestFullscreen(); } else if(kha_SystemImpl.khanvas.msRequestFullscreen) { kha_SystemImpl.khanvas.msRequestFullscreen(); } else if(kha_SystemImpl.khanvas.mozRequestFullScreen) { kha_SystemImpl.khanvas.mozRequestFullScreen(); } else if(kha_SystemImpl.khanvas.webkitRequestFullscreen) { kha_SystemImpl.khanvas.webkitRequestFullscreen(); } }; kha_SystemImpl.exitFullscreen = function() { if(document.exitFullscreen) { document.exitFullscreen(); } else if(document.msExitFullscreen) { document.msExitFullscreen(); } else if(document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if(document.webkitExitFullscreen) { document.webkitExitFullscreen(); } }; kha_SystemImpl.notifyOfFullscreenChange = function(func,error) { window.document.addEventListener("fullscreenchange",func,false); window.document.addEventListener("mozfullscreenchange",func,false); window.document.addEventListener("webkitfullscreenchange",func,false); window.document.addEventListener("MSFullscreenChange",func,false); window.document.addEventListener("fullscreenerror",error,false); window.document.addEventListener("mozfullscreenerror",error,false); window.document.addEventListener("webkitfullscreenerror",error,false); window.document.addEventListener("MSFullscreenError",error,false); }; kha_SystemImpl.removeFromFullscreenChange = function(func,error) { window.document.removeEventListener("fullscreenchange",func,false); window.document.removeEventListener("mozfullscreenchange",func,false); window.document.removeEventListener("webkitfullscreenchange",func,false); window.document.removeEventListener("MSFullscreenChange",func,false); window.document.removeEventListener("fullscreenerror",error,false); window.document.removeEventListener("mozfullscreenerror",error,false); window.document.removeEventListener("webkitfullscreenerror",error,false); window.document.removeEventListener("MSFullscreenError",error,false); }; kha_SystemImpl.changeResolution = function(width,height) { }; kha_SystemImpl.setKeepScreenOn = function(on) { }; kha_SystemImpl.loadUrl = function(url) { window.open(url,"_blank"); }; kha_SystemImpl.getGamepadId = function(index) { var sysGamepads = kha_SystemImpl.getGamepads(); if(sysGamepads != null && sysGamepads[index]) { return sysGamepads[index].id; } return "unkown"; }; kha_SystemImpl.getGamepads = function() { if(kha_SystemImpl.chrome && kha_vr_VrInterface.instance.IsVrEnabled()) { return null; } if(navigator.getGamepads) { return window.navigator.getGamepads(); } else { return null; } }; var kha_Video = function() { }; $hxClasses["kha.Video"] = kha_Video; kha_Video.__name__ = true; kha_Video.__interfaces__ = [kha_Resource]; kha_Video.prototype = { width: function() { return 100; } ,height: function() { return 100; } ,play: function(loop) { if(loop == null) { loop = false; } } ,pause: function() { } ,stop: function() { } ,getLength: function() { return 0; } ,getCurrentPos: function() { return 0; } ,get_position: function() { return 0; } ,set_position: function(value) { return 0; } ,getVolume: function() { return 1; } ,setVolume: function(volume) { } ,isFinished: function() { return this.getCurrentPos() >= this.getLength(); } ,unload: function() { } ,__class__: kha_Video }; var kha_WebGLImage = function(width,height,format,renderTarget,depthStencilFormat) { this.pixels = null; this.depthTexture = null; this.texture = null; this.renderBuffer = null; this.frameBuffer = null; this.myWidth = width; this.myHeight = height; this.format = format; this.renderTarget = renderTarget; this.image = null; this.video = null; this.depthStencilFormat = depthStencilFormat; kha_WebGLImage.init(); if(renderTarget) { this.createTexture(); } }; $hxClasses["kha.WebGLImage"] = kha_WebGLImage; kha_WebGLImage.__name__ = true; kha_WebGLImage.init = function() { if(kha_WebGLImage.context == null) { var canvas = window.document.createElement("canvas"); if(canvas != null) { kha_WebGLImage.context = canvas.getContext("2d"); canvas.width = 2048; canvas.height = 2048; kha_WebGLImage.context.globalCompositeOperation = "copy"; } } }; kha_WebGLImage.upperPowerOfTwo = function(v) { --v; v |= v >>> 1; v |= v >>> 2; v |= v >>> 4; v |= v >>> 8; v |= v >>> 16; return ++v; }; kha_WebGLImage.formatByteSize = function(format) { switch(format[1]) { case 0: return 4; case 1: return 1; case 2: return 16; case 3: return 2; case 4: return 8; case 5: return 4; case 6: return 2; } }; kha_WebGLImage.__super__ = kha_Image; kha_WebGLImage.prototype = $extend(kha_Image.prototype,{ image: null ,video: null ,data: null ,myWidth: null ,myHeight: null ,format: null ,renderTarget: null ,frameBuffer: null ,renderBuffer: null ,texture: null ,depthTexture: null ,graphics1: null ,graphics2: null ,graphics4: null ,depthStencilFormat: null ,get_g1: function() { if(this.graphics1 == null) { this.graphics1 = new kha_graphics2_Graphics1(this); } return this.graphics1; } ,get_g2: function() { if(this.graphics2 == null) { this.graphics2 = new kha_js_graphics4_Graphics2(this); } return this.graphics2; } ,get_g4: function() { if(this.graphics4 == null) { this.graphics4 = new kha_js_graphics4_Graphics(this); } return this.graphics4; } ,get_width: function() { return this.myWidth; } ,get_height: function() { return this.myHeight; } ,get_realWidth: function() { return this.myWidth; } ,get_realHeight: function() { return this.myHeight; } ,isOpaque: function(x,y) { if(this.data == null) { if(kha_WebGLImage.context == null) { return true; } else { this.createImageData(); } } return this.data.data[y * (this.image.width | 0) * 4 + x * 4 + 3] != 0; } ,at: function(x,y) { if(this.data == null) { if(kha_WebGLImage.context == null) { return -16777216; } else { this.createImageData(); } } var r = this.data.data[y * (this.image.width | 0) * 4 + x * 4]; var g = this.data.data[y * (this.image.width | 0) * 4 + x * 4 + 1]; var b = this.data.data[y * (this.image.width | 0) * 4 + x * 4 + 2]; var a = this.data.data[y * (this.image.width | 0) * 4 + x * 4 + 3]; return kha__$Color_Color_$Impl_$._new(a << 24 | r << 16 | g << 8 | b); } ,createImageData: function() { if(js_Boot.__instanceof(this.image,Uint8Array)) { this.data = new ImageData(new Uint8ClampedArray(this.image.buffer),this.get_width(),this.get_height()); } else { kha_WebGLImage.context.strokeStyle = "rgba(0,0,0,0)"; kha_WebGLImage.context.fillStyle = "rgba(0,0,0,0)"; kha_WebGLImage.context.fillRect(0,0,this.image.width,this.image.height); kha_WebGLImage.context.drawImage(this.image,0,0,this.image.width,this.image.height,0,0,this.image.width,this.image.height); this.data = kha_WebGLImage.context.getImageData(0,0,this.image.width,this.image.height); } } ,createTexture: function() { if(kha_SystemImpl.gl == null) { return; } this.texture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(3553,this.texture); kha_SystemImpl.gl.texParameteri(3553,10240,9729); kha_SystemImpl.gl.texParameteri(3553,10241,9729); kha_SystemImpl.gl.texParameteri(3553,10242,33071); kha_SystemImpl.gl.texParameteri(3553,10243,33071); if(this.renderTarget) { this.frameBuffer = kha_SystemImpl.gl.createFramebuffer(); kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); var _g = this.format; switch(_g[1]) { case 0: kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null); break; case 2: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 34836 : 6408,this.get_realWidth(),this.get_realHeight(),0,6408,5126,null); break; case 3: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33189 : 6402,this.get_realWidth(),this.get_realHeight(),0,6402,5123,null); break; case 4: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 34842 : 6408,this.get_realWidth(),this.get_realHeight(),0,6408,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,null); break; case 5: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33326 : 6406,this.get_realWidth(),this.get_realHeight(),0,6406,5126,null); break; case 6: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33325 : 6406,this.get_realWidth(),this.get_realHeight(),0,6406,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,null); break; default: kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null); } if(this.format == kha_graphics4_TextureFormat.DEPTH16) { kha_SystemImpl.gl.texParameteri(3553,10240,9728); kha_SystemImpl.gl.texParameteri(3553,10241,9728); kha_SystemImpl.gl.framebufferTexture2D(36160,36096,3553,this.texture,0); if(navigator.appVersion.indexOf("Win") == -1) { var colortex = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(3553,colortex); kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null); kha_SystemImpl.gl.framebufferTexture2D(36160,36064,3553,colortex,0); kha_SystemImpl.gl.bindTexture(3553,this.texture); } } else { kha_SystemImpl.gl.framebufferTexture2D(36160,36064,3553,this.texture,0); } this.initDepthStencilBuffer(this.depthStencilFormat); if(kha_SystemImpl.gl.checkFramebufferStatus(36160) != 36053) { haxe_Log.trace("WebGL error: Framebuffer incomplete",{ fileName : "WebGLImage.hx", lineNumber : 205, className : "kha.WebGLImage", methodName : "createTexture"}); } kha_SystemImpl.gl.bindRenderbuffer(36161,null); kha_SystemImpl.gl.bindFramebuffer(36160,null); } else if(this.video != null) { kha_SystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.video); } else { var _g1 = this.format; switch(_g1[1]) { case 0: if(js_Boot.__instanceof(this.image,Uint8Array)) { kha_SystemImpl.gl.texImage2D(3553,0,6408,this.myWidth,this.myHeight,0,6408,5121,this.image); } else { kha_SystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.image); } break; case 2: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 34836 : 6408,this.myWidth,this.myHeight,0,6408,5126,this.image); break; case 4: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 34842 : 6408,this.myWidth,this.myHeight,0,6408,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,this.image); break; case 5: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33326 : 6406,this.myWidth,this.myHeight,0,6406,5126,this.image); break; case 6: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33325 : 6406,this.myWidth,this.myHeight,0,6406,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,this.image); break; default: kha_SystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.image); } } kha_SystemImpl.gl.bindTexture(3553,null); } ,initDepthStencilBuffer: function(depthStencilFormat) { switch(depthStencilFormat) { case 0: break; case 1:case 5: if(kha_SystemImpl.depthTexture == null) { this.renderBuffer = kha_SystemImpl.gl.createRenderbuffer(); kha_SystemImpl.gl.bindRenderbuffer(36161,this.renderBuffer); kha_SystemImpl.gl.renderbufferStorage(36161,33189,this.get_realWidth(),this.get_realHeight()); kha_SystemImpl.gl.framebufferRenderbuffer(36160,36096,36161,this.renderBuffer); } else { this.depthTexture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(3553,this.depthTexture); if(depthStencilFormat == 1) { kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33190 : 6402,this.get_realWidth(),this.get_realHeight(),0,6402,5125,null); } else { kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33189 : 6402,this.get_realWidth(),this.get_realHeight(),0,6402,5123,null); } kha_SystemImpl.gl.texParameteri(3553,10240,9728); kha_SystemImpl.gl.texParameteri(3553,10241,9728); kha_SystemImpl.gl.texParameteri(3553,10242,33071); kha_SystemImpl.gl.texParameteri(3553,10243,33071); kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); kha_SystemImpl.gl.framebufferTexture2D(36160,36096,3553,this.depthTexture,0); } break; case 2:case 3:case 4: if(kha_SystemImpl.depthTexture == null) { this.renderBuffer = kha_SystemImpl.gl.createRenderbuffer(); kha_SystemImpl.gl.bindRenderbuffer(36161,this.renderBuffer); kha_SystemImpl.gl.renderbufferStorage(36161,34041,this.get_realWidth(),this.get_realHeight()); kha_SystemImpl.gl.framebufferRenderbuffer(36160,33306,36161,this.renderBuffer); } else { this.depthTexture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(3553,this.depthTexture); kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 35056 : 34041,this.get_realWidth(),this.get_realHeight(),0,34041,kha_SystemImpl.depthTexture.UNSIGNED_INT_24_8_WEBGL,null); kha_SystemImpl.gl.texParameteri(3553,10240,9728); kha_SystemImpl.gl.texParameteri(3553,10241,9728); kha_SystemImpl.gl.texParameteri(3553,10242,33071); kha_SystemImpl.gl.texParameteri(3553,10243,33071); kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); kha_SystemImpl.gl.framebufferTexture2D(36160,33306,3553,this.depthTexture,0); } break; } } ,set: function(stage) { kha_SystemImpl.gl.activeTexture(33984 + stage); kha_SystemImpl.gl.bindTexture(3553,this.texture); if(this.video != null) { kha_SystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.video); } } ,setDepth: function(stage) { kha_SystemImpl.gl.activeTexture(33984 + stage); kha_SystemImpl.gl.bindTexture(3553,this.depthTexture); } ,setDepthStencilFrom: function(image) { kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); kha_SystemImpl.gl.framebufferTexture2D(36160,36096,3553,(js_Boot.__cast(image , kha_WebGLImage)).depthTexture,0); } ,bytesToArray: function(bytes) { var _g = this.format; switch(_g[1]) { case 0:case 1: return new Uint8Array(bytes.b.bufferValue); case 2:case 4:case 5:case 6: return new Float32Array(bytes.b.bufferValue); default: return new Uint8Array(bytes.b.bufferValue); } } ,bytes: null ,lock: function(level) { if(level == null) { level = 0; } this.bytes = new haxe_io_Bytes(new ArrayBuffer(kha_WebGLImage.formatByteSize(this.format) * this.get_width() * this.get_height())); return this.bytes; } ,unlock: function() { if(kha_SystemImpl.gl != null) { this.texture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(3553,this.texture); kha_SystemImpl.gl.texParameteri(3553,10240,9729); kha_SystemImpl.gl.texParameteri(3553,10241,9729); kha_SystemImpl.gl.texParameteri(3553,10242,33071); kha_SystemImpl.gl.texParameteri(3553,10243,33071); var _g = this.format; switch(_g[1]) { case 0: kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,this.bytesToArray(this.bytes)); break; case 1: kha_SystemImpl.gl.texImage2D(3553,0,6409,this.get_width(),this.get_height(),0,6409,5121,this.bytesToArray(this.bytes)); if(kha_SystemImpl.gl.getError() == 1282) { var rgbaBytes = new haxe_io_Bytes(new ArrayBuffer(this.get_width() * this.get_height() * 4)); var _g1 = 0; var _g2 = this.get_height(); while(_g1 < _g2) { var y = _g1++; var _g3 = 0; var _g21 = this.get_width(); while(_g3 < _g21) { var x = _g3++; var _this = this.bytes; var pos = y * this.get_width() + x; var value = _this.b[pos]; var pos1 = y * this.get_width() * 4 + x * 4; rgbaBytes.b[pos1] = value & 255; var pos2 = y * this.get_width() * 4 + x * 4 + 1; rgbaBytes.b[pos2] = value & 255; var pos3 = y * this.get_width() * 4 + x * 4 + 2; rgbaBytes.b[pos3] = value & 255; var pos4 = y * this.get_width() * 4 + x * 4 + 3; rgbaBytes.b[pos4] = 255; } } kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,this.bytesToArray(rgbaBytes)); } break; case 2: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 34836 : 6408,this.get_width(),this.get_height(),0,6408,5126,this.bytesToArray(this.bytes)); break; case 4: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 34842 : 6408,this.get_width(),this.get_height(),0,6408,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,this.bytesToArray(this.bytes)); break; case 5: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33326 : 6406,this.get_width(),this.get_height(),0,6406,5126,this.bytesToArray(this.bytes)); break; case 6: kha_SystemImpl.gl.texImage2D(3553,0,kha_SystemImpl.gl2 ? 33325 : 6406,this.get_width(),this.get_height(),0,6406,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,this.bytesToArray(this.bytes)); break; default: kha_SystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,this.bytesToArray(this.bytes)); } kha_SystemImpl.gl.bindTexture(3553,null); this.bytes = null; } } ,pixels: null ,getPixels: function() { if(this.frameBuffer == null) { return null; } if(this.pixels == null) { this.pixels = new Uint8Array(this.format == kha_graphics4_TextureFormat.RGBA32 ? 4 * this.get_width() * this.get_height() : this.get_width() * this.get_height()); } kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); kha_SystemImpl.gl.readPixels(0,0,this.myWidth,this.myHeight,6408,5121,this.pixels); return haxe_io_Bytes.ofData(this.pixels.buffer); } ,unload: function() { if(this.texture != null) { kha_SystemImpl.gl.deleteTexture(this.texture); } if(this.depthTexture != null) { kha_SystemImpl.gl.deleteTexture(this.depthTexture); } if(this.frameBuffer != null) { kha_SystemImpl.gl.deleteFramebuffer(this.frameBuffer); } if(this.renderBuffer != null) { kha_SystemImpl.gl.deleteRenderbuffer(this.renderBuffer); } } ,generateMipmaps: function(levels) { kha_SystemImpl.gl.bindTexture(3553,this.texture); kha_SystemImpl.gl.generateMipmap(3553); } ,setMipmaps: function(mipmaps) { kha_SystemImpl.gl.bindTexture(3553,this.texture); if(this.format == kha_graphics4_TextureFormat.RGBA128) { var _g1 = 0; var _g = mipmaps.length; while(_g1 < _g) { var i = _g1++; kha_SystemImpl.gl.texImage2D(3553,i + 1,kha_SystemImpl.gl2 ? 34836 : 6408,mipmaps[i].get_width(),mipmaps[i].get_height(),0,6408,5126,(js_Boot.__cast(mipmaps[i] , kha_WebGLImage)).image); } } else if(this.format == kha_graphics4_TextureFormat.RGBA64) { var _g11 = 0; var _g2 = mipmaps.length; while(_g11 < _g2) { var i1 = _g11++; kha_SystemImpl.gl.texImage2D(3553,i1 + 1,kha_SystemImpl.gl2 ? 34842 : 6408,mipmaps[i1].get_width(),mipmaps[i1].get_height(),0,6408,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,(js_Boot.__cast(mipmaps[i1] , kha_WebGLImage)).image); } } else { var _g12 = 0; var _g3 = mipmaps.length; while(_g12 < _g3) { var i2 = _g12++; kha_SystemImpl.gl.texImage2D(3553,i2 + 1,6408,6408,5121,(js_Boot.__cast(mipmaps[i2] , kha_WebGLImage)).image); } } } ,__class__: kha_WebGLImage }); var kha_WindowMode = $hxClasses["kha.WindowMode"] = { __ename__ : true, __constructs__ : ["Window","BorderlessWindow","Fullscreen"] }; kha_WindowMode.Window = ["Window",0]; kha_WindowMode.Window.toString = $estr; kha_WindowMode.Window.__enum__ = kha_WindowMode; kha_WindowMode.BorderlessWindow = ["BorderlessWindow",1]; kha_WindowMode.BorderlessWindow.toString = $estr; kha_WindowMode.BorderlessWindow.__enum__ = kha_WindowMode; kha_WindowMode.Fullscreen = ["Fullscreen",2]; kha_WindowMode.Fullscreen.toString = $estr; kha_WindowMode.Fullscreen.__enum__ = kha_WindowMode; var kha_Position = $hxClasses["kha.Position"] = { __ename__ : true, __constructs__ : ["Center","Fixed"] }; kha_Position.Center = ["Center",0]; kha_Position.Center.toString = $estr; kha_Position.Center.__enum__ = kha_Position; kha_Position.Fixed = function(v) { var $x = ["Fixed",1,v]; $x.__enum__ = kha_Position; $x.toString = $estr; return $x; }; var kha_TargetDisplay = $hxClasses["kha.TargetDisplay"] = { __ename__ : true, __constructs__ : ["Primary","ById"] }; kha_TargetDisplay.Primary = ["Primary",0]; kha_TargetDisplay.Primary.toString = $estr; kha_TargetDisplay.Primary.__enum__ = kha_TargetDisplay; kha_TargetDisplay.ById = function(id) { var $x = ["ById",1,id]; $x.__enum__ = kha_TargetDisplay; $x.toString = $estr; return $x; }; var kha_RendererOptions = function(textureFormat,depthStencilFormat,samplesPerPixel) { this.textureFormat = textureFormat; this.depthStencilFormat = depthStencilFormat; this.samplesPerPixel = samplesPerPixel; }; $hxClasses["kha.RendererOptions"] = kha_RendererOptions; kha_RendererOptions.__name__ = true; kha_RendererOptions.prototype = { textureFormat: null ,depthStencilFormat: null ,samplesPerPixel: null ,__class__: kha_RendererOptions }; var kha_WindowedModeOptions = function(minimizable,maximizable,resizable) { this.minimizable = minimizable; this.maximizable = maximizable; this.resizable = resizable; }; $hxClasses["kha.WindowedModeOptions"] = kha_WindowedModeOptions; kha_WindowedModeOptions.__name__ = true; kha_WindowedModeOptions.prototype = { minimizable: null ,maximizable: null ,resizable: null ,__class__: kha_WindowedModeOptions }; var kha_WindowOptions = function(width,height,mode,title,x,y,targetDisplay,rendererOptions,windowedModeOptions) { this.width = width; this.height = height; this.mode = mode; this.title = title; this.x = x; this.y = y; this.targetDisplay = targetDisplay; this.rendererOptions = rendererOptions; this.windowedModeOptions = windowedModeOptions; }; $hxClasses["kha.WindowOptions"] = kha_WindowOptions; kha_WindowOptions.__name__ = true; kha_WindowOptions.prototype = { width: null ,height: null ,mode: null ,title: null ,x: null ,y: null ,targetDisplay: null ,rendererOptions: null ,windowedModeOptions: null ,__class__: kha_WindowOptions }; var kha_arrays__$Float32Array_Float32Array_$Impl_$ = {}; $hxClasses["kha.arrays._Float32Array.Float32Array_Impl_"] = kha_arrays__$Float32Array_Float32Array_$Impl_$; kha_arrays__$Float32Array_Float32Array_$Impl_$.__name__ = true; kha_arrays__$Float32Array_Float32Array_$Impl_$._new = function(elements) { var this1 = new Float32Array(elements); return this1; }; kha_arrays__$Float32Array_Float32Array_$Impl_$.get_length = function(this1) { return this1.length; }; kha_arrays__$Float32Array_Float32Array_$Impl_$.set = function(this1,index,value) { return this1[index] = value; }; kha_arrays__$Float32Array_Float32Array_$Impl_$.get = function(this1,index) { return this1[index]; }; kha_arrays__$Float32Array_Float32Array_$Impl_$.data = function(this1) { return this1; }; kha_arrays__$Float32Array_Float32Array_$Impl_$.arrayRead = function(this1,index) { return this1[index]; }; kha_arrays__$Float32Array_Float32Array_$Impl_$.arrayWrite = function(this1,index,value) { return this1[index] = value; }; kha_arrays__$Float32Array_Float32Array_$Impl_$.subarray = function(this1,start,end) { return this1.subarray(start,end); }; var kha_arrays__$Uint32Array_Uint32Array_$Impl_$ = {}; $hxClasses["kha.arrays._Uint32Array.Uint32Array_Impl_"] = kha_arrays__$Uint32Array_Uint32Array_$Impl_$; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.__name__ = true; kha_arrays__$Uint32Array_Uint32Array_$Impl_$._new = function(elements) { var this1 = new Uint32Array(elements); return this1; }; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.get_length = function(this1) { return this1.length; }; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.set = function(this1,index,value) { return this1[index] = value; }; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.get = function(this1,index) { return this1[index]; }; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.data = function(this1) { return this1; }; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.arrayRead = function(this1,index) { return this1[index]; }; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.arrayWrite = function(this1,index,value) { return this1[index] = value; }; kha_arrays__$Uint32Array_Uint32Array_$Impl_$.subarray = function(this1,start,end) { return this1.subarray(start,end); }; var kha_audio1_AudioChannel = function() { }; $hxClasses["kha.audio1.AudioChannel"] = kha_audio1_AudioChannel; kha_audio1_AudioChannel.__name__ = true; kha_audio1_AudioChannel.prototype = { play: null ,pause: null ,stop: null ,length: null ,get_length: null ,position: null ,get_position: null ,get_volume: null ,set_volume: null ,finished: null ,get_finished: null ,__class__: kha_audio1_AudioChannel }; var kha_audio2_Audio = function() { }; $hxClasses["kha.audio2.Audio"] = kha_audio2_Audio; kha_audio2_Audio.__name__ = true; kha_audio2_Audio.initContext = function() { try { kha_audio2_Audio._context = new AudioContext(); return; } catch( e ) { } try { this._context = new webkitAudioContext(); return; } catch( e1 ) { } }; kha_audio2_Audio._init = function() { kha_audio2_Audio.initContext(); if(kha_audio2_Audio._context == null) { return false; } var bufferSize = 2048; kha_audio2_Audio.buffer = new kha_audio2_Buffer(bufferSize * 4,2,kha_audio2_Audio._context.sampleRate | 0); kha_audio2_Audio.processingNode = kha_audio2_Audio._context.createScriptProcessor(bufferSize,0,2); kha_audio2_Audio.processingNode.onaudioprocess = function(e) { var output1 = e.outputBuffer.getChannelData(0); var output2 = e.outputBuffer.getChannelData(1); if(kha_audio2_Audio.audioCallback != null) { kha_audio2_Audio.audioCallback(e.outputBuffer.length * 2,kha_audio2_Audio.buffer); var _g1 = 0; var _g = e.outputBuffer.length; while(_g1 < _g) { var i = _g1++; output1[i] = kha_audio2_Audio.buffer.data[kha_audio2_Audio.buffer.readLocation]; kha_audio2_Audio.buffer.readLocation += 1; output2[i] = kha_audio2_Audio.buffer.data[kha_audio2_Audio.buffer.readLocation]; kha_audio2_Audio.buffer.readLocation += 1; if(kha_audio2_Audio.buffer.readLocation >= kha_audio2_Audio.buffer.size) { kha_audio2_Audio.buffer.readLocation = 0; } } } else { var _g11 = 0; var _g2 = e.outputBuffer.length; while(_g11 < _g2) { var i1 = _g11++; output1[i1] = 0; output2[i1] = 0; } } }; kha_audio2_Audio.processingNode.connect(kha_audio2_Audio._context.destination); return true; }; kha_audio2_Audio.stream = function(sound,loop) { if(loop == null) { loop = false; } var element = window.document.createElement("audio"); var blob = new Blob([sound.compressedData.b.bufferValue],{ type : "audio/mp4"}); element.src = URL.createObjectURL(blob); element.loop = loop; var channel = new kha_js_AEAudioChannel(element); channel.play(); return channel; }; var kha_audio2_Audio1 = function() { }; $hxClasses["kha.audio2.Audio1"] = kha_audio2_Audio1; kha_audio2_Audio1.__name__ = true; kha_audio2_Audio1._init = function() { var this1 = new Array(16); kha_audio2_Audio1.soundChannels = this1; var this2 = new Array(16); kha_audio2_Audio1.streamChannels = this2; var this3 = new Array(16); kha_audio2_Audio1.internalSoundChannels = this3; var this4 = new Array(16); kha_audio2_Audio1.internalStreamChannels = this4; var this5 = new Array(512); kha_audio2_Audio1.sampleCache1 = this5; var this6 = new Array(512); kha_audio2_Audio1.sampleCache2 = this6; kha_audio2_Audio.audioCallback = kha_audio2_Audio1._mix; }; kha_audio2_Audio1.max = function(a,b) { if(a > b) { return a; } else { return b; } }; kha_audio2_Audio1.min = function(a,b) { if(a < b) { return a; } else { return b; } }; kha_audio2_Audio1._mix = function(samples,buffer) { if(kha_audio2_Audio1.sampleCache1.length < samples) { var this1 = new Array(samples); kha_audio2_Audio1.sampleCache1 = this1; var this2 = new Array(samples); kha_audio2_Audio1.sampleCache2 = this2; } var _g1 = 0; var _g = samples; while(_g1 < _g) { var i = _g1++; kha_audio2_Audio1.sampleCache2[i] = 0; } var _g2 = 0; while(_g2 < 16) { var i1 = _g2++; kha_audio2_Audio1.internalSoundChannels[i1] = kha_audio2_Audio1.soundChannels[i1]; } var _g3 = 0; while(_g3 < 16) { var i2 = _g3++; kha_audio2_Audio1.internalStreamChannels[i2] = kha_audio2_Audio1.streamChannels[i2]; } var _g4 = 0; var _g11 = kha_audio2_Audio1.internalSoundChannels; while(_g4 < _g11.length) { var channel = _g11[_g4]; ++_g4; if(channel == null || channel.get_finished()) { continue; } channel.nextSamples(kha_audio2_Audio1.sampleCache1,samples,buffer.samplesPerSecond); var _g31 = 0; var _g21 = samples; while(_g31 < _g21) { var i3 = _g31++; var _g41 = i3; var _g5 = kha_audio2_Audio1.sampleCache2; var val = kha_audio2_Audio1.sampleCache1[i3] * channel.get_volume(); _g5[_g41] = _g5[_g41] + val; } } var _g6 = 0; var _g12 = kha_audio2_Audio1.internalStreamChannels; while(_g6 < _g12.length) { var channel1 = _g12[_g6]; ++_g6; if(channel1 == null || channel1.get_finished()) { continue; } channel1.nextSamples(kha_audio2_Audio1.sampleCache1,samples,buffer.samplesPerSecond); var _g32 = 0; var _g22 = samples; while(_g32 < _g22) { var i4 = _g32++; var _g42 = i4; var _g51 = kha_audio2_Audio1.sampleCache2; var val1 = kha_audio2_Audio1.sampleCache1[i4] * channel1.get_volume(); _g51[_g42] = _g51[_g42] + val1; } } var _g13 = 0; var _g7 = samples; while(_g13 < _g7) { var i5 = _g13++; var a = kha_audio2_Audio1.sampleCache2[i5]; var a1 = a < 1.0 ? a : 1.0; buffer.data[buffer.writeLocation] = a1 > -1.0 ? a1 : -1.0; buffer.writeLocation += 1; if(buffer.writeLocation >= buffer.size) { buffer.writeLocation = 0; } } }; kha_audio2_Audio1.play = function(sound,loop) { if(loop == null) { loop = false; } var channel = null; var _g = 0; while(_g < 16) { var i = _g++; if(kha_audio2_Audio1.soundChannels[i] == null || kha_audio2_Audio1.soundChannels[i].get_finished()) { channel = new kha_audio2_AudioChannel(loop); channel.data = sound.uncompressedData; kha_audio2_Audio1.soundChannels[i] = channel; break; } } return channel; }; kha_audio2_Audio1._playAgain = function(channel) { var _g = 0; while(_g < 16) { var i = _g++; if(kha_audio2_Audio1.soundChannels[i] == null || kha_audio2_Audio1.soundChannels[i].get_finished() || kha_audio2_Audio1.soundChannels[i] == channel) { kha_audio2_Audio1.soundChannels[i] = channel; break; } } }; kha_audio2_Audio1.stream = function(sound,loop) { if(loop == null) { loop = false; } var hardwareChannel = kha_audio2_Audio.stream(sound,loop); if(hardwareChannel != null) { return hardwareChannel; } var channel = null; var _g = 0; while(_g < 16) { var i = _g++; if(kha_audio2_Audio1.streamChannels[i] == null || kha_audio2_Audio1.streamChannels[i].get_finished()) { channel = new kha_audio2_StreamChannel(sound.compressedData,loop); kha_audio2_Audio1.streamChannels[i] = channel; break; } } return channel; }; var kha_audio2_AudioChannel = function(looping) { this.paused = false; this.looping = looping; this.myVolume = 1; this.myPosition = 0; }; $hxClasses["kha.audio2.AudioChannel"] = kha_audio2_AudioChannel; kha_audio2_AudioChannel.__name__ = true; kha_audio2_AudioChannel.__interfaces__ = [kha_audio1_AudioChannel]; kha_audio2_AudioChannel.prototype = { data: null ,myVolume: null ,myPosition: null ,paused: null ,looping: null ,nextSamples: function(samples,length,sampleRate) { if(this.paused) { var _g1 = 0; var _g = length; while(_g1 < _g) { var i = _g1++; samples[i] = 0; } return; } var _g11 = 0; var _g2 = length; while(_g11 < _g2) { var i1 = _g11++; if(this.myPosition >= this.data.length && this.looping) { this.myPosition = 0; } samples[i1] = this.myPosition < this.data.length ? this.data[this.myPosition] : 0; ++this.myPosition; } } ,play: function() { this.paused = false; if(this.get_finished()) { this.myPosition = 0; kha_audio2_Audio1._playAgain(this); } } ,pause: function() { this.paused = true; } ,stop: function() { this.myPosition = this.data.length; } ,length: null ,get_length: function() { return this.data.length / 44100 / 2; } ,position: null ,get_position: function() { return this.myPosition / 44100 / 2; } ,get_volume: function() { return this.myVolume; } ,set_volume: function(value) { return this.myVolume = value; } ,finished: null ,get_finished: function() { return this.myPosition >= this.data.length; } ,__class__: kha_audio2_AudioChannel }; var kha_audio2_Buffer = function(size,channels,samplesPerSecond) { this.size = size; var this1 = new Array(size); this.data = this1; this.channels = channels; this.samplesPerSecond = samplesPerSecond; this.readLocation = 0; this.writeLocation = 0; }; $hxClasses["kha.audio2.Buffer"] = kha_audio2_Buffer; kha_audio2_Buffer.__name__ = true; kha_audio2_Buffer.prototype = { channels: null ,samplesPerSecond: null ,data: null ,size: null ,readLocation: null ,writeLocation: null ,__class__: kha_audio2_Buffer }; var kha_audio2_StreamChannel = function(data,loop) { this.paused = false; this.atend = false; this.myVolume = 1; this.loop = loop; this.reader = kha_audio2_ogg_vorbis_Reader.openFromBytes(data); }; $hxClasses["kha.audio2.StreamChannel"] = kha_audio2_StreamChannel; kha_audio2_StreamChannel.__name__ = true; kha_audio2_StreamChannel.__interfaces__ = [kha_audio1_AudioChannel]; kha_audio2_StreamChannel.prototype = { reader: null ,atend: null ,loop: null ,myVolume: null ,paused: null ,nextSamples: function(samples,length,sampleRate) { if(this.paused) { var _g1 = 0; var _g = length; while(_g1 < _g) { var i = _g1++; samples[i] = 0; } return; } var count = this.reader.read(samples,length / 2 | 0,2,sampleRate,true) * 2; if(count < length) { if(this.loop) { this.reader.set_currentMillisecond(0); } else { this.atend = true; } var _g11 = count; var _g2 = length; while(_g11 < _g2) { var i1 = _g11++; samples[i1] = 0; } } } ,play: function() { this.paused = false; } ,pause: function() { this.paused = true; } ,stop: function() { this.atend = true; } ,length: null ,get_length: function() { return this.reader.get_totalMillisecond() / 1000.0; } ,position: null ,get_position: function() { return this.reader.get_currentMillisecond() / 1000.0; } ,get_volume: function() { return this.myVolume; } ,set_volume: function(value) { return this.myVolume = value; } ,finished: null ,get_finished: function() { return this.atend; } ,__class__: kha_audio2_StreamChannel }; var kha_audio2_ogg_tools_Crc32 = function() { }; $hxClasses["kha.audio2.ogg.tools.Crc32"] = kha_audio2_ogg_tools_Crc32; kha_audio2_ogg_tools_Crc32.__name__ = true; kha_audio2_ogg_tools_Crc32.init = function() { if(kha_audio2_ogg_tools_Crc32.table != null) { return; } var this1 = new Array(256); kha_audio2_ogg_tools_Crc32.table = this1; var _g = 0; while(_g < 256) { var i = _g++; var s = i << 24; var _g1 = 0; while(_g1 < 8) { var j = _g1++; s = s << 1 ^ (_$UInt_UInt_$Impl_$.gte(s,1 << 31) ? 79764919 : 0); } kha_audio2_ogg_tools_Crc32.table[i] = s; } }; kha_audio2_ogg_tools_Crc32.update = function(crc,$byte) { return crc << 8 ^ kha_audio2_ogg_tools_Crc32.table[$byte ^ crc >>> 24]; }; var kha_audio2_ogg_tools_MathTools = function() { }; $hxClasses["kha.audio2.ogg.tools.MathTools"] = kha_audio2_ogg_tools_MathTools; kha_audio2_ogg_tools_MathTools.__name__ = true; kha_audio2_ogg_tools_MathTools.ilog = function(n) { var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; if(n < 16384) { if(n < 16) { return log2_4[n]; } else if(n < 512) { return 5 + log2_4[n >> 5]; } else { return 10 + log2_4[n >> 10]; } } else if(n < 16777216) { if(n < 524288) { return 15 + log2_4[n >> 15]; } else { return 20 + log2_4[n >> 20]; } } else if(n < 536870912) { return 25 + log2_4[n >> 25]; } else if(n < -2147483648) { return 30 + log2_4[n >> 30]; } else { return 0; } }; var kha_audio2_ogg_tools_Mdct = function() { }; $hxClasses["kha.audio2.ogg.tools.Mdct"] = kha_audio2_ogg_tools_Mdct; kha_audio2_ogg_tools_Mdct.__name__ = true; kha_audio2_ogg_tools_Mdct.inverseTransform = function(buffer,n,a,b,c,bitReverse) { var n2 = n >> 1; var n4 = n >> 2; var n8 = n >> 3; var this1 = new Array(n2); var buf2 = this1; var dOffset = n2 - 2; var aaOffset = 0; var eOffset = 0; var eStopOffset = n2; while(eOffset != eStopOffset) { buf2[dOffset + 1] = buffer[eOffset] * a[aaOffset] - buffer[eOffset + 2] * a[aaOffset + 1]; buf2[dOffset] = buffer[eOffset] * a[aaOffset + 1] + buffer[eOffset + 2] * a[aaOffset]; dOffset -= 2; aaOffset += 2; eOffset += 4; } eOffset = n2 - 3; while(dOffset >= 0) { buf2[dOffset + 1] = -buffer[eOffset + 2] * a[aaOffset] - -buffer[eOffset] * a[aaOffset + 1]; buf2[dOffset] = -buffer[eOffset + 2] * a[aaOffset + 1] + -buffer[eOffset] * a[aaOffset]; dOffset -= 2; aaOffset += 2; eOffset -= 4; } var u = buffer; var v = buf2; var aaOffset1 = n2 - 8; var eOffset0 = n4; var eOffset1 = 0; var dOffset0 = n4; var dOffset1 = 0; while(aaOffset1 >= 0) { var v41_21 = v[eOffset0 + 1] - v[eOffset1 + 1]; var v40_20 = v[eOffset0] - v[eOffset1]; u[dOffset0 + 1] = v[eOffset0 + 1] + v[eOffset1 + 1]; u[dOffset0] = v[eOffset0] + v[eOffset1]; u[dOffset1 + 1] = v41_21 * a[aaOffset1 + 4] - v40_20 * a[aaOffset1 + 5]; u[dOffset1] = v40_20 * a[aaOffset1 + 4] + v41_21 * a[aaOffset1 + 5]; v41_21 = v[eOffset0 + 3] - v[eOffset1 + 3]; v40_20 = v[eOffset0 + 2] - v[eOffset1 + 2]; u[dOffset0 + 3] = v[eOffset0 + 3] + v[eOffset1 + 3]; u[dOffset0 + 2] = v[eOffset0 + 2] + v[eOffset1 + 2]; u[dOffset1 + 3] = v41_21 * a[aaOffset1] - v40_20 * a[aaOffset1 + 1]; u[dOffset1 + 2] = v40_20 * a[aaOffset1] + v41_21 * a[aaOffset1 + 1]; aaOffset1 -= 8; dOffset0 += 4; dOffset1 += 4; eOffset0 += 4; eOffset1 += 4; } var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var ld = (n < 16384 ? n < 16 ? log2_4[n] : n < 512 ? 5 + log2_4[n >> 5] : 10 + log2_4[n >> 10] : n < 16777216 ? n < 524288 ? 15 + log2_4[n >> 15] : 20 + log2_4[n >> 20] : n < 536870912 ? 25 + log2_4[n >> 25] : n < -2147483648 ? 30 + log2_4[n >> 30] : 0) - 1; var i_off = n2 - 1 - n4 * 0; var eeOffset0 = i_off; var eeOffset2 = i_off + -(n >> 3); var aOffset = 0; var i = (n >> 4 >> 2) + 1; while(--i > 0) { var k00_20 = u[eeOffset0] - u[eeOffset2]; var k01_21 = u[eeOffset0 + -1] - u[eeOffset2 + -1]; var _g = eeOffset0; var _g1 = u; _g1[_g] = _g1[_g] + u[eeOffset2]; var _g2 = eeOffset0 + -1; var _g11 = u; _g11[_g2] = _g11[_g2] + u[eeOffset2 + -1]; u[eeOffset2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -1] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = u[eeOffset0 + -2] - u[eeOffset2 + -2]; k01_21 = u[eeOffset0 + -3] - u[eeOffset2 + -3]; var _g3 = eeOffset0 + -2; var _g12 = u; _g12[_g3] = _g12[_g3] + u[eeOffset2 + -2]; var _g4 = eeOffset0 + -3; var _g13 = u; _g13[_g4] = _g13[_g4] + u[eeOffset2 + -3]; u[eeOffset2 + -2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -3] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = u[eeOffset0 + -4] - u[eeOffset2 + -4]; k01_21 = u[eeOffset0 + -5] - u[eeOffset2 + -5]; var _g5 = eeOffset0 + -4; var _g14 = u; _g14[_g5] = _g14[_g5] + u[eeOffset2 + -4]; var _g6 = eeOffset0 + -5; var _g15 = u; _g15[_g6] = _g15[_g6] + u[eeOffset2 + -5]; u[eeOffset2 + -4] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -5] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = u[eeOffset0 + -6] - u[eeOffset2 + -6]; k01_21 = u[eeOffset0 + -7] - u[eeOffset2 + -7]; var _g7 = eeOffset0 + -6; var _g16 = u; _g16[_g7] = _g16[_g7] + u[eeOffset2 + -6]; var _g8 = eeOffset0 + -7; var _g17 = u; _g17[_g8] = _g17[_g8] + u[eeOffset2 + -7]; u[eeOffset2 + -6] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -7] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; eeOffset0 -= 8; eeOffset2 -= 8; } var i_off1 = n2 - 1 - n4; var eeOffset01 = i_off1; var eeOffset21 = i_off1 + -(n >> 3); var aOffset1 = 0; var i1 = (n >> 4 >> 2) + 1; while(--i1 > 0) { var k00_201 = u[eeOffset01] - u[eeOffset21]; var k01_211 = u[eeOffset01 + -1] - u[eeOffset21 + -1]; var _g9 = eeOffset01; var _g18 = u; _g18[_g9] = _g18[_g9] + u[eeOffset21]; var _g10 = eeOffset01 + -1; var _g19 = u; _g19[_g10] = _g19[_g10] + u[eeOffset21 + -1]; u[eeOffset21] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -1] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; k00_201 = u[eeOffset01 + -2] - u[eeOffset21 + -2]; k01_211 = u[eeOffset01 + -3] - u[eeOffset21 + -3]; var _g20 = eeOffset01 + -2; var _g110 = u; _g110[_g20] = _g110[_g20] + u[eeOffset21 + -2]; var _g21 = eeOffset01 + -3; var _g111 = u; _g111[_g21] = _g111[_g21] + u[eeOffset21 + -3]; u[eeOffset21 + -2] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -3] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; k00_201 = u[eeOffset01 + -4] - u[eeOffset21 + -4]; k01_211 = u[eeOffset01 + -5] - u[eeOffset21 + -5]; var _g22 = eeOffset01 + -4; var _g112 = u; _g112[_g22] = _g112[_g22] + u[eeOffset21 + -4]; var _g23 = eeOffset01 + -5; var _g113 = u; _g113[_g23] = _g113[_g23] + u[eeOffset21 + -5]; u[eeOffset21 + -4] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -5] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; k00_201 = u[eeOffset01 + -6] - u[eeOffset21 + -6]; k01_211 = u[eeOffset01 + -7] - u[eeOffset21 + -7]; var _g24 = eeOffset01 + -6; var _g114 = u; _g114[_g24] = _g114[_g24] + u[eeOffset21 + -6]; var _g25 = eeOffset01 + -7; var _g115 = u; _g115[_g25] = _g115[_g25] + u[eeOffset21 + -7]; u[eeOffset21 + -6] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -7] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; eeOffset01 -= 8; eeOffset21 -= 8; } var d0 = n2 - 1 - n8 * 0; var aOffset2 = 0; var eOffset01 = d0; var eOffset2 = d0 + -(n >> 4); var i2 = (n >> 5 >> 2) + 1; while(--i2 > 0) { var k00_202 = u[eOffset01] - u[eOffset2]; var k01_212 = u[eOffset01 + -1] - u[eOffset2 + -1]; var _g26 = eOffset01; var _g116 = u; _g116[_g26] = _g116[_g26] + u[eOffset2]; var _g27 = eOffset01 + -1; var _g117 = u; _g117[_g27] = _g117[_g27] + u[eOffset2 + -1]; u[eOffset2] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -1] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; aOffset2 += 16; k00_202 = u[eOffset01 + -2] - u[eOffset2 + -2]; k01_212 = u[eOffset01 + -3] - u[eOffset2 + -3]; var _g28 = eOffset01 + -2; var _g118 = u; _g118[_g28] = _g118[_g28] + u[eOffset2 + -2]; var _g29 = eOffset01 + -3; var _g119 = u; _g119[_g29] = _g119[_g29] + u[eOffset2 + -3]; u[eOffset2 + -2] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -3] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; aOffset2 += 16; k00_202 = u[eOffset01 + -4] - u[eOffset2 + -4]; k01_212 = u[eOffset01 + -5] - u[eOffset2 + -5]; var _g30 = eOffset01 + -4; var _g120 = u; _g120[_g30] = _g120[_g30] + u[eOffset2 + -4]; var _g31 = eOffset01 + -5; var _g121 = u; _g121[_g31] = _g121[_g31] + u[eOffset2 + -5]; u[eOffset2 + -4] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -5] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; aOffset2 += 16; k00_202 = u[eOffset01 + -6] - u[eOffset2 + -6]; k01_212 = u[eOffset01 + -7] - u[eOffset2 + -7]; var _g32 = eOffset01 + -6; var _g122 = u; _g122[_g32] = _g122[_g32] + u[eOffset2 + -6]; var _g33 = eOffset01 + -7; var _g123 = u; _g123[_g33] = _g123[_g33] + u[eOffset2 + -7]; u[eOffset2 + -6] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -7] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; eOffset01 -= 8; eOffset2 -= 8; aOffset2 += 16; } var d01 = n2 - 1 - n8; var aOffset3 = 0; var eOffset02 = d01; var eOffset21 = d01 + -(n >> 4); var i3 = (n >> 5 >> 2) + 1; while(--i3 > 0) { var k00_203 = u[eOffset02] - u[eOffset21]; var k01_213 = u[eOffset02 + -1] - u[eOffset21 + -1]; var _g34 = eOffset02; var _g124 = u; _g124[_g34] = _g124[_g34] + u[eOffset21]; var _g35 = eOffset02 + -1; var _g125 = u; _g125[_g35] = _g125[_g35] + u[eOffset21 + -1]; u[eOffset21] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -1] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; aOffset3 += 16; k00_203 = u[eOffset02 + -2] - u[eOffset21 + -2]; k01_213 = u[eOffset02 + -3] - u[eOffset21 + -3]; var _g36 = eOffset02 + -2; var _g126 = u; _g126[_g36] = _g126[_g36] + u[eOffset21 + -2]; var _g37 = eOffset02 + -3; var _g127 = u; _g127[_g37] = _g127[_g37] + u[eOffset21 + -3]; u[eOffset21 + -2] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -3] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; aOffset3 += 16; k00_203 = u[eOffset02 + -4] - u[eOffset21 + -4]; k01_213 = u[eOffset02 + -5] - u[eOffset21 + -5]; var _g38 = eOffset02 + -4; var _g128 = u; _g128[_g38] = _g128[_g38] + u[eOffset21 + -4]; var _g39 = eOffset02 + -5; var _g129 = u; _g129[_g39] = _g129[_g39] + u[eOffset21 + -5]; u[eOffset21 + -4] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -5] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; aOffset3 += 16; k00_203 = u[eOffset02 + -6] - u[eOffset21 + -6]; k01_213 = u[eOffset02 + -7] - u[eOffset21 + -7]; var _g40 = eOffset02 + -6; var _g130 = u; _g130[_g40] = _g130[_g40] + u[eOffset21 + -6]; var _g41 = eOffset02 + -7; var _g131 = u; _g131[_g41] = _g131[_g41] + u[eOffset21 + -7]; u[eOffset21 + -6] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -7] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; eOffset02 -= 8; eOffset21 -= 8; aOffset3 += 16; } var d02 = n2 - 1 - n8 * 2; var aOffset4 = 0; var eOffset03 = d02; var eOffset22 = d02 + -(n >> 4); var i4 = (n >> 5 >> 2) + 1; while(--i4 > 0) { var k00_204 = u[eOffset03] - u[eOffset22]; var k01_214 = u[eOffset03 + -1] - u[eOffset22 + -1]; var _g42 = eOffset03; var _g132 = u; _g132[_g42] = _g132[_g42] + u[eOffset22]; var _g43 = eOffset03 + -1; var _g133 = u; _g133[_g43] = _g133[_g43] + u[eOffset22 + -1]; u[eOffset22] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -1] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; aOffset4 += 16; k00_204 = u[eOffset03 + -2] - u[eOffset22 + -2]; k01_214 = u[eOffset03 + -3] - u[eOffset22 + -3]; var _g44 = eOffset03 + -2; var _g134 = u; _g134[_g44] = _g134[_g44] + u[eOffset22 + -2]; var _g45 = eOffset03 + -3; var _g135 = u; _g135[_g45] = _g135[_g45] + u[eOffset22 + -3]; u[eOffset22 + -2] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -3] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; aOffset4 += 16; k00_204 = u[eOffset03 + -4] - u[eOffset22 + -4]; k01_214 = u[eOffset03 + -5] - u[eOffset22 + -5]; var _g46 = eOffset03 + -4; var _g136 = u; _g136[_g46] = _g136[_g46] + u[eOffset22 + -4]; var _g47 = eOffset03 + -5; var _g137 = u; _g137[_g47] = _g137[_g47] + u[eOffset22 + -5]; u[eOffset22 + -4] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -5] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; aOffset4 += 16; k00_204 = u[eOffset03 + -6] - u[eOffset22 + -6]; k01_214 = u[eOffset03 + -7] - u[eOffset22 + -7]; var _g48 = eOffset03 + -6; var _g138 = u; _g138[_g48] = _g138[_g48] + u[eOffset22 + -6]; var _g49 = eOffset03 + -7; var _g139 = u; _g139[_g49] = _g139[_g49] + u[eOffset22 + -7]; u[eOffset22 + -6] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -7] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; eOffset03 -= 8; eOffset22 -= 8; aOffset4 += 16; } var d03 = n2 - 1 - n8 * 3; var aOffset5 = 0; var eOffset04 = d03; var eOffset23 = d03 + -(n >> 4); var i5 = (n >> 5 >> 2) + 1; while(--i5 > 0) { var k00_205 = u[eOffset04] - u[eOffset23]; var k01_215 = u[eOffset04 + -1] - u[eOffset23 + -1]; var _g50 = eOffset04; var _g140 = u; _g140[_g50] = _g140[_g50] + u[eOffset23]; var _g51 = eOffset04 + -1; var _g141 = u; _g141[_g51] = _g141[_g51] + u[eOffset23 + -1]; u[eOffset23] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -1] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; aOffset5 += 16; k00_205 = u[eOffset04 + -2] - u[eOffset23 + -2]; k01_215 = u[eOffset04 + -3] - u[eOffset23 + -3]; var _g52 = eOffset04 + -2; var _g142 = u; _g142[_g52] = _g142[_g52] + u[eOffset23 + -2]; var _g53 = eOffset04 + -3; var _g143 = u; _g143[_g53] = _g143[_g53] + u[eOffset23 + -3]; u[eOffset23 + -2] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -3] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; aOffset5 += 16; k00_205 = u[eOffset04 + -4] - u[eOffset23 + -4]; k01_215 = u[eOffset04 + -5] - u[eOffset23 + -5]; var _g54 = eOffset04 + -4; var _g144 = u; _g144[_g54] = _g144[_g54] + u[eOffset23 + -4]; var _g55 = eOffset04 + -5; var _g145 = u; _g145[_g55] = _g145[_g55] + u[eOffset23 + -5]; u[eOffset23 + -4] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -5] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; aOffset5 += 16; k00_205 = u[eOffset04 + -6] - u[eOffset23 + -6]; k01_215 = u[eOffset04 + -7] - u[eOffset23 + -7]; var _g56 = eOffset04 + -6; var _g146 = u; _g146[_g56] = _g146[_g56] + u[eOffset23 + -6]; var _g57 = eOffset04 + -7; var _g147 = u; _g147[_g57] = _g147[_g57] + u[eOffset23 + -7]; u[eOffset23 + -6] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -7] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; eOffset04 -= 8; eOffset23 -= 8; aOffset5 += 16; } var _g148 = 2; var _g58 = ld - 3 >> 1; while(_g148 < _g58) { var l = _g148++; var k0 = n >> l + 2; var k0_2 = k0 >> 1; var lim = 1 << l + 1; var _g310 = 0; var _g210 = lim; while(_g310 < _g210) { var i6 = _g310++; var d04 = n2 - 1 - k0 * i6; var k1 = 1 << l + 3; var aOffset6 = 0; var eOffset05 = d04; var eOffset24 = d04 + -k0_2; var i7 = (n >> l + 4 >> 2) + 1; while(--i7 > 0) { var k00_206 = u[eOffset05] - u[eOffset24]; var k01_216 = u[eOffset05 + -1] - u[eOffset24 + -1]; var _g59 = eOffset05; var _g149 = u; _g149[_g59] = _g149[_g59] + u[eOffset24]; var _g60 = eOffset05 + -1; var _g150 = u; _g150[_g60] = _g150[_g60] + u[eOffset24 + -1]; u[eOffset24] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -1] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; aOffset6 += k1; k00_206 = u[eOffset05 + -2] - u[eOffset24 + -2]; k01_216 = u[eOffset05 + -3] - u[eOffset24 + -3]; var _g61 = eOffset05 + -2; var _g151 = u; _g151[_g61] = _g151[_g61] + u[eOffset24 + -2]; var _g62 = eOffset05 + -3; var _g152 = u; _g152[_g62] = _g152[_g62] + u[eOffset24 + -3]; u[eOffset24 + -2] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -3] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; aOffset6 += k1; k00_206 = u[eOffset05 + -4] - u[eOffset24 + -4]; k01_216 = u[eOffset05 + -5] - u[eOffset24 + -5]; var _g63 = eOffset05 + -4; var _g153 = u; _g153[_g63] = _g153[_g63] + u[eOffset24 + -4]; var _g64 = eOffset05 + -5; var _g154 = u; _g154[_g64] = _g154[_g64] + u[eOffset24 + -5]; u[eOffset24 + -4] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -5] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; aOffset6 += k1; k00_206 = u[eOffset05 + -6] - u[eOffset24 + -6]; k01_216 = u[eOffset05 + -7] - u[eOffset24 + -7]; var _g65 = eOffset05 + -6; var _g155 = u; _g155[_g65] = _g155[_g65] + u[eOffset24 + -6]; var _g66 = eOffset05 + -7; var _g156 = u; _g156[_g66] = _g156[_g66] + u[eOffset24 + -7]; u[eOffset24 + -6] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -7] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; eOffset05 -= 8; eOffset24 -= 8; aOffset6 += k1; } } } var _g157 = ld - 3 >> 1; var _g67 = ld - 6; while(_g157 < _g67) { var l1 = _g157++; var k01 = n >> l1 + 2; var k11 = 1 << l1 + 3; var k0_21 = k01 >> 1; var rlim = n >> l1 + 6; var lim1 = 1 << l1 + 1; var aOffset7 = 0; var i_off2 = n2 - 1; var r = rlim + 1; while(--r > 0) { var A0 = a[aOffset7]; var A1 = a[aOffset7 + 1]; var A2 = a[aOffset7 + k11]; var A3 = a[aOffset7 + k11 + 1]; var A4 = a[aOffset7 + k11 * 2]; var A5 = a[aOffset7 + k11 * 2 + 1]; var A6 = a[aOffset7 + k11 * 3]; var A7 = a[aOffset7 + k11 * 3 + 1]; var eeOffset02 = i_off2; var eeOffset22 = i_off2 + -k0_21; var i8 = lim1 + 1; while(--i8 > 0) { var k00 = u[eeOffset02] - u[eeOffset22]; var k111 = u[eeOffset02 + -1] - u[eeOffset22 + -1]; u[eeOffset02] = u[eeOffset02] + u[eeOffset22]; u[eeOffset02 + -1] = u[eeOffset02 + -1] + u[eeOffset22 + -1]; u[eeOffset22] = k00 * A0 - k111 * A1; u[eeOffset22 + -1] = k111 * A0 + k00 * A1; k00 = u[eeOffset02 + -2] - u[eeOffset22 + -2]; k111 = u[eeOffset02 + -3] - u[eeOffset22 + -3]; u[eeOffset02 + -2] = u[eeOffset02 + -2] + u[eeOffset22 + -2]; u[eeOffset02 + -3] = u[eeOffset02 + -3] + u[eeOffset22 + -3]; u[eeOffset22 + -2] = k00 * A2 - k111 * A3; u[eeOffset22 + -3] = k111 * A2 + k00 * A3; k00 = u[eeOffset02 + -4] - u[eeOffset22 + -4]; k111 = u[eeOffset02 + -5] - u[eeOffset22 + -5]; u[eeOffset02 + -4] = u[eeOffset02 + -4] + u[eeOffset22 + -4]; u[eeOffset02 + -5] = u[eeOffset02 + -5] + u[eeOffset22 + -5]; u[eeOffset22 + -4] = k00 * A4 - k111 * A5; u[eeOffset22 + -5] = k111 * A4 + k00 * A5; k00 = u[eeOffset02 + -6] - u[eeOffset22 + -6]; k111 = u[eeOffset02 + -7] - u[eeOffset22 + -7]; u[eeOffset02 + -6] = u[eeOffset02 + -6] + u[eeOffset22 + -6]; u[eeOffset02 + -7] = u[eeOffset02 + -7] + u[eeOffset22 + -7]; u[eeOffset22 + -6] = k00 * A6 - k111 * A7; u[eeOffset22 + -7] = k111 * A6 + k00 * A7; eeOffset02 -= k01; eeOffset22 -= k01; } aOffset7 += k11 * 4; i_off2 -= 8; } } var i_off3 = n2 - 1; var A21 = a[n >> 3]; var zOffset = i_off3; var baseOffset = i_off3 - 16 * (n >> 5); while(zOffset > baseOffset) { var t0 = u[zOffset]; var t1 = u[zOffset + -8]; u[zOffset + -8] = t0 - t1; u[zOffset] = t0 + t1; t0 = u[zOffset + -1]; t1 = u[zOffset + -9]; u[zOffset + -9] = t0 - t1; u[zOffset + -1] = t0 + t1; t0 = u[zOffset + -2]; t1 = u[zOffset + -10]; var k001 = t0 - t1; u[zOffset + -2] = t0 + t1; t0 = u[zOffset + -3]; t1 = u[zOffset + -11]; var k112 = t0 - t1; u[zOffset + -3] = t0 + t1; u[zOffset + -10] = (k001 + k112) * A21; u[zOffset + -11] = (k112 - k001) * A21; t0 = u[zOffset + -4]; t1 = u[zOffset + -12]; k001 = t1 - t0; u[zOffset + -4] = t0 + t1; t0 = u[zOffset + -5]; t1 = u[zOffset + -13]; k112 = t0 - t1; u[zOffset + -5] = t0 + t1; u[zOffset + -12] = k112; u[zOffset + -13] = k001; t0 = u[zOffset + -6]; t1 = u[zOffset + -14]; k001 = t1 - t0; u[zOffset + -6] = t0 + t1; t0 = u[zOffset + -7]; t1 = u[zOffset + -15]; k112 = t0 - t1; u[zOffset + -7] = t0 + t1; u[zOffset + -14] = (k001 + k112) * A21; u[zOffset + -15] = (k001 - k112) * A21; var t01 = u[zOffset]; var t11 = u[zOffset + -4]; var k002 = t01 - t11; var y0 = t01 + t11; t01 = u[zOffset + -2]; t11 = u[zOffset + -6]; var y2 = t01 + t11; var k22 = t01 - t11; u[zOffset] = y0 + y2; u[zOffset + -2] = y0 - y2; var k33 = u[zOffset + -3] - u[zOffset + -7]; u[zOffset + -4] = k002 + k33; u[zOffset + -6] = k002 - k33; t01 = u[zOffset + -1]; t11 = u[zOffset + -5]; var k113 = t01 - t11; var y1 = t01 + t11; var y3 = u[zOffset + -3] + u[zOffset + -7]; u[zOffset + -1] = y1 + y3; u[zOffset + -3] = y1 - y3; u[zOffset + -5] = k113 - k22; u[zOffset + -7] = k113 + k22; var zOffset1 = zOffset - 8; var t02 = u[zOffset1]; var t12 = u[zOffset1 + -4]; var k003 = t02 - t12; var y01 = t02 + t12; t02 = u[zOffset1 + -2]; t12 = u[zOffset1 + -6]; var y21 = t02 + t12; var k221 = t02 - t12; u[zOffset1] = y01 + y21; u[zOffset1 + -2] = y01 - y21; var k331 = u[zOffset1 + -3] - u[zOffset1 + -7]; u[zOffset1 + -4] = k003 + k331; u[zOffset1 + -6] = k003 - k331; t02 = u[zOffset1 + -1]; t12 = u[zOffset1 + -5]; var k114 = t02 - t12; var y11 = t02 + t12; var y31 = u[zOffset1 + -3] + u[zOffset1 + -7]; u[zOffset1 + -1] = y11 + y31; u[zOffset1 + -3] = y11 - y31; u[zOffset1 + -5] = k114 - k221; u[zOffset1 + -7] = k114 + k221; zOffset -= 16; } var brOffset = 0; var dOffset01 = n4 - 4; var dOffset11 = n2 - 4; while(dOffset01 >= 0) { var k4 = bitReverse[brOffset]; v[dOffset11 + 3] = u[k4]; v[dOffset11 + 2] = u[k4 + 1]; v[dOffset01 + 3] = u[k4 + 2]; v[dOffset01 + 2] = u[k4 + 3]; k4 = bitReverse[brOffset + 1]; v[dOffset11 + 1] = u[k4]; v[dOffset11] = u[k4 + 1]; v[dOffset01 + 1] = u[k4 + 2]; v[dOffset01] = u[k4 + 3]; dOffset01 -= 4; dOffset11 -= 4; brOffset += 2; } var cOffset = 0; var dOffset2 = 0; var eOffset3 = n2 - 4; while(dOffset2 < eOffset3) { var a02 = v[dOffset2] - v[eOffset3 + 2]; var a11 = v[dOffset2 + 1] + v[eOffset3 + 3]; var b0 = c[cOffset + 1] * a02 + c[cOffset] * a11; var b1 = c[cOffset + 1] * a11 - c[cOffset] * a02; var b2 = v[dOffset2] + v[eOffset3 + 2]; var b3 = v[dOffset2 + 1] - v[eOffset3 + 3]; v[dOffset2] = b2 + b0; v[dOffset2 + 1] = b3 + b1; v[eOffset3 + 2] = b2 - b0; v[eOffset3 + 3] = b1 - b3; a02 = v[dOffset2 + 2] - v[eOffset3]; a11 = v[dOffset2 + 3] + v[eOffset3 + 1]; b0 = c[cOffset + 3] * a02 + c[cOffset + 2] * a11; b1 = c[cOffset + 3] * a11 - c[cOffset + 2] * a02; b2 = v[dOffset2 + 2] + v[eOffset3]; b3 = v[dOffset2 + 3] - v[eOffset3 + 1]; v[dOffset2 + 2] = b2 + b0; v[dOffset2 + 3] = b3 + b1; v[eOffset3] = b2 - b0; v[eOffset3 + 1] = b1 - b3; cOffset += 4; dOffset2 += 4; eOffset3 -= 4; } var bOffset = n2 - 8; var eOffset4 = n2 - 8; var dOffset02 = 0; var dOffset12 = n2 - 4; var dOffset21 = n2; var dOffset3 = n - 4; while(eOffset4 >= 0) { var p3 = buf2[eOffset4 + 6] * b[bOffset + 7] - buf2[eOffset4 + 7] * b[bOffset + 6]; var p2 = -buf2[eOffset4 + 6] * b[bOffset + 6] - buf2[eOffset4 + 7] * b[bOffset + 7]; buffer[dOffset02] = p3; buffer[dOffset12 + 3] = -p3; buffer[dOffset21] = p2; buffer[dOffset3 + 3] = p2; var p1 = buf2[eOffset4 + 4] * b[bOffset + 5] - buf2[eOffset4 + 5] * b[bOffset + 4]; var p0 = -buf2[eOffset4 + 4] * b[bOffset + 4] - buf2[eOffset4 + 5] * b[bOffset + 5]; buffer[dOffset02 + 1] = p1; buffer[dOffset12 + 2] = -p1; buffer[dOffset21 + 1] = p0; buffer[dOffset3 + 2] = p0; p3 = buf2[eOffset4 + 2] * b[bOffset + 3] - buf2[eOffset4 + 3] * b[bOffset + 2]; p2 = -buf2[eOffset4 + 2] * b[bOffset + 2] - buf2[eOffset4 + 3] * b[bOffset + 3]; buffer[dOffset02 + 2] = p3; buffer[dOffset12 + 1] = -p3; buffer[dOffset21 + 2] = p2; buffer[dOffset3 + 1] = p2; p1 = buf2[eOffset4] * b[bOffset + 1] - buf2[eOffset4 + 1] * b[bOffset]; p0 = -buf2[eOffset4] * b[bOffset] - buf2[eOffset4 + 1] * b[bOffset + 1]; buffer[dOffset02 + 3] = p1; buffer[dOffset12] = -p1; buffer[dOffset21 + 3] = p0; buffer[dOffset3] = p0; bOffset -= 8; eOffset4 -= 8; dOffset02 += 4; dOffset21 += 4; dOffset12 -= 4; dOffset3 -= 4; } }; kha_audio2_ogg_tools_Mdct.step3Iter0Loop = function(n,e,i_off,k_off,a) { var eeOffset0 = i_off; var eeOffset2 = i_off + k_off; var aOffset = 0; var i = (n >> 2) + 1; while(--i > 0) { var k00_20 = e[eeOffset0] - e[eeOffset2]; var k01_21 = e[eeOffset0 + -1] - e[eeOffset2 + -1]; var _g = eeOffset0; var _g1 = e; _g1[_g] = _g1[_g] + e[eeOffset2]; var _g2 = eeOffset0 + -1; var _g11 = e; _g11[_g2] = _g11[_g2] + e[eeOffset2 + -1]; e[eeOffset2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eeOffset2 + -1] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = e[eeOffset0 + -2] - e[eeOffset2 + -2]; k01_21 = e[eeOffset0 + -3] - e[eeOffset2 + -3]; var _g3 = eeOffset0 + -2; var _g12 = e; _g12[_g3] = _g12[_g3] + e[eeOffset2 + -2]; var _g4 = eeOffset0 + -3; var _g13 = e; _g13[_g4] = _g13[_g4] + e[eeOffset2 + -3]; e[eeOffset2 + -2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eeOffset2 + -3] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = e[eeOffset0 + -4] - e[eeOffset2 + -4]; k01_21 = e[eeOffset0 + -5] - e[eeOffset2 + -5]; var _g5 = eeOffset0 + -4; var _g14 = e; _g14[_g5] = _g14[_g5] + e[eeOffset2 + -4]; var _g6 = eeOffset0 + -5; var _g15 = e; _g15[_g6] = _g15[_g6] + e[eeOffset2 + -5]; e[eeOffset2 + -4] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eeOffset2 + -5] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = e[eeOffset0 + -6] - e[eeOffset2 + -6]; k01_21 = e[eeOffset0 + -7] - e[eeOffset2 + -7]; var _g7 = eeOffset0 + -6; var _g16 = e; _g16[_g7] = _g16[_g7] + e[eeOffset2 + -6]; var _g8 = eeOffset0 + -7; var _g17 = e; _g17[_g8] = _g17[_g8] + e[eeOffset2 + -7]; e[eeOffset2 + -6] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eeOffset2 + -7] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; eeOffset0 -= 8; eeOffset2 -= 8; } }; kha_audio2_ogg_tools_Mdct.step3InnerRLoop = function(lim,e,d0,k_off,a,k1) { var aOffset = 0; var eOffset0 = d0; var eOffset2 = d0 + k_off; var i = (lim >> 2) + 1; while(--i > 0) { var k00_20 = e[eOffset0] - e[eOffset2]; var k01_21 = e[eOffset0 + -1] - e[eOffset2 + -1]; var _g = eOffset0; var _g1 = e; _g1[_g] = _g1[_g] + e[eOffset2]; var _g2 = eOffset0 + -1; var _g11 = e; _g11[_g2] = _g11[_g2] + e[eOffset2 + -1]; e[eOffset2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eOffset2 + -1] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += k1; k00_20 = e[eOffset0 + -2] - e[eOffset2 + -2]; k01_21 = e[eOffset0 + -3] - e[eOffset2 + -3]; var _g3 = eOffset0 + -2; var _g12 = e; _g12[_g3] = _g12[_g3] + e[eOffset2 + -2]; var _g4 = eOffset0 + -3; var _g13 = e; _g13[_g4] = _g13[_g4] + e[eOffset2 + -3]; e[eOffset2 + -2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eOffset2 + -3] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += k1; k00_20 = e[eOffset0 + -4] - e[eOffset2 + -4]; k01_21 = e[eOffset0 + -5] - e[eOffset2 + -5]; var _g5 = eOffset0 + -4; var _g14 = e; _g14[_g5] = _g14[_g5] + e[eOffset2 + -4]; var _g6 = eOffset0 + -5; var _g15 = e; _g15[_g6] = _g15[_g6] + e[eOffset2 + -5]; e[eOffset2 + -4] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eOffset2 + -5] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += k1; k00_20 = e[eOffset0 + -6] - e[eOffset2 + -6]; k01_21 = e[eOffset0 + -7] - e[eOffset2 + -7]; var _g7 = eOffset0 + -6; var _g16 = e; _g16[_g7] = _g16[_g7] + e[eOffset2 + -6]; var _g8 = eOffset0 + -7; var _g17 = e; _g17[_g8] = _g17[_g8] + e[eOffset2 + -7]; e[eOffset2 + -6] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; e[eOffset2 + -7] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; eOffset0 -= 8; eOffset2 -= 8; aOffset += k1; } }; kha_audio2_ogg_tools_Mdct.step3InnerSLoop = function(n,e,i_off,k_off,a,aOffset0,aOffset1,k0) { var A0 = a[aOffset0]; var A1 = a[aOffset0 + 1]; var A2 = a[aOffset0 + aOffset1]; var A3 = a[aOffset0 + aOffset1 + 1]; var A4 = a[aOffset0 + aOffset1 * 2]; var A5 = a[aOffset0 + aOffset1 * 2 + 1]; var A6 = a[aOffset0 + aOffset1 * 3]; var A7 = a[aOffset0 + aOffset1 * 3 + 1]; var eeOffset0 = i_off; var eeOffset2 = i_off + k_off; var i = n + 1; while(--i > 0) { var k00 = e[eeOffset0] - e[eeOffset2]; var k11 = e[eeOffset0 + -1] - e[eeOffset2 + -1]; e[eeOffset0] = e[eeOffset0] + e[eeOffset2]; e[eeOffset0 + -1] = e[eeOffset0 + -1] + e[eeOffset2 + -1]; e[eeOffset2] = k00 * A0 - k11 * A1; e[eeOffset2 + -1] = k11 * A0 + k00 * A1; k00 = e[eeOffset0 + -2] - e[eeOffset2 + -2]; k11 = e[eeOffset0 + -3] - e[eeOffset2 + -3]; e[eeOffset0 + -2] = e[eeOffset0 + -2] + e[eeOffset2 + -2]; e[eeOffset0 + -3] = e[eeOffset0 + -3] + e[eeOffset2 + -3]; e[eeOffset2 + -2] = k00 * A2 - k11 * A3; e[eeOffset2 + -3] = k11 * A2 + k00 * A3; k00 = e[eeOffset0 + -4] - e[eeOffset2 + -4]; k11 = e[eeOffset0 + -5] - e[eeOffset2 + -5]; e[eeOffset0 + -4] = e[eeOffset0 + -4] + e[eeOffset2 + -4]; e[eeOffset0 + -5] = e[eeOffset0 + -5] + e[eeOffset2 + -5]; e[eeOffset2 + -4] = k00 * A4 - k11 * A5; e[eeOffset2 + -5] = k11 * A4 + k00 * A5; k00 = e[eeOffset0 + -6] - e[eeOffset2 + -6]; k11 = e[eeOffset0 + -7] - e[eeOffset2 + -7]; e[eeOffset0 + -6] = e[eeOffset0 + -6] + e[eeOffset2 + -6]; e[eeOffset0 + -7] = e[eeOffset0 + -7] + e[eeOffset2 + -7]; e[eeOffset2 + -6] = k00 * A6 - k11 * A7; e[eeOffset2 + -7] = k11 * A6 + k00 * A7; eeOffset0 -= k0; eeOffset2 -= k0; } }; kha_audio2_ogg_tools_Mdct.iter54 = function(e,zOffset) { var t0 = e[zOffset]; var t1 = e[zOffset + -4]; var k00 = t0 - t1; var y0 = t0 + t1; t0 = e[zOffset + -2]; t1 = e[zOffset + -6]; var y2 = t0 + t1; var k22 = t0 - t1; e[zOffset] = y0 + y2; e[zOffset + -2] = y0 - y2; var k33 = e[zOffset + -3] - e[zOffset + -7]; e[zOffset + -4] = k00 + k33; e[zOffset + -6] = k00 - k33; t0 = e[zOffset + -1]; t1 = e[zOffset + -5]; var k11 = t0 - t1; var y1 = t0 + t1; var y3 = e[zOffset + -3] + e[zOffset + -7]; e[zOffset + -1] = y1 + y3; e[zOffset + -3] = y1 - y3; e[zOffset + -5] = k11 - k22; e[zOffset + -7] = k11 + k22; }; kha_audio2_ogg_tools_Mdct.step3InnerSLoopLd654 = function(n,e,i_off,a,baseN) { var A2 = a[baseN >> 3]; var zOffset = i_off; var baseOffset = i_off - 16 * n; while(zOffset > baseOffset) { var t0 = e[zOffset]; var t1 = e[zOffset + -8]; e[zOffset + -8] = t0 - t1; e[zOffset] = t0 + t1; t0 = e[zOffset + -1]; t1 = e[zOffset + -9]; e[zOffset + -9] = t0 - t1; e[zOffset + -1] = t0 + t1; t0 = e[zOffset + -2]; t1 = e[zOffset + -10]; var k00 = t0 - t1; e[zOffset + -2] = t0 + t1; t0 = e[zOffset + -3]; t1 = e[zOffset + -11]; var k11 = t0 - t1; e[zOffset + -3] = t0 + t1; e[zOffset + -10] = (k00 + k11) * A2; e[zOffset + -11] = (k11 - k00) * A2; t0 = e[zOffset + -4]; t1 = e[zOffset + -12]; k00 = t1 - t0; e[zOffset + -4] = t0 + t1; t0 = e[zOffset + -5]; t1 = e[zOffset + -13]; k11 = t0 - t1; e[zOffset + -5] = t0 + t1; e[zOffset + -12] = k11; e[zOffset + -13] = k00; t0 = e[zOffset + -6]; t1 = e[zOffset + -14]; k00 = t1 - t0; e[zOffset + -6] = t0 + t1; t0 = e[zOffset + -7]; t1 = e[zOffset + -15]; k11 = t0 - t1; e[zOffset + -7] = t0 + t1; e[zOffset + -14] = (k00 + k11) * A2; e[zOffset + -15] = (k00 - k11) * A2; var t01 = e[zOffset]; var t11 = e[zOffset + -4]; var k001 = t01 - t11; var y0 = t01 + t11; t01 = e[zOffset + -2]; t11 = e[zOffset + -6]; var y2 = t01 + t11; var k22 = t01 - t11; e[zOffset] = y0 + y2; e[zOffset + -2] = y0 - y2; var k33 = e[zOffset + -3] - e[zOffset + -7]; e[zOffset + -4] = k001 + k33; e[zOffset + -6] = k001 - k33; t01 = e[zOffset + -1]; t11 = e[zOffset + -5]; var k111 = t01 - t11; var y1 = t01 + t11; var y3 = e[zOffset + -3] + e[zOffset + -7]; e[zOffset + -1] = y1 + y3; e[zOffset + -3] = y1 - y3; e[zOffset + -5] = k111 - k22; e[zOffset + -7] = k111 + k22; var zOffset1 = zOffset - 8; var t02 = e[zOffset1]; var t12 = e[zOffset1 + -4]; var k002 = t02 - t12; var y01 = t02 + t12; t02 = e[zOffset1 + -2]; t12 = e[zOffset1 + -6]; var y21 = t02 + t12; var k221 = t02 - t12; e[zOffset1] = y01 + y21; e[zOffset1 + -2] = y01 - y21; var k331 = e[zOffset1 + -3] - e[zOffset1 + -7]; e[zOffset1 + -4] = k002 + k331; e[zOffset1 + -6] = k002 - k331; t02 = e[zOffset1 + -1]; t12 = e[zOffset1 + -5]; var k112 = t02 - t12; var y11 = t02 + t12; var y31 = e[zOffset1 + -3] + e[zOffset1 + -7]; e[zOffset1 + -1] = y11 + y31; e[zOffset1 + -3] = y11 - y31; e[zOffset1 + -5] = k112 - k221; e[zOffset1 + -7] = k112 + k221; zOffset -= 16; } }; var kha_audio2_ogg_vorbis_Reader = function(input,seekFunc,inputLength) { this.seekFunc = seekFunc; this.inputLength = inputLength; this.decoder = kha_audio2_ogg_vorbis_VorbisDecoder.start(input); this.decoder.setupSampleNumber(seekFunc,inputLength); this.loopStart = this.get_header().comment.get_loopStart(); this.loopLength = this.get_header().comment.get_loopLength(); }; $hxClasses["kha.audio2.ogg.vorbis.Reader"] = kha_audio2_ogg_vorbis_Reader; kha_audio2_ogg_vorbis_Reader.__name__ = true; kha_audio2_ogg_vorbis_Reader.openFromBytes = function(bytes) { var input = new haxe_io_BytesInput(bytes); var a1 = input; return new kha_audio2_ogg_vorbis_Reader(input,function(a2) { kha_audio2_ogg_vorbis_Reader.seekBytes(a1,a2); },bytes.length); }; kha_audio2_ogg_vorbis_Reader.seekBytes = function(bytes,pos) { bytes.set_position(pos); }; kha_audio2_ogg_vorbis_Reader.readAll = function(bytes,output,useFloat) { if(useFloat == null) { useFloat = false; } var input = new haxe_io_BytesInput(bytes); var decoder = kha_audio2_ogg_vorbis_VorbisDecoder.start(input); var a1 = input; decoder.setupSampleNumber(function(a2) { kha_audio2_ogg_vorbis_Reader.seekBytes(a1,a2); },bytes.length); var header = decoder.header; var count = 0; var bufferSize = 4096; var length = bufferSize * header.channel; var this1 = new Array(length); var buffer = this1; while(true) { var n = decoder.read(buffer,bufferSize,header.channel,header.sampleRate,useFloat); var _g1 = 0; var _g = n * header.channel; while(_g1 < _g) { var i = _g1++; output.writeFloat(buffer[i]); } if(n == 0) { break; } count += n; } return decoder.header; }; kha_audio2_ogg_vorbis_Reader.prototype = { decoder: null ,get_header: function() { return this.decoder.header; } ,get_totalSample: function() { return this.decoder.totalSample; } ,get_totalMillisecond: function() { var samples = this.decoder.totalSample; var b = this.get_header().sampleRate; return _$UInt_UInt_$Impl_$.toFloat(samples) / _$UInt_UInt_$Impl_$.toFloat(b) * 1000; } ,get_currentSample: function() { return this.decoder.currentSample; } ,set_currentSample: function(value) { this.decoder.seek(this.seekFunc,this.inputLength,value); return this.decoder.currentSample; } ,get_currentMillisecond: function() { var samples = this.get_currentSample(); var b = this.get_header().sampleRate; return _$UInt_UInt_$Impl_$.toFloat(samples) / _$UInt_UInt_$Impl_$.toFloat(b) * 1000; } ,set_currentMillisecond: function(value) { var _g = value / 1000; var _g1 = this.get_header().sampleRate; this.set_currentSample(Math.floor(_$UInt_UInt_$Impl_$.toFloat(_g1) * _g)); return this.get_currentMillisecond(); } ,loopStart: null ,loopLength: null ,seekFunc: null ,inputLength: null ,read: function(output,samples,channels,sampleRate,useFloat) { if(useFloat == null) { useFloat = false; } this.decoder.ensurePosition(this.seekFunc); if(samples == null) { samples = this.decoder.totalSample; } if(channels == null) { channels = this.get_header().channel; } if(sampleRate == null) { sampleRate = this.get_header().sampleRate; } return this.decoder.read(output,samples,channels,sampleRate,useFloat); } ,clone: function() { var reader = Type.createEmptyInstance(kha_audio2_ogg_vorbis_Reader); reader.seekFunc = this.seekFunc; reader.inputLength = this.inputLength; reader.decoder = this.decoder.clone(this.seekFunc); reader.loopStart = this.loopStart; reader.loopLength = this.loopLength; return reader; } ,sampleToMillisecond: function(samples) { var b = this.get_header().sampleRate; return _$UInt_UInt_$Impl_$.toFloat(samples) / _$UInt_UInt_$Impl_$.toFloat(b) * 1000; } ,millisecondToSample: function(millseconds) { var _g = millseconds / 1000; var _g1 = this.get_header().sampleRate; return Math.floor(_$UInt_UInt_$Impl_$.toFloat(_g1) * _g); } ,__class__: kha_audio2_ogg_vorbis_Reader }; var kha_audio2_ogg_vorbis_VorbisDecodeState = function(input) { this.nextSeg = 0; this.firstDecode = false; this.bytesInSeg = 0; this.validBits = 0; this.input = input; this.inputPosition = 0; this.page = new kha_audio2_ogg_vorbis_data_Page(); kha_audio2_ogg_tools_Crc32.init(); }; $hxClasses["kha.audio2.ogg.vorbis.VorbisDecodeState"] = kha_audio2_ogg_vorbis_VorbisDecodeState; kha_audio2_ogg_vorbis_VorbisDecodeState.__name__ = true; kha_audio2_ogg_vorbis_VorbisDecodeState.prototype = { page: null ,eof: null ,pFirst: null ,pLast: null ,validBits: null ,inputPosition: null ,input: null ,discardSamplesDeferred: null ,segments: null ,bytesInSeg: null ,channelBuffers: null ,channelBufferStart: null ,channelBufferEnd: null ,currentSample: null ,previousWindow: null ,previousLength: null ,finalY: null ,firstDecode: null ,nextSeg: null ,acc: null ,lastSeg: null ,lastSegWhich: null ,endSegWithKnownLoc: null ,knownLocForPacket: null ,error: null ,currentLoc: null ,currentLocValid: null ,firstAudioPageOffset: null ,setup: function(loc0,loc1) { this.inputPosition += 1; var segmentCount = this.input.readByte(); this.inputPosition += segmentCount; var this1 = new Array(segmentCount); var vec = this1; var _g1 = 0; var _g = segmentCount; while(_g1 < _g) { var i = _g1++; vec[i] = this.input.readByte(); } this.segments = vec; this.endSegWithKnownLoc = -2; if(loc0 != -1 || loc1 != -1) { var i1 = segmentCount - 1; while(i1 >= 0) { if(this.segments[i1] < 255) { break; } if(i1 >= 0) { this.endSegWithKnownLoc = i1; this.knownLocForPacket = loc0; } --i1; } } if(this.firstDecode) { var i2 = 0; var len = 0; var p = new kha_audio2_ogg_vorbis_data_ProbedPage(); var _g11 = 0; var _g2 = segmentCount; while(_g11 < _g2) { var i3 = _g11++; len += this.segments[i3]; } len += 27 + segmentCount; p.pageStart = this.firstAudioPageOffset; p.pageEnd = p.pageStart + len; p.firstDecodedSample = 0; p.lastDecodedSample = loc0; this.pFirst = p; } this.nextSeg = 0; } ,clone: function(seekFunc) { var state = Type.createEmptyInstance(kha_audio2_ogg_vorbis_VorbisDecodeState); seekFunc(this.inputPosition); state.input = this.input; state.eof = this.eof; state.validBits = this.validBits; state.discardSamplesDeferred = this.discardSamplesDeferred; state.firstDecode = this.firstDecode; state.nextSeg = this.nextSeg; state.bytesInSeg = this.bytesInSeg; state.acc = state.acc; state.lastSeg = this.lastSeg; state.lastSegWhich = this.lastSegWhich; state.currentLoc = this.currentLoc; state.currentLocValid = this.currentLocValid; state.inputPosition = this.inputPosition; state.firstAudioPageOffset = this.firstAudioPageOffset; state.error = this.error; state.segments = this.segments; state.pFirst = this.pFirst; state.pLast = this.pLast; state.page = this.page.clone(); return state; } ,next: function() { if(this.lastSeg) { return 0; } if(this.nextSeg == -1) { this.lastSegWhich = this.segments.length - 1; try { this.page.start(this); } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; if( js_Boot.__instanceof(e,kha_audio2_ogg_vorbis_data_ReaderError) ) { this.lastSeg = true; this.error = e; return 0; } else throw(e); } if((this.page.flag & 1) == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 171, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "next"})); } } var len = this.segments[this.nextSeg++]; if(len < 255) { this.lastSeg = true; this.lastSegWhich = this.nextSeg - 1; } if(this.nextSeg >= this.segments.length) { this.nextSeg = -1; } var b = this.bytesInSeg == 0; this.bytesInSeg = len; return len; } ,startPacket: function() { while(this.nextSeg == -1) { this.page.start(this); if((this.page.flag & 1) != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 193, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "startPacket"})); } } this.lastSeg = false; this.validBits = 0; this.bytesInSeg = 0; } ,maybeStartPacket: function() { if(this.nextSeg == -1) { var eof = false; var x; try { this.inputPosition += 1; x = this.input.readByte(); } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; if( js_Boot.__instanceof(e,haxe_io_Eof) ) { eof = true; x = 0; } else throw(e); } if(eof) { return false; } var tmp; var tmp1; var tmp2; if(x == 79) { this.inputPosition += 1; tmp2 = this.input.readByte() != 103; } else { tmp2 = true; } if(!tmp2) { this.inputPosition += 1; tmp1 = this.input.readByte() != 103; } else { tmp1 = true; } if(!tmp1) { this.inputPosition += 1; tmp = this.input.readByte() != 83; } else { tmp = true; } if(tmp) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 218, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "maybeStartPacket"})); } this.page.startWithoutCapturePattern(this); } this.startPacket(); return true; } ,readBits: function(n) { if(this.validBits < 0) { return 0; } else if(this.validBits < n) { if(n > 24) { return this.readBits(24) + (this.readBits(n - 24) << 24); } else { if(this.validBits == 0) { this.acc = 0; } while(true) { if(this.bytesInSeg == 0 && (this.lastSeg || this.next() == 0)) { this.validBits = -1; break; } else { this.bytesInSeg--; this.inputPosition += 1; this.acc = this.acc + (this.input.readByte() << this.validBits); this.validBits += 8; } if(!(this.validBits < n)) { break; } } if(this.validBits < 0) { return 0; } else { var z = this.acc & (1 << n) - 1; this.acc = this.acc >>> n; this.validBits -= n; return z; } } } else { var z1 = this.acc & (1 << n) - 1; this.acc = this.acc >>> n; this.validBits -= n; return z1; } } ,readPacketRaw: function() { if(this.bytesInSeg == 0 && (this.lastSeg || this.next() == 0)) { return -1; } else { this.bytesInSeg--; this.inputPosition += 1; return this.input.readByte(); } } ,readPacket: function() { var x; if(this.bytesInSeg == 0 && (this.lastSeg || this.next() == 0)) { x = -1; } else { this.bytesInSeg--; this.inputPosition += 1; x = this.input.readByte(); } this.validBits = 0; return x; } ,flushPacket: function() { while(this.bytesInSeg != 0 || !this.lastSeg && this.next() != 0) { this.bytesInSeg--; this.inputPosition += 1; this.input.readByte(); } } ,vorbisValidate: function() { var header = new haxe_io_Bytes(new ArrayBuffer(6)); var _g = 0; while(_g < 6) { var i = _g++; var x; if(this.bytesInSeg == 0 && (this.lastSeg || this.next() == 0)) { x = -1; } else { this.bytesInSeg--; this.inputPosition += 1; x = this.input.readByte(); } this.validBits = 0; header.b[i] = x & 255; } if(header.toString() != "vorbis") { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"vorbis header",{ fileName : "VorbisDecodeState.hx", lineNumber : 300, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "vorbisValidate"})); } } ,firstPageValidate: function() { if(this.segments.length != 1) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"segmentCount",{ fileName : "VorbisDecodeState.hx", lineNumber : 307, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "firstPageValidate"})); } if(this.segments[0] != 30) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"decodeState head",{ fileName : "VorbisDecodeState.hx", lineNumber : 310, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "firstPageValidate"})); } } ,startFirstDecode: function() { this.firstAudioPageOffset = this.inputPosition; this.firstDecode = true; } ,capturePattern: function() { var tmp; var tmp1; var tmp2; this.inputPosition += 1; if(this.input.readByte() == 79) { this.inputPosition += 1; tmp2 = this.input.readByte() != 103; } else { tmp2 = true; } if(!tmp2) { this.inputPosition += 1; tmp1 = this.input.readByte() != 103; } else { tmp1 = true; } if(!tmp1) { this.inputPosition += 1; tmp = this.input.readByte() != 83; } else { tmp = true; } if(tmp) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 323, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "capturePattern"})); } } ,skip: function(len) { this.inputPosition += len; var this1 = new Array(len); var vec = this1; var _g1 = 0; var _g = len; while(_g1 < _g) { var i = _g1++; vec[i] = this.input.readByte(); } } ,prepHuffman: function() { if(this.validBits <= 24) { if(this.validBits == 0) { this.acc = 0; } while(true) { if(this.bytesInSeg == 0 && (this.lastSeg || this.next() == 0)) { return; } else { this.bytesInSeg--; this.inputPosition += 1; this.acc = this.acc + (this.input.readByte() << this.validBits); this.validBits += 8; } if(!(this.validBits <= 24)) { break; } } } } ,decode: function(c) { if(this.validBits < 10) { this.prepHuffman(); } var i = c.fastHuffman[this.acc & 1023]; var val; if(i >= 0) { var l = c.codewordLengths[i]; this.acc = this.acc >>> l; this.validBits -= l; if(this.validBits < 0) { this.validBits = 0; val = -1; } else { val = i; } } else { val = this.decodeScalarRaw(c); } if(c.sparse) { val = c.sortedValues[val]; } return val; } ,decodeRaw: function(c) { if(this.validBits < 10) { this.prepHuffman(); } var i = c.fastHuffman[this.acc & 1023]; if(i >= 0) { var l = c.codewordLengths[i]; this.acc = this.acc >>> l; this.validBits -= l; if(this.validBits < 0) { this.validBits = 0; return -1; } else { return i; } } else { return this.decodeScalarRaw(c); } } ,isLastByte: function() { if(this.bytesInSeg == 0) { return this.lastSeg; } else { return false; } } ,finishDecodePacket: function(previousLength,n,r) { var left = r.left.start; var currentLocValid = false; var n2 = n >> 1; if(this.firstDecode) { this.currentLoc = -n2; this.discardSamplesDeferred = n - r.right.end; currentLocValid = true; this.firstDecode = false; } else if(this.discardSamplesDeferred != 0) { r.left.start += this.discardSamplesDeferred; left = r.left.start; this.discardSamplesDeferred = 0; } else { var tmp = previousLength == 0 && currentLocValid; } if(this.lastSegWhich == this.endSegWithKnownLoc) { if(currentLocValid && (this.page.flag & 4) != 0) { var currentEnd = this.knownLocForPacket - (n - r.right.end); if(currentEnd < this.currentLoc + r.right.end) { var len = currentEnd < this.currentLoc ? 0 : currentEnd - this.currentLoc; len += r.left.start; this.currentLoc += len; return { len : len, left : left, right : r.right.start}; } } this.currentLoc = this.knownLocForPacket - (n2 - r.left.start); currentLocValid = true; } if(currentLocValid) { this.currentLoc += r.right.start - r.left.start; } return { len : r.right.end, left : left, right : r.right.start}; } ,readInt32: function() { this.inputPosition += 4; return this.input.readInt32(); } ,readByte: function() { this.inputPosition += 1; return this.input.readByte(); } ,read: function(n) { this.inputPosition += n; var this1 = new Array(n); var vec = this1; var _g1 = 0; var _g = n; while(_g1 < _g) { var i = _g1++; vec[i] = this.input.readByte(); } return vec; } ,readBytes: function(n) { this.inputPosition += n; return this.input.read(n); } ,readString: function(n) { this.inputPosition += n; return this.input.readString(n); } ,getSampleNumber: function(seekFunc,inputLength) { var restoreOffset = this.inputPosition; var previousSafe = _$UInt_UInt_$Impl_$.gte(inputLength,65536) && _$UInt_UInt_$Impl_$.gte(inputLength - 65536,this.firstAudioPageOffset) ? inputLength - 65536 : this.firstAudioPageOffset; seekFunc(this.inputPosition = previousSafe); var end = 0; var last = false; var _g = this.findPage(seekFunc,inputLength); switch(_g[1]) { case 0: var l = _g[3]; var e = _g[2]; end = e; last = l; break; case 1: throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 518, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "getSampleNumber"})); break; } var lastPageLoc = this.inputPosition; try { while(!last) { seekFunc(this.inputPosition = end); var _g1 = this.findPage(seekFunc,inputLength); switch(_g1[1]) { case 0: var l1 = _g1[3]; var e1 = _g1[2]; end = e1; last = l1; break; case 1: throw "__break__"; break; } previousSafe = lastPageLoc + 1; lastPageLoc = this.inputPosition; } } catch( e ) { if( e != "__break__" ) throw e; } seekFunc(this.inputPosition = lastPageLoc); this.inputPosition += 6; var this1 = new Array(6); var vec = this1; var _g11 = 0; var _g2 = 6; while(_g11 < _g2) { var i = _g11++; vec[i] = this.input.readByte(); } var vorbisHeader = vec; this.inputPosition += 4; var lo = this.input.readInt32(); this.inputPosition += 4; var hi = this.input.readInt32(); if(lo == -1 && hi == -1 || hi > 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 552, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "getSampleNumber"})); } this.pLast = new kha_audio2_ogg_vorbis_data_ProbedPage(); this.pLast.pageStart = lastPageLoc; this.pLast.pageEnd = end; this.pLast.lastDecodedSample = lo; this.pLast.firstDecodedSample = null; this.pLast.afterPreviousPageStart = previousSafe; seekFunc(this.inputPosition = restoreOffset); return lo; } ,forcePageResync: function() { this.nextSeg = -1; } ,setInputOffset: function(seekFunc,n) { seekFunc(this.inputPosition = n); } ,findPage: function(seekFunc,inputLength) { try { while(true) { this.inputPosition += 1; var n = this.input.readByte(); if(n == 79) { var retryLoc = this.inputPosition; if(retryLoc - 25 > inputLength) { return kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.NotFound; } var tmp; var tmp1; this.inputPosition += 1; if(this.input.readByte() == 103) { this.inputPosition += 1; tmp1 = this.input.readByte() != 103; } else { tmp1 = true; } if(!tmp1) { this.inputPosition += 1; tmp = this.input.readByte() != 83; } else { tmp = true; } if(tmp) { continue; } var this1 = new Array(27); var header = this1; header[0] = 79; header[1] = 103; header[2] = 103; header[3] = 83; var _g = 4; while(_g < 27) { var i = _g++; this.inputPosition += 1; header[i] = this.input.readByte(); } if(header[4] != 0) { seekFunc(this.inputPosition = retryLoc); continue; } var goal = header[22] + (header[23] << 8) + (header[24] << 16) + (header[25] << 24); var _g1 = 22; while(_g1 < 26) { var i1 = _g1++; header[i1] = 0; } var crc = 0; var _g2 = 0; while(_g2 < 27) { var i2 = _g2++; crc = crc << 8 ^ kha_audio2_ogg_tools_Crc32.table[header[i2] ^ crc >>> 24]; } var len = 0; try { var _g11 = 0; var _g3 = header[26]; while(_g11 < _g3) { var i3 = _g11++; this.inputPosition += 1; var s = this.input.readByte(); crc = crc << 8 ^ kha_audio2_ogg_tools_Crc32.table[s ^ crc >>> 24]; len += s; } var _g12 = 0; var _g4 = len; while(_g12 < _g4) { var i4 = _g12++; this.inputPosition += 1; var $byte = this.input.readByte(); crc = crc << 8 ^ kha_audio2_ogg_tools_Crc32.table[$byte ^ crc >>> 24]; } } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; if( js_Boot.__instanceof(e,haxe_io_Eof) ) { return kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.NotFound; } else throw(e); } if(crc == goal) { var end = this.inputPosition; seekFunc(this.inputPosition = retryLoc - 1); return kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.Found(end,(header[5] & 4) != 0); } } } } catch( e1 ) { if (e1 instanceof js__$Boot_HaxeError) e1 = e1.val; if( js_Boot.__instanceof(e1,haxe_io_Eof) ) { return kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.NotFound; } else throw(e1); } } ,analyzePage: function(seekFunc,h) { var z = new kha_audio2_ogg_vorbis_data_ProbedPage(); var this1 = new Array(255); var packetType = this1; z.pageStart = this.inputPosition; this.inputPosition += 27; var this2 = new Array(27); var vec = this2; var _g1 = 0; var _g = 27; while(_g1 < _g) { var i = _g1++; vec[i] = this.input.readByte(); } var pageHeader = vec; var n = pageHeader[26]; this.inputPosition += n; var this3 = new Array(n); var vec1 = this3; var _g11 = 0; var _g2 = n; while(_g11 < _g2) { var i1 = _g11++; vec1[i1] = this.input.readByte(); } var lacing = vec1; var len = 0; var _g12 = 0; var _g3 = pageHeader[26]; while(_g12 < _g3) { var i2 = _g12++; len += lacing[i2]; } z.pageEnd = z.pageStart + 27 + pageHeader[26] + len; z.lastDecodedSample = pageHeader[6] + (pageHeader[7] << 8) + (pageHeader[8] << 16) + (pageHeader[9] << 16); if((pageHeader[5] & 4) != 0) { z.firstDecodedSample = null; seekFunc(this.inputPosition = z.pageStart); return z; } var numPacket = 0; var packetStart = (pageHeader[5] & 1) == 0; var modeCount = h.modes.length; var _g13 = 0; var _g4 = pageHeader[26]; while(_g13 < _g4) { var i3 = _g13++; if(packetStart) { if(lacing[i3] == 0) { seekFunc(this.inputPosition = z.pageStart); return null; } this.inputPosition += 1; var n1 = this.input.readByte(); if((n1 & 1) != 0) { seekFunc(this.inputPosition = z.pageStart); return null; } n1 >>= 1; var n2 = modeCount - 1; var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var b = n2 < 16384 ? n2 < 16 ? log2_4[n2] : n2 < 512 ? 5 + log2_4[n2 >> 5] : 10 + log2_4[n2 >> 10] : n2 < 16777216 ? n2 < 524288 ? 15 + log2_4[n2 >> 15] : 20 + log2_4[n2 >> 20] : n2 < 536870912 ? 25 + log2_4[n2 >> 25] : n2 < -2147483648 ? 30 + log2_4[n2 >> 30] : 0; n1 &= (1 << b) - 1; if(n1 >= modeCount) { seekFunc(this.inputPosition = z.pageStart); return null; } packetType[numPacket++] = h.modes[n1].blockflag; var len1 = lacing[i3] - 1; this.inputPosition += len1; var this4 = new Array(len1); var vec2 = this4; var _g14 = 0; var _g5 = len1; while(_g14 < _g5) { var i4 = _g14++; vec2[i4] = this.input.readByte(); } } else { var len2 = lacing[i3]; this.inputPosition += len2; var this5 = new Array(len2); var vec3 = this5; var _g15 = 0; var _g6 = len2; while(_g15 < _g6) { var i5 = _g15++; vec3[i5] = this.input.readByte(); } } packetStart = lacing[i3] < 255; } var samples = 0; if(numPacket > 1) { samples += packetType[numPacket - 1] ? h.blocksize1 : h.blocksize0; } var i6 = numPacket - 2; while(i6 >= 1) { --i6; if(packetType[i6]) { if(packetType[i6 + 1]) { samples += h.blocksize1 >> 1; } else { samples += (h.blocksize1 - h.blocksize0 >> 2) + (h.blocksize0 >> 1); } } else { samples += h.blocksize0 >> 1; } --i6; } z.firstDecodedSample = z.lastDecodedSample - samples; seekFunc(this.inputPosition = z.pageStart); return z; } ,decodeScalarRaw: function(c) { this.prepHuffman(); var b = c.sortedCodewords != null || c.codewords != null; var codewordLengths = c.codewordLengths; var codewords = c.codewords; var sortedCodewords = c.sortedCodewords; if(c.entries > 8 ? sortedCodewords != null : codewords != null) { var n = this.acc; n = (n & -1431655766) >>> 1 | (n & 1431655765) << 1; n = (n & -858993460) >>> 2 | (n & 858993459) << 2; n = (n & -252645136) >>> 4 | (n & 252645135) << 4; n = (n & -16711936) >>> 8 | (n & 16711935) << 8; var code = n >>> 16 | n << 16; var x = 0; var n1 = c.sortedEntries; while(n1 > 1) { var m = x + (n1 >> 1); if(_$UInt_UInt_$Impl_$.gte(code,sortedCodewords[m])) { x = m; n1 -= n1 >> 1; } else { n1 >>= 1; } } if(!c.sparse) { x = c.sortedValues[x]; } var len = codewordLengths[x]; if(this.validBits >= len) { this.acc = this.acc >>> len; this.validBits -= len; return x; } this.validBits = 0; return -1; } var b1 = !c.sparse; var _g1 = 0; var _g = c.entries; while(_g1 < _g) { var i = _g1++; var cl = codewordLengths[i]; if(cl == 255) { continue; } if(codewords[i] == (this.acc & (1 << cl) - 1)) { if(this.validBits >= cl) { this.acc = this.acc >>> cl; this.validBits -= cl; return i; } this.validBits = 0; return -1; } } this.error = new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 846, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "decodeScalarRaw"}); this.validBits = 0; return -1; } ,__class__: kha_audio2_ogg_vorbis_VorbisDecodeState }; var kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult = $hxClasses["kha.audio2.ogg.vorbis._VorbisDecodeState.FindPageResult"] = { __ename__ : true, __constructs__ : ["Found","NotFound"] }; kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.Found = function(end,last) { var $x = ["Found",0,end,last]; $x.__enum__ = kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult; $x.toString = $estr; return $x; }; kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.NotFound = ["NotFound",1]; kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.NotFound.toString = $estr; kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult.NotFound.__enum__ = kha_audio2_ogg_vorbis__$VorbisDecodeState_FindPageResult; var kha_audio2_ogg_vorbis_VorbisDecoder = function(header,decodeState) { this.header = header; this.decodeState = decodeState; this.totalSample = null; this.currentSample = 0; this.previousLength = 0; var length = header.channel; var this1 = new Array(length); this.channelBuffers = this1; var length1 = header.channel; var this2 = new Array(length1); this.previousWindow = this2; var length2 = header.channel; var this3 = new Array(length2); this.finalY = this3; var _g1 = 0; var _g = header.channel; while(_g1 < _g) { var i = _g1++; var this4 = this.channelBuffers; var len = header.blocksize1; var this5 = new Array(len); var vec = this5; this4[i] = vec; var this6 = this.previousWindow; var len1 = header.blocksize1 / 2 | 0; var this7 = new Array(len1); var vec1 = this7; this6[i] = vec1; this.finalY[i] = []; } var this8 = new Array(2); this.a = this8; var this9 = new Array(2); this.b = this9; var this10 = new Array(2); this.c = this10; var this11 = new Array(2); this.window = this11; var this12 = new Array(2); this.bitReverseData = this12; this.initBlocksize(0,header.blocksize0); this.initBlocksize(1,header.blocksize1); }; $hxClasses["kha.audio2.ogg.vorbis.VorbisDecoder"] = kha_audio2_ogg_vorbis_VorbisDecoder; kha_audio2_ogg_vorbis_VorbisDecoder.__name__ = true; kha_audio2_ogg_vorbis_VorbisDecoder.start = function(input) { var decodeState = new kha_audio2_ogg_vorbis_VorbisDecodeState(input); var header = kha_audio2_ogg_vorbis_data_Header.read(decodeState); var decoder = new kha_audio2_ogg_vorbis_VorbisDecoder(header,decodeState); decodeState.startFirstDecode(); decoder.pumpFirstFrame(); return decoder; }; kha_audio2_ogg_vorbis_VorbisDecoder.prototype = { previousWindow: null ,previousLength: null ,finalY: null ,a: null ,b: null ,c: null ,window: null ,bitReverseData: null ,channelBuffers: null ,channelBufferStart: null ,channelBufferEnd: null ,header: null ,currentSample: null ,totalSample: null ,decodeState: null ,read: function(output,samples,channels,sampleRate,useFloat) { var b = this.header.sampleRate; if((_$UInt_UInt_$Impl_$.toFloat(sampleRate) % _$UInt_UInt_$Impl_$.toFloat(b) | 0) != 0) { throw new js__$Boot_HaxeError("Unsupported sampleRate : can't convert " + Std.string(_$UInt_UInt_$Impl_$.toFloat(this.header.sampleRate)) + " to " + sampleRate); } if(channels % this.header.channel != 0) { throw new js__$Boot_HaxeError("Unsupported channels : can't convert " + this.header.channel + " to " + channels); } var b1 = this.header.sampleRate; var sampleRepeat = _$UInt_UInt_$Impl_$.toFloat(sampleRate) / _$UInt_UInt_$Impl_$.toFloat(b1) | 0; var channelRepeat = channels / this.header.channel | 0; var n = 0; var len = Math.floor(samples / sampleRepeat); if(this.totalSample != null && len > this.totalSample - this.currentSample) { len = this.totalSample - this.currentSample; } var index = 0; while(n < len) { var k = this.channelBufferEnd - this.channelBufferStart; if(k >= len - n) { k = len - n; } var _g1 = this.channelBufferStart; var _g = this.channelBufferStart + k; while(_g1 < _g) { var j = _g1++; var _g3 = 0; var _g2 = sampleRepeat; while(_g3 < _g2) { var sr = _g3++; var _g5 = 0; var _g4 = this.header.channel; while(_g5 < _g4) { var i = _g5++; var _g7 = 0; var _g6 = channelRepeat; while(_g7 < _g6) { var cr = _g7++; var value = this.channelBuffers[i][j]; if(value > 1) { value = 1; } else if(value < -1) { value = -1; } if(useFloat) { output[index] = value; ++index; } } } } } n += k; this.channelBufferStart += k; if(n == len || this.getFrameFloat() == 0) { break; } } var _g11 = n; var _g8 = len; while(_g11 < _g8) { var j1 = _g11++; var _g31 = 0; var _g21 = sampleRepeat; while(_g31 < _g21) { var sr1 = _g31++; var _g51 = 0; var _g41 = this.header.channel; while(_g51 < _g41) { var i1 = _g51++; var _g71 = 0; var _g61 = channelRepeat; while(_g71 < _g61) { var cr1 = _g71++; if(useFloat) { output[index] = 0; ++index; } } } } } this.currentSample += len; return len * sampleRepeat; } ,skipSamples: function(len) { var n = 0; if(this.totalSample != null && len > this.totalSample - this.currentSample) { len = this.totalSample - this.currentSample; } while(n < len) { var k = this.channelBufferEnd - this.channelBufferStart; if(k >= len - n) { k = len - n; } n += k; this.channelBufferStart += k; if(n == len || this.getFrameFloat() == 0) { break; } } this.currentSample += len; return len; } ,setupSampleNumber: function(seekFunc,inputLength) { if(this.totalSample == null) { this.totalSample = this.decodeState.getSampleNumber(seekFunc,inputLength); } } ,seek: function(seekFunc,inputLength,sampleNumber) { if(this.currentSample == sampleNumber) { return; } if(this.totalSample == null) { this.setupSampleNumber(seekFunc,inputLength); if(this.totalSample == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE,null,{ fileName : "VorbisDecoder.hx", lineNumber : 187, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "seek"})); } } if(sampleNumber < 0) { sampleNumber = 0; } var p0 = this.decodeState.pFirst; var p1 = this.decodeState.pLast; if(sampleNumber >= p1.lastDecodedSample) { sampleNumber = p1.lastDecodedSample - 1; } if(sampleNumber < p0.lastDecodedSample) { this.seekFrameFromPage(seekFunc,p0.pageStart,0,sampleNumber); } else { var attempts = 0; while(p0.pageEnd < p1.pageStart) { var startOffset = p0.pageEnd; var endOffset = p1.afterPreviousPageStart; var startSample = p0.lastDecodedSample; var endSample = p1.lastDecodedSample; if(startSample == null || endSample == null) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.hx", lineNumber : 219, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "seek"})); } if(_$UInt_UInt_$Impl_$.gt(endOffset,startOffset + 4000)) { endOffset = endOffset - 4000; } var probe = startOffset + Math.floor(_$UInt_UInt_$Impl_$.toFloat(endOffset - startOffset) / _$UInt_UInt_$Impl_$.toFloat(endSample - startSample) * (sampleNumber - startSample)); if(attempts >= 4) { var probe2 = startOffset + (endOffset - startOffset >>> 1); if(attempts >= 8) { probe = probe2; } else if(_$UInt_UInt_$Impl_$.gt(probe2,probe)) { probe = probe + (probe2 - probe >>> 1); } else { probe = probe2 + (probe - probe2 >>> 1); } } ++attempts; seekFunc(this.decodeState.inputPosition = probe); var _g = this.decodeState.findPage(seekFunc,inputLength); switch(_g[1]) { case 0: break; case 1: throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.hx", lineNumber : 249, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "seek"})); break; } var q = this.decodeState.analyzePage(seekFunc,this.header); if(q == null) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.hx", lineNumber : 255, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "seek"})); } q.afterPreviousPageStart = probe; if(q.pageStart == p1.pageStart) { p1 = q; continue; } if(sampleNumber < q.lastDecodedSample) { p1 = q; } else { p0 = q; } } if(p0.lastDecodedSample <= sampleNumber && sampleNumber < p1.lastDecodedSample) { this.seekFrameFromPage(seekFunc,p1.pageStart,p0.lastDecodedSample,sampleNumber); } else { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.hx", lineNumber : 275, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "seek"})); } } } ,seekFrameFromPage: function(seekFunc,pageStart,firstSample,targetSample) { var frame = 0; var frameStart = firstSample; seekFunc(this.decodeState.inputPosition = pageStart); this.decodeState.nextSeg = -1; var leftEnd = 0; var leftStart = 0; var prevState = null; var lastState = null; while(true) { prevState = lastState; lastState = this.decodeState.clone(seekFunc); var initialResult = this.decodeInitial(); if(initialResult == null) { lastState = prevState; break; } leftStart = initialResult.left.start; leftEnd = initialResult.left.end; var start = frame == 0 ? leftEnd : leftStart; if(targetSample < frameStart + initialResult.right.start - start) { break; } var _this = this.decodeState; while(_this.bytesInSeg != 0 || !_this.lastSeg && _this.next() != 0) { _this.bytesInSeg--; _this.inputPosition += 1; _this.input.readByte(); } frameStart += initialResult.right.start - start; ++frame; } this.decodeState = lastState; seekFunc(this.decodeState.inputPosition); this.previousLength = 0; this.pumpFirstFrame(); this.currentSample = frameStart; this.skipSamples(targetSample - frameStart); } ,clone: function(seekFunc) { var decoder = Type.createEmptyInstance(kha_audio2_ogg_vorbis_VorbisDecoder); decoder.currentSample = this.currentSample; decoder.totalSample = this.totalSample; decoder.previousLength = this.previousLength; decoder.channelBufferStart = this.channelBufferStart; decoder.channelBufferEnd = this.channelBufferEnd; decoder.a = this.a; decoder.b = this.b; decoder.c = this.c; decoder.window = this.window; decoder.bitReverseData = this.bitReverseData; decoder.header = this.header; decoder.decodeState = this.decodeState.clone(seekFunc); var length = this.header.channel; var this1 = new Array(length); decoder.channelBuffers = this1; var length1 = this.header.channel; var this2 = new Array(length1); decoder.previousWindow = this2; var length2 = this.header.channel; var this3 = new Array(length2); decoder.finalY = this3; var _g1 = 0; var _g = this.header.channel; while(_g1 < _g) { var i = _g1++; decoder.channelBuffers[i] = kha_audio2_ogg_vorbis_VorbisTools.copyVector(this.channelBuffers[i]); decoder.previousWindow[i] = kha_audio2_ogg_vorbis_VorbisTools.copyVector(this.previousWindow[i]); decoder.finalY[i] = Lambda.array(this.finalY[i]); } return decoder; } ,ensurePosition: function(seekFunc) { seekFunc(this.decodeState.inputPosition); } ,getFrameFloat: function() { var result = this.decodePacket(); if(result == null) { this.channelBufferStart = this.channelBufferEnd = 0; return 0; } var len = this.finishFrame(result); this.channelBufferStart = result.left; this.channelBufferEnd = result.left + len; return len; } ,pumpFirstFrame: function() { this.finishFrame(this.decodePacket()); } ,finishFrame: function(r) { var len = r.len; var right = r.right; var left = r.left; if(this.previousLength != 0) { var n = this.previousLength; var w = this.getWindow(n); var _g1 = 0; var _g = this.header.channel; while(_g1 < _g) { var i = _g1++; var cb = this.channelBuffers[i]; var pw = this.previousWindow[i]; var _g3 = 0; var _g2 = n; while(_g3 < _g2) { var j = _g3++; cb[left + j] = cb[left + j] * w[j] + pw[j] * w[n - 1 - j]; } } } var prev = this.previousLength; this.previousLength = len - right; var _g11 = 0; var _g4 = this.header.channel; while(_g11 < _g4) { var i1 = _g11++; var pw1 = this.previousWindow[i1]; var cb1 = this.channelBuffers[i1]; var _g31 = 0; var _g21 = len - right; while(_g31 < _g21) { var j1 = _g31++; pw1[j1] = cb1[right + j1]; } } if(prev == 0) { return 0; } if(len < right) { right = len; } return right - left; } ,getWindow: function(len) { len <<= 1; if(len == this.header.blocksize0) { return this.window[0]; } else if(len == this.header.blocksize1) { return this.window[1]; } else { return null; } } ,initBlocksize: function(bs,n) { var n2 = n >> 1; var n4 = n >> 2; var n8 = n >> 3; var this1 = this.a; var this2 = new Array(n2); this1[bs] = this2; var this3 = this.b; var this4 = new Array(n2); this3[bs] = this4; var this5 = this.c; var this6 = new Array(n4); this5[bs] = this6; var this7 = this.window; var this8 = new Array(n2); this7[bs] = this8; var this9 = this.bitReverseData; var this10 = new Array(n8); this9[bs] = this10; kha_audio2_ogg_vorbis_VorbisTools.computeTwiddleFactors(n,this.a[bs],this.b[bs],this.c[bs]); kha_audio2_ogg_vorbis_VorbisTools.computeWindow(n,this.window[bs]); kha_audio2_ogg_vorbis_VorbisTools.computeBitReverse(n,this.bitReverseData[bs]); } ,inverseMdct: function(buffer,n,blocktype) { var bt = blocktype ? 1 : 0; var a = this.a[bt]; var b = this.b[bt]; var c = this.c[bt]; var bitReverse = this.bitReverseData[bt]; var n2 = n >> 1; var n4 = n >> 2; var n8 = n >> 3; var this1 = new Array(n2); var buf2 = this1; var dOffset = n2 - 2; var aaOffset = 0; var eOffset = 0; var eStopOffset = n2; while(eOffset != eStopOffset) { buf2[dOffset + 1] = buffer[eOffset] * a[aaOffset] - buffer[eOffset + 2] * a[aaOffset + 1]; buf2[dOffset] = buffer[eOffset] * a[aaOffset + 1] + buffer[eOffset + 2] * a[aaOffset]; dOffset -= 2; aaOffset += 2; eOffset += 4; } eOffset = n2 - 3; while(dOffset >= 0) { buf2[dOffset + 1] = -buffer[eOffset + 2] * a[aaOffset] - -buffer[eOffset] * a[aaOffset + 1]; buf2[dOffset] = -buffer[eOffset + 2] * a[aaOffset + 1] + -buffer[eOffset] * a[aaOffset]; dOffset -= 2; aaOffset += 2; eOffset -= 4; } var u = buffer; var v = buf2; var aaOffset1 = n2 - 8; var eOffset0 = n4; var eOffset1 = 0; var dOffset0 = n4; var dOffset1 = 0; while(aaOffset1 >= 0) { var v41_21 = v[eOffset0 + 1] - v[eOffset1 + 1]; var v40_20 = v[eOffset0] - v[eOffset1]; u[dOffset0 + 1] = v[eOffset0 + 1] + v[eOffset1 + 1]; u[dOffset0] = v[eOffset0] + v[eOffset1]; u[dOffset1 + 1] = v41_21 * a[aaOffset1 + 4] - v40_20 * a[aaOffset1 + 5]; u[dOffset1] = v40_20 * a[aaOffset1 + 4] + v41_21 * a[aaOffset1 + 5]; v41_21 = v[eOffset0 + 3] - v[eOffset1 + 3]; v40_20 = v[eOffset0 + 2] - v[eOffset1 + 2]; u[dOffset0 + 3] = v[eOffset0 + 3] + v[eOffset1 + 3]; u[dOffset0 + 2] = v[eOffset0 + 2] + v[eOffset1 + 2]; u[dOffset1 + 3] = v41_21 * a[aaOffset1] - v40_20 * a[aaOffset1 + 1]; u[dOffset1 + 2] = v40_20 * a[aaOffset1] + v41_21 * a[aaOffset1 + 1]; aaOffset1 -= 8; dOffset0 += 4; dOffset1 += 4; eOffset0 += 4; eOffset1 += 4; } var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var ld = (n < 16384 ? n < 16 ? log2_4[n] : n < 512 ? 5 + log2_4[n >> 5] : 10 + log2_4[n >> 10] : n < 16777216 ? n < 524288 ? 15 + log2_4[n >> 15] : 20 + log2_4[n >> 20] : n < 536870912 ? 25 + log2_4[n >> 25] : n < -2147483648 ? 30 + log2_4[n >> 30] : 0) - 1; var i_off = n2 - 1 - n4 * 0; var eeOffset0 = i_off; var eeOffset2 = i_off + -(n >> 3); var aOffset = 0; var i = (n >> 4 >> 2) + 1; while(--i > 0) { var k00_20 = u[eeOffset0] - u[eeOffset2]; var k01_21 = u[eeOffset0 + -1] - u[eeOffset2 + -1]; var _g = eeOffset0; var _g1 = u; _g1[_g] = _g1[_g] + u[eeOffset2]; var _g2 = eeOffset0 + -1; var _g11 = u; _g11[_g2] = _g11[_g2] + u[eeOffset2 + -1]; u[eeOffset2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -1] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = u[eeOffset0 + -2] - u[eeOffset2 + -2]; k01_21 = u[eeOffset0 + -3] - u[eeOffset2 + -3]; var _g3 = eeOffset0 + -2; var _g12 = u; _g12[_g3] = _g12[_g3] + u[eeOffset2 + -2]; var _g4 = eeOffset0 + -3; var _g13 = u; _g13[_g4] = _g13[_g4] + u[eeOffset2 + -3]; u[eeOffset2 + -2] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -3] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = u[eeOffset0 + -4] - u[eeOffset2 + -4]; k01_21 = u[eeOffset0 + -5] - u[eeOffset2 + -5]; var _g5 = eeOffset0 + -4; var _g14 = u; _g14[_g5] = _g14[_g5] + u[eeOffset2 + -4]; var _g6 = eeOffset0 + -5; var _g15 = u; _g15[_g6] = _g15[_g6] + u[eeOffset2 + -5]; u[eeOffset2 + -4] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -5] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; k00_20 = u[eeOffset0 + -6] - u[eeOffset2 + -6]; k01_21 = u[eeOffset0 + -7] - u[eeOffset2 + -7]; var _g7 = eeOffset0 + -6; var _g16 = u; _g16[_g7] = _g16[_g7] + u[eeOffset2 + -6]; var _g8 = eeOffset0 + -7; var _g17 = u; _g17[_g8] = _g17[_g8] + u[eeOffset2 + -7]; u[eeOffset2 + -6] = k00_20 * a[aOffset] - k01_21 * a[aOffset + 1]; u[eeOffset2 + -7] = k01_21 * a[aOffset] + k00_20 * a[aOffset + 1]; aOffset += 8; eeOffset0 -= 8; eeOffset2 -= 8; } var i_off1 = n2 - 1 - n4; var eeOffset01 = i_off1; var eeOffset21 = i_off1 + -(n >> 3); var aOffset1 = 0; var i1 = (n >> 4 >> 2) + 1; while(--i1 > 0) { var k00_201 = u[eeOffset01] - u[eeOffset21]; var k01_211 = u[eeOffset01 + -1] - u[eeOffset21 + -1]; var _g9 = eeOffset01; var _g18 = u; _g18[_g9] = _g18[_g9] + u[eeOffset21]; var _g10 = eeOffset01 + -1; var _g19 = u; _g19[_g10] = _g19[_g10] + u[eeOffset21 + -1]; u[eeOffset21] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -1] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; k00_201 = u[eeOffset01 + -2] - u[eeOffset21 + -2]; k01_211 = u[eeOffset01 + -3] - u[eeOffset21 + -3]; var _g20 = eeOffset01 + -2; var _g110 = u; _g110[_g20] = _g110[_g20] + u[eeOffset21 + -2]; var _g21 = eeOffset01 + -3; var _g111 = u; _g111[_g21] = _g111[_g21] + u[eeOffset21 + -3]; u[eeOffset21 + -2] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -3] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; k00_201 = u[eeOffset01 + -4] - u[eeOffset21 + -4]; k01_211 = u[eeOffset01 + -5] - u[eeOffset21 + -5]; var _g22 = eeOffset01 + -4; var _g112 = u; _g112[_g22] = _g112[_g22] + u[eeOffset21 + -4]; var _g23 = eeOffset01 + -5; var _g113 = u; _g113[_g23] = _g113[_g23] + u[eeOffset21 + -5]; u[eeOffset21 + -4] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -5] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; k00_201 = u[eeOffset01 + -6] - u[eeOffset21 + -6]; k01_211 = u[eeOffset01 + -7] - u[eeOffset21 + -7]; var _g24 = eeOffset01 + -6; var _g114 = u; _g114[_g24] = _g114[_g24] + u[eeOffset21 + -6]; var _g25 = eeOffset01 + -7; var _g115 = u; _g115[_g25] = _g115[_g25] + u[eeOffset21 + -7]; u[eeOffset21 + -6] = k00_201 * a[aOffset1] - k01_211 * a[aOffset1 + 1]; u[eeOffset21 + -7] = k01_211 * a[aOffset1] + k00_201 * a[aOffset1 + 1]; aOffset1 += 8; eeOffset01 -= 8; eeOffset21 -= 8; } var d0 = n2 - 1 - n8 * 0; var aOffset2 = 0; var eOffset01 = d0; var eOffset2 = d0 + -(n >> 4); var i2 = (n >> 5 >> 2) + 1; while(--i2 > 0) { var k00_202 = u[eOffset01] - u[eOffset2]; var k01_212 = u[eOffset01 + -1] - u[eOffset2 + -1]; var _g26 = eOffset01; var _g116 = u; _g116[_g26] = _g116[_g26] + u[eOffset2]; var _g27 = eOffset01 + -1; var _g117 = u; _g117[_g27] = _g117[_g27] + u[eOffset2 + -1]; u[eOffset2] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -1] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; aOffset2 += 16; k00_202 = u[eOffset01 + -2] - u[eOffset2 + -2]; k01_212 = u[eOffset01 + -3] - u[eOffset2 + -3]; var _g28 = eOffset01 + -2; var _g118 = u; _g118[_g28] = _g118[_g28] + u[eOffset2 + -2]; var _g29 = eOffset01 + -3; var _g119 = u; _g119[_g29] = _g119[_g29] + u[eOffset2 + -3]; u[eOffset2 + -2] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -3] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; aOffset2 += 16; k00_202 = u[eOffset01 + -4] - u[eOffset2 + -4]; k01_212 = u[eOffset01 + -5] - u[eOffset2 + -5]; var _g30 = eOffset01 + -4; var _g120 = u; _g120[_g30] = _g120[_g30] + u[eOffset2 + -4]; var _g31 = eOffset01 + -5; var _g121 = u; _g121[_g31] = _g121[_g31] + u[eOffset2 + -5]; u[eOffset2 + -4] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -5] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; aOffset2 += 16; k00_202 = u[eOffset01 + -6] - u[eOffset2 + -6]; k01_212 = u[eOffset01 + -7] - u[eOffset2 + -7]; var _g32 = eOffset01 + -6; var _g122 = u; _g122[_g32] = _g122[_g32] + u[eOffset2 + -6]; var _g33 = eOffset01 + -7; var _g123 = u; _g123[_g33] = _g123[_g33] + u[eOffset2 + -7]; u[eOffset2 + -6] = k00_202 * a[aOffset2] - k01_212 * a[aOffset2 + 1]; u[eOffset2 + -7] = k01_212 * a[aOffset2] + k00_202 * a[aOffset2 + 1]; eOffset01 -= 8; eOffset2 -= 8; aOffset2 += 16; } var d01 = n2 - 1 - n8; var aOffset3 = 0; var eOffset02 = d01; var eOffset21 = d01 + -(n >> 4); var i3 = (n >> 5 >> 2) + 1; while(--i3 > 0) { var k00_203 = u[eOffset02] - u[eOffset21]; var k01_213 = u[eOffset02 + -1] - u[eOffset21 + -1]; var _g34 = eOffset02; var _g124 = u; _g124[_g34] = _g124[_g34] + u[eOffset21]; var _g35 = eOffset02 + -1; var _g125 = u; _g125[_g35] = _g125[_g35] + u[eOffset21 + -1]; u[eOffset21] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -1] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; aOffset3 += 16; k00_203 = u[eOffset02 + -2] - u[eOffset21 + -2]; k01_213 = u[eOffset02 + -3] - u[eOffset21 + -3]; var _g36 = eOffset02 + -2; var _g126 = u; _g126[_g36] = _g126[_g36] + u[eOffset21 + -2]; var _g37 = eOffset02 + -3; var _g127 = u; _g127[_g37] = _g127[_g37] + u[eOffset21 + -3]; u[eOffset21 + -2] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -3] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; aOffset3 += 16; k00_203 = u[eOffset02 + -4] - u[eOffset21 + -4]; k01_213 = u[eOffset02 + -5] - u[eOffset21 + -5]; var _g38 = eOffset02 + -4; var _g128 = u; _g128[_g38] = _g128[_g38] + u[eOffset21 + -4]; var _g39 = eOffset02 + -5; var _g129 = u; _g129[_g39] = _g129[_g39] + u[eOffset21 + -5]; u[eOffset21 + -4] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -5] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; aOffset3 += 16; k00_203 = u[eOffset02 + -6] - u[eOffset21 + -6]; k01_213 = u[eOffset02 + -7] - u[eOffset21 + -7]; var _g40 = eOffset02 + -6; var _g130 = u; _g130[_g40] = _g130[_g40] + u[eOffset21 + -6]; var _g41 = eOffset02 + -7; var _g131 = u; _g131[_g41] = _g131[_g41] + u[eOffset21 + -7]; u[eOffset21 + -6] = k00_203 * a[aOffset3] - k01_213 * a[aOffset3 + 1]; u[eOffset21 + -7] = k01_213 * a[aOffset3] + k00_203 * a[aOffset3 + 1]; eOffset02 -= 8; eOffset21 -= 8; aOffset3 += 16; } var d02 = n2 - 1 - n8 * 2; var aOffset4 = 0; var eOffset03 = d02; var eOffset22 = d02 + -(n >> 4); var i4 = (n >> 5 >> 2) + 1; while(--i4 > 0) { var k00_204 = u[eOffset03] - u[eOffset22]; var k01_214 = u[eOffset03 + -1] - u[eOffset22 + -1]; var _g42 = eOffset03; var _g132 = u; _g132[_g42] = _g132[_g42] + u[eOffset22]; var _g43 = eOffset03 + -1; var _g133 = u; _g133[_g43] = _g133[_g43] + u[eOffset22 + -1]; u[eOffset22] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -1] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; aOffset4 += 16; k00_204 = u[eOffset03 + -2] - u[eOffset22 + -2]; k01_214 = u[eOffset03 + -3] - u[eOffset22 + -3]; var _g44 = eOffset03 + -2; var _g134 = u; _g134[_g44] = _g134[_g44] + u[eOffset22 + -2]; var _g45 = eOffset03 + -3; var _g135 = u; _g135[_g45] = _g135[_g45] + u[eOffset22 + -3]; u[eOffset22 + -2] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -3] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; aOffset4 += 16; k00_204 = u[eOffset03 + -4] - u[eOffset22 + -4]; k01_214 = u[eOffset03 + -5] - u[eOffset22 + -5]; var _g46 = eOffset03 + -4; var _g136 = u; _g136[_g46] = _g136[_g46] + u[eOffset22 + -4]; var _g47 = eOffset03 + -5; var _g137 = u; _g137[_g47] = _g137[_g47] + u[eOffset22 + -5]; u[eOffset22 + -4] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -5] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; aOffset4 += 16; k00_204 = u[eOffset03 + -6] - u[eOffset22 + -6]; k01_214 = u[eOffset03 + -7] - u[eOffset22 + -7]; var _g48 = eOffset03 + -6; var _g138 = u; _g138[_g48] = _g138[_g48] + u[eOffset22 + -6]; var _g49 = eOffset03 + -7; var _g139 = u; _g139[_g49] = _g139[_g49] + u[eOffset22 + -7]; u[eOffset22 + -6] = k00_204 * a[aOffset4] - k01_214 * a[aOffset4 + 1]; u[eOffset22 + -7] = k01_214 * a[aOffset4] + k00_204 * a[aOffset4 + 1]; eOffset03 -= 8; eOffset22 -= 8; aOffset4 += 16; } var d03 = n2 - 1 - n8 * 3; var aOffset5 = 0; var eOffset04 = d03; var eOffset23 = d03 + -(n >> 4); var i5 = (n >> 5 >> 2) + 1; while(--i5 > 0) { var k00_205 = u[eOffset04] - u[eOffset23]; var k01_215 = u[eOffset04 + -1] - u[eOffset23 + -1]; var _g50 = eOffset04; var _g140 = u; _g140[_g50] = _g140[_g50] + u[eOffset23]; var _g51 = eOffset04 + -1; var _g141 = u; _g141[_g51] = _g141[_g51] + u[eOffset23 + -1]; u[eOffset23] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -1] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; aOffset5 += 16; k00_205 = u[eOffset04 + -2] - u[eOffset23 + -2]; k01_215 = u[eOffset04 + -3] - u[eOffset23 + -3]; var _g52 = eOffset04 + -2; var _g142 = u; _g142[_g52] = _g142[_g52] + u[eOffset23 + -2]; var _g53 = eOffset04 + -3; var _g143 = u; _g143[_g53] = _g143[_g53] + u[eOffset23 + -3]; u[eOffset23 + -2] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -3] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; aOffset5 += 16; k00_205 = u[eOffset04 + -4] - u[eOffset23 + -4]; k01_215 = u[eOffset04 + -5] - u[eOffset23 + -5]; var _g54 = eOffset04 + -4; var _g144 = u; _g144[_g54] = _g144[_g54] + u[eOffset23 + -4]; var _g55 = eOffset04 + -5; var _g145 = u; _g145[_g55] = _g145[_g55] + u[eOffset23 + -5]; u[eOffset23 + -4] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -5] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; aOffset5 += 16; k00_205 = u[eOffset04 + -6] - u[eOffset23 + -6]; k01_215 = u[eOffset04 + -7] - u[eOffset23 + -7]; var _g56 = eOffset04 + -6; var _g146 = u; _g146[_g56] = _g146[_g56] + u[eOffset23 + -6]; var _g57 = eOffset04 + -7; var _g147 = u; _g147[_g57] = _g147[_g57] + u[eOffset23 + -7]; u[eOffset23 + -6] = k00_205 * a[aOffset5] - k01_215 * a[aOffset5 + 1]; u[eOffset23 + -7] = k01_215 * a[aOffset5] + k00_205 * a[aOffset5 + 1]; eOffset04 -= 8; eOffset23 -= 8; aOffset5 += 16; } var _g148 = 2; var _g58 = ld - 3 >> 1; while(_g148 < _g58) { var l = _g148++; var k0 = n >> l + 2; var k0_2 = k0 >> 1; var lim = 1 << l + 1; var _g310 = 0; var _g210 = lim; while(_g310 < _g210) { var i6 = _g310++; var d04 = n2 - 1 - k0 * i6; var k1 = 1 << l + 3; var aOffset6 = 0; var eOffset05 = d04; var eOffset24 = d04 + -k0_2; var i7 = (n >> l + 4 >> 2) + 1; while(--i7 > 0) { var k00_206 = u[eOffset05] - u[eOffset24]; var k01_216 = u[eOffset05 + -1] - u[eOffset24 + -1]; var _g59 = eOffset05; var _g149 = u; _g149[_g59] = _g149[_g59] + u[eOffset24]; var _g60 = eOffset05 + -1; var _g150 = u; _g150[_g60] = _g150[_g60] + u[eOffset24 + -1]; u[eOffset24] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -1] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; aOffset6 += k1; k00_206 = u[eOffset05 + -2] - u[eOffset24 + -2]; k01_216 = u[eOffset05 + -3] - u[eOffset24 + -3]; var _g61 = eOffset05 + -2; var _g151 = u; _g151[_g61] = _g151[_g61] + u[eOffset24 + -2]; var _g62 = eOffset05 + -3; var _g152 = u; _g152[_g62] = _g152[_g62] + u[eOffset24 + -3]; u[eOffset24 + -2] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -3] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; aOffset6 += k1; k00_206 = u[eOffset05 + -4] - u[eOffset24 + -4]; k01_216 = u[eOffset05 + -5] - u[eOffset24 + -5]; var _g63 = eOffset05 + -4; var _g153 = u; _g153[_g63] = _g153[_g63] + u[eOffset24 + -4]; var _g64 = eOffset05 + -5; var _g154 = u; _g154[_g64] = _g154[_g64] + u[eOffset24 + -5]; u[eOffset24 + -4] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -5] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; aOffset6 += k1; k00_206 = u[eOffset05 + -6] - u[eOffset24 + -6]; k01_216 = u[eOffset05 + -7] - u[eOffset24 + -7]; var _g65 = eOffset05 + -6; var _g155 = u; _g155[_g65] = _g155[_g65] + u[eOffset24 + -6]; var _g66 = eOffset05 + -7; var _g156 = u; _g156[_g66] = _g156[_g66] + u[eOffset24 + -7]; u[eOffset24 + -6] = k00_206 * a[aOffset6] - k01_216 * a[aOffset6 + 1]; u[eOffset24 + -7] = k01_216 * a[aOffset6] + k00_206 * a[aOffset6 + 1]; eOffset05 -= 8; eOffset24 -= 8; aOffset6 += k1; } } } var _g157 = ld - 3 >> 1; var _g67 = ld - 6; while(_g157 < _g67) { var l1 = _g157++; var k01 = n >> l1 + 2; var k11 = 1 << l1 + 3; var k0_21 = k01 >> 1; var rlim = n >> l1 + 6; var lim1 = 1 << l1 + 1; var aOffset7 = 0; var i_off2 = n2 - 1; var r = rlim + 1; while(--r > 0) { var A0 = a[aOffset7]; var A1 = a[aOffset7 + 1]; var A2 = a[aOffset7 + k11]; var A3 = a[aOffset7 + k11 + 1]; var A4 = a[aOffset7 + k11 * 2]; var A5 = a[aOffset7 + k11 * 2 + 1]; var A6 = a[aOffset7 + k11 * 3]; var A7 = a[aOffset7 + k11 * 3 + 1]; var eeOffset02 = i_off2; var eeOffset22 = i_off2 + -k0_21; var i8 = lim1 + 1; while(--i8 > 0) { var k00 = u[eeOffset02] - u[eeOffset22]; var k111 = u[eeOffset02 + -1] - u[eeOffset22 + -1]; u[eeOffset02] = u[eeOffset02] + u[eeOffset22]; u[eeOffset02 + -1] = u[eeOffset02 + -1] + u[eeOffset22 + -1]; u[eeOffset22] = k00 * A0 - k111 * A1; u[eeOffset22 + -1] = k111 * A0 + k00 * A1; k00 = u[eeOffset02 + -2] - u[eeOffset22 + -2]; k111 = u[eeOffset02 + -3] - u[eeOffset22 + -3]; u[eeOffset02 + -2] = u[eeOffset02 + -2] + u[eeOffset22 + -2]; u[eeOffset02 + -3] = u[eeOffset02 + -3] + u[eeOffset22 + -3]; u[eeOffset22 + -2] = k00 * A2 - k111 * A3; u[eeOffset22 + -3] = k111 * A2 + k00 * A3; k00 = u[eeOffset02 + -4] - u[eeOffset22 + -4]; k111 = u[eeOffset02 + -5] - u[eeOffset22 + -5]; u[eeOffset02 + -4] = u[eeOffset02 + -4] + u[eeOffset22 + -4]; u[eeOffset02 + -5] = u[eeOffset02 + -5] + u[eeOffset22 + -5]; u[eeOffset22 + -4] = k00 * A4 - k111 * A5; u[eeOffset22 + -5] = k111 * A4 + k00 * A5; k00 = u[eeOffset02 + -6] - u[eeOffset22 + -6]; k111 = u[eeOffset02 + -7] - u[eeOffset22 + -7]; u[eeOffset02 + -6] = u[eeOffset02 + -6] + u[eeOffset22 + -6]; u[eeOffset02 + -7] = u[eeOffset02 + -7] + u[eeOffset22 + -7]; u[eeOffset22 + -6] = k00 * A6 - k111 * A7; u[eeOffset22 + -7] = k111 * A6 + k00 * A7; eeOffset02 -= k01; eeOffset22 -= k01; } aOffset7 += k11 * 4; i_off2 -= 8; } } var i_off3 = n2 - 1; var A21 = a[n >> 3]; var zOffset = i_off3; var baseOffset = i_off3 - 16 * (n >> 5); while(zOffset > baseOffset) { var t0 = u[zOffset]; var t1 = u[zOffset + -8]; u[zOffset + -8] = t0 - t1; u[zOffset] = t0 + t1; t0 = u[zOffset + -1]; t1 = u[zOffset + -9]; u[zOffset + -9] = t0 - t1; u[zOffset + -1] = t0 + t1; t0 = u[zOffset + -2]; t1 = u[zOffset + -10]; var k001 = t0 - t1; u[zOffset + -2] = t0 + t1; t0 = u[zOffset + -3]; t1 = u[zOffset + -11]; var k112 = t0 - t1; u[zOffset + -3] = t0 + t1; u[zOffset + -10] = (k001 + k112) * A21; u[zOffset + -11] = (k112 - k001) * A21; t0 = u[zOffset + -4]; t1 = u[zOffset + -12]; k001 = t1 - t0; u[zOffset + -4] = t0 + t1; t0 = u[zOffset + -5]; t1 = u[zOffset + -13]; k112 = t0 - t1; u[zOffset + -5] = t0 + t1; u[zOffset + -12] = k112; u[zOffset + -13] = k001; t0 = u[zOffset + -6]; t1 = u[zOffset + -14]; k001 = t1 - t0; u[zOffset + -6] = t0 + t1; t0 = u[zOffset + -7]; t1 = u[zOffset + -15]; k112 = t0 - t1; u[zOffset + -7] = t0 + t1; u[zOffset + -14] = (k001 + k112) * A21; u[zOffset + -15] = (k001 - k112) * A21; var t01 = u[zOffset]; var t11 = u[zOffset + -4]; var k002 = t01 - t11; var y0 = t01 + t11; t01 = u[zOffset + -2]; t11 = u[zOffset + -6]; var y2 = t01 + t11; var k22 = t01 - t11; u[zOffset] = y0 + y2; u[zOffset + -2] = y0 - y2; var k33 = u[zOffset + -3] - u[zOffset + -7]; u[zOffset + -4] = k002 + k33; u[zOffset + -6] = k002 - k33; t01 = u[zOffset + -1]; t11 = u[zOffset + -5]; var k113 = t01 - t11; var y1 = t01 + t11; var y3 = u[zOffset + -3] + u[zOffset + -7]; u[zOffset + -1] = y1 + y3; u[zOffset + -3] = y1 - y3; u[zOffset + -5] = k113 - k22; u[zOffset + -7] = k113 + k22; var zOffset1 = zOffset - 8; var t02 = u[zOffset1]; var t12 = u[zOffset1 + -4]; var k003 = t02 - t12; var y01 = t02 + t12; t02 = u[zOffset1 + -2]; t12 = u[zOffset1 + -6]; var y21 = t02 + t12; var k221 = t02 - t12; u[zOffset1] = y01 + y21; u[zOffset1 + -2] = y01 - y21; var k331 = u[zOffset1 + -3] - u[zOffset1 + -7]; u[zOffset1 + -4] = k003 + k331; u[zOffset1 + -6] = k003 - k331; t02 = u[zOffset1 + -1]; t12 = u[zOffset1 + -5]; var k114 = t02 - t12; var y11 = t02 + t12; var y31 = u[zOffset1 + -3] + u[zOffset1 + -7]; u[zOffset1 + -1] = y11 + y31; u[zOffset1 + -3] = y11 - y31; u[zOffset1 + -5] = k114 - k221; u[zOffset1 + -7] = k114 + k221; zOffset -= 16; } var brOffset = 0; var dOffset01 = n4 - 4; var dOffset11 = n2 - 4; while(dOffset01 >= 0) { var k4 = bitReverse[brOffset]; v[dOffset11 + 3] = u[k4]; v[dOffset11 + 2] = u[k4 + 1]; v[dOffset01 + 3] = u[k4 + 2]; v[dOffset01 + 2] = u[k4 + 3]; k4 = bitReverse[brOffset + 1]; v[dOffset11 + 1] = u[k4]; v[dOffset11] = u[k4 + 1]; v[dOffset01 + 1] = u[k4 + 2]; v[dOffset01] = u[k4 + 3]; dOffset01 -= 4; dOffset11 -= 4; brOffset += 2; } var cOffset = 0; var dOffset2 = 0; var eOffset3 = n2 - 4; while(dOffset2 < eOffset3) { var a02 = v[dOffset2] - v[eOffset3 + 2]; var a11 = v[dOffset2 + 1] + v[eOffset3 + 3]; var b0 = c[cOffset + 1] * a02 + c[cOffset] * a11; var b1 = c[cOffset + 1] * a11 - c[cOffset] * a02; var b2 = v[dOffset2] + v[eOffset3 + 2]; var b3 = v[dOffset2 + 1] - v[eOffset3 + 3]; v[dOffset2] = b2 + b0; v[dOffset2 + 1] = b3 + b1; v[eOffset3 + 2] = b2 - b0; v[eOffset3 + 3] = b1 - b3; a02 = v[dOffset2 + 2] - v[eOffset3]; a11 = v[dOffset2 + 3] + v[eOffset3 + 1]; b0 = c[cOffset + 3] * a02 + c[cOffset + 2] * a11; b1 = c[cOffset + 3] * a11 - c[cOffset + 2] * a02; b2 = v[dOffset2 + 2] + v[eOffset3]; b3 = v[dOffset2 + 3] - v[eOffset3 + 1]; v[dOffset2 + 2] = b2 + b0; v[dOffset2 + 3] = b3 + b1; v[eOffset3] = b2 - b0; v[eOffset3 + 1] = b1 - b3; cOffset += 4; dOffset2 += 4; eOffset3 -= 4; } var bOffset = n2 - 8; var eOffset4 = n2 - 8; var dOffset02 = 0; var dOffset12 = n2 - 4; var dOffset21 = n2; var dOffset3 = n - 4; while(eOffset4 >= 0) { var p3 = buf2[eOffset4 + 6] * b[bOffset + 7] - buf2[eOffset4 + 7] * b[bOffset + 6]; var p2 = -buf2[eOffset4 + 6] * b[bOffset + 6] - buf2[eOffset4 + 7] * b[bOffset + 7]; buffer[dOffset02] = p3; buffer[dOffset12 + 3] = -p3; buffer[dOffset21] = p2; buffer[dOffset3 + 3] = p2; var p1 = buf2[eOffset4 + 4] * b[bOffset + 5] - buf2[eOffset4 + 5] * b[bOffset + 4]; var p0 = -buf2[eOffset4 + 4] * b[bOffset + 4] - buf2[eOffset4 + 5] * b[bOffset + 5]; buffer[dOffset02 + 1] = p1; buffer[dOffset12 + 2] = -p1; buffer[dOffset21 + 1] = p0; buffer[dOffset3 + 2] = p0; p3 = buf2[eOffset4 + 2] * b[bOffset + 3] - buf2[eOffset4 + 3] * b[bOffset + 2]; p2 = -buf2[eOffset4 + 2] * b[bOffset + 2] - buf2[eOffset4 + 3] * b[bOffset + 3]; buffer[dOffset02 + 2] = p3; buffer[dOffset12 + 1] = -p3; buffer[dOffset21 + 2] = p2; buffer[dOffset3 + 1] = p2; p1 = buf2[eOffset4] * b[bOffset + 1] - buf2[eOffset4 + 1] * b[bOffset]; p0 = -buf2[eOffset4] * b[bOffset] - buf2[eOffset4 + 1] * b[bOffset + 1]; buffer[dOffset02 + 3] = p1; buffer[dOffset12] = -p1; buffer[dOffset21 + 3] = p0; buffer[dOffset3] = p0; bOffset -= 8; eOffset4 -= 8; dOffset02 += 4; dOffset21 += 4; dOffset12 -= 4; dOffset3 -= 4; } } ,decodePacket: function() { var result = this.decodeInitial(); if(result == null) { return null; } var rest = this.decodePacketRest(result); return rest; } ,decodeInitial: function() { this.channelBufferStart = this.channelBufferEnd = 0; while(true) { if(!this.decodeState.maybeStartPacket()) { return null; } var _this = this.decodeState; var tmp; if(_this.validBits < 0) { tmp = 0; } else if(_this.validBits < 1) { if(_this.validBits == 0) { _this.acc = 0; } while(true) { if(_this.bytesInSeg == 0 && (_this.lastSeg || _this.next() == 0)) { _this.validBits = -1; break; } else { _this.bytesInSeg--; _this.inputPosition += 1; _this.acc = _this.acc + (_this.input.readByte() << _this.validBits); _this.validBits += 8; } if(!(_this.validBits < 1)) { break; } } if(_this.validBits < 0) { tmp = 0; } else { var z = _this.acc & 1; _this.acc = _this.acc >>> 1; _this.validBits -= 1; tmp = z; } } else { var z1 = _this.acc & 1; _this.acc = _this.acc >>> 1; _this.validBits -= 1; tmp = z1; } if(tmp != 0) { while(true) { var _this1 = this.decodeState; var x; if(_this1.bytesInSeg == 0 && (_this1.lastSeg || _this1.next() == 0)) { x = -1; } else { _this1.bytesInSeg--; _this1.inputPosition += 1; x = _this1.input.readByte(); } _this1.validBits = 0; if(!(-1 != x)) { break; } } continue; } break; } var _this2 = this.decodeState; var n = this.header.modes.length - 1; var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var n1 = n < 16384 ? n < 16 ? log2_4[n] : n < 512 ? 5 + log2_4[n >> 5] : 10 + log2_4[n >> 10] : n < 16777216 ? n < 524288 ? 15 + log2_4[n >> 15] : 20 + log2_4[n >> 20] : n < 536870912 ? 25 + log2_4[n >> 25] : n < -2147483648 ? 30 + log2_4[n >> 30] : 0; var i; if(_this2.validBits < 0) { i = 0; } else if(_this2.validBits < n1) { if(n1 > 24) { i = _this2.readBits(24) + (_this2.readBits(n1 - 24) << 24); } else { if(_this2.validBits == 0) { _this2.acc = 0; } while(true) { if(_this2.bytesInSeg == 0 && (_this2.lastSeg || _this2.next() == 0)) { _this2.validBits = -1; break; } else { _this2.bytesInSeg--; _this2.inputPosition += 1; _this2.acc = _this2.acc + (_this2.input.readByte() << _this2.validBits); _this2.validBits += 8; } if(!(_this2.validBits < n1)) { break; } } if(_this2.validBits < 0) { i = 0; } else { var z2 = _this2.acc & (1 << n1) - 1; _this2.acc = _this2.acc >>> n1; _this2.validBits -= n1; i = z2; } } } else { var z3 = _this2.acc & (1 << n1) - 1; _this2.acc = _this2.acc >>> n1; _this2.validBits -= n1; i = z3; } if(i == -1 || i >= this.header.modes.length) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.hx", lineNumber : 519, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "decodeInitial"})); } var m = this.header.modes[i]; var n2; var prev; var next; if(m.blockflag) { n2 = this.header.blocksize1; var _this3 = this.decodeState; if(_this3.validBits < 0) { prev = 0; } else if(_this3.validBits < 1) { if(_this3.validBits == 0) { _this3.acc = 0; } while(true) { if(_this3.bytesInSeg == 0 && (_this3.lastSeg || _this3.next() == 0)) { _this3.validBits = -1; break; } else { _this3.bytesInSeg--; _this3.inputPosition += 1; _this3.acc = _this3.acc + (_this3.input.readByte() << _this3.validBits); _this3.validBits += 8; } if(!(_this3.validBits < 1)) { break; } } if(_this3.validBits < 0) { prev = 0; } else { var z4 = _this3.acc & 1; _this3.acc = _this3.acc >>> 1; _this3.validBits -= 1; prev = z4; } } else { var z5 = _this3.acc & 1; _this3.acc = _this3.acc >>> 1; _this3.validBits -= 1; prev = z5; } var _this4 = this.decodeState; if(_this4.validBits < 0) { next = 0; } else if(_this4.validBits < 1) { if(_this4.validBits == 0) { _this4.acc = 0; } while(true) { if(_this4.bytesInSeg == 0 && (_this4.lastSeg || _this4.next() == 0)) { _this4.validBits = -1; break; } else { _this4.bytesInSeg--; _this4.inputPosition += 1; _this4.acc = _this4.acc + (_this4.input.readByte() << _this4.validBits); _this4.validBits += 8; } if(!(_this4.validBits < 1)) { break; } } if(_this4.validBits < 0) { next = 0; } else { var z6 = _this4.acc & 1; _this4.acc = _this4.acc >>> 1; _this4.validBits -= 1; next = z6; } } else { var z7 = _this4.acc & 1; _this4.acc = _this4.acc >>> 1; _this4.validBits -= 1; next = z7; } } else { next = 0; prev = next; n2 = this.header.blocksize0; } var windowCenter = n2 >> 1; return { mode : i, left : m.blockflag && prev == 0 ? { start : n2 - this.header.blocksize0 >> 2, end : n2 + this.header.blocksize0 >> 2} : { start : 0, end : windowCenter}, right : m.blockflag && next == 0 ? { start : n2 * 3 - this.header.blocksize0 >> 2, end : n2 * 3 + this.header.blocksize0 >> 2} : { start : windowCenter, end : n2}}; } ,decodePacketRest: function(r) { var len = 0; var m = this.header.modes[r.mode]; var this1 = new Array(256); var zeroChannel = this1; var this2 = new Array(256); var reallyZeroChannel = this2; var n = m.blockflag ? this.header.blocksize1 : this.header.blocksize0; var map = this.header.mapping[m.mapping]; var n2 = n >> 1; var rangeList = [256,128,86,64]; var codebooks = this.header.codebooks; var _g1 = 0; var _g = this.header.channel; while(_g1 < _g) { var i = _g1++; var s = map.chan[i].mux; zeroChannel[i] = false; var floor = this.header.floorConfig[map.submapFloor[s]]; if(floor.type == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "VorbisDecoder.hx", lineNumber : 581, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "decodePacketRest"})); } else { var g = floor.floor1; var _this = this.decodeState; var tmp; if(_this.validBits < 0) { tmp = 0; } else if(_this.validBits < 1) { if(_this.validBits == 0) { _this.acc = 0; } while(true) { if(_this.bytesInSeg == 0 && (_this.lastSeg || _this.next() == 0)) { _this.validBits = -1; break; } else { _this.bytesInSeg--; _this.inputPosition += 1; _this.acc = _this.acc + (_this.input.readByte() << _this.validBits); _this.validBits += 8; } if(!(_this.validBits < 1)) { break; } } if(_this.validBits < 0) { tmp = 0; } else { var z = _this.acc & 1; _this.acc = _this.acc >>> 1; _this.validBits -= 1; tmp = z; } } else { var z1 = _this.acc & 1; _this.acc = _this.acc >>> 1; _this.validBits -= 1; tmp = z1; } if(tmp != 0) { var fy = []; var this3 = new Array(256); var step2Flag = this3; var range = rangeList[g.floor1Multiplier - 1]; var offset = 2; fy = this.finalY[i]; var _this1 = this.decodeState; var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var n1 = (range < 16384 ? range < 16 ? log2_4[range] : range < 512 ? 5 + log2_4[range >> 5] : 10 + log2_4[range >> 10] : range < 16777216 ? range < 524288 ? 15 + log2_4[range >> 15] : 20 + log2_4[range >> 20] : range < 536870912 ? 25 + log2_4[range >> 25] : range < -2147483648 ? 30 + log2_4[range >> 30] : 0) - 1; var tmp1; if(_this1.validBits < 0) { tmp1 = 0; } else if(_this1.validBits < n1) { if(n1 > 24) { tmp1 = _this1.readBits(24) + (_this1.readBits(n1 - 24) << 24); } else { if(_this1.validBits == 0) { _this1.acc = 0; } while(true) { if(_this1.bytesInSeg == 0 && (_this1.lastSeg || _this1.next() == 0)) { _this1.validBits = -1; break; } else { _this1.bytesInSeg--; _this1.inputPosition += 1; _this1.acc = _this1.acc + (_this1.input.readByte() << _this1.validBits); _this1.validBits += 8; } if(!(_this1.validBits < n1)) { break; } } if(_this1.validBits < 0) { tmp1 = 0; } else { var z2 = _this1.acc & (1 << n1) - 1; _this1.acc = _this1.acc >>> n1; _this1.validBits -= n1; tmp1 = z2; } } } else { var z3 = _this1.acc & (1 << n1) - 1; _this1.acc = _this1.acc >>> n1; _this1.validBits -= n1; tmp1 = z3; } fy[0] = tmp1; var _this2 = this.decodeState; var log2_41 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var n3 = (range < 16384 ? range < 16 ? log2_41[range] : range < 512 ? 5 + log2_41[range >> 5] : 10 + log2_41[range >> 10] : range < 16777216 ? range < 524288 ? 15 + log2_41[range >> 15] : 20 + log2_41[range >> 20] : range < 536870912 ? 25 + log2_41[range >> 25] : range < -2147483648 ? 30 + log2_41[range >> 30] : 0) - 1; var tmp2; if(_this2.validBits < 0) { tmp2 = 0; } else if(_this2.validBits < n3) { if(n3 > 24) { tmp2 = _this2.readBits(24) + (_this2.readBits(n3 - 24) << 24); } else { if(_this2.validBits == 0) { _this2.acc = 0; } while(true) { if(_this2.bytesInSeg == 0 && (_this2.lastSeg || _this2.next() == 0)) { _this2.validBits = -1; break; } else { _this2.bytesInSeg--; _this2.inputPosition += 1; _this2.acc = _this2.acc + (_this2.input.readByte() << _this2.validBits); _this2.validBits += 8; } if(!(_this2.validBits < n3)) { break; } } if(_this2.validBits < 0) { tmp2 = 0; } else { var z4 = _this2.acc & (1 << n3) - 1; _this2.acc = _this2.acc >>> n3; _this2.validBits -= n3; tmp2 = z4; } } } else { var z5 = _this2.acc & (1 << n3) - 1; _this2.acc = _this2.acc >>> n3; _this2.validBits -= n3; tmp2 = z5; } fy[1] = tmp2; var _g3 = 0; var _g2 = g.partitions; while(_g3 < _g2) { var j = _g3++; var pclass = g.partitionClassList[j]; var cdim = g.classDimensions[pclass]; var cbits = g.classSubclasses[pclass]; var csub = (1 << cbits) - 1; var cval = 0; if(cbits != 0) { var c = codebooks[g.classMasterbooks[pclass]]; var _this3 = this.decodeState; if(_this3.validBits < 10) { _this3.prepHuffman(); } var i1 = c.fastHuffman[_this3.acc & 1023]; var val; if(i1 >= 0) { var l = c.codewordLengths[i1]; _this3.acc = _this3.acc >>> l; _this3.validBits -= l; if(_this3.validBits < 0) { _this3.validBits = 0; val = -1; } else { val = i1; } } else { val = _this3.decodeScalarRaw(c); } if(c.sparse) { val = c.sortedValues[val]; } cval = val; } var books = g.subclassBooks[pclass]; var _g5 = 0; var _g4 = cdim; while(_g5 < _g4) { var k = _g5++; var book = books[cval & csub]; cval >>= cbits; var tmp3 = offset++; var tmp4; if(book >= 0) { var _this4 = this.decodeState; var c1 = codebooks[book]; if(_this4.validBits < 10) { _this4.prepHuffman(); } var i2 = c1.fastHuffman[_this4.acc & 1023]; var val1; if(i2 >= 0) { var l1 = c1.codewordLengths[i2]; _this4.acc = _this4.acc >>> l1; _this4.validBits -= l1; if(_this4.validBits < 0) { _this4.validBits = 0; val1 = -1; } else { val1 = i2; } } else { val1 = _this4.decodeScalarRaw(c1); } if(c1.sparse) { val1 = c1.sortedValues[val1]; } tmp4 = val1; } else { tmp4 = 0; } fy[tmp3] = tmp4; } } if(this.decodeState.validBits == -1) { zeroChannel[i] = true; continue; } step2Flag[0] = step2Flag[1] = true; var naighbors = g.neighbors; var xlist = g.xlist; var _g31 = 2; var _g21 = g.values; while(_g31 < _g21) { var j1 = _g31++; var low = naighbors[j1][0]; var high = naighbors[j1][1]; var x0 = xlist[low]; var y0 = fy[low]; var dy = fy[high] - y0; var adx = xlist[high] - x0; var err = Math.abs(dy) * (xlist[j1] - x0); var off = err / adx | 0; var lowroom = dy < 0 ? y0 - off : y0 + off; var val2 = fy[j1]; var highroom = range - lowroom; var room = highroom < lowroom ? highroom * 2 : lowroom * 2; if(val2 != 0) { step2Flag[low] = step2Flag[high] = true; step2Flag[j1] = true; if(val2 >= room) { if(highroom > lowroom) { fy[j1] = val2 - lowroom + lowroom; } else { fy[j1] = lowroom - val2 + highroom - 1; } } else if((val2 & 1) != 0) { fy[j1] = lowroom - (val2 + 1 >> 1); } else { fy[j1] = lowroom + (val2 >> 1); } } else { step2Flag[j1] = false; fy[j1] = lowroom; } } var _g32 = 0; var _g22 = g.values; while(_g32 < _g22) { var j2 = _g32++; if(!step2Flag[j2]) { fy[j2] = -1; } } } else { zeroChannel[i] = true; } } } var _g11 = 0; var _g6 = this.header.channel; while(_g11 < _g6) { var i3 = _g11++; reallyZeroChannel[i3] = zeroChannel[i3]; } var _g12 = 0; var _g7 = map.couplingSteps; while(_g12 < _g7) { var i4 = _g12++; if(!zeroChannel[map.chan[i4].magnitude] || !zeroChannel[map.chan[i4].angle]) { zeroChannel[map.chan[i4].magnitude] = zeroChannel[map.chan[i4].angle] = false; } } var _g13 = 0; var _g8 = map.submaps; while(_g13 < _g8) { var i5 = _g13++; var length = this.header.channel; var this4 = new Array(length); var residueBuffers = this4; var this5 = new Array(256); var doNotDecode = this5; var ch = 0; var _g33 = 0; var _g23 = this.header.channel; while(_g33 < _g23) { var j3 = _g33++; if(map.chan[j3].mux == i5) { if(zeroChannel[j3]) { doNotDecode[ch] = true; residueBuffers[ch] = null; } else { doNotDecode[ch] = false; residueBuffers[ch] = this.channelBuffers[j3]; } ++ch; } } var r1 = map.submapResidue[i5]; var residue = this.header.residueConfig[r1]; residue.decode(this.decodeState,this.header,residueBuffers,ch,n2,doNotDecode,this.channelBuffers); } var i6 = map.couplingSteps; var n21 = n >> 1; while(--i6 >= 0) { var m1 = this.channelBuffers[map.chan[i6].magnitude]; var a = this.channelBuffers[map.chan[i6].angle]; var _g14 = 0; var _g9 = n21; while(_g14 < _g9) { var j4 = _g14++; var a2; var m2; if(m1[j4] > 0) { if(a[j4] > 0) { m2 = m1[j4]; a2 = m1[j4] - a[j4]; } else { a2 = m1[j4]; m2 = m1[j4] + a[j4]; } } else if(a[j4] > 0) { m2 = m1[j4]; a2 = m1[j4] + a[j4]; } else { a2 = m1[j4]; m2 = m1[j4] - a[j4]; } m1[j4] = m2; a[j4] = a2; } } var _g15 = 0; var _g10 = this.header.channel; while(_g15 < _g10) { var i7 = _g15++; if(reallyZeroChannel[i7]) { var _g34 = 0; var _g24 = n21; while(_g34 < _g24) { var j5 = _g34++; this.channelBuffers[i7][j5] = 0; } } else { map.doFloor(this.header.floorConfig,i7,n,this.channelBuffers[i7],this.finalY[i7],null); } } var _g16 = 0; var _g17 = this.header.channel; while(_g16 < _g17) { var i8 = _g16++; this.inverseMdct(this.channelBuffers[i8],n,m.blockflag); } var _this5 = this.decodeState; while(_this5.bytesInSeg != 0 || !_this5.lastSeg && _this5.next() != 0) { _this5.bytesInSeg--; _this5.inputPosition += 1; _this5.input.readByte(); } return this.decodeState.finishDecodePacket(this.previousLength,n,r); } ,__class__: kha_audio2_ogg_vorbis_VorbisDecoder }; var kha_audio2_ogg_vorbis_VorbisTools = function() { }; $hxClasses["kha.audio2.ogg.vorbis.VorbisTools"] = kha_audio2_ogg_vorbis_VorbisTools; kha_audio2_ogg_vorbis_VorbisTools.__name__ = true; kha_audio2_ogg_vorbis_VorbisTools.assert = function(b,p) { }; kha_audio2_ogg_vorbis_VorbisTools.neighbors = function(x,n) { var low = -1; var high = 65536; var plow = 0; var phigh = 0; var _g1 = 0; var _g = n; while(_g1 < _g) { var i = _g1++; if(x[i] > low && x[i] < x[n]) { plow = i; low = x[i]; } if(x[i] < high && x[i] > x[n]) { phigh = i; high = x[i]; } } return { low : plow, high : phigh}; }; kha_audio2_ogg_vorbis_VorbisTools.floatUnpack = function(x) { var mantissa = _$UInt_UInt_$Impl_$.toFloat(x & 2097151); var sign = x & -2147483648; var exp = (x & 2145386496) >>> 21; var res = sign != 0 ? -mantissa : mantissa; return res * Math.pow(2,exp - 788); }; kha_audio2_ogg_vorbis_VorbisTools.bitReverse = function(n) { n = (n & -1431655766) >>> 1 | (n & 1431655765) << 1; n = (n & -858993460) >>> 2 | (n & 858993459) << 2; n = (n & -252645136) >>> 4 | (n & 252645135) << 4; n = (n & -16711936) >>> 8 | (n & 16711935) << 8; return n >>> 16 | n << 16; }; kha_audio2_ogg_vorbis_VorbisTools.pointCompare = function(a,b) { if(a.x < b.x) { return -1; } else if(a.x > b.x) { return 1; } else { return 0; } }; kha_audio2_ogg_vorbis_VorbisTools.uintAsc = function(a,b) { if(_$UInt_UInt_$Impl_$.gt(b,a)) { return -1; } else if(a == b) { return 0; } else { return 1; } }; kha_audio2_ogg_vorbis_VorbisTools.lookup1Values = function(entries,dim) { var r = Math.exp(Math.log(entries) / dim) | 0; if((Math.pow(r + 1,dim) | 0) <= entries) { ++r; } var b = Math.pow(r + 1,dim) > entries; var b1 = (Math.pow(r,dim) | 0) <= entries; return r; }; kha_audio2_ogg_vorbis_VorbisTools.computeWindow = function(n,window) { var n2 = n >> 1; var _g1 = 0; var _g = n2; while(_g1 < _g) { var i = _g1++; window[i] = Math.sin(1.57079632679489656 * kha_audio2_ogg_vorbis_VorbisTools.square(Math.sin((i + 0.5) / n2 * 0.5 * 3.14159265358979323846264))); } }; kha_audio2_ogg_vorbis_VorbisTools.square = function(f) { return f * f; }; kha_audio2_ogg_vorbis_VorbisTools.computeBitReverse = function(n,rev) { var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var ld = (n < 16384 ? n < 16 ? log2_4[n] : n < 512 ? 5 + log2_4[n >> 5] : 10 + log2_4[n >> 10] : n < 16777216 ? n < 524288 ? 15 + log2_4[n >> 15] : 20 + log2_4[n >> 20] : n < 536870912 ? 25 + log2_4[n >> 25] : n < -2147483648 ? 30 + log2_4[n >> 30] : 0) - 1; var n8 = n >> 3; var _g1 = 0; var _g = n8; while(_g1 < _g) { var i = _g1++; var n1 = i; n1 = (n1 & -1431655766) >>> 1 | (n1 & 1431655765) << 1; n1 = (n1 & -858993460) >>> 2 | (n1 & 858993459) << 2; n1 = (n1 & -252645136) >>> 4 | (n1 & 252645135) << 4; n1 = (n1 & -16711936) >>> 8 | (n1 & 16711935) << 8; rev[i] = (n1 >>> 16 | n1 << 16) >>> 32 - ld + 3 << 2; } }; kha_audio2_ogg_vorbis_VorbisTools.computeTwiddleFactors = function(n,af,bf,cf) { var n4 = n >> 2; var n8 = n >> 3; var k2 = 0; var _g1 = 0; var _g = n4; while(_g1 < _g) { var k = _g1++; af[k2] = Math.cos(4 * k * 3.14159265358979323846264 / n); af[k2 + 1] = -Math.sin(4 * k * 3.14159265358979323846264 / n); bf[k2] = Math.cos((k2 + 1) * 3.14159265358979323846264 / n / 2) * 0.5; bf[k2 + 1] = Math.sin((k2 + 1) * 3.14159265358979323846264 / n / 2) * 0.5; k2 += 2; } var k21 = 0; var _g11 = 0; var _g2 = n8; while(_g11 < _g2) { var k1 = _g11++; cf[k21] = Math.cos(2 * (k21 + 1) * 3.14159265358979323846264 / n); cf[k21 + 1] = -Math.sin(2 * (k21 + 1) * 3.14159265358979323846264 / n); k21 += 2; } }; kha_audio2_ogg_vorbis_VorbisTools.drawLine = function(output,x0,y0,x1,y1,n) { if(kha_audio2_ogg_vorbis_VorbisTools.integerDivideTable == null) { var this1 = new Array(32); kha_audio2_ogg_vorbis_VorbisTools.integerDivideTable = this1; var _g = 0; while(_g < 32) { var i = _g++; var this2 = kha_audio2_ogg_vorbis_VorbisTools.integerDivideTable; var this3 = new Array(64); this2[i] = this3; var _g1 = 1; while(_g1 < 64) { var j = _g1++; kha_audio2_ogg_vorbis_VorbisTools.integerDivideTable[i][j] = i / j | 0; } } } var dy = y1 - y0; var adx = x1 - x0; var ady = dy < 0 ? -dy : dy; var base; var x = x0; var y = y0; var err = 0; var sy; if(adx < 64 && ady < 32) { if(dy < 0) { base = -kha_audio2_ogg_vorbis_VorbisTools.integerDivideTable[ady][adx]; sy = base - 1; } else { base = kha_audio2_ogg_vorbis_VorbisTools.integerDivideTable[ady][adx]; sy = base + 1; } } else { base = dy / adx | 0; if(dy < 0) { sy = base - 1; } else { sy = base + 1; } } ady -= (base < 0 ? -base : base) * adx; if(x1 > n) { x1 = n; } var _g2 = x; var _g11 = output; _g11[_g2] = _g11[_g2] * kha_audio2_ogg_vorbis_VorbisTools.INVERSE_DB_TABLE[y]; var _g12 = x + 1; var _g3 = x1; while(_g12 < _g3) { var i1 = _g12++; err += ady; if(err >= adx) { err -= adx; y += sy; } else { y += base; } var _g21 = i1; var _g31 = output; _g31[_g21] = _g31[_g21] * kha_audio2_ogg_vorbis_VorbisTools.INVERSE_DB_TABLE[y]; } }; kha_audio2_ogg_vorbis_VorbisTools.predictPoint = function(x,x0,x1,y0,y1) { var dy = y1 - y0; var adx = x1 - x0; var err = Math.abs(dy) * (x - x0); var off = err / adx | 0; if(dy < 0) { return y0 - off; } else { return y0 + off; } }; kha_audio2_ogg_vorbis_VorbisTools.emptyFloatVector = function(len) { var this1 = new Array(len); var vec = this1; return vec; }; kha_audio2_ogg_vorbis_VorbisTools.copyVector = function(source) { var length = source.length; var this1 = new Array(length); var dest = this1; var _g1 = 0; var _g = source.length; while(_g1 < _g) { var i = _g1++; dest[i] = source[i]; } return dest; }; var kha_audio2_ogg_vorbis_data_Codebook = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Codebook"] = kha_audio2_ogg_vorbis_data_Codebook; kha_audio2_ogg_vorbis_data_Codebook.__name__ = true; kha_audio2_ogg_vorbis_data_Codebook.read = function(decodeState) { var c = new kha_audio2_ogg_vorbis_data_Codebook(); var tmp; var tmp1; var tmp2; if(decodeState.validBits < 0) { tmp2 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp2 = 0; } else { var z = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp2 = z; } } else { var z1 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp2 = z1; } if(tmp2 == 66) { var tmp3; if(decodeState.validBits < 0) { tmp3 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp3 = 0; } else { var z2 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp3 = z2; } } else { var z3 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp3 = z3; } tmp1 = tmp3 != 67; } else { tmp1 = true; } if(!tmp1) { var tmp4; if(decodeState.validBits < 0) { tmp4 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp4 = 0; } else { var z4 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp4 = z4; } } else { var z5 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp4 = z5; } tmp = tmp4 != 86; } else { tmp = true; } if(tmp) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Codebook.hx", lineNumber : 40, className : "kha.audio2.ogg.vorbis.data.Codebook", methodName : "read"})); } var x; if(decodeState.validBits < 0) { x = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { x = 0; } else { var z6 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; x = z6; } } else { var z7 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; x = z7; } var tmp5; if(decodeState.validBits < 0) { tmp5 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp5 = 0; } else { var z8 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp5 = z8; } } else { var z9 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp5 = z9; } c.dimensions = (tmp5 << 8) + x; var x1; if(decodeState.validBits < 0) { x1 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { x1 = 0; } else { var z10 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; x1 = z10; } } else { var z11 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; x1 = z11; } var y; if(decodeState.validBits < 0) { y = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { y = 0; } else { var z12 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; y = z12; } } else { var z13 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; y = z13; } var tmp6; if(decodeState.validBits < 0) { tmp6 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp6 = 0; } else { var z14 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp6 = z14; } } else { var z15 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp6 = z15; } c.entries = (tmp6 << 16) + (y << 8) + x1; var ordered; if(decodeState.validBits < 0) { ordered = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { ordered = 0; } else { var z16 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; ordered = z16; } } else { var z17 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; ordered = z17; } var tmp7; if(ordered != 0) { tmp7 = false; } else { var tmp8; if(decodeState.validBits < 0) { tmp8 = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { tmp8 = 0; } else { var z18 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp8 = z18; } } else { var z19 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp8 = z19; } tmp7 = tmp8 != 0; } c.sparse = tmp7; var length = c.entries; var this1 = new Array(length); var lengths = this1; if(!c.sparse) { c.codewordLengths = lengths; } var total = 0; if(ordered != 0) { var currentEntry = 0; var currentLength; if(decodeState.validBits < 0) { currentLength = 0; } else if(decodeState.validBits < 5) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 5)) { break; } } if(decodeState.validBits < 0) { currentLength = 0; } else { var z20 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; currentLength = z20; } } else { var z21 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; currentLength = z21; } var currentLength1 = currentLength + 1; while(currentEntry < c.entries) { var limit = c.entries - currentEntry; var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var n = limit < 16384 ? limit < 16 ? log2_4[limit] : limit < 512 ? 5 + log2_4[limit >> 5] : 10 + log2_4[limit >> 10] : limit < 16777216 ? limit < 524288 ? 15 + log2_4[limit >> 15] : 20 + log2_4[limit >> 20] : limit < 536870912 ? 25 + log2_4[limit >> 25] : limit < -2147483648 ? 30 + log2_4[limit >> 30] : 0; var n1; if(decodeState.validBits < 0) { n1 = 0; } else if(decodeState.validBits < n) { if(n > 24) { n1 = decodeState.readBits(24) + (decodeState.readBits(n - 24) << 24); } else { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < n)) { break; } } if(decodeState.validBits < 0) { n1 = 0; } else { var z22 = decodeState.acc & (1 << n) - 1; decodeState.acc = decodeState.acc >>> n; decodeState.validBits -= n; n1 = z22; } } } else { var z23 = decodeState.acc & (1 << n) - 1; decodeState.acc = decodeState.acc >>> n; decodeState.validBits -= n; n1 = z23; } if(currentEntry + n1 > c.entries) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"codebook entrys",{ fileName : "Codebook.hx", lineNumber : 67, className : "kha.audio2.ogg.vorbis.data.Codebook", methodName : "read"})); } var _g1 = 0; var _g = n1; while(_g1 < _g) { var i = _g1++; lengths[currentEntry + i] = currentLength1; } currentEntry += n1; ++currentLength1; } } else { var _g11 = 0; var _g2 = c.entries; while(_g11 < _g2) { var j = _g11++; var present; if(c.sparse) { if(decodeState.validBits < 0) { present = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { present = 0; } else { var z24 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; present = z24; } } else { var z25 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; present = z25; } } else { present = 1; } if(present != 0) { var val; if(decodeState.validBits < 0) { val = 0; } else if(decodeState.validBits < 5) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 5)) { break; } } if(decodeState.validBits < 0) { val = 0; } else { var z26 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; val = z26; } } else { var z27 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; val = z27; } lengths[j] = val + 1; ++total; } else { lengths[j] = 255; } } } if(c.sparse && total >= c.entries >> 2) { c.codewordLengths = lengths; c.sparse = false; } var tmp9; if(c.sparse) { tmp9 = total; } else { var sortedCount = 0; var _g12 = 0; var _g3 = c.entries; while(_g12 < _g3) { var j1 = _g12++; var l = lengths[j1]; if(l > 10 && l != 255) { ++sortedCount; } } tmp9 = sortedCount; } c.sortedEntries = tmp9; var values = null; if(!c.sparse) { var length1 = c.entries; var this2 = new Array(length1); c.codewords = this2; } else { if(c.sortedEntries != 0) { var length2 = c.sortedEntries; var this3 = new Array(length2); c.codewordLengths = this3; var length3 = c.entries; var this4 = new Array(length3); c.codewords = this4; var length4 = c.entries; var this5 = new Array(length4); values = this5; } var size = c.entries + 64 * c.sortedEntries; } if(!c.computeCodewords(lengths,c.entries,values)) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"compute codewords",{ fileName : "Codebook.hx", lineNumber : 120, className : "kha.audio2.ogg.vorbis.data.Codebook", methodName : "read"})); } if(c.sortedEntries != 0) { c.sortedCodewords = []; var length5 = c.sortedEntries; var this6 = new Array(length5); c.sortedValues = this6; c.computeSortedHuffman(lengths,values); } if(c.sparse) { values = null; c.codewords = null; lengths = null; } c.computeAcceleratedHuffman(); var tmp10; if(decodeState.validBits < 0) { tmp10 = 0; } else if(decodeState.validBits < 4) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 4)) { break; } } if(decodeState.validBits < 0) { tmp10 = 0; } else { var z28 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp10 = z28; } } else { var z29 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp10 = z29; } c.lookupType = tmp10; if(c.lookupType > 2) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"codebook lookup type",{ fileName : "Codebook.hx", lineNumber : 143, className : "kha.audio2.ogg.vorbis.data.Codebook", methodName : "read"})); } if(c.lookupType > 0) { var x2; if(decodeState.validBits < 0) { x2 = 0; } else if(decodeState.validBits < 32) { x2 = decodeState.readBits(24) + (decodeState.readBits(8) << 24); } else { var z30 = decodeState.acc & -1; decodeState.acc = decodeState.acc >>> 32; decodeState.validBits -= 32; x2 = z30; } var mantissa = _$UInt_UInt_$Impl_$.toFloat(x2 & 2097151); var sign = x2 & -2147483648; var exp = (x2 & 2145386496) >>> 21; var res = sign != 0 ? -mantissa : mantissa; c.minimumValue = res * Math.pow(2,exp - 788); var x3; if(decodeState.validBits < 0) { x3 = 0; } else if(decodeState.validBits < 32) { x3 = decodeState.readBits(24) + (decodeState.readBits(8) << 24); } else { var z31 = decodeState.acc & -1; decodeState.acc = decodeState.acc >>> 32; decodeState.validBits -= 32; x3 = z31; } var mantissa1 = _$UInt_UInt_$Impl_$.toFloat(x3 & 2097151); var sign1 = x3 & -2147483648; var exp1 = (x3 & 2145386496) >>> 21; var res1 = sign1 != 0 ? -mantissa1 : mantissa1; c.deltaValue = res1 * Math.pow(2,exp1 - 788); var tmp11; if(decodeState.validBits < 0) { tmp11 = 0; } else if(decodeState.validBits < 4) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 4)) { break; } } if(decodeState.validBits < 0) { tmp11 = 0; } else { var z32 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp11 = z32; } } else { var z33 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp11 = z33; } c.valueBits = tmp11 + 1; var tmp12; if(decodeState.validBits < 0) { tmp12 = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { tmp12 = 0; } else { var z34 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp12 = z34; } } else { var z35 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp12 = z35; } c.sequenceP = tmp12 != 0; if(c.lookupType == 1) { c.lookupValues = kha_audio2_ogg_vorbis_VorbisTools.lookup1Values(c.entries,c.dimensions); } else { c.lookupValues = c.entries * c.dimensions; } var length6 = c.lookupValues; var this7 = new Array(length6); var mults = this7; var _g13 = 0; var _g4 = c.lookupValues; while(_g13 < _g4) { var j2 = _g13++; var n2 = c.valueBits; var q; if(decodeState.validBits < 0) { q = 0; } else if(decodeState.validBits < n2) { if(n2 > 24) { q = decodeState.readBits(24) + (decodeState.readBits(n2 - 24) << 24); } else { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < n2)) { break; } } if(decodeState.validBits < 0) { q = 0; } else { var z36 = decodeState.acc & (1 << n2) - 1; decodeState.acc = decodeState.acc >>> n2; decodeState.validBits -= n2; q = z36; } } } else { var z37 = decodeState.acc & (1 << n2) - 1; decodeState.acc = decodeState.acc >>> n2; decodeState.validBits -= n2; q = z37; } if(q == -1) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"fail lookup",{ fileName : "Codebook.hx", lineNumber : 161, className : "kha.audio2.ogg.vorbis.data.Codebook", methodName : "read"})); } mults[j2] = q; } var length7 = c.lookupValues; var this8 = new Array(length7); c.multiplicands = this8; var _g14 = 0; var _g5 = c.lookupValues; while(_g14 < _g5) { var j3 = _g14++; c.multiplicands[j3] = mults[j3] * c.deltaValue + c.minimumValue; } if(c.lookupType == 2 && c.sequenceP) { var _g15 = 1; var _g6 = c.lookupValues; while(_g15 < _g6) { var j4 = _g15++; c.multiplicands[j4] = c.multiplicands[j4 - 1]; } c.sequenceP = false; } } return c; }; kha_audio2_ogg_vorbis_data_Codebook.prototype = { dimensions: null ,entries: null ,codewordLengths: null ,minimumValue: null ,deltaValue: null ,valueBits: null ,lookupType: null ,sequenceP: null ,sparse: null ,lookupValues: null ,multiplicands: null ,codewords: null ,fastHuffman: null ,sortedCodewords: null ,sortedValues: null ,sortedEntries: null ,addEntry: function(huffCode,symbol,count,len,values) { if(!this.sparse) { this.codewords[symbol] = huffCode; } else { this.codewords[count] = huffCode; this.codewordLengths[count] = len; values[count] = symbol; } } ,includeInSort: function(len) { if(this.sparse) { return true; } else if(len == 255) { return false; } else if(len > 10) { return true; } else { return false; } } ,computeCodewords: function(len,n,values) { var this1 = new Array(32); var available = this1; var _g = 0; while(_g < 32) { var x = _g++; available[x] = 0; } var k = 0; while(k < n) { if(len[k] < 255) { break; } ++k; } if(k == n) { var b = this.sortedEntries == 0; return true; } var m = 0; var count = m++; if(!this.sparse) { this.codewords[k] = 0; } else { this.codewords[count] = 0; this.codewordLengths[count] = len[k]; values[count] = k; } var i = 0; while(++i <= len[k]) available[i] = 1 << 32 - i; i = k; while(++i < n) { var z = len[i]; if(z == 255) { continue; } while(z > 0 && available[z] == 0) --z; if(z == 0) { return false; } var res = available[z]; available[z] = 0; var n1 = res; n1 = (n1 & -1431655766) >>> 1 | (n1 & 1431655765) << 1; n1 = (n1 & -858993460) >>> 2 | (n1 & 858993459) << 2; n1 = (n1 & -252645136) >>> 4 | (n1 & 252645135) << 4; n1 = (n1 & -16711936) >>> 8 | (n1 & 16711935) << 8; var huffCode = n1 >>> 16 | n1 << 16; var count1 = m++; if(!this.sparse) { this.codewords[i] = huffCode; } else { this.codewords[count1] = huffCode; this.codewordLengths[count1] = len[i]; values[count1] = i; } if(z != len[i]) { var y = len[i]; while(y > z) { available[y] = res + (1 << 32 - y); --y; } } } return true; } ,computeSortedHuffman: function(lengths,values) { if(!this.sparse) { var k = 0; var _g1 = 0; var _g = this.entries; while(_g1 < _g) { var i = _g1++; var len = lengths[i]; if(this.sparse ? true : len == 255 ? false : len > 10) { var n = this.codewords[i]; n = (n & -1431655766) >>> 1 | (n & 1431655765) << 1; n = (n & -858993460) >>> 2 | (n & 858993459) << 2; n = (n & -252645136) >>> 4 | (n & 252645135) << 4; n = (n & -16711936) >>> 8 | (n & 16711935) << 8; this.sortedCodewords[k++] = n >>> 16 | n << 16; } } var b = k == this.sortedEntries; } else { var _g11 = 0; var _g2 = this.sortedEntries; while(_g11 < _g2) { var i1 = _g11++; var n1 = this.codewords[i1]; n1 = (n1 & -1431655766) >>> 1 | (n1 & 1431655765) << 1; n1 = (n1 & -858993460) >>> 2 | (n1 & 858993459) << 2; n1 = (n1 & -252645136) >>> 4 | (n1 & 252645135) << 4; n1 = (n1 & -16711936) >>> 8 | (n1 & 16711935) << 8; this.sortedCodewords[i1] = n1 >>> 16 | n1 << 16; } } this.sortedCodewords[this.sortedEntries] = -1; this.sortedCodewords.sort(kha_audio2_ogg_vorbis_VorbisTools.uintAsc); var len1 = this.sparse ? this.sortedEntries : this.entries; var _g12 = 0; var _g3 = len1; while(_g12 < _g3) { var i2 = _g12++; var huffLen = this.sparse ? lengths[values[i2]] : lengths[i2]; if(this.sparse ? true : huffLen == 255 ? false : huffLen > 10) { var n2 = this.codewords[i2]; n2 = (n2 & -1431655766) >>> 1 | (n2 & 1431655765) << 1; n2 = (n2 & -858993460) >>> 2 | (n2 & 858993459) << 2; n2 = (n2 & -252645136) >>> 4 | (n2 & 252645135) << 4; n2 = (n2 & -16711936) >>> 8 | (n2 & 16711935) << 8; var code = n2 >>> 16 | n2 << 16; var x = 0; var n3 = this.sortedEntries; while(n3 > 1) { var m = x + (n3 >> 1); if(_$UInt_UInt_$Impl_$.gte(code,this.sortedCodewords[m])) { x = m; n3 -= n3 >> 1; } else { n3 >>= 1; } } if(this.sparse) { this.sortedValues[x] = values[i2]; this.codewordLengths[x] = huffLen; } else { this.sortedValues[x] = i2; } } } } ,computeAcceleratedHuffman: function() { var this1 = new Array(1024); this.fastHuffman = this1; this.fastHuffman[0] = -1; var _g1 = 0; var _g = 1024; while(_g1 < _g) { var i = _g1++; this.fastHuffman[i] = -1; } var len = this.sparse ? this.sortedEntries : this.entries; var _g11 = 0; var _g2 = len; while(_g11 < _g2) { var i1 = _g11++; if(this.codewordLengths[i1] <= 10) { var z; if(this.sparse) { var n = this.sortedCodewords[i1]; n = (n & -1431655766) >>> 1 | (n & 1431655765) << 1; n = (n & -858993460) >>> 2 | (n & 858993459) << 2; n = (n & -252645136) >>> 4 | (n & 252645135) << 4; n = (n & -16711936) >>> 8 | (n & 16711935) << 8; z = n >>> 16 | n << 16; } else { z = this.codewords[i1]; } while(z < 1024) { this.fastHuffman[z] = i1; z += 1 << this.codewordLengths[i1]; } } } } ,codebookDecode: function(decodeState,output,offset,len) { if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i = this.fastHuffman[decodeState.acc & 1023]; var val; if(i >= 0) { var l = this.codewordLengths[i]; decodeState.acc = decodeState.acc >>> l; decodeState.validBits -= l; if(decodeState.validBits < 0) { decodeState.validBits = 0; val = -1; } else { val = i; } } else { val = decodeState.decodeScalarRaw(this); } if(this.sparse) { val = this.sortedValues[val]; } var z = val; var lookupValues = this.lookupValues; var sequenceP = this.sequenceP; var multiplicands = this.multiplicands; var minimumValue = this.minimumValue; if(z < 0) { return false; } if(len > this.dimensions) { len = this.dimensions; } if(this.lookupType == 1) { var div = 1; var last = 0.0; var _g1 = 0; var _g = len; while(_g1 < _g) { var i1 = _g1++; var off = _$UInt_UInt_$Impl_$.toFloat(z / div | 0) % _$UInt_UInt_$Impl_$.toFloat(lookupValues) | 0; var val1 = multiplicands[off] + last; var _g2 = offset + i1; var _g3 = output; _g3[_g2] = _g3[_g2] + val1; if(sequenceP) { last = val1 + minimumValue; } div = div * lookupValues; } return true; } z *= this.dimensions; if(sequenceP) { var last1 = 0.0; var _g11 = 0; var _g4 = len; while(_g11 < _g4) { var i2 = _g11++; var val2 = multiplicands[z + i2] + last1; var _g21 = offset + i2; var _g31 = output; _g31[_g21] = _g31[_g21] + val2; last1 = val2 + minimumValue; } } else { var last2 = 0.0; var _g12 = 0; var _g5 = len; while(_g12 < _g5) { var i3 = _g12++; var _g22 = offset + i3; var _g32 = output; _g32[_g22] = _g32[_g22] + (multiplicands[z + i3] + last2); } } return true; } ,codebookDecodeStep: function(decodeState,output,offset,len,step) { if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i = this.fastHuffman[decodeState.acc & 1023]; var val; if(i >= 0) { var l = this.codewordLengths[i]; decodeState.acc = decodeState.acc >>> l; decodeState.validBits -= l; if(decodeState.validBits < 0) { decodeState.validBits = 0; val = -1; } else { val = i; } } else { val = decodeState.decodeScalarRaw(this); } if(this.sparse) { val = this.sortedValues[val]; } var z = val; var last = 0.0; if(z < 0) { return false; } if(len > this.dimensions) { len = this.dimensions; } var lookupValues = this.lookupValues; var sequenceP = this.sequenceP; var multiplicands = this.multiplicands; if(this.lookupType == 1) { var div = 1; var _g1 = 0; var _g = len; while(_g1 < _g) { var i1 = _g1++; var off = _$UInt_UInt_$Impl_$.toFloat(z / div | 0) % _$UInt_UInt_$Impl_$.toFloat(lookupValues) | 0; var val1 = multiplicands[off] + last; var _g2 = offset + i1 * step; var _g3 = output; _g3[_g2] = _g3[_g2] + val1; if(sequenceP) { last = val1; } div = div * lookupValues; } return true; } z *= this.dimensions; var _g11 = 0; var _g4 = len; while(_g11 < _g4) { var i2 = _g11++; var val2 = multiplicands[z + i2] + last; var _g21 = offset + i2 * step; var _g31 = output; _g31[_g21] = _g31[_g21] + val2; if(sequenceP) { last = val2; } } return true; } ,decodeStart: function(decodeState) { if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i = this.fastHuffman[decodeState.acc & 1023]; var val; if(i >= 0) { var l = this.codewordLengths[i]; decodeState.acc = decodeState.acc >>> l; decodeState.validBits -= l; if(decodeState.validBits < 0) { decodeState.validBits = 0; val = -1; } else { val = i; } } else { val = decodeState.decodeScalarRaw(this); } if(this.sparse) { val = this.sortedValues[val]; } return val; } ,decodeDeinterleaveRepeat: function(decodeState,residueBuffers,ch,cInter,pInter,len,totalDecode) { var effective = this.dimensions; if(this.lookupType == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "Codebook.hx", lineNumber : 488, className : "kha.audio2.ogg.vorbis.data.Codebook", methodName : "decodeDeinterleaveRepeat"})); } var multiplicands = this.multiplicands; var sequenceP = this.sequenceP; var lookupValues = this.lookupValues; while(totalDecode > 0) { var last = 0.0; if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i = this.fastHuffman[decodeState.acc & 1023]; var val; if(i >= 0) { var l = this.codewordLengths[i]; decodeState.acc = decodeState.acc >>> l; decodeState.validBits -= l; if(decodeState.validBits < 0) { decodeState.validBits = 0; val = -1; } else { val = i; } } else { val = decodeState.decodeScalarRaw(this); } if(this.sparse) { val = this.sortedValues[val]; } var z = val; if(z < 0) { if(decodeState.bytesInSeg == 0 && decodeState.lastSeg) { return null; } throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "Codebook.hx", lineNumber : 503, className : "kha.audio2.ogg.vorbis.data.Codebook", methodName : "decodeDeinterleaveRepeat"})); } if(cInter + pInter * ch + effective > len * ch) { effective = len * ch - (pInter * ch - cInter); } if(this.lookupType == 1) { var div = 1; if(sequenceP) { var _g1 = 0; var _g = effective; while(_g1 < _g) { var i1 = _g1++; var off = _$UInt_UInt_$Impl_$.toFloat(z / div | 0) % _$UInt_UInt_$Impl_$.toFloat(lookupValues) | 0; var val1 = multiplicands[off] + last; var _g2 = pInter; var _g3 = residueBuffers[cInter]; _g3[_g2] = _g3[_g2] + val1; if(++cInter == ch) { cInter = 0; ++pInter; } last = val1; div = div * lookupValues; } } else { var _g11 = 0; var _g4 = effective; while(_g11 < _g4) { var i2 = _g11++; var off1 = _$UInt_UInt_$Impl_$.toFloat(z / div | 0) % _$UInt_UInt_$Impl_$.toFloat(lookupValues) | 0; var val2 = multiplicands[off1] + last; var _g21 = pInter; var _g31 = residueBuffers[cInter]; _g31[_g21] = _g31[_g21] + val2; if(++cInter == ch) { cInter = 0; ++pInter; } div = div * lookupValues; } } } else { z *= this.dimensions; if(sequenceP) { var _g12 = 0; var _g5 = effective; while(_g12 < _g5) { var i3 = _g12++; var val3 = multiplicands[z + i3] + last; var _g22 = pInter; var _g32 = residueBuffers[cInter]; _g32[_g22] = _g32[_g22] + val3; if(++cInter == ch) { cInter = 0; ++pInter; } last = val3; } } else { var _g13 = 0; var _g6 = effective; while(_g13 < _g6) { var i4 = _g13++; var val4 = multiplicands[z + i4] + last; var _g23 = pInter; var _g33 = residueBuffers[cInter]; _g33[_g23] = _g33[_g23] + val4; if(++cInter == ch) { cInter = 0; ++pInter; } } } } totalDecode -= effective; } return { cInter : cInter, pInter : pInter}; } ,residueDecode: function(decodeState,target,offset,n,rtype) { if(rtype == 0) { var step = n / this.dimensions | 0; var _g1 = 0; var _g = step; while(_g1 < _g) { var k = _g1++; if(!this.codebookDecodeStep(decodeState,target,offset + k,n - offset - k,step)) { return false; } } } else { var k1 = 0; while(k1 < n) { if(!this.codebookDecode(decodeState,target,offset,n - k1)) { return false; } k1 += this.dimensions; offset += this.dimensions; } } return true; } ,__class__: kha_audio2_ogg_vorbis_data_Codebook }; var kha_audio2_ogg_vorbis_data_Comment = function() { this.data = new haxe_ds_StringMap(); }; $hxClasses["kha.audio2.ogg.vorbis.data.Comment"] = kha_audio2_ogg_vorbis_data_Comment; kha_audio2_ogg_vorbis_data_Comment.__name__ = true; kha_audio2_ogg_vorbis_data_Comment.prototype = { data: null ,get_title: function() { return this.getString("title"); } ,get_loopStart: function() { return Std.parseInt(this.getString("loopstart")); } ,get_loopLength: function() { return Std.parseInt(this.getString("looplength")); } ,get_version: function() { return this.getString("version"); } ,get_album: function() { return this.getString("album"); } ,get_organization: function() { return this.getString("organization"); } ,get_tracknumber: function() { return this.getString("tracknumber"); } ,get_performer: function() { return this.getString("performer"); } ,get_copyright: function() { return this.getString("copyright"); } ,get_license: function() { return this.getString("license"); } ,get_artist: function() { return this.getString("artist"); } ,get_description: function() { return this.getString("description"); } ,get_genre: function() { return this.getString("genre"); } ,get_date: function() { return this.getString("date"); } ,get_location: function() { return this.getString("location"); } ,get_contact: function() { return this.getString("contact"); } ,get_isrc: function() { return this.getString("isrc"); } ,get_artists: function() { return this.getArray("artist"); } ,add: function(key,value) { key = key.toLowerCase(); var _this = this.data; if(__map_reserved[key] != null ? _this.existsReserved(key) : _this.h.hasOwnProperty(key)) { var _this1 = this.data; (__map_reserved[key] != null ? _this1.getReserved(key) : _this1.h[key]).push(value); } else { var v = [value]; var _this2 = this.data; if(__map_reserved[key] != null) { _this2.setReserved(key,v); } else { _this2.h[key] = v; } } } ,getString: function(key) { key = key.toLowerCase(); var _this = this.data; if(__map_reserved[key] != null ? _this.existsReserved(key) : _this.h.hasOwnProperty(key)) { var _this1 = this.data; return (__map_reserved[key] != null ? _this1.getReserved(key) : _this1.h[key])[0]; } else { return null; } } ,getArray: function(key) { key = key.toLowerCase(); var _this = this.data; if(__map_reserved[key] != null ? _this.existsReserved(key) : _this.h.hasOwnProperty(key)) { var _this1 = this.data; if(__map_reserved[key] != null) { return _this1.getReserved(key); } else { return _this1.h[key]; } } else { return null; } } ,__class__: kha_audio2_ogg_vorbis_data_Comment }; var kha_audio2_ogg_vorbis_data_Floor = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Floor"] = kha_audio2_ogg_vorbis_data_Floor; kha_audio2_ogg_vorbis_data_Floor.__name__ = true; kha_audio2_ogg_vorbis_data_Floor.read = function(decodeState,codebooks) { var floor = new kha_audio2_ogg_vorbis_data_Floor(); var tmp; if(decodeState.validBits < 0) { tmp = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { tmp = 0; } else { var z = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp = z; } } else { var z1 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp = z1; } floor.type = tmp; if(floor.type > 1) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Floor.hx", lineNumber : 28, className : "kha.audio2.ogg.vorbis.data.Floor", methodName : "read"})); } if(floor.type == 0) { var g = floor.floor0 = new kha_audio2_ogg_vorbis_data_Floor0(); var tmp1; if(decodeState.validBits < 0) { tmp1 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp1 = 0; } else { var z2 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp1 = z2; } } else { var z3 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp1 = z3; } g.order = tmp1; var tmp2; if(decodeState.validBits < 0) { tmp2 = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { tmp2 = 0; } else { var z4 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp2 = z4; } } else { var z5 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp2 = z5; } g.rate = tmp2; var tmp3; if(decodeState.validBits < 0) { tmp3 = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { tmp3 = 0; } else { var z6 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp3 = z6; } } else { var z7 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp3 = z7; } g.barkMapSize = tmp3; var tmp4; if(decodeState.validBits < 0) { tmp4 = 0; } else if(decodeState.validBits < 6) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 6)) { break; } } if(decodeState.validBits < 0) { tmp4 = 0; } else { var z8 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; tmp4 = z8; } } else { var z9 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; tmp4 = z9; } g.amplitudeBits = tmp4; var tmp5; if(decodeState.validBits < 0) { tmp5 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp5 = 0; } else { var z10 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp5 = z10; } } else { var z11 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp5 = z11; } g.amplitudeOffset = tmp5; var tmp6; if(decodeState.validBits < 0) { tmp6 = 0; } else if(decodeState.validBits < 4) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 4)) { break; } } if(decodeState.validBits < 0) { tmp6 = 0; } else { var z12 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp6 = z12; } } else { var z13 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp6 = z13; } g.numberOfBooks = tmp6 + 1; var _g1 = 0; var _g = g.numberOfBooks; while(_g1 < _g) { var j = _g1++; var this1 = g.bookList; var val; if(decodeState.validBits < 0) { val = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { val = 0; } else { var z14 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val = z14; } } else { var z15 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val = z15; } this1[j] = val; } throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED,null,{ fileName : "Floor.hx", lineNumber : 41, className : "kha.audio2.ogg.vorbis.data.Floor", methodName : "read"})); } else { var p = []; var g1 = floor.floor1 = new kha_audio2_ogg_vorbis_data_Floor1(); var maxClass = -1; var tmp7; if(decodeState.validBits < 0) { tmp7 = 0; } else if(decodeState.validBits < 5) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 5)) { break; } } if(decodeState.validBits < 0) { tmp7 = 0; } else { var z16 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; tmp7 = z16; } } else { var z17 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; tmp7 = z17; } g1.partitions = tmp7; var length = g1.partitions; var this2 = new Array(length); g1.partitionClassList = this2; var _g11 = 0; var _g2 = g1.partitions; while(_g11 < _g2) { var j1 = _g11++; var this3 = g1.partitionClassList; var val1; if(decodeState.validBits < 0) { val1 = 0; } else if(decodeState.validBits < 4) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 4)) { break; } } if(decodeState.validBits < 0) { val1 = 0; } else { var z18 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; val1 = z18; } } else { var z19 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; val1 = z19; } this3[j1] = val1; if(g1.partitionClassList[j1] > maxClass) { maxClass = g1.partitionClassList[j1]; } } var this4 = new Array(maxClass + 1); g1.classDimensions = this4; var this5 = new Array(maxClass + 1); g1.classMasterbooks = this5; var this6 = new Array(maxClass + 1); g1.classSubclasses = this6; var this7 = new Array(maxClass + 1); g1.subclassBooks = this7; var _g12 = 0; var _g3 = maxClass + 1; while(_g12 < _g3) { var j2 = _g12++; var this8 = g1.classDimensions; var val2; if(decodeState.validBits < 0) { val2 = 0; } else if(decodeState.validBits < 3) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 3)) { break; } } if(decodeState.validBits < 0) { val2 = 0; } else { var z20 = decodeState.acc & 7; decodeState.acc = decodeState.acc >>> 3; decodeState.validBits -= 3; val2 = z20; } } else { var z21 = decodeState.acc & 7; decodeState.acc = decodeState.acc >>> 3; decodeState.validBits -= 3; val2 = z21; } this8[j2] = val2 + 1; var this9 = g1.classSubclasses; var val3; if(decodeState.validBits < 0) { val3 = 0; } else if(decodeState.validBits < 2) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 2)) { break; } } if(decodeState.validBits < 0) { val3 = 0; } else { var z22 = decodeState.acc & 3; decodeState.acc = decodeState.acc >>> 2; decodeState.validBits -= 2; val3 = z22; } } else { var z23 = decodeState.acc & 3; decodeState.acc = decodeState.acc >>> 2; decodeState.validBits -= 2; val3 = z23; } this9[j2] = val3; if(g1.classSubclasses[j2] != 0) { var this10 = g1.classMasterbooks; var val4; if(decodeState.validBits < 0) { val4 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { val4 = 0; } else { var z24 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val4 = z24; } } else { var z25 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val4 = z25; } this10[j2] = val4; if(g1.classMasterbooks[j2] >= codebooks.length) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Floor.hx", lineNumber : 64, className : "kha.audio2.ogg.vorbis.data.Floor", methodName : "read"})); } } var kl = 1 << g1.classSubclasses[j2]; var this11 = g1.subclassBooks; var this12 = new Array(kl); this11[j2] = this12; var _g31 = 0; var _g21 = kl; while(_g31 < _g21) { var k = _g31++; var this13 = g1.subclassBooks[j2]; var val5; if(decodeState.validBits < 0) { val5 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { val5 = 0; } else { var z26 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val5 = z26; } } else { var z27 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val5 = z27; } this13[k] = val5 - 1; if(g1.subclassBooks[j2][k] >= codebooks.length) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Floor.hx", lineNumber : 73, className : "kha.audio2.ogg.vorbis.data.Floor", methodName : "read"})); } } } var tmp8; if(decodeState.validBits < 0) { tmp8 = 0; } else if(decodeState.validBits < 2) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 2)) { break; } } if(decodeState.validBits < 0) { tmp8 = 0; } else { var z28 = decodeState.acc & 3; decodeState.acc = decodeState.acc >>> 2; decodeState.validBits -= 2; tmp8 = z28; } } else { var z29 = decodeState.acc & 3; decodeState.acc = decodeState.acc >>> 2; decodeState.validBits -= 2; tmp8 = z29; } g1.floor1Multiplier = tmp8 + 1; var tmp9; if(decodeState.validBits < 0) { tmp9 = 0; } else if(decodeState.validBits < 4) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 4)) { break; } } if(decodeState.validBits < 0) { tmp9 = 0; } else { var z30 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp9 = z30; } } else { var z31 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp9 = z31; } g1.rangebits = tmp9; var this14 = new Array(250); g1.xlist = this14; g1.xlist[0] = 0; g1.xlist[1] = 1 << g1.rangebits; g1.values = 2; var _g13 = 0; var _g4 = g1.partitions; while(_g13 < _g4) { var j3 = _g13++; var c = g1.partitionClassList[j3]; var _g32 = 0; var _g22 = g1.classDimensions[c]; while(_g32 < _g22) { var k1 = _g32++; var this15 = g1.xlist; var index = g1.values; var n = g1.rangebits; var val6; if(decodeState.validBits < 0) { val6 = 0; } else if(decodeState.validBits < n) { if(n > 24) { val6 = decodeState.readBits(24) + (decodeState.readBits(n - 24) << 24); } else { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < n)) { break; } } if(decodeState.validBits < 0) { val6 = 0; } else { var z32 = decodeState.acc & (1 << n) - 1; decodeState.acc = decodeState.acc >>> n; decodeState.validBits -= n; val6 = z32; } } } else { var z33 = decodeState.acc & (1 << n) - 1; decodeState.acc = decodeState.acc >>> n; decodeState.validBits -= n; val6 = z33; } this15[index] = val6; g1.values++; } } var _g14 = 0; var _g5 = g1.values; while(_g14 < _g5) { var j4 = _g14++; p.push(new kha_audio2_ogg_vorbis_data_IntPoint()); p[j4].x = g1.xlist[j4]; p[j4].y = j4; } p.sort(kha_audio2_ogg_vorbis_VorbisTools.pointCompare); var length1 = g1.values; var this16 = new Array(length1); g1.sortedOrder = this16; var _g15 = 0; var _g6 = g1.values; while(_g15 < _g6) { var j5 = _g15++; g1.sortedOrder[j5] = p[j5].y; } var length2 = g1.values; var this17 = new Array(length2); g1.neighbors = this17; var _g16 = 2; var _g7 = g1.values; while(_g16 < _g7) { var j6 = _g16++; var ne_low; var ne_high; var x = g1.xlist; var low = -1; var high = 65536; var plow = 0; var phigh = 0; var _g17 = 0; var _g8 = j6; while(_g17 < _g8) { var i = _g17++; if(x[i] > low && x[i] < x[j6]) { plow = i; low = x[i]; } if(x[i] < high && x[i] > x[j6]) { phigh = i; high = x[i]; } } ne_low = plow; ne_high = phigh; var this18 = g1.neighbors; var length3 = g1.values; var this19 = new Array(length3); this18[j6] = this19; g1.neighbors[j6][0] = ne_low; g1.neighbors[j6][1] = ne_high; } } return floor; }; kha_audio2_ogg_vorbis_data_Floor.prototype = { floor0: null ,floor1: null ,type: null ,__class__: kha_audio2_ogg_vorbis_data_Floor }; var kha_audio2_ogg_vorbis_data_Floor0 = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Floor0"] = kha_audio2_ogg_vorbis_data_Floor0; kha_audio2_ogg_vorbis_data_Floor0.__name__ = true; kha_audio2_ogg_vorbis_data_Floor0.prototype = { order: null ,rate: null ,barkMapSize: null ,amplitudeBits: null ,amplitudeOffset: null ,numberOfBooks: null ,bookList: null ,__class__: kha_audio2_ogg_vorbis_data_Floor0 }; var kha_audio2_ogg_vorbis_data_Floor1 = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Floor1"] = kha_audio2_ogg_vorbis_data_Floor1; kha_audio2_ogg_vorbis_data_Floor1.__name__ = true; kha_audio2_ogg_vorbis_data_Floor1.prototype = { partitions: null ,partitionClassList: null ,classDimensions: null ,classSubclasses: null ,classMasterbooks: null ,subclassBooks: null ,xlist: null ,sortedOrder: null ,neighbors: null ,floor1Multiplier: null ,rangebits: null ,values: null ,__class__: kha_audio2_ogg_vorbis_data_Floor1 }; var kha_audio2_ogg_vorbis_data_Header = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Header"] = kha_audio2_ogg_vorbis_data_Header; kha_audio2_ogg_vorbis_data_Header.__name__ = true; kha_audio2_ogg_vorbis_data_Header.read = function(decodeState) { var page = decodeState.page; page.start(decodeState); if((page.flag & 2) == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"not firstPage",{ fileName : "Header.hx", lineNumber : 46, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } if((page.flag & 4) != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"lastPage",{ fileName : "Header.hx", lineNumber : 49, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } if((page.flag & 1) != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"continuedPacket",{ fileName : "Header.hx", lineNumber : 52, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } decodeState.firstPageValidate(); decodeState.inputPosition += 1; if(decodeState.input.readByte() != 1) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"decodeState head",{ fileName : "Header.hx", lineNumber : 57, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } var header = new haxe_io_Bytes(new ArrayBuffer(6)); var _g = 0; while(_g < 6) { var i = _g++; var x; if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { x = -1; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; x = decodeState.input.readByte(); } decodeState.validBits = 0; header.b[i] = x & 255; } if(header.toString() != "vorbis") { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"vorbis header",{ fileName : "VorbisDecodeState.hx", lineNumber : 300, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "vorbisValidate"})); } decodeState.inputPosition += 4; var version = decodeState.input.readInt32(); if(version != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"vorbis version : " + version,{ fileName : "Header.hx", lineNumber : 66, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } var header1 = new kha_audio2_ogg_vorbis_data_Header(); decodeState.inputPosition += 1; header1.channel = decodeState.input.readByte(); if(header1.channel == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"no channel",{ fileName : "Header.hx", lineNumber : 73, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } else if(header1.channel > 16) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS,"too many channels",{ fileName : "Header.hx", lineNumber : 75, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } decodeState.inputPosition += 4; header1.sampleRate = decodeState.input.readInt32(); if(header1.sampleRate == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"no sampling rate",{ fileName : "Header.hx", lineNumber : 80, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } decodeState.inputPosition += 4; header1.maximumBitRate = decodeState.input.readInt32(); decodeState.inputPosition += 4; header1.nominalBitRate = decodeState.input.readInt32(); decodeState.inputPosition += 4; header1.minimumBitRate = decodeState.input.readInt32(); decodeState.inputPosition += 1; var x1 = decodeState.input.readByte(); var log0 = x1 & 15; var log1 = x1 >> 4; header1.blocksize0 = 1 << log0; header1.blocksize1 = 1 << log1; if(log0 < 6 || log0 > 13) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 93, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } if(log1 < 6 || log1 > 13) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 96, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } if(log0 > log1) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 99, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } decodeState.inputPosition += 1; var x2 = decodeState.input.readByte(); if((x2 & 1) == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,null,{ fileName : "Header.hx", lineNumber : 105, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } decodeState.page.start(decodeState); decodeState.startPacket(); var len = 0; var output = new haxe_io_BytesOutput(); while(true) { len = decodeState.next(); if(!(len != 0)) { break; } decodeState.inputPosition += len; output.write(decodeState.input.read(len)); decodeState.bytesInSeg = 0; } var packetInput = new haxe_io_BytesInput(output.getBytes()); packetInput.readByte(); packetInput.read(6); var vendorLength = packetInput.readInt32(); header1.vendor = packetInput.readString(vendorLength); header1.comment = new kha_audio2_ogg_vorbis_data_Comment(); var commentCount = packetInput.readInt32(); var _g1 = 0; var _g2 = commentCount; while(_g1 < _g2) { var i1 = _g1++; var n = packetInput.readInt32(); var str = packetInput.readString(n); var splitter = str.indexOf("="); if(splitter != -1) { header1.comment.add(str.substring(0,splitter),str.substring(splitter + 1)); } } var x3 = packetInput.readByte(); if((x3 & 1) == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 141, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } decodeState.startPacket(); var x4; if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { x4 = -1; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; x4 = decodeState.input.readByte(); } decodeState.validBits = 0; if(x4 != 5) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"setup packet",{ fileName : "Header.hx", lineNumber : 149, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } var header2 = new haxe_io_Bytes(new ArrayBuffer(6)); var _g3 = 0; while(_g3 < 6) { var i2 = _g3++; var x5; if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { x5 = -1; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; x5 = decodeState.input.readByte(); } decodeState.validBits = 0; header2.b[i2] = x5 & 255; } if(header2.toString() != "vorbis") { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"vorbis header",{ fileName : "VorbisDecodeState.hx", lineNumber : 300, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "vorbisValidate"})); } var codebookCount; if(decodeState.validBits < 0) { codebookCount = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { codebookCount = 0; } else { var z = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; codebookCount = z; } } else { var z1 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; codebookCount = z1; } var codebookCount1 = codebookCount + 1; var this1 = new Array(codebookCount1); header1.codebooks = this1; var _g11 = 0; var _g4 = codebookCount1; while(_g11 < _g4) { var i3 = _g11++; header1.codebooks[i3] = kha_audio2_ogg_vorbis_data_Codebook.read(decodeState); } var x6; if(decodeState.validBits < 0) { x6 = 0; } else if(decodeState.validBits < 6) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 6)) { break; } } if(decodeState.validBits < 0) { x6 = 0; } else { var z2 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; x6 = z2; } } else { var z3 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; x6 = z3; } x2 = x6 + 1; var _g12 = 0; var _g5 = x2; while(_g12 < _g5) { var i4 = _g12++; var tmp; if(decodeState.validBits < 0) { tmp = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { tmp = 0; } else { var z4 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp = z4; } } else { var z5 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp = z5; } if(tmp != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 165, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } } var floorCount; if(decodeState.validBits < 0) { floorCount = 0; } else if(decodeState.validBits < 6) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 6)) { break; } } if(decodeState.validBits < 0) { floorCount = 0; } else { var z6 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; floorCount = z6; } } else { var z7 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; floorCount = z7; } var floorCount1 = floorCount + 1; var this2 = new Array(floorCount1); header1.floorConfig = this2; var _g13 = 0; var _g6 = floorCount1; while(_g13 < _g6) { var i5 = _g13++; header1.floorConfig[i5] = kha_audio2_ogg_vorbis_data_Floor.read(decodeState,header1.codebooks); } var residueCount; if(decodeState.validBits < 0) { residueCount = 0; } else if(decodeState.validBits < 6) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 6)) { break; } } if(decodeState.validBits < 0) { residueCount = 0; } else { var z8 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; residueCount = z8; } } else { var z9 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; residueCount = z9; } var residueCount1 = residueCount + 1; var this3 = new Array(residueCount1); header1.residueConfig = this3; var _g14 = 0; var _g7 = residueCount1; while(_g14 < _g7) { var i6 = _g14++; header1.residueConfig[i6] = kha_audio2_ogg_vorbis_data_Residue.read(decodeState,header1.codebooks); } var mappingCount; if(decodeState.validBits < 0) { mappingCount = 0; } else if(decodeState.validBits < 6) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 6)) { break; } } if(decodeState.validBits < 0) { mappingCount = 0; } else { var z10 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; mappingCount = z10; } } else { var z11 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; mappingCount = z11; } var mappingCount1 = mappingCount + 1; var this4 = new Array(mappingCount1); header1.mapping = this4; var _g15 = 0; var _g8 = mappingCount1; while(_g15 < _g8) { var i7 = _g15++; var map = kha_audio2_ogg_vorbis_data_Mapping.read(decodeState,header1.channel); header1.mapping[i7] = map; var _g31 = 0; var _g21 = map.submaps; while(_g31 < _g21) { var j = _g31++; if(map.submapFloor[j] >= header1.floorConfig.length) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 191, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } if(map.submapResidue[j] >= header1.residueConfig.length) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 194, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } } } var modeCount; if(decodeState.validBits < 0) { modeCount = 0; } else if(decodeState.validBits < 6) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 6)) { break; } } if(decodeState.validBits < 0) { modeCount = 0; } else { var z12 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; modeCount = z12; } } else { var z13 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; modeCount = z13; } var modeCount1 = modeCount + 1; var this5 = new Array(modeCount1); header1.modes = this5; var _g16 = 0; var _g9 = modeCount1; while(_g16 < _g9) { var i8 = _g16++; var mode = kha_audio2_ogg_vorbis_data_Mode.read(decodeState); header1.modes[i8] = mode; if(mode.mapping >= header1.mapping.length) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.hx", lineNumber : 205, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"})); } } while(decodeState.bytesInSeg != 0 || !decodeState.lastSeg && decodeState.next() != 0) { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.input.readByte(); } return header1; }; kha_audio2_ogg_vorbis_data_Header.prototype = { maximumBitRate: null ,nominalBitRate: null ,minimumBitRate: null ,sampleRate: null ,channel: null ,blocksize0: null ,blocksize1: null ,codebooks: null ,floorConfig: null ,residueConfig: null ,mapping: null ,modes: null ,comment: null ,vendor: null ,__class__: kha_audio2_ogg_vorbis_data_Header }; var kha_audio2_ogg_vorbis_data_IntPoint = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.IntPoint"] = kha_audio2_ogg_vorbis_data_IntPoint; kha_audio2_ogg_vorbis_data_IntPoint.__name__ = true; kha_audio2_ogg_vorbis_data_IntPoint.prototype = { x: null ,y: null ,__class__: kha_audio2_ogg_vorbis_data_IntPoint }; var kha_audio2_ogg_vorbis_data_Mapping = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Mapping"] = kha_audio2_ogg_vorbis_data_Mapping; kha_audio2_ogg_vorbis_data_Mapping.__name__ = true; kha_audio2_ogg_vorbis_data_Mapping.read = function(decodeState,channels) { var m = new kha_audio2_ogg_vorbis_data_Mapping(); var mappingType; if(decodeState.validBits < 0) { mappingType = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { mappingType = 0; } else { var z = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; mappingType = z; } } else { var z1 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; mappingType = z1; } if(mappingType != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"mapping type " + mappingType,{ fileName : "Mapping.hx", lineNumber : 22, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"})); } var this1 = new Array(channels); m.chan = this1; var _g1 = 0; var _g = channels; while(_g1 < _g) { var j = _g1++; m.chan[j] = new kha_audio2_ogg_vorbis_data_MappingChannel(); } var tmp; if(decodeState.validBits < 0) { tmp = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { tmp = 0; } else { var z2 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp = z2; } } else { var z3 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp = z3; } if(tmp != 0) { var tmp1; if(decodeState.validBits < 0) { tmp1 = 0; } else if(decodeState.validBits < 4) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 4)) { break; } } if(decodeState.validBits < 0) { tmp1 = 0; } else { var z4 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp1 = z4; } } else { var z5 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp1 = z5; } m.submaps = tmp1 + 1; } else { m.submaps = 1; } var tmp2; if(decodeState.validBits < 0) { tmp2 = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { tmp2 = 0; } else { var z6 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp2 = z6; } } else { var z7 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp2 = z7; } if(tmp2 != 0) { var tmp3; if(decodeState.validBits < 0) { tmp3 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp3 = 0; } else { var z8 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp3 = z8; } } else { var z9 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp3 = z9; } m.couplingSteps = tmp3 + 1; var _g11 = 0; var _g2 = m.couplingSteps; while(_g11 < _g2) { var k = _g11++; var tmp4 = m.chan[k]; var n = channels - 1; var log2_4 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var n1 = n < 16384 ? n < 16 ? log2_4[n] : n < 512 ? 5 + log2_4[n >> 5] : 10 + log2_4[n >> 10] : n < 16777216 ? n < 524288 ? 15 + log2_4[n >> 15] : 20 + log2_4[n >> 20] : n < 536870912 ? 25 + log2_4[n >> 25] : n < -2147483648 ? 30 + log2_4[n >> 30] : 0; var tmp5; if(decodeState.validBits < 0) { tmp5 = 0; } else if(decodeState.validBits < n1) { if(n1 > 24) { tmp5 = decodeState.readBits(24) + (decodeState.readBits(n1 - 24) << 24); } else { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < n1)) { break; } } if(decodeState.validBits < 0) { tmp5 = 0; } else { var z10 = decodeState.acc & (1 << n1) - 1; decodeState.acc = decodeState.acc >>> n1; decodeState.validBits -= n1; tmp5 = z10; } } } else { var z11 = decodeState.acc & (1 << n1) - 1; decodeState.acc = decodeState.acc >>> n1; decodeState.validBits -= n1; tmp5 = z11; } tmp4.magnitude = tmp5; var tmp6 = m.chan[k]; var n2 = channels - 1; var log2_41 = [0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4]; var n3 = n2 < 16384 ? n2 < 16 ? log2_41[n2] : n2 < 512 ? 5 + log2_41[n2 >> 5] : 10 + log2_41[n2 >> 10] : n2 < 16777216 ? n2 < 524288 ? 15 + log2_41[n2 >> 15] : 20 + log2_41[n2 >> 20] : n2 < 536870912 ? 25 + log2_41[n2 >> 25] : n2 < -2147483648 ? 30 + log2_41[n2 >> 30] : 0; var tmp7; if(decodeState.validBits < 0) { tmp7 = 0; } else if(decodeState.validBits < n3) { if(n3 > 24) { tmp7 = decodeState.readBits(24) + (decodeState.readBits(n3 - 24) << 24); } else { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < n3)) { break; } } if(decodeState.validBits < 0) { tmp7 = 0; } else { var z12 = decodeState.acc & (1 << n3) - 1; decodeState.acc = decodeState.acc >>> n3; decodeState.validBits -= n3; tmp7 = z12; } } } else { var z13 = decodeState.acc & (1 << n3) - 1; decodeState.acc = decodeState.acc >>> n3; decodeState.validBits -= n3; tmp7 = z13; } tmp6.angle = tmp7; if(m.chan[k].magnitude >= channels) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.hx", lineNumber : 46, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"})); } if(m.chan[k].angle >= channels) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.hx", lineNumber : 49, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"})); } if(m.chan[k].magnitude == m.chan[k].angle) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.hx", lineNumber : 52, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"})); } } } else { m.couplingSteps = 0; } var tmp8; if(decodeState.validBits < 0) { tmp8 = 0; } else if(decodeState.validBits < 2) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 2)) { break; } } if(decodeState.validBits < 0) { tmp8 = 0; } else { var z14 = decodeState.acc & 3; decodeState.acc = decodeState.acc >>> 2; decodeState.validBits -= 2; tmp8 = z14; } } else { var z15 = decodeState.acc & 3; decodeState.acc = decodeState.acc >>> 2; decodeState.validBits -= 2; tmp8 = z15; } if(tmp8 != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.hx", lineNumber : 61, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"})); } if(m.submaps > 1) { var _g12 = 0; var _g3 = channels; while(_g12 < _g3) { var j1 = _g12++; var tmp9 = m.chan[j1]; var tmp10; if(decodeState.validBits < 0) { tmp10 = 0; } else if(decodeState.validBits < 4) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 4)) { break; } } if(decodeState.validBits < 0) { tmp10 = 0; } else { var z16 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp10 = z16; } } else { var z17 = decodeState.acc & 15; decodeState.acc = decodeState.acc >>> 4; decodeState.validBits -= 4; tmp10 = z17; } tmp9.mux = tmp10; if(m.chan[j1].mux >= m.submaps) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.hx", lineNumber : 67, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"})); } } } else { var _g13 = 0; var _g4 = channels; while(_g13 < _g4) { var j2 = _g13++; m.chan[j2].mux = 0; } } var length = m.submaps; var this2 = new Array(length); m.submapFloor = this2; var length1 = m.submaps; var this3 = new Array(length1); m.submapResidue = this3; var _g14 = 0; var _g5 = m.submaps; while(_g14 < _g5) { var j3 = _g14++; if(decodeState.validBits >= 0) { if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits >= 0) { var z18 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; } } else { var z19 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; } } var this4 = m.submapFloor; var val; if(decodeState.validBits < 0) { val = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { val = 0; } else { var z20 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val = z20; } } else { var z21 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val = z21; } this4[j3] = val; var this5 = m.submapResidue; var val1; if(decodeState.validBits < 0) { val1 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { val1 = 0; } else { var z22 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val1 = z22; } } else { var z23 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val1 = z23; } this5[j3] = val1; } return m; }; kha_audio2_ogg_vorbis_data_Mapping.prototype = { couplingSteps: null ,chan: null ,submaps: null ,submapFloor: null ,submapResidue: null ,doFloor: function(floors,i,n,target,finalY,step2Flag) { var n2 = n >> 1; var s = this.chan[i].mux; var floor; var floor1 = floors[this.submapFloor[s]]; if(floor1.type == 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "Mapping.hx", lineNumber : 94, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "doFloor"})); } else { var g = floor1.floor1; var lx = 0; var ly = finalY[0] * g.floor1Multiplier; var _g1 = 1; var _g = g.values; while(_g1 < _g) { var q = _g1++; var j = g.sortedOrder[q]; if(finalY[j] >= 0) { var hy = finalY[j] * g.floor1Multiplier; var hx = g.xlist[j]; kha_audio2_ogg_vorbis_VorbisTools.drawLine(target,lx,ly,hx,hy,n2); lx = hx; ly = hy; } } if(lx < n2) { var _g11 = lx; var _g2 = n2; while(_g11 < _g2) { var j1 = _g11++; var _g21 = j1; var _g3 = target; _g3[_g21] = _g3[_g21] * kha_audio2_ogg_vorbis_VorbisTools.INVERSE_DB_TABLE[ly]; } } } } ,__class__: kha_audio2_ogg_vorbis_data_Mapping }; var kha_audio2_ogg_vorbis_data_MappingChannel = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.MappingChannel"] = kha_audio2_ogg_vorbis_data_MappingChannel; kha_audio2_ogg_vorbis_data_MappingChannel.__name__ = true; kha_audio2_ogg_vorbis_data_MappingChannel.prototype = { magnitude: null ,angle: null ,mux: null ,__class__: kha_audio2_ogg_vorbis_data_MappingChannel }; var kha_audio2_ogg_vorbis_data_Mode = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Mode"] = kha_audio2_ogg_vorbis_data_Mode; kha_audio2_ogg_vorbis_data_Mode.__name__ = true; kha_audio2_ogg_vorbis_data_Mode.read = function(decodeState) { var m = new kha_audio2_ogg_vorbis_data_Mode(); var tmp; if(decodeState.validBits < 0) { tmp = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { tmp = 0; } else { var z = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp = z; } } else { var z1 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp = z1; } m.blockflag = tmp != 0; var tmp1; if(decodeState.validBits < 0) { tmp1 = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { tmp1 = 0; } else { var z2 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp1 = z2; } } else { var z3 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp1 = z3; } m.windowtype = tmp1; var tmp2; if(decodeState.validBits < 0) { tmp2 = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { tmp2 = 0; } else { var z4 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp2 = z4; } } else { var z5 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp2 = z5; } m.transformtype = tmp2; var tmp3; if(decodeState.validBits < 0) { tmp3 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp3 = 0; } else { var z6 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp3 = z6; } } else { var z7 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp3 = z7; } m.mapping = tmp3; if(m.windowtype != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mode.hx", lineNumber : 22, className : "kha.audio2.ogg.vorbis.data.Mode", methodName : "read"})); } if(m.transformtype != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mode.hx", lineNumber : 25, className : "kha.audio2.ogg.vorbis.data.Mode", methodName : "read"})); } return m; }; kha_audio2_ogg_vorbis_data_Mode.prototype = { blockflag: null ,mapping: null ,windowtype: null ,transformtype: null ,__class__: kha_audio2_ogg_vorbis_data_Mode }; var kha_audio2_ogg_vorbis_data_Page = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Page"] = kha_audio2_ogg_vorbis_data_Page; kha_audio2_ogg_vorbis_data_Page.__name__ = true; kha_audio2_ogg_vorbis_data_Page.prototype = { flag: null ,clone: function() { var page = new kha_audio2_ogg_vorbis_data_Page(); page.flag = this.flag; return page; } ,start: function(decodeState) { var tmp; var tmp1; var tmp2; decodeState.inputPosition += 1; if(decodeState.input.readByte() == 79) { decodeState.inputPosition += 1; tmp2 = decodeState.input.readByte() != 103; } else { tmp2 = true; } if(!tmp2) { decodeState.inputPosition += 1; tmp1 = decodeState.input.readByte() != 103; } else { tmp1 = true; } if(!tmp1) { decodeState.inputPosition += 1; tmp = decodeState.input.readByte() != 83; } else { tmp = true; } if(tmp) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.hx", lineNumber : 323, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "capturePattern"})); } this.startWithoutCapturePattern(decodeState); } ,startWithoutCapturePattern: function(decodeState) { decodeState.inputPosition += 1; var version = decodeState.input.readByte(); if(version != 0) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION,"" + version,{ fileName : "Page.hx", lineNumber : 34, className : "kha.audio2.ogg.vorbis.data.Page", methodName : "startWithoutCapturePattern"})); } decodeState.inputPosition += 1; this.flag = decodeState.input.readByte(); decodeState.inputPosition += 4; var loc0 = decodeState.input.readInt32(); decodeState.inputPosition += 4; var loc1 = decodeState.input.readInt32(); decodeState.inputPosition += 4; decodeState.input.readInt32(); decodeState.inputPosition += 4; decodeState.input.readInt32(); decodeState.inputPosition += 4; decodeState.input.readInt32(); decodeState.setup(loc0,loc1); } ,__class__: kha_audio2_ogg_vorbis_data_Page }; var kha_audio2_ogg_vorbis_data_PageFlag = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.PageFlag"] = kha_audio2_ogg_vorbis_data_PageFlag; kha_audio2_ogg_vorbis_data_PageFlag.__name__ = true; var kha_audio2_ogg_vorbis_data_ProbedPage = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.ProbedPage"] = kha_audio2_ogg_vorbis_data_ProbedPage; kha_audio2_ogg_vorbis_data_ProbedPage.__name__ = true; kha_audio2_ogg_vorbis_data_ProbedPage.prototype = { pageStart: null ,pageEnd: null ,afterPreviousPageStart: null ,firstDecodedSample: null ,lastDecodedSample: null ,__class__: kha_audio2_ogg_vorbis_data_ProbedPage }; var kha_audio2_ogg_vorbis_data_ReaderError = function(type,message,posInfos) { if(message == null) { message = ""; } this.type = type; this.message = message; this.posInfos = posInfos; }; $hxClasses["kha.audio2.ogg.vorbis.data.ReaderError"] = kha_audio2_ogg_vorbis_data_ReaderError; kha_audio2_ogg_vorbis_data_ReaderError.__name__ = true; kha_audio2_ogg_vorbis_data_ReaderError.prototype = { type: null ,message: null ,posInfos: null ,__class__: kha_audio2_ogg_vorbis_data_ReaderError }; var kha_audio2_ogg_vorbis_data_ReaderErrorType = $hxClasses["kha.audio2.ogg.vorbis.data.ReaderErrorType"] = { __ename__ : true, __constructs__ : ["NEED_MORE_DATA","INVALID_API_MIXING","OUTOFMEM","FEATURE_NOT_SUPPORTED","TOO_MANY_CHANNELS","FILE_OPEN_FAILURE","SEEK_WITHOUT_LENGTH","UNEXPECTED_EOF","SEEK_INVALID","INVALID_SETUP","INVALID_STREAM","MISSING_CAPTURE_PATTERN","INVALID_STREAM_STRUCTURE_VERSION","CONTINUED_PACKET_FLAG_INVALID","INCORRECT_STREAM_SERIAL_NUMBER","INVALID_FIRST_PAGE","BAD_PACKET_TYPE","CANT_FIND_LAST_PAGE","SEEK_FAILED","OTHER"] }; kha_audio2_ogg_vorbis_data_ReaderErrorType.NEED_MORE_DATA = ["NEED_MORE_DATA",0]; kha_audio2_ogg_vorbis_data_ReaderErrorType.NEED_MORE_DATA.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.NEED_MORE_DATA.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_API_MIXING = ["INVALID_API_MIXING",1]; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_API_MIXING.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_API_MIXING.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.OUTOFMEM = ["OUTOFMEM",2]; kha_audio2_ogg_vorbis_data_ReaderErrorType.OUTOFMEM.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.OUTOFMEM.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED = ["FEATURE_NOT_SUPPORTED",3]; kha_audio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS = ["TOO_MANY_CHANNELS",4]; kha_audio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.FILE_OPEN_FAILURE = ["FILE_OPEN_FAILURE",5]; kha_audio2_ogg_vorbis_data_ReaderErrorType.FILE_OPEN_FAILURE.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.FILE_OPEN_FAILURE.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_WITHOUT_LENGTH = ["SEEK_WITHOUT_LENGTH",6]; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_WITHOUT_LENGTH.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_WITHOUT_LENGTH.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.UNEXPECTED_EOF = ["UNEXPECTED_EOF",7]; kha_audio2_ogg_vorbis_data_ReaderErrorType.UNEXPECTED_EOF.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.UNEXPECTED_EOF.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_INVALID = ["SEEK_INVALID",8]; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_INVALID.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_INVALID.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP = ["INVALID_SETUP",9]; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM = ["INVALID_STREAM",10]; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN = ["MISSING_CAPTURE_PATTERN",11]; kha_audio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION = ["INVALID_STREAM_STRUCTURE_VERSION",12]; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID = ["CONTINUED_PACKET_FLAG_INVALID",13]; kha_audio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.INCORRECT_STREAM_SERIAL_NUMBER = ["INCORRECT_STREAM_SERIAL_NUMBER",14]; kha_audio2_ogg_vorbis_data_ReaderErrorType.INCORRECT_STREAM_SERIAL_NUMBER.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.INCORRECT_STREAM_SERIAL_NUMBER.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE = ["INVALID_FIRST_PAGE",15]; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.BAD_PACKET_TYPE = ["BAD_PACKET_TYPE",16]; kha_audio2_ogg_vorbis_data_ReaderErrorType.BAD_PACKET_TYPE.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.BAD_PACKET_TYPE.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE = ["CANT_FIND_LAST_PAGE",17]; kha_audio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED = ["SEEK_FAILED",18]; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; kha_audio2_ogg_vorbis_data_ReaderErrorType.OTHER = ["OTHER",19]; kha_audio2_ogg_vorbis_data_ReaderErrorType.OTHER.toString = $estr; kha_audio2_ogg_vorbis_data_ReaderErrorType.OTHER.__enum__ = kha_audio2_ogg_vorbis_data_ReaderErrorType; var kha_audio2_ogg_vorbis_data_Residue = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Residue"] = kha_audio2_ogg_vorbis_data_Residue; kha_audio2_ogg_vorbis_data_Residue.__name__ = true; kha_audio2_ogg_vorbis_data_Residue.read = function(decodeState,codebooks) { var r = new kha_audio2_ogg_vorbis_data_Residue(); var tmp; if(decodeState.validBits < 0) { tmp = 0; } else if(decodeState.validBits < 16) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 16)) { break; } } if(decodeState.validBits < 0) { tmp = 0; } else { var z = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp = z; } } else { var z1 = decodeState.acc & 65535; decodeState.acc = decodeState.acc >>> 16; decodeState.validBits -= 16; tmp = z1; } r.type = tmp; if(r.type > 2) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Residue.hx", lineNumber : 29, className : "kha.audio2.ogg.vorbis.data.Residue", methodName : "read"})); } var this1 = new Array(64); var residueCascade = this1; var tmp1; if(decodeState.validBits < 0) { tmp1 = 0; } else if(decodeState.validBits < 24) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 24)) { break; } } if(decodeState.validBits < 0) { tmp1 = 0; } else { var z2 = decodeState.acc & 16777215; decodeState.acc = decodeState.acc >>> 24; decodeState.validBits -= 24; tmp1 = z2; } } else { var z3 = decodeState.acc & 16777215; decodeState.acc = decodeState.acc >>> 24; decodeState.validBits -= 24; tmp1 = z3; } r.begin = tmp1; var tmp2; if(decodeState.validBits < 0) { tmp2 = 0; } else if(decodeState.validBits < 24) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 24)) { break; } } if(decodeState.validBits < 0) { tmp2 = 0; } else { var z4 = decodeState.acc & 16777215; decodeState.acc = decodeState.acc >>> 24; decodeState.validBits -= 24; tmp2 = z4; } } else { var z5 = decodeState.acc & 16777215; decodeState.acc = decodeState.acc >>> 24; decodeState.validBits -= 24; tmp2 = z5; } r.end = tmp2; var tmp3; if(decodeState.validBits < 0) { tmp3 = 0; } else if(decodeState.validBits < 24) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 24)) { break; } } if(decodeState.validBits < 0) { tmp3 = 0; } else { var z6 = decodeState.acc & 16777215; decodeState.acc = decodeState.acc >>> 24; decodeState.validBits -= 24; tmp3 = z6; } } else { var z7 = decodeState.acc & 16777215; decodeState.acc = decodeState.acc >>> 24; decodeState.validBits -= 24; tmp3 = z7; } r.partSize = tmp3 + 1; var classifications; if(decodeState.validBits < 0) { classifications = 0; } else if(decodeState.validBits < 6) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 6)) { break; } } if(decodeState.validBits < 0) { classifications = 0; } else { var z8 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; classifications = z8; } } else { var z9 = decodeState.acc & 63; decodeState.acc = decodeState.acc >>> 6; decodeState.validBits -= 6; classifications = z9; } var classifications1 = r.classifications = classifications + 1; var tmp4; if(decodeState.validBits < 0) { tmp4 = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { tmp4 = 0; } else { var z10 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp4 = z10; } } else { var z11 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; tmp4 = z11; } r.classbook = tmp4; var _g1 = 0; var _g = r.classifications; while(_g1 < _g) { var j = _g1++; var highBits = 0; var lowBits; if(decodeState.validBits < 0) { lowBits = 0; } else if(decodeState.validBits < 3) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 3)) { break; } } if(decodeState.validBits < 0) { lowBits = 0; } else { var z12 = decodeState.acc & 7; decodeState.acc = decodeState.acc >>> 3; decodeState.validBits -= 3; lowBits = z12; } } else { var z13 = decodeState.acc & 7; decodeState.acc = decodeState.acc >>> 3; decodeState.validBits -= 3; lowBits = z13; } var tmp5; if(decodeState.validBits < 0) { tmp5 = 0; } else if(decodeState.validBits < 1) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 1)) { break; } } if(decodeState.validBits < 0) { tmp5 = 0; } else { var z14 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp5 = z14; } } else { var z15 = decodeState.acc & 1; decodeState.acc = decodeState.acc >>> 1; decodeState.validBits -= 1; tmp5 = z15; } if(tmp5 != 0) { if(decodeState.validBits < 0) { highBits = 0; } else if(decodeState.validBits < 5) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 5)) { break; } } if(decodeState.validBits < 0) { highBits = 0; } else { var z16 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; highBits = z16; } } else { var z17 = decodeState.acc & 31; decodeState.acc = decodeState.acc >>> 5; decodeState.validBits -= 5; highBits = z17; } } residueCascade[j] = highBits * 8 + lowBits; } var length = r.classifications; var this2 = new Array(length); r.residueBooks = this2; var _g11 = 0; var _g2 = r.classifications; while(_g11 < _g2) { var j1 = _g11++; var this3 = r.residueBooks; var this4 = new Array(8); this3[j1] = this4; var _g21 = 0; while(_g21 < 8) { var k = _g21++; if((residueCascade[j1] & 1 << k) != 0) { var this5 = r.residueBooks[j1]; var val; if(decodeState.validBits < 0) { val = 0; } else if(decodeState.validBits < 8) { if(decodeState.validBits == 0) { decodeState.acc = 0; } while(true) { if(decodeState.bytesInSeg == 0 && (decodeState.lastSeg || decodeState.next() == 0)) { decodeState.validBits = -1; break; } else { decodeState.bytesInSeg--; decodeState.inputPosition += 1; decodeState.acc = decodeState.acc + (decodeState.input.readByte() << decodeState.validBits); decodeState.validBits += 8; } if(!(decodeState.validBits < 8)) { break; } } if(decodeState.validBits < 0) { val = 0; } else { var z18 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val = z18; } } else { var z19 = decodeState.acc & 255; decodeState.acc = decodeState.acc >>> 8; decodeState.validBits -= 8; val = z19; } this5[k] = val; if(r.residueBooks[j1][k] >= codebooks.length) { throw new js__$Boot_HaxeError(new kha_audio2_ogg_vorbis_data_ReaderError(kha_audio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Residue.hx", lineNumber : 55, className : "kha.audio2.ogg.vorbis.data.Residue", methodName : "read"})); } } else { r.residueBooks[j1][k] = -1; } } } var el = codebooks[r.classbook].entries; var classwords = codebooks[r.classbook].dimensions; var this6 = new Array(el); r.classdata = this6; var _g12 = 0; var _g3 = el; while(_g12 < _g3) { var j2 = _g12++; var temp = j2; var k1 = classwords; var this7 = r.classdata; var this8 = new Array(classwords); var cd = this7[j2] = this8; while(--k1 >= 0) { cd[k1] = temp % classifications1; temp = temp / classifications1 | 0; } } return r; }; kha_audio2_ogg_vorbis_data_Residue.prototype = { begin: null ,end: null ,partSize: null ,classifications: null ,classbook: null ,classdata: null ,residueBooks: null ,type: null ,decode: function(decodeState,header,residueBuffers,ch,n,doNotDecode,channelBuffers) { var codebooks = header.codebooks; var classwords = codebooks[this.classbook].dimensions; var nRead = this.end - this.begin; var partSize = this.partSize; var partRead = _$UInt_UInt_$Impl_$.toFloat(nRead) / _$UInt_UInt_$Impl_$.toFloat(partSize) | 0; var length = header.channel * partRead + 1; var this1 = new Array(length); var classifications = this1; var _g1 = 0; var _g = ch; while(_g1 < _g) { var i = _g1++; if(!doNotDecode[i]) { var buffer = residueBuffers[i]; var _g3 = 0; var _g2 = buffer.length; while(_g3 < _g2) { var j = _g3++; buffer[j] = 0; } } } if(this.type == 2 && ch != 1) { var _g11 = 0; var _g4 = ch; while(_g11 < _g4) { var j1 = _g11++; if(!doNotDecode[j1]) { break; } else if(j1 == ch - 1) { return; } } var _g5 = 0; while(_g5 < 8) { var pass = _g5++; var pcount = 0; var classSet = 0; if(ch == 2) { while(pcount < partRead) { var z = this.begin + pcount * partSize; var cInter = z & 1; var pInter = z >>> 1; if(pass == 0) { var c = codebooks[this.classbook]; if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i1 = c.fastHuffman[decodeState.acc & 1023]; var val; if(i1 >= 0) { var l = c.codewordLengths[i1]; decodeState.acc = decodeState.acc >>> l; decodeState.validBits -= l; if(decodeState.validBits < 0) { decodeState.validBits = 0; val = -1; } else { val = i1; } } else { val = decodeState.decodeScalarRaw(c); } if(c.sparse) { val = c.sortedValues[val]; } var q = val; if(q == -1) { return; } var i2 = classwords; while(--i2 >= 0) { classifications[i2 + pcount] = q % this.classifications; q = q / this.classifications | 0; } } var _g21 = 0; var _g12 = classwords; while(_g21 < _g12) { var i3 = _g21++; if(pcount >= partRead) { break; } var z1 = this.begin + pcount * partSize; var c1 = classifications[pcount]; var b = this.residueBooks[c1][pass]; if(b >= 0) { var book = codebooks[b]; var result = book.decodeDeinterleaveRepeat(decodeState,residueBuffers,ch,cInter,pInter,n,partSize); if(result == null) { return; } else { cInter = result.cInter; pInter = result.pInter; } } else { z1 = z1 + partSize; cInter = z1 & 1; pInter = z1 >>> 1; } ++pcount; } } } else if(ch == 1) { while(pcount < partRead) { var z2 = this.begin + pcount * partSize; var cInter1 = 0; var pInter1 = z2; if(pass == 0) { var c2 = codebooks[this.classbook]; if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i4 = c2.fastHuffman[decodeState.acc & 1023]; var val1; if(i4 >= 0) { var l1 = c2.codewordLengths[i4]; decodeState.acc = decodeState.acc >>> l1; decodeState.validBits -= l1; if(decodeState.validBits < 0) { decodeState.validBits = 0; val1 = -1; } else { val1 = i4; } } else { val1 = decodeState.decodeScalarRaw(c2); } if(c2.sparse) { val1 = c2.sortedValues[val1]; } var q1 = val1; if(q1 == -1) { return; } var i5 = classwords; while(--i5 >= 0) { classifications[i5 + pcount] = q1 % this.classifications; q1 = q1 / this.classifications | 0; } } var _g22 = 0; var _g13 = classwords; while(_g22 < _g13) { var i6 = _g22++; if(pcount >= partRead) { break; } var z3 = this.begin + pcount * partSize; var b1 = this.residueBooks[classifications[pcount]][pass]; if(b1 >= 0) { var book1 = codebooks[b1]; var result1 = book1.decodeDeinterleaveRepeat(decodeState,residueBuffers,ch,cInter1,pInter1,n,partSize); if(result1 == null) { return; } else { cInter1 = result1.cInter; pInter1 = result1.pInter; } } else { z3 = z3 + partSize; cInter1 = 0; pInter1 = z3; } ++pcount; } } } else { while(pcount < partRead) { var z4 = this.begin + pcount * partSize; var cInter2 = _$UInt_UInt_$Impl_$.toFloat(z4) % _$UInt_UInt_$Impl_$.toFloat(ch) | 0; var pInter2 = _$UInt_UInt_$Impl_$.toFloat(z4) / _$UInt_UInt_$Impl_$.toFloat(ch) | 0; if(pass == 0) { var c3 = codebooks[this.classbook]; if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i7 = c3.fastHuffman[decodeState.acc & 1023]; var val2; if(i7 >= 0) { var l2 = c3.codewordLengths[i7]; decodeState.acc = decodeState.acc >>> l2; decodeState.validBits -= l2; if(decodeState.validBits < 0) { decodeState.validBits = 0; val2 = -1; } else { val2 = i7; } } else { val2 = decodeState.decodeScalarRaw(c3); } if(c3.sparse) { val2 = c3.sortedValues[val2]; } var q2 = val2; if(q2 == -1) { return; } var i8 = classwords; while(--i8 >= 0) { classifications[i8 + pcount] = q2 % this.classifications; q2 = q2 / this.classifications | 0; } } var _g23 = 0; var _g14 = classwords; while(_g23 < _g14) { var i9 = _g23++; if(pcount >= partRead) { break; } var z5 = this.begin + pcount * partSize; var b2 = this.residueBooks[classifications[pcount]][pass]; if(b2 >= 0) { var book2 = codebooks[b2]; var result2 = book2.decodeDeinterleaveRepeat(decodeState,residueBuffers,ch,cInter2,pInter2,n,partSize); if(result2 == null) { return; } else { cInter2 = result2.cInter; pInter2 = result2.pInter; } } else { z5 = z5 + partSize; cInter2 = _$UInt_UInt_$Impl_$.toFloat(z5) % _$UInt_UInt_$Impl_$.toFloat(ch) | 0; pInter2 = _$UInt_UInt_$Impl_$.toFloat(z5) / _$UInt_UInt_$Impl_$.toFloat(ch) | 0; } ++pcount; } } } } return; } var _g6 = 0; while(_g6 < 8) { var pass1 = _g6++; var pcount1 = 0; var classSet1 = 0; while(pcount1 < partRead) { if(pass1 == 0) { var _g24 = 0; var _g15 = ch; while(_g24 < _g15) { var j2 = _g24++; if(!doNotDecode[j2]) { var c4 = codebooks[this.classbook]; if(decodeState.validBits < 10) { decodeState.prepHuffman(); } var i10 = c4.fastHuffman[decodeState.acc & 1023]; var val3; if(i10 >= 0) { var l3 = c4.codewordLengths[i10]; decodeState.acc = decodeState.acc >>> l3; decodeState.validBits -= l3; if(decodeState.validBits < 0) { decodeState.validBits = 0; val3 = -1; } else { val3 = i10; } } else { val3 = decodeState.decodeScalarRaw(c4); } if(c4.sparse) { val3 = c4.sortedValues[val3]; } var temp = val3; if(temp == -1) { return; } var i11 = classwords; while(--i11 >= 0) { classifications[j2 * partRead + i11 + pcount1] = temp % this.classifications; temp = temp / this.classifications | 0; } } } } var _g25 = 0; var _g16 = classwords; while(_g25 < _g16) { var i12 = _g25++; if(pcount1 >= partRead) { break; } var _g41 = 0; var _g31 = ch; while(_g41 < _g31) { var j3 = _g41++; if(!doNotDecode[j3]) { var c5 = classifications[j3 * partRead + pcount1]; var b3 = this.residueBooks[c5][pass1]; if(b3 >= 0) { var target = residueBuffers[j3]; var offset = this.begin + pcount1 * partSize; var n1 = partSize; var book3 = codebooks[b3]; if(!book3.residueDecode(decodeState,target,offset,n1,this.type)) { return; } } } } ++pcount1; } } } } ,__class__: kha_audio2_ogg_vorbis_data_Residue }; var kha_audio2_ogg_vorbis_data_Setting = function() { }; $hxClasses["kha.audio2.ogg.vorbis.data.Setting"] = kha_audio2_ogg_vorbis_data_Setting; kha_audio2_ogg_vorbis_data_Setting.__name__ = true; var kha_graphics1_Graphics = function() { }; $hxClasses["kha.graphics1.Graphics"] = kha_graphics1_Graphics; kha_graphics1_Graphics.__name__ = true; kha_graphics1_Graphics.prototype = { begin: null ,end: null ,setPixel: null ,__class__: kha_graphics1_Graphics }; var kha_graphics2_Graphics = function() { this.transformations = []; this.transformations.push(new kha_math_FastMatrix3(1,0,0,0,1,0,0,0,1)); this.opacities = []; this.opacities.push(1); this.myFontSize = 12; this.myFontGlyphs = []; var _g = 32; while(_g < 256) { var i = _g++; this.myFontGlyphs.push(i); } this.pipe = null; }; $hxClasses["kha.graphics2.Graphics"] = kha_graphics2_Graphics; kha_graphics2_Graphics.__name__ = true; kha_graphics2_Graphics.prototype = { begin: function(clear,clearColor) { if(clear == null) { clear = true; } } ,end: function() { } ,flush: function() { } ,clear: function(color) { } ,drawImage: function(img,x,y) { this.drawSubImage(img,x,y,0,0,img.get_width(),img.get_height()); } ,drawSubImage: function(img,x,y,sx,sy,sw,sh) { this.drawScaledSubImage(img,sx,sy,sw,sh,x,y,sw,sh); } ,drawScaledImage: function(img,dx,dy,dw,dh) { this.drawScaledSubImage(img,0,0,img.get_width(),img.get_height(),dx,dy,dw,dh); } ,drawScaledSubImage: function(image,sx,sy,sw,sh,dx,dy,dw,dh) { } ,drawRect: function(x,y,width,height,strength) { if(strength == null) { strength = 1.0; } } ,fillRect: function(x,y,width,height) { } ,drawString: function(text,x,y) { } ,drawLine: function(x1,y1,x2,y2,strength) { if(strength == null) { strength = 1.0; } } ,drawVideo: function(video,x,y,width,height) { } ,fillTriangle: function(x1,y1,x2,y2,x3,y3) { } ,get_imageScaleQuality: function() { return kha_graphics2_ImageScaleQuality.Low; } ,set_imageScaleQuality: function(value) { return kha_graphics2_ImageScaleQuality.High; } ,get_mipmapScaleQuality: function() { return kha_graphics2_ImageScaleQuality.Low; } ,set_mipmapScaleQuality: function(value) { return kha_graphics2_ImageScaleQuality.High; } ,get_color: function() { return -16777216; } ,set_color: function(color) { return -16777216; } ,get_font: function() { return null; } ,set_font: function(font) { return null; } ,get_fontSize: function() { return this.myFontSize; } ,set_fontSize: function(value) { return this.myFontSize = value; } ,get_fontGlyphs: function() { return this.myFontGlyphs; } ,set_fontGlyphs: function(value) { return this.myFontGlyphs = value; } ,pushTransformation: function(transformation) { var trans = new kha_math_FastMatrix3(1,0,0,0,1,0,0,0,1); trans._00 = transformation._00; trans._10 = transformation._10; trans._20 = transformation._20; trans._01 = transformation._01; trans._11 = transformation._11; trans._21 = transformation._21; trans._02 = transformation._02; trans._12 = transformation._12; trans._22 = transformation._22; this.setTransformation(trans); this.transformations.push(trans); } ,popTransformation: function() { var ret = this.transformations.pop(); this.setTransformation(this.transformations[this.transformations.length - 1]); return ret; } ,get_transformation: function() { return this.transformations[this.transformations.length - 1]; } ,set_transformation: function(transformation) { this.setTransformation(transformation); var _this = this.transformations[this.transformations.length - 1]; _this._00 = transformation._00; _this._10 = transformation._10; _this._20 = transformation._20; _this._01 = transformation._01; _this._11 = transformation._11; _this._21 = transformation._21; _this._02 = transformation._02; _this._12 = transformation._12; _this._22 = transformation._22; return transformation; } ,translation: function(tx,ty) { var _this__22; var _this__21; var _this__20; var _this__12; var _this__11; var _this__10; var _this__02; var _this__01; var _this__00 = 1; _this__10 = 0; _this__20 = tx; _this__01 = 0; _this__11 = 1; _this__21 = ty; _this__02 = 0; _this__12 = 0; _this__22 = 1; var m = this.transformations[this.transformations.length - 1]; return new kha_math_FastMatrix3(_this__00 * m._00 + _this__10 * m._01 + _this__20 * m._02,_this__00 * m._10 + _this__10 * m._11 + _this__20 * m._12,_this__00 * m._20 + _this__10 * m._21 + _this__20 * m._22,_this__01 * m._00 + _this__11 * m._01 + _this__21 * m._02,_this__01 * m._10 + _this__11 * m._11 + _this__21 * m._12,_this__01 * m._20 + _this__11 * m._21 + _this__21 * m._22,_this__02 * m._00 + _this__12 * m._01 + _this__22 * m._02,_this__02 * m._10 + _this__12 * m._11 + _this__22 * m._12,_this__02 * m._20 + _this__12 * m._21 + _this__22 * m._22); } ,translate: function(tx,ty) { var _this__22; var _this__21; var _this__20; var _this__12; var _this__11; var _this__10; var _this__02; var _this__01; var _this__00 = 1; _this__10 = 0; _this__20 = tx; _this__01 = 0; _this__11 = 1; _this__21 = ty; _this__02 = 0; _this__12 = 0; _this__22 = 1; var m = this.transformations[this.transformations.length - 1]; var transformation = new kha_math_FastMatrix3(_this__00 * m._00 + _this__10 * m._01 + _this__20 * m._02,_this__00 * m._10 + _this__10 * m._11 + _this__20 * m._12,_this__00 * m._20 + _this__10 * m._21 + _this__20 * m._22,_this__01 * m._00 + _this__11 * m._01 + _this__21 * m._02,_this__01 * m._10 + _this__11 * m._11 + _this__21 * m._12,_this__01 * m._20 + _this__11 * m._21 + _this__21 * m._22,_this__02 * m._00 + _this__12 * m._01 + _this__22 * m._02,_this__02 * m._10 + _this__12 * m._11 + _this__22 * m._12,_this__02 * m._20 + _this__12 * m._21 + _this__22 * m._22); this.setTransformation(transformation); var _this = this.transformations[this.transformations.length - 1]; _this._00 = transformation._00; _this._10 = transformation._10; _this._20 = transformation._20; _this._01 = transformation._01; _this._11 = transformation._11; _this._21 = transformation._21; _this._02 = transformation._02; _this._12 = transformation._12; _this._22 = transformation._22; } ,pushTranslation: function(tx,ty) { var _this__22; var _this__21; var _this__20; var _this__12; var _this__11; var _this__10; var _this__02; var _this__01; var _this__00 = 1; _this__10 = 0; _this__20 = tx; _this__01 = 0; _this__11 = 1; _this__21 = ty; _this__02 = 0; _this__12 = 0; _this__22 = 1; var m = this.transformations[this.transformations.length - 1]; this.pushTransformation(new kha_math_FastMatrix3(_this__00 * m._00 + _this__10 * m._01 + _this__20 * m._02,_this__00 * m._10 + _this__10 * m._11 + _this__20 * m._12,_this__00 * m._20 + _this__10 * m._21 + _this__20 * m._22,_this__01 * m._00 + _this__11 * m._01 + _this__21 * m._02,_this__01 * m._10 + _this__11 * m._11 + _this__21 * m._12,_this__01 * m._20 + _this__11 * m._21 + _this__21 * m._22,_this__02 * m._00 + _this__12 * m._01 + _this__22 * m._02,_this__02 * m._10 + _this__12 * m._11 + _this__22 * m._12,_this__02 * m._20 + _this__12 * m._21 + _this__22 * m._22)); } ,rotation: function(angle,centerx,centery) { var _this__22; var _this__21; var _this__20; var _this__12; var _this__11; var _this__10; var _this__02; var _this__01; var _this__00; var _this__221; var _this__211; var _this__201; var _this__121; var _this__111; var _this__101; var _this__021; var _this__011; var _this__001; var _this__222; var _this__212; var _this__202; var _this__122; var _this__112; var _this__102; var _this__022; var _this__012; var _this__002 = 1; _this__102 = 0; _this__202 = centerx; _this__012 = 0; _this__112 = 1; _this__212 = centery; _this__022 = 0; _this__122 = 0; _this__222 = 1; var m__22; var m__21; var m__20; var m__12; var m__11; var m__10; var m__02; var m__01; var m__00 = Math.cos(angle); m__10 = -Math.sin(angle); m__20 = 0; m__01 = Math.sin(angle); m__11 = Math.cos(angle); m__21 = 0; m__02 = 0; m__12 = 0; m__22 = 1; _this__001 = _this__002 * m__00 + _this__102 * m__01 + _this__202 * m__02; _this__101 = _this__002 * m__10 + _this__102 * m__11 + _this__202 * m__12; _this__201 = _this__002 * m__20 + _this__102 * m__21 + _this__202 * m__22; _this__011 = _this__012 * m__00 + _this__112 * m__01 + _this__212 * m__02; _this__111 = _this__012 * m__10 + _this__112 * m__11 + _this__212 * m__12; _this__211 = _this__012 * m__20 + _this__112 * m__21 + _this__212 * m__22; _this__021 = _this__022 * m__00 + _this__122 * m__01 + _this__222 * m__02; _this__121 = _this__022 * m__10 + _this__122 * m__11 + _this__222 * m__12; _this__221 = _this__022 * m__20 + _this__122 * m__21 + _this__222 * m__22; var m__221; var m__211; var m__201; var m__121; var m__111; var m__101; var m__021; var m__011; var m__001 = 1; m__101 = 0; m__201 = -centerx; m__011 = 0; m__111 = 1; m__211 = -centery; m__021 = 0; m__121 = 0; m__221 = 1; _this__00 = _this__001 * m__001 + _this__101 * m__011 + _this__201 * m__021; _this__10 = _this__001 * m__101 + _this__101 * m__111 + _this__201 * m__121; _this__20 = _this__001 * m__201 + _this__101 * m__211 + _this__201 * m__221; _this__01 = _this__011 * m__001 + _this__111 * m__011 + _this__211 * m__021; _this__11 = _this__011 * m__101 + _this__111 * m__111 + _this__211 * m__121; _this__21 = _this__011 * m__201 + _this__111 * m__211 + _this__211 * m__221; _this__02 = _this__021 * m__001 + _this__121 * m__011 + _this__221 * m__021; _this__12 = _this__021 * m__101 + _this__121 * m__111 + _this__221 * m__121; _this__22 = _this__021 * m__201 + _this__121 * m__211 + _this__221 * m__221; var m = this.transformations[this.transformations.length - 1]; return new kha_math_FastMatrix3(_this__00 * m._00 + _this__10 * m._01 + _this__20 * m._02,_this__00 * m._10 + _this__10 * m._11 + _this__20 * m._12,_this__00 * m._20 + _this__10 * m._21 + _this__20 * m._22,_this__01 * m._00 + _this__11 * m._01 + _this__21 * m._02,_this__01 * m._10 + _this__11 * m._11 + _this__21 * m._12,_this__01 * m._20 + _this__11 * m._21 + _this__21 * m._22,_this__02 * m._00 + _this__12 * m._01 + _this__22 * m._02,_this__02 * m._10 + _this__12 * m._11 + _this__22 * m._12,_this__02 * m._20 + _this__12 * m._21 + _this__22 * m._22); } ,rotate: function(angle,centerx,centery) { var temp__22; var temp__21; var temp__20; var temp__12; var temp__11; var temp__10; var temp__02; var temp__01; var temp__00; var _this__22; var _this__21; var _this__20; var _this__12; var _this__11; var _this__10; var _this__02; var _this__01; var _this__00; var _this__221; var _this__211; var _this__201; var _this__121; var _this__111; var _this__101; var _this__021; var _this__011; var _this__001; var _this__222; var _this__212; var _this__202; var _this__122; var _this__112; var _this__102; var _this__022; var _this__012; var _this__002 = 1; _this__102 = 0; _this__202 = centerx; _this__012 = 0; _this__112 = 1; _this__212 = centery; _this__022 = 0; _this__122 = 0; _this__222 = 1; var m__22; var m__21; var m__20; var m__12; var m__11; var m__10; var m__02; var m__01; var m__00 = Math.cos(angle); m__10 = -Math.sin(angle); m__20 = 0; m__01 = Math.sin(angle); m__11 = Math.cos(angle); m__21 = 0; m__02 = 0; m__12 = 0; m__22 = 1; _this__001 = _this__002 * m__00 + _this__102 * m__01 + _this__202 * m__02; _this__101 = _this__002 * m__10 + _this__102 * m__11 + _this__202 * m__12; _this__201 = _this__002 * m__20 + _this__102 * m__21 + _this__202 * m__22; _this__011 = _this__012 * m__00 + _this__112 * m__01 + _this__212 * m__02; _this__111 = _this__012 * m__10 + _this__112 * m__11 + _this__212 * m__12; _this__211 = _this__012 * m__20 + _this__112 * m__21 + _this__212 * m__22; _this__021 = _this__022 * m__00 + _this__122 * m__01 + _this__222 * m__02; _this__121 = _this__022 * m__10 + _this__122 * m__11 + _this__222 * m__12; _this__221 = _this__022 * m__20 + _this__122 * m__21 + _this__222 * m__22; var m__221; var m__211; var m__201; var m__121; var m__111; var m__101; var m__021; var m__011; var m__001 = 1; m__101 = 0; m__201 = -centerx; m__011 = 0; m__111 = 1; m__211 = -centery; m__021 = 0; m__121 = 0; m__221 = 1; _this__00 = _this__001 * m__001 + _this__101 * m__011 + _this__201 * m__021; _this__10 = _this__001 * m__101 + _this__101 * m__111 + _this__201 * m__121; _this__20 = _this__001 * m__201 + _this__101 * m__211 + _this__201 * m__221; _this__01 = _this__011 * m__001 + _this__111 * m__011 + _this__211 * m__021; _this__11 = _this__011 * m__101 + _this__111 * m__111 + _this__211 * m__121; _this__21 = _this__011 * m__201 + _this__111 * m__211 + _this__211 * m__221; _this__02 = _this__021 * m__001 + _this__121 * m__011 + _this__221 * m__021; _this__12 = _this__021 * m__101 + _this__121 * m__111 + _this__221 * m__121; _this__22 = _this__021 * m__201 + _this__121 * m__211 + _this__221 * m__221; var m = this.transformations[this.transformations.length - 1]; temp__00 = _this__00 * m._00 + _this__10 * m._01 + _this__20 * m._02; temp__10 = _this__00 * m._10 + _this__10 * m._11 + _this__20 * m._12; temp__20 = _this__00 * m._20 + _this__10 * m._21 + _this__20 * m._22; temp__01 = _this__01 * m._00 + _this__11 * m._01 + _this__21 * m._02; temp__11 = _this__01 * m._10 + _this__11 * m._11 + _this__21 * m._12; temp__21 = _this__01 * m._20 + _this__11 * m._21 + _this__21 * m._22; temp__02 = _this__02 * m._00 + _this__12 * m._01 + _this__22 * m._02; temp__12 = _this__02 * m._10 + _this__12 * m._11 + _this__22 * m._12; temp__22 = _this__02 * m._20 + _this__12 * m._21 + _this__22 * m._22; this.transformations[this.transformations.length - 1]._00 = temp__00; this.transformations[this.transformations.length - 1]._01 = temp__01; this.transformations[this.transformations.length - 1]._02 = temp__02; this.transformations[this.transformations.length - 1]._10 = temp__10; this.transformations[this.transformations.length - 1]._11 = temp__11; this.transformations[this.transformations.length - 1]._12 = temp__12; this.transformations[this.transformations.length - 1]._20 = temp__20; this.transformations[this.transformations.length - 1]._21 = temp__21; this.transformations[this.transformations.length - 1]._22 = temp__22; } ,pushRotation: function(angle,centerx,centery) { var _this__22; var _this__21; var _this__20; var _this__12; var _this__11; var _this__10; var _this__02; var _this__01; var _this__00; var _this__221; var _this__211; var _this__201; var _this__121; var _this__111; var _this__101; var _this__021; var _this__011; var _this__001; var _this__222; var _this__212; var _this__202; var _this__122; var _this__112; var _this__102; var _this__022; var _this__012; var _this__002 = 1; _this__102 = 0; _this__202 = centerx; _this__012 = 0; _this__112 = 1; _this__212 = centery; _this__022 = 0; _this__122 = 0; _this__222 = 1; var m__22; var m__21; var m__20; var m__12; var m__11; var m__10; var m__02; var m__01; var m__00 = Math.cos(angle); m__10 = -Math.sin(angle); m__20 = 0; m__01 = Math.sin(angle); m__11 = Math.cos(angle); m__21 = 0; m__02 = 0; m__12 = 0; m__22 = 1; _this__001 = _this__002 * m__00 + _this__102 * m__01 + _this__202 * m__02; _this__101 = _this__002 * m__10 + _this__102 * m__11 + _this__202 * m__12; _this__201 = _this__002 * m__20 + _this__102 * m__21 + _this__202 * m__22; _this__011 = _this__012 * m__00 + _this__112 * m__01 + _this__212 * m__02; _this__111 = _this__012 * m__10 + _this__112 * m__11 + _this__212 * m__12; _this__211 = _this__012 * m__20 + _this__112 * m__21 + _this__212 * m__22; _this__021 = _this__022 * m__00 + _this__122 * m__01 + _this__222 * m__02; _this__121 = _this__022 * m__10 + _this__122 * m__11 + _this__222 * m__12; _this__221 = _this__022 * m__20 + _this__122 * m__21 + _this__222 * m__22; var m__221; var m__211; var m__201; var m__121; var m__111; var m__101; var m__021; var m__011; var m__001 = 1; m__101 = 0; m__201 = -centerx; m__011 = 0; m__111 = 1; m__211 = -centery; m__021 = 0; m__121 = 0; m__221 = 1; _this__00 = _this__001 * m__001 + _this__101 * m__011 + _this__201 * m__021; _this__10 = _this__001 * m__101 + _this__101 * m__111 + _this__201 * m__121; _this__20 = _this__001 * m__201 + _this__101 * m__211 + _this__201 * m__221; _this__01 = _this__011 * m__001 + _this__111 * m__011 + _this__211 * m__021; _this__11 = _this__011 * m__101 + _this__111 * m__111 + _this__211 * m__121; _this__21 = _this__011 * m__201 + _this__111 * m__211 + _this__211 * m__221; _this__02 = _this__021 * m__001 + _this__121 * m__011 + _this__221 * m__021; _this__12 = _this__021 * m__101 + _this__121 * m__111 + _this__221 * m__121; _this__22 = _this__021 * m__201 + _this__121 * m__211 + _this__221 * m__221; var m = this.transformations[this.transformations.length - 1]; this.pushTransformation(new kha_math_FastMatrix3(_this__00 * m._00 + _this__10 * m._01 + _this__20 * m._02,_this__00 * m._10 + _this__10 * m._11 + _this__20 * m._12,_this__00 * m._20 + _this__10 * m._21 + _this__20 * m._22,_this__01 * m._00 + _this__11 * m._01 + _this__21 * m._02,_this__01 * m._10 + _this__11 * m._11 + _this__21 * m._12,_this__01 * m._20 + _this__11 * m._21 + _this__21 * m._22,_this__02 * m._00 + _this__12 * m._01 + _this__22 * m._02,_this__02 * m._10 + _this__12 * m._11 + _this__22 * m._12,_this__02 * m._20 + _this__12 * m._21 + _this__22 * m._22)); } ,pushOpacity: function(opacity) { this.setOpacity(opacity); this.opacities.push(opacity); } ,popOpacity: function() { var ret = this.opacities.pop(); this.setOpacity(this.get_opacity()); return ret; } ,get_opacity: function() { return this.opacities[this.opacities.length - 1]; } ,set_opacity: function(opacity) { this.setOpacity(opacity); return this.opacities[this.opacities.length - 1] = opacity; } ,scissor: function(x,y,width,height) { } ,disableScissor: function() { } ,pipe: null ,get_pipeline: function() { return this.pipe; } ,set_pipeline: function(pipeline) { this.setPipeline(pipeline); return this.pipe = pipeline; } ,transformations: null ,opacities: null ,myFontSize: null ,myFontGlyphs: null ,setTransformation: function(transformation) { } ,setOpacity: function(opacity) { } ,setPipeline: function(pipeline) { } ,__class__: kha_graphics2_Graphics }; var kha_graphics2_Graphics1 = function(canvas) { this.canvas = canvas; }; $hxClasses["kha.graphics2.Graphics1"] = kha_graphics2_Graphics1; kha_graphics2_Graphics1.__name__ = true; kha_graphics2_Graphics1.__interfaces__ = [kha_graphics1_Graphics]; kha_graphics2_Graphics1.prototype = { canvas: null ,texture: null ,pixels: null ,begin: function() { if(this.texture == null) { this.texture = kha_Image.create(this.canvas.get_width(),this.canvas.get_height(),kha_graphics4_TextureFormat.RGBA32,kha_graphics4_Usage.ReadableUsage); } this.pixels = this.texture.lock(); } ,end: function() { this.texture.unlock(); this.canvas.get_g2().begin(); this.canvas.get_g2().drawImage(this.texture,0,0); this.canvas.get_g2().end(); } ,setPixel: function(x,y,color) { this.pixels.setInt32(y * this.texture.get_realWidth() * 4 + x * 4,kha__$Color_Color_$Impl_$.fromBytes(color & 255,(color & 65280) >>> 8,(color & 16711680) >>> 16,color >>> 24)); } ,__class__: kha_graphics2_Graphics1 }; var kha_graphics2_ImageScaleQuality = $hxClasses["kha.graphics2.ImageScaleQuality"] = { __ename__ : true, __constructs__ : ["Low","High"] }; kha_graphics2_ImageScaleQuality.Low = ["Low",0]; kha_graphics2_ImageScaleQuality.Low.toString = $estr; kha_graphics2_ImageScaleQuality.Low.__enum__ = kha_graphics2_ImageScaleQuality; kha_graphics2_ImageScaleQuality.High = ["High",1]; kha_graphics2_ImageScaleQuality.High.toString = $estr; kha_graphics2_ImageScaleQuality.High.__enum__ = kha_graphics2_ImageScaleQuality; var kha_graphics2_truetype_VectorOfIntPointer = function() { }; $hxClasses["kha.graphics2.truetype.VectorOfIntPointer"] = kha_graphics2_truetype_VectorOfIntPointer; kha_graphics2_truetype_VectorOfIntPointer.__name__ = true; kha_graphics2_truetype_VectorOfIntPointer.prototype = { value: null ,__class__: kha_graphics2_truetype_VectorOfIntPointer }; var kha_graphics2_truetype_Stbtt_$temp_$rect = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_temp_rect"] = kha_graphics2_truetype_Stbtt_$temp_$rect; kha_graphics2_truetype_Stbtt_$temp_$rect.__name__ = true; kha_graphics2_truetype_Stbtt_$temp_$rect.prototype = { x0: null ,y0: null ,x1: null ,y1: null ,__class__: kha_graphics2_truetype_Stbtt_$temp_$rect }; var kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_temp_glyph_h_metrics"] = kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics; kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics.__name__ = true; kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics.prototype = { advanceWidth: null ,leftSideBearing: null ,__class__: kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics }; var kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_temp_font_v_metrics"] = kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics; kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics.__name__ = true; kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics.prototype = { ascent: null ,descent: null ,lineGap: null ,__class__: kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics }; var kha_graphics2_truetype_Stbtt_$temp_$region = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_temp_region"] = kha_graphics2_truetype_Stbtt_$temp_$region; kha_graphics2_truetype_Stbtt_$temp_$region.__name__ = true; kha_graphics2_truetype_Stbtt_$temp_$region.prototype = { width: null ,height: null ,xoff: null ,yoff: null ,__class__: kha_graphics2_truetype_Stbtt_$temp_$region }; var kha_graphics2_truetype_Stbtt_$bakedchar = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_bakedchar"] = kha_graphics2_truetype_Stbtt_$bakedchar; kha_graphics2_truetype_Stbtt_$bakedchar.__name__ = true; kha_graphics2_truetype_Stbtt_$bakedchar.prototype = { x0: null ,y0: null ,x1: null ,y1: null ,xoff: null ,yoff: null ,xadvance: null ,__class__: kha_graphics2_truetype_Stbtt_$bakedchar }; var kha_graphics2_truetype_Stbtt_$aligned_$quad = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_aligned_quad"] = kha_graphics2_truetype_Stbtt_$aligned_$quad; kha_graphics2_truetype_Stbtt_$aligned_$quad.__name__ = true; kha_graphics2_truetype_Stbtt_$aligned_$quad.prototype = { x0: null ,y0: null ,s0: null ,t0: null ,x1: null ,y1: null ,s1: null ,t1: null ,__class__: kha_graphics2_truetype_Stbtt_$aligned_$quad }; var kha_graphics2_truetype_Stbtt_$packedchar = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_packedchar"] = kha_graphics2_truetype_Stbtt_$packedchar; kha_graphics2_truetype_Stbtt_$packedchar.__name__ = true; kha_graphics2_truetype_Stbtt_$packedchar.prototype = { x0: null ,y0: null ,x1: null ,y1: null ,xoff: null ,yoff: null ,xadvance: null ,xoff2: null ,yoff2: null ,__class__: kha_graphics2_truetype_Stbtt_$packedchar }; var kha_graphics2_truetype_Stbtt_$pack_$range = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_pack_range"] = kha_graphics2_truetype_Stbtt_$pack_$range; kha_graphics2_truetype_Stbtt_$pack_$range.__name__ = true; kha_graphics2_truetype_Stbtt_$pack_$range.prototype = { font_size: null ,first_unicode_codepoint_in_range: null ,array_of_unicode_codepoints: null ,num_chars: null ,chardata_for_range: null ,h_oversample: null ,v_oversample: null ,__class__: kha_graphics2_truetype_Stbtt_$pack_$range }; var kha_graphics2_truetype_Stbtt_$pack_$context = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_pack_context"] = kha_graphics2_truetype_Stbtt_$pack_$context; kha_graphics2_truetype_Stbtt_$pack_$context.__name__ = true; kha_graphics2_truetype_Stbtt_$pack_$context.prototype = { width: null ,height: null ,stride_in_bytes: null ,padding: null ,h_oversample: null ,v_oversample: null ,pixels: null ,__class__: kha_graphics2_truetype_Stbtt_$pack_$context }; var kha_graphics2_truetype_Stbtt_$fontinfo = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_fontinfo"] = kha_graphics2_truetype_Stbtt_$fontinfo; kha_graphics2_truetype_Stbtt_$fontinfo.__name__ = true; kha_graphics2_truetype_Stbtt_$fontinfo.prototype = { data: null ,fontstart: null ,numGlyphs: null ,loca: null ,head: null ,glyf: null ,hhea: null ,hmtx: null ,kern: null ,index_map: null ,indexToLocFormat: null ,__class__: kha_graphics2_truetype_Stbtt_$fontinfo }; var kha_graphics2_truetype_Stbtt_$vertex = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt_vertex"] = kha_graphics2_truetype_Stbtt_$vertex; kha_graphics2_truetype_Stbtt_$vertex.__name__ = true; kha_graphics2_truetype_Stbtt_$vertex.prototype = { x: null ,y: null ,cx: null ,cy: null ,type: null ,padding: null ,__class__: kha_graphics2_truetype_Stbtt_$vertex }; var kha_graphics2_truetype_Stbtt_$_$bitmap = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt__bitmap"] = kha_graphics2_truetype_Stbtt_$_$bitmap; kha_graphics2_truetype_Stbtt_$_$bitmap.__name__ = true; kha_graphics2_truetype_Stbtt_$_$bitmap.prototype = { w: null ,h: null ,stride: null ,pixels: null ,pixels_offset: null ,__class__: kha_graphics2_truetype_Stbtt_$_$bitmap }; var kha_graphics2_truetype_Stbtt_$_$edge = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt__edge"] = kha_graphics2_truetype_Stbtt_$_$edge; kha_graphics2_truetype_Stbtt_$_$edge.__name__ = true; kha_graphics2_truetype_Stbtt_$_$edge.prototype = { x0: null ,y0: null ,x1: null ,y1: null ,invert: null ,__class__: kha_graphics2_truetype_Stbtt_$_$edge }; var kha_graphics2_truetype_Stbtt_$_$active_$edge = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt__active_edge"] = kha_graphics2_truetype_Stbtt_$_$active_$edge; kha_graphics2_truetype_Stbtt_$_$active_$edge.__name__ = true; kha_graphics2_truetype_Stbtt_$_$active_$edge.prototype = { next: null ,fx: null ,fdx: null ,fdy: null ,direction: null ,sy: null ,ey: null ,__class__: kha_graphics2_truetype_Stbtt_$_$active_$edge }; var kha_graphics2_truetype_Stbtt_$_$point = function() { }; $hxClasses["kha.graphics2.truetype.Stbtt__point"] = kha_graphics2_truetype_Stbtt_$_$point; kha_graphics2_truetype_Stbtt_$_$point.__name__ = true; kha_graphics2_truetype_Stbtt_$_$point.prototype = { x: null ,y: null ,__class__: kha_graphics2_truetype_Stbtt_$_$point }; var kha_graphics2_truetype_StbTruetype = function() { }; $hxClasses["kha.graphics2.truetype.StbTruetype"] = kha_graphics2_truetype_StbTruetype; kha_graphics2_truetype_StbTruetype.__name__ = true; kha_graphics2_truetype_StbTruetype.STBTT_assert = function(value) { if(!value) { throw new js__$Boot_HaxeError("Error"); } }; kha_graphics2_truetype_StbTruetype.STBTT_POINT_SIZE = function(x) { return -x; }; kha_graphics2_truetype_StbTruetype.ttBYTE = function(p,pos) { if(pos == null) { pos = 0; } return p.readU8(pos); }; kha_graphics2_truetype_StbTruetype.ttCHAR = function(p,pos) { if(pos == null) { pos = 0; } var n = p.readU8(pos); if(n >= 128) { return n - 256; } return n; }; kha_graphics2_truetype_StbTruetype.ttUSHORT = function(p,pos) { if(pos == null) { pos = 0; } var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); return ch2 | ch1 << 8; }; kha_graphics2_truetype_StbTruetype.ttSHORT = function(p,pos) { if(pos == null) { pos = 0; } var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var n = ch2 | ch1 << 8; if((n & 32768) != 0) { return n - 65536; } return n; }; kha_graphics2_truetype_StbTruetype.ttULONG = function(p,pos) { if(pos == null) { pos = 0; } var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var ch3 = p.readU8(pos + 2); var ch4 = p.readU8(pos + 3); return ch4 | ch3 << 8 | ch2 << 16 | ch1 << 24; }; kha_graphics2_truetype_StbTruetype.ttLONG = function(p,pos) { if(pos == null) { pos = 0; } var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var ch3 = p.readU8(pos + 2); var ch4 = p.readU8(pos + 3); return ch4 | ch3 << 8 | ch2 << 16 | ch1 << 24; }; kha_graphics2_truetype_StbTruetype.ttFixed = function(p,pos) { if(pos == null) { pos = 0; } var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var ch3 = p.readU8(pos + 2); var ch4 = p.readU8(pos + 3); return ch4 | ch3 << 8 | ch2 << 16 | ch1 << 24; }; kha_graphics2_truetype_StbTruetype.stbtt_tag4 = function(p,pos,c0,c1,c2,c3) { if(p.readU8(pos) == c0 && p.readU8(pos + 1) == c1 && p.readU8(pos + 2) == c2) { return p.readU8(pos + 3) == c3; } else { return false; } }; kha_graphics2_truetype_StbTruetype.stbtt_tag = function(p,pos,str) { var c0 = HxOverrides.cca(str,0); var c1 = HxOverrides.cca(str,1); var c2 = HxOverrides.cca(str,2); var c3 = HxOverrides.cca(str,3); if(p.readU8(pos) == c0 && p.readU8(pos + 1) == c1 && p.readU8(pos + 2) == c2) { return p.readU8(pos + 3) == c3; } else { return false; } }; kha_graphics2_truetype_StbTruetype.stbtt__isfont = function(font) { var c0 = HxOverrides.cca("1",0); if(font.readU8(0) == c0 && font.readU8(1) == 0 && font.readU8(2) == 0 && font.readU8(3) == 0) { return true; } var c01 = HxOverrides.cca("typ1",0); var c1 = HxOverrides.cca("typ1",1); var c2 = HxOverrides.cca("typ1",2); var c3 = HxOverrides.cca("typ1",3); if(font.readU8(0) == c01 && font.readU8(1) == c1 && font.readU8(2) == c2 && font.readU8(3) == c3) { return true; } var c02 = HxOverrides.cca("OTTO",0); var c11 = HxOverrides.cca("OTTO",1); var c21 = HxOverrides.cca("OTTO",2); var c31 = HxOverrides.cca("OTTO",3); if(font.readU8(0) == c02 && font.readU8(1) == c11 && font.readU8(2) == c21 && font.readU8(3) == c31) { return true; } if(font.readU8(0) == 0 && font.readU8(1) == 1 && font.readU8(2) == 0 && font.readU8(3) == 0) { return true; } return false; }; kha_graphics2_truetype_StbTruetype.stbtt__find_table = function(data,fontstart,tag) { var pos = fontstart + 4; var ch1 = data.readU8(pos); var ch2 = data.readU8(pos + 1); var num_tables = ch2 | ch1 << 8; var tabledir = fontstart + 12; var _g1 = 0; var _g = num_tables; while(_g1 < _g) { var i = _g1++; var loc = tabledir + 16 * i; var c0 = HxOverrides.cca(tag,0); var c1 = HxOverrides.cca(tag,1); var c2 = HxOverrides.cca(tag,2); var c3 = HxOverrides.cca(tag,3); if(data.readU8(loc) == c0 && data.readU8(loc + 1) == c1 && data.readU8(loc + 2) == c2 && data.readU8(loc + 3) == c3) { var pos1 = loc + 8; var ch11 = data.readU8(pos1); var ch21 = data.readU8(pos1 + 1); var ch3 = data.readU8(pos1 + 2); var ch4 = data.readU8(pos1 + 3); return ch4 | ch3 << 8 | ch21 << 16 | ch11 << 24; } } return 0; }; kha_graphics2_truetype_StbTruetype.stbtt_GetFontOffsetForIndex = function(font_collection,index) { if(kha_graphics2_truetype_StbTruetype.stbtt__isfont(font_collection)) { if(index == 0) { return 0; } else { return -1; } } var c0 = HxOverrides.cca("ttcf",0); var c1 = HxOverrides.cca("ttcf",1); var c2 = HxOverrides.cca("ttcf",2); var c3 = HxOverrides.cca("ttcf",3); if(font_collection.readU8(0) == c0 && font_collection.readU8(1) == c1 && font_collection.readU8(2) == c2 && font_collection.readU8(3) == c3) { var tmp; var ch1 = font_collection.readU8(4); var ch2 = font_collection.readU8(5); var ch3 = font_collection.readU8(6); var ch4 = font_collection.readU8(7); if((ch4 | ch3 << 8 | ch2 << 16 | ch1 << 24) != 65536) { var ch11 = font_collection.readU8(4); var ch21 = font_collection.readU8(5); var ch31 = font_collection.readU8(6); var ch41 = font_collection.readU8(7); tmp = (ch41 | ch31 << 8 | ch21 << 16 | ch11 << 24) == 131072; } else { tmp = true; } if(tmp) { var ch12 = font_collection.readU8(8); var ch22 = font_collection.readU8(9); var ch32 = font_collection.readU8(10); var ch42 = font_collection.readU8(11); var n = ch42 | ch32 << 8 | ch22 << 16 | ch12 << 24; if(index >= n) { return -1; } var pos = 12 + index * 4; var ch13 = font_collection.readU8(pos); var ch23 = font_collection.readU8(pos + 1); var ch33 = font_collection.readU8(pos + 2); var ch43 = font_collection.readU8(pos + 3); return ch43 | ch33 << 8 | ch23 << 16 | ch13 << 24; } } return -1; }; kha_graphics2_truetype_StbTruetype.stbtt_InitFont = function(info,data,fontstart) { var cmap; var t; var numTables; info.data = data; info.fontstart = fontstart; cmap = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"cmap"); info.loca = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"loca"); info.head = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"head"); info.glyf = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"glyf"); info.hhea = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"hhea"); info.hmtx = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"hmtx"); info.kern = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"kern"); if(cmap == 0 || info.loca == 0 || info.head == 0 || info.glyf == 0 || info.hhea == 0 || info.hmtx == 0) { return false; } t = kha_graphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"maxp"); if(t != 0) { var pos = t + 4; var ch1 = data.readU8(pos); var ch2 = data.readU8(pos + 1); info.numGlyphs = ch2 | ch1 << 8; } else { info.numGlyphs = 65535; } var pos1 = cmap + 2; var ch11 = data.readU8(pos1); var ch21 = data.readU8(pos1 + 1); numTables = ch21 | ch11 << 8; info.index_map = 0; var _g1 = 0; var _g = numTables; while(_g1 < _g) { var i = _g1++; var encoding_record = cmap + 4 + 8 * i; var ch12 = data.readU8(encoding_record); var ch22 = data.readU8(encoding_record + 1); var _g2 = ch22 | ch12 << 8; switch(_g2) { case 0: var pos2 = encoding_record + 4; var ch13 = data.readU8(pos2); var ch23 = data.readU8(pos2 + 1); var ch3 = data.readU8(pos2 + 2); var ch4 = data.readU8(pos2 + 3); info.index_map = cmap + (ch4 | ch3 << 8 | ch23 << 16 | ch13 << 24); break; case 3: var pos3 = encoding_record + 2; var ch14 = data.readU8(pos3); var ch24 = data.readU8(pos3 + 1); var _g21 = ch24 | ch14 << 8; switch(_g21) { case 1:case 10: var pos4 = encoding_record + 4; var ch15 = data.readU8(pos4); var ch25 = data.readU8(pos4 + 1); var ch31 = data.readU8(pos4 + 2); var ch41 = data.readU8(pos4 + 3); info.index_map = cmap + (ch41 | ch31 << 8 | ch25 << 16 | ch15 << 24); break; } break; } } if(info.index_map == 0) { return false; } var pos5 = info.head + 50; var ch16 = data.readU8(pos5); var ch26 = data.readU8(pos5 + 1); info.indexToLocFormat = ch26 | ch16 << 8; return true; }; kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex = function(info,unicode_codepoint) { var data = info.data; var index_map = info.index_map; var ch1 = data.readU8(index_map); var ch2 = data.readU8(index_map + 1); var format = ch2 | ch1 << 8; if(format == 0) { var pos = index_map + 2; var ch11 = data.readU8(pos); var ch21 = data.readU8(pos + 1); var bytes = ch21 | ch11 << 8; if(unicode_codepoint < bytes - 6) { return data.readU8(index_map + 6 + unicode_codepoint); } return 0; } else if(format == 6) { var pos1 = index_map + 6; var ch12 = data.readU8(pos1); var ch22 = data.readU8(pos1 + 1); var first = ch22 | ch12 << 8; var pos2 = index_map + 8; var ch13 = data.readU8(pos2); var ch23 = data.readU8(pos2 + 1); var count = ch23 | ch13 << 8; if(unicode_codepoint >= first && unicode_codepoint < first + count) { var pos3 = index_map + 10 + (unicode_codepoint - first) * 2; var ch14 = data.readU8(pos3); var ch24 = data.readU8(pos3 + 1); return ch24 | ch14 << 8; } return 0; } else if(format == 2) { throw new js__$Boot_HaxeError("Error"); } else if(format == 4) { var pos4 = index_map + 6; var ch15 = data.readU8(pos4); var ch25 = data.readU8(pos4 + 1); var segcount = (ch25 | ch15 << 8) >> 1; var pos5 = index_map + 8; var ch16 = data.readU8(pos5); var ch26 = data.readU8(pos5 + 1); var searchRange = (ch26 | ch16 << 8) >> 1; var pos6 = index_map + 10; var ch17 = data.readU8(pos6); var ch27 = data.readU8(pos6 + 1); var entrySelector = ch27 | ch17 << 8; var pos7 = index_map + 12; var ch18 = data.readU8(pos7); var ch28 = data.readU8(pos7 + 1); var rangeShift = (ch28 | ch18 << 8) >> 1; var endCount = index_map + 14; var search = endCount; if(unicode_codepoint > 65535) { return 0; } var pos8 = search + rangeShift * 2; var ch19 = data.readU8(pos8); var ch29 = data.readU8(pos8 + 1); if(unicode_codepoint >= (ch29 | ch19 << 8)) { search += rangeShift * 2; } search -= 2; while(entrySelector != 0) { var end; searchRange >>= 1; var pos9 = search + searchRange * 2; var ch110 = data.readU8(pos9); var ch210 = data.readU8(pos9 + 1); end = ch210 | ch110 << 8; if(unicode_codepoint > end) { search += searchRange * 2; } --entrySelector; } search += 2; var offset; var start; var item = search - endCount >> 1; var pos10 = endCount + 2 * item; var ch111 = data.readU8(pos10); var ch211 = data.readU8(pos10 + 1); if(unicode_codepoint > (ch211 | ch111 << 8)) { throw new js__$Boot_HaxeError("Error"); } var pos11 = index_map + 14 + segcount * 2 + 2 + 2 * item; var ch112 = data.readU8(pos11); var ch212 = data.readU8(pos11 + 1); start = ch212 | ch112 << 8; if(unicode_codepoint < start) { return 0; } var pos12 = index_map + 14 + segcount * 6 + 2 + 2 * item; var ch113 = data.readU8(pos12); var ch213 = data.readU8(pos12 + 1); offset = ch213 | ch113 << 8; if(offset == 0) { var pos13 = index_map + 14 + segcount * 4 + 2 + 2 * item; var ch114 = data.readU8(pos13); var ch214 = data.readU8(pos13 + 1); var n = ch214 | ch114 << 8; return unicode_codepoint + ((n & 32768) != 0 ? n - 65536 : n); } var pos14 = offset + (unicode_codepoint - start) * 2 + index_map + 14 + segcount * 6 + 2 + 2 * item; var ch115 = data.readU8(pos14); var ch215 = data.readU8(pos14 + 1); return ch215 | ch115 << 8; } else if(format == 12 || format == 13) { var pos15 = index_map + 12; var ch116 = data.readU8(pos15); var ch216 = data.readU8(pos15 + 1); var ch3 = data.readU8(pos15 + 2); var ch4 = data.readU8(pos15 + 3); var ngroups = ch4 | ch3 << 8 | ch216 << 16 | ch116 << 24; var low; var high; low = 0; high = ngroups; while(low < high) { var mid = low + (high - low >> 1); var pos16 = index_map + 16 + mid * 12; var ch117 = data.readU8(pos16); var ch217 = data.readU8(pos16 + 1); var ch31 = data.readU8(pos16 + 2); var ch41 = data.readU8(pos16 + 3); var start_char = ch41 | ch31 << 8 | ch217 << 16 | ch117 << 24; var pos17 = index_map + 16 + mid * 12 + 4; var ch118 = data.readU8(pos17); var ch218 = data.readU8(pos17 + 1); var ch32 = data.readU8(pos17 + 2); var ch42 = data.readU8(pos17 + 3); var end_char = ch42 | ch32 << 8 | ch218 << 16 | ch118 << 24; if(unicode_codepoint < start_char) { high = mid; } else if(unicode_codepoint > end_char) { low = mid + 1; } else { var pos18 = index_map + 16 + mid * 12 + 8; var ch119 = data.readU8(pos18); var ch219 = data.readU8(pos18 + 1); var ch33 = data.readU8(pos18 + 2); var ch43 = data.readU8(pos18 + 3); var start_glyph = ch43 | ch33 << 8 | ch219 << 16 | ch119 << 24; if(format == 12) { return start_glyph + unicode_codepoint - start_char; } else { return start_glyph; } } } return 0; } throw new js__$Boot_HaxeError("Error"); }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointShape = function(info,unicode_codepoint) { return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,unicode_codepoint)); }; kha_graphics2_truetype_StbTruetype.stbtt_setvertex = function(v,type,x,y,cx,cy) { v.type = type; v.x = x; v.y = y; v.cx = cx; v.cy = cy; }; kha_graphics2_truetype_StbTruetype.stbtt__GetGlyfOffset = function(info,glyph_index) { var g1; var g2; if(glyph_index >= info.numGlyphs) { return -1; } if(info.indexToLocFormat >= 2) { return -1; } if(info.indexToLocFormat == 0) { var info1 = info.glyf; var p = info.data; var pos = info.loca + glyph_index * 2; var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); g1 = info1 + (ch2 | ch1 << 8) * 2; var info2 = info.glyf; var p1 = info.data; var pos1 = info.loca + glyph_index * 2 + 2; var ch11 = p1.readU8(pos1); var ch21 = p1.readU8(pos1 + 1); g2 = info2 + (ch21 | ch11 << 8) * 2; } else { var info3 = info.glyf; var p2 = info.data; var pos2 = info.loca + glyph_index * 4; var ch12 = p2.readU8(pos2); var ch22 = p2.readU8(pos2 + 1); var ch3 = p2.readU8(pos2 + 2); var ch4 = p2.readU8(pos2 + 3); g1 = info3 + (ch4 | ch3 << 8 | ch22 << 16 | ch12 << 24); var info4 = info.glyf; var p3 = info.data; var pos3 = info.loca + glyph_index * 4 + 4; var ch13 = p3.readU8(pos3); var ch23 = p3.readU8(pos3 + 1); var ch31 = p3.readU8(pos3 + 2); var ch41 = p3.readU8(pos3 + 3); g2 = info4 + (ch41 | ch31 << 8 | ch23 << 16 | ch13 << 24); } if(g1 == g2) { return -1; } else { return g1; } }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBox = function(info,glyph_index,rect) { var g = kha_graphics2_truetype_StbTruetype.stbtt__GetGlyfOffset(info,glyph_index); if(g < 0) { return false; } var p = info.data; var pos = g + 2; var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var n = ch2 | ch1 << 8; rect.x0 = (n & 32768) != 0 ? n - 65536 : n; var p1 = info.data; var pos1 = g + 4; var ch11 = p1.readU8(pos1); var ch21 = p1.readU8(pos1 + 1); var n1 = ch21 | ch11 << 8; rect.y0 = (n1 & 32768) != 0 ? n1 - 65536 : n1; var p2 = info.data; var pos2 = g + 6; var ch12 = p2.readU8(pos2); var ch22 = p2.readU8(pos2 + 1); var n2 = ch22 | ch12 << 8; rect.x1 = (n2 & 32768) != 0 ? n2 - 65536 : n2; var p3 = info.data; var pos3 = g + 8; var ch13 = p3.readU8(pos3); var ch23 = p3.readU8(pos3 + 1); var n3 = ch23 | ch13 << 8; rect.y1 = (n3 & 32768) != 0 ? n3 - 65536 : n3; return true; }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointBox = function(info,codepoint,rect) { return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBox(info,kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint),rect); }; kha_graphics2_truetype_StbTruetype.stbtt_IsGlyphEmpty = function(info,glyph_index) { var numberOfContours; var g = kha_graphics2_truetype_StbTruetype.stbtt__GetGlyfOffset(info,glyph_index); if(g < 0) { return true; } var p = info.data; var ch1 = p.readU8(g); var ch2 = p.readU8(g + 1); var n = ch2 | ch1 << 8; if((n & 32768) != 0) { numberOfContours = n - 65536; } else { numberOfContours = n; } return numberOfContours == 0; }; kha_graphics2_truetype_StbTruetype.stbtt__close_shape = function(vertices,num_vertices,was_off,start_off,sx,sy,scx,scy,cx,cy) { if(start_off) { if(was_off) { kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,cx + scx >> 1,cy + scy >> 1,cx,cy); } kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,sx,sy,scx,scy); } else if(was_off) { kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,sx,sy,cx,cy); } else { kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],2,sx,sy,0,0); } return num_vertices; }; kha_graphics2_truetype_StbTruetype.copyVertices = function(from,to,offset,count) { var _g1 = 0; var _g = count; while(_g1 < _g) { var i = _g1++; to[offset + i] = from[i]; } }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphShape = function(info,glyph_index) { var numberOfContours; var endPtsOfContours; var data = info.data; var vertices = null; var num_vertices = 0; var g = kha_graphics2_truetype_StbTruetype.stbtt__GetGlyfOffset(info,glyph_index); if(g < 0) { return null; } var ch1 = data.readU8(g); var ch2 = data.readU8(g + 1); var n = ch2 | ch1 << 8; if((n & 32768) != 0) { numberOfContours = n - 65536; } else { numberOfContours = n; } if(numberOfContours > 0) { var flags = 0; var flagcount; var ins; var j = 0; var m; var n1; var next_move = 0; var off = 0; var was_off = false; var start_off = false; var x; var y; var cx; var cy; var sx; var sy; var scx; var scy; var points; var pointsIndex = 0; endPtsOfContours = data.sub(g + 10,data.get_length() - (g + 10)); var pos = g + 10 + numberOfContours * 2; var ch11 = data.readU8(pos); var ch21 = data.readU8(pos + 1); ins = ch21 | ch11 << 8; points = data.sub(g + 10 + numberOfContours * 2 + 2 + ins,data.get_length() - (g + 10 + numberOfContours * 2 + 2 + ins)); var pos1 = numberOfContours * 2 - 2; var ch12 = endPtsOfContours.readU8(pos1); var ch22 = endPtsOfContours.readU8(pos1 + 1); n1 = 1 + (ch22 | ch12 << 8); m = n1 + 2 * numberOfContours; var this1 = new Array(m); vertices = this1; if(vertices == null) { return null; } else { var _g1 = 0; var _g = vertices.length; while(_g1 < _g) { var i = _g1++; vertices[i] = new kha_graphics2_truetype_Stbtt_$vertex(); } } next_move = 0; flagcount = 0; off = m - n1; var _g11 = 0; var _g2 = n1; while(_g11 < _g2) { var i1 = _g11++; if(flagcount == 0) { flags = points.readU8(pointsIndex++); if((flags & 8) != 0) { flagcount = points.readU8(pointsIndex++); } } else { --flagcount; } vertices[off + i1].type = flags; } x = 0; var _g12 = 0; var _g3 = n1; while(_g12 < _g3) { var i2 = _g12++; flags = vertices[off + i2].type; if((flags & 2) != 0) { var dx = points.readU8(pointsIndex++); x += (flags & 16) != 0 ? dx : -dx; } else if((flags & 16) == 0) { var value; var ch13 = points.readU8(pointsIndex); var ch23 = points.readU8(pointsIndex + 1); var n2 = ch23 | ch13 << 8; if((n2 & 32768) != 0) { value = n2 - 65536; } else { value = n2; } x += value; pointsIndex += 2; } vertices[off + i2].x = x; } y = 0; var _g13 = 0; var _g4 = n1; while(_g13 < _g4) { var i3 = _g13++; flags = vertices[off + i3].type; if((flags & 4) != 0) { var dy = points.readU8(pointsIndex++); y += (flags & 32) != 0 ? dy : -dy; } else if((flags & 32) == 0) { var value1; var ch14 = points.readU8(pointsIndex); var ch24 = points.readU8(pointsIndex + 1); var n3 = ch24 | ch14 << 8; if((n3 & 32768) != 0) { value1 = n3 - 65536; } else { value1 = n3; } y += value1; pointsIndex += 2; } vertices[off + i3].y = y; } num_vertices = 0; scy = 0; scx = scy; cy = scx; cx = cy; sy = cx; sx = sy; var i4 = 0; while(i4 < n1) { flags = vertices[off + i4].type; x = vertices[off + i4].x; y = vertices[off + i4].y; if(next_move == i4) { if(i4 != 0) { num_vertices = kha_graphics2_truetype_StbTruetype.stbtt__close_shape(vertices,num_vertices,was_off,start_off,sx,sy,scx,scy,cx,cy); } start_off = (flags & 1) == 0; if(start_off) { scx = x; scy = y; if((vertices[off + i4 + 1].type & 1) == 0) { sx = x + vertices[off + i4 + 1].x >> 1; sy = y + vertices[off + i4 + 1].y >> 1; } else { sx = vertices[off + i4 + 1].x; sy = vertices[off + i4 + 1].y; ++i4; } } else { sx = x; sy = y; } kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],1,sx,sy,0,0); was_off = false; var pos2 = j * 2; var ch15 = endPtsOfContours.readU8(pos2); var ch25 = endPtsOfContours.readU8(pos2 + 1); next_move = 1 + (ch25 | ch15 << 8); ++j; } else if((flags & 1) == 0) { if(was_off) { kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,cx + x >> 1,cy + y >> 1,cx,cy); } cx = x; cy = y; was_off = true; } else { if(was_off) { kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,x,y,cx,cy); } else { kha_graphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],2,x,y,0,0); } was_off = false; } ++i4; } num_vertices = kha_graphics2_truetype_StbTruetype.stbtt__close_shape(vertices,num_vertices,was_off,start_off,sx,sy,scx,scy,cx,cy); } else if(numberOfContours == -1) { var more = 1; var comp = data.sub(g + 10,data.get_length() - (g + 10)); var compIndex = 0; num_vertices = 0; vertices = null; while(more != 0) { var flags1; var gidx; var comp_num_verts = 0; var i5; var comp_verts = null; var tmp = null; var mtx0 = 1; var mtx1 = 0; var mtx2 = 0; var mtx3 = 1; var mtx4 = 0; var mtx5 = 0; var m1; var n4; var ch16 = comp.readU8(compIndex); var ch26 = comp.readU8(compIndex + 1); var n5 = ch26 | ch16 << 8; if((n5 & 32768) != 0) { flags1 = n5 - 65536; } else { flags1 = n5; } compIndex += 2; var ch17 = comp.readU8(compIndex); var ch27 = comp.readU8(compIndex + 1); var n6 = ch27 | ch17 << 8; if((n6 & 32768) != 0) { gidx = n6 - 65536; } else { gidx = n6; } compIndex += 2; if((flags1 & 2) != 0) { if((flags1 & 1) != 0) { var ch18 = comp.readU8(compIndex); var ch28 = comp.readU8(compIndex + 1); var n7 = ch28 | ch18 << 8; if((n7 & 32768) != 0) { mtx4 = n7 - 65536; } else { mtx4 = n7; } compIndex += 2; var ch19 = comp.readU8(compIndex); var ch29 = comp.readU8(compIndex + 1); var n8 = ch29 | ch19 << 8; if((n8 & 32768) != 0) { mtx5 = n8 - 65536; } else { mtx5 = n8; } compIndex += 2; } else { var n9 = comp.readU8(compIndex); if(n9 >= 128) { mtx4 = n9 - 256; } else { mtx4 = n9; } ++compIndex; var n10 = comp.readU8(compIndex); if(n10 >= 128) { mtx5 = n10 - 256; } else { mtx5 = n10; } ++compIndex; } } else { throw new js__$Boot_HaxeError("Error"); } if((flags1 & 8) != 0) { var ch110 = comp.readU8(compIndex); var ch210 = comp.readU8(compIndex + 1); var n11 = ch210 | ch110 << 8; mtx3 = ((n11 & 32768) != 0 ? n11 - 65536 : n11) / 16384.0; mtx0 = mtx3; compIndex += 2; mtx2 = 0; mtx1 = mtx2; } else if((flags1 & 64) != 0) { var ch111 = comp.readU8(compIndex); var ch211 = comp.readU8(compIndex + 1); var n12 = ch211 | ch111 << 8; mtx0 = ((n12 & 32768) != 0 ? n12 - 65536 : n12) / 16384.0; compIndex += 2; mtx2 = 0; mtx1 = mtx2; var ch112 = comp.readU8(compIndex); var ch212 = comp.readU8(compIndex + 1); var n13 = ch212 | ch112 << 8; mtx3 = ((n13 & 32768) != 0 ? n13 - 65536 : n13) / 16384.0; compIndex += 2; } else if((flags1 & 128) != 0) { var ch113 = comp.readU8(compIndex); var ch213 = comp.readU8(compIndex + 1); var n14 = ch213 | ch113 << 8; mtx0 = ((n14 & 32768) != 0 ? n14 - 65536 : n14) / 16384.0; compIndex += 2; var ch114 = comp.readU8(compIndex); var ch214 = comp.readU8(compIndex + 1); var n15 = ch214 | ch114 << 8; mtx1 = ((n15 & 32768) != 0 ? n15 - 65536 : n15) / 16384.0; compIndex += 2; var ch115 = comp.readU8(compIndex); var ch215 = comp.readU8(compIndex + 1); var n16 = ch215 | ch115 << 8; mtx2 = ((n16 & 32768) != 0 ? n16 - 65536 : n16) / 16384.0; compIndex += 2; var ch116 = comp.readU8(compIndex); var ch216 = comp.readU8(compIndex + 1); var n17 = ch216 | ch116 << 8; mtx3 = ((n17 & 32768) != 0 ? n17 - 65536 : n17) / 16384.0; compIndex += 2; } m1 = Math.sqrt(mtx0 * mtx0 + mtx1 * mtx1); n4 = Math.sqrt(mtx2 * mtx2 + mtx3 * mtx3); comp_verts = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,gidx); if(comp_verts == null) { comp_num_verts = 0; } else { comp_num_verts = comp_verts.length; } if(comp_num_verts > 0) { var _g14 = 0; var _g5 = comp_num_verts; while(_g14 < _g5) { var i6 = _g14++; var v = comp_verts[i6]; var x1; var y1; x1 = v.x; y1 = v.y; v.x = m1 * (mtx0 * x1 + mtx2 * y1 + mtx4) | 0; v.y = n4 * (mtx1 * x1 + mtx3 * y1 + mtx5) | 0; x1 = v.cx; y1 = v.cy; v.cx = m1 * (mtx0 * x1 + mtx2 * y1 + mtx4) | 0; v.cy = n4 * (mtx1 * x1 + mtx3 * y1 + mtx5) | 0; } var this2 = new Array(num_vertices + comp_num_verts); tmp = this2; if(tmp == null) { return null; } if(num_vertices > 0) { kha_graphics2_truetype_StbTruetype.copyVertices(vertices,tmp,0,num_vertices); } kha_graphics2_truetype_StbTruetype.copyVertices(comp_verts,tmp,num_vertices,comp_num_verts); vertices = tmp; num_vertices += comp_num_verts; } more = flags1 & 32; } } else if(numberOfContours < 0) { throw new js__$Boot_HaxeError("Error"); } if(vertices == null) { return null; } if(vertices.length < num_vertices) { throw new js__$Boot_HaxeError("Error"); } if(num_vertices < vertices.length) { var this3 = new Array(num_vertices); var tmp1 = this3; kha_graphics2_truetype_StbTruetype.copyVertices(vertices,tmp1,0,num_vertices); return tmp1; } else { return vertices; } }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphHMetrics = function(info,glyph_index) { var p = info.data; var pos = info.hhea + 34; var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var numOfLongHorMetrics = ch2 | ch1 << 8; var metrics = new kha_graphics2_truetype_Stbtt_$temp_$glyph_$h_$metrics(); if(glyph_index < numOfLongHorMetrics) { var p1 = info.data; var pos1 = info.hmtx + 4 * glyph_index; var ch11 = p1.readU8(pos1); var ch21 = p1.readU8(pos1 + 1); var n = ch21 | ch11 << 8; metrics.advanceWidth = (n & 32768) != 0 ? n - 65536 : n; var p2 = info.data; var pos2 = info.hmtx + 4 * glyph_index + 2; var ch12 = p2.readU8(pos2); var ch22 = p2.readU8(pos2 + 1); var n1 = ch22 | ch12 << 8; metrics.leftSideBearing = (n1 & 32768) != 0 ? n1 - 65536 : n1; } else { var p3 = info.data; var pos3 = info.hmtx + 4 * (numOfLongHorMetrics - 1); var ch13 = p3.readU8(pos3); var ch23 = p3.readU8(pos3 + 1); var n2 = ch23 | ch13 << 8; metrics.advanceWidth = (n2 & 32768) != 0 ? n2 - 65536 : n2; var p4 = info.data; var pos4 = info.hmtx + 4 * numOfLongHorMetrics + 2 * (glyph_index - numOfLongHorMetrics); var ch14 = p4.readU8(pos4); var ch24 = p4.readU8(pos4 + 1); var n3 = ch24 | ch14 << 8; metrics.leftSideBearing = (n3 & 32768) != 0 ? n3 - 65536 : n3; } return metrics; }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphKernAdvance = function(info,glyph1,glyph2) { var data = info.data.sub(info.kern,info.data.get_length() - info.kern); var needle; var straw; var l; var r; var m; if(info.kern == 0) { return 0; } var ch1 = data.readU8(2); var ch2 = data.readU8(3); if((ch2 | ch1 << 8) < 1) { return 0; } var ch11 = data.readU8(8); var ch21 = data.readU8(9); if((ch21 | ch11 << 8) != 1) { return 0; } l = 0; var ch12 = data.readU8(10); var ch22 = data.readU8(11); r = (ch22 | ch12 << 8) - 1; needle = glyph1 << 16 | glyph2; while(l <= r) { m = l + r >> 1; var pos = 18 + m * 6; var ch13 = data.readU8(pos); var ch23 = data.readU8(pos + 1); var ch3 = data.readU8(pos + 2); var ch4 = data.readU8(pos + 3); straw = ch4 | ch3 << 8 | ch23 << 16 | ch13 << 24; if(needle < straw) { r = m - 1; } else if(needle > straw) { l = m + 1; } else { var pos1 = 22 + m * 6; var ch14 = data.readU8(pos1); var ch24 = data.readU8(pos1 + 1); var n = ch24 | ch14 << 8; if((n & 32768) != 0) { return n - 65536; } else { return n; } } } return 0; }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointKernAdvance = function(info,ch1,ch2) { if(info.kern == 0) { return 0; } return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphKernAdvance(info,kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,ch1),kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,ch2)); }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointHMetrics = function(info,codepoint) { return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphHMetrics(info,kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint)); }; kha_graphics2_truetype_StbTruetype.stbtt_GetFontVMetrics = function(info) { var metrics = new kha_graphics2_truetype_Stbtt_$temp_$font_$v_$metrics(); var p = info.data; var pos = info.hhea + 4; var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var n = ch2 | ch1 << 8; metrics.ascent = (n & 32768) != 0 ? n - 65536 : n; var p1 = info.data; var pos1 = info.hhea + 6; var ch11 = p1.readU8(pos1); var ch21 = p1.readU8(pos1 + 1); var n1 = ch21 | ch11 << 8; metrics.descent = (n1 & 32768) != 0 ? n1 - 65536 : n1; var p2 = info.data; var pos2 = info.hhea + 8; var ch12 = p2.readU8(pos2); var ch22 = p2.readU8(pos2 + 1); var n2 = ch22 | ch12 << 8; metrics.lineGap = (n2 & 32768) != 0 ? n2 - 65536 : n2; return metrics; }; kha_graphics2_truetype_StbTruetype.stbtt_GetFontBoundingBox = function(info) { var rect = new kha_graphics2_truetype_Stbtt_$temp_$rect(); var p = info.data; var pos = info.head + 36; var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var n = ch2 | ch1 << 8; rect.x0 = (n & 32768) != 0 ? n - 65536 : n; var p1 = info.data; var pos1 = info.head + 38; var ch11 = p1.readU8(pos1); var ch21 = p1.readU8(pos1 + 1); var n1 = ch21 | ch11 << 8; rect.y0 = (n1 & 32768) != 0 ? n1 - 65536 : n1; var p2 = info.data; var pos2 = info.head + 40; var ch12 = p2.readU8(pos2); var ch22 = p2.readU8(pos2 + 1); var n2 = ch22 | ch12 << 8; rect.x1 = (n2 & 32768) != 0 ? n2 - 65536 : n2; var p3 = info.data; var pos3 = info.head + 42; var ch13 = p3.readU8(pos3); var ch23 = p3.readU8(pos3 + 1); var n3 = ch23 | ch13 << 8; rect.y1 = (n3 & 32768) != 0 ? n3 - 65536 : n3; return rect; }; kha_graphics2_truetype_StbTruetype.stbtt_ScaleForPixelHeight = function(info,height) { var p = info.data; var pos = info.hhea + 4; var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var n = ch2 | ch1 << 8; var p1 = info.data; var pos1 = info.hhea + 6; var ch11 = p1.readU8(pos1); var ch21 = p1.readU8(pos1 + 1); var n1 = ch21 | ch11 << 8; var fheight = ((n & 32768) != 0 ? n - 65536 : n) - ((n1 & 32768) != 0 ? n1 - 65536 : n1); return height / fheight; }; kha_graphics2_truetype_StbTruetype.stbtt_ScaleForMappingEmToPixels = function(info,pixels) { var p = info.data; var pos = info.head + 18; var ch1 = p.readU8(pos); var ch2 = p.readU8(pos + 1); var unitsPerEm = ch2 | ch1 << 8; return pixels / unitsPerEm; }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel = function(font,glyph,scale_x,scale_y,shift_x,shift_y) { var rect = new kha_graphics2_truetype_Stbtt_$temp_$rect(); if(!kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBox(font,glyph,rect)) { rect.x0 = 0; rect.y0 = 0; rect.x1 = 0; rect.y1 = 0; } else { var x0 = rect.x0; var x1 = rect.x1; var y0 = rect.y0; var y1 = rect.y1; rect.x0 = Math.floor(x0 * scale_x + shift_x); rect.y0 = Math.floor(-y1 * scale_y + shift_y); rect.x1 = Math.ceil(x1 * scale_x + shift_x); rect.y1 = Math.ceil(-y0 * scale_y + shift_y); } return rect; }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBox = function(font,glyph,scale_x,scale_y) { return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(font,glyph,scale_x,scale_y,0.0,0.0); }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapBoxSubpixel = function(font,codepoint,scale_x,scale_y,shift_x,shift_y) { return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(font,kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(font,codepoint),scale_x,scale_y,shift_x,shift_y); }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapBox = function(font,codepoint,scale_x,scale_y) { return kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapBoxSubpixel(font,codepoint,scale_x,scale_y,0.0,0.0); }; kha_graphics2_truetype_StbTruetype.stbtt__new_active = function(e,eIndex,off_x,start_point) { var z = new kha_graphics2_truetype_Stbtt_$_$active_$edge(); var dxdy = (e[eIndex].x1 - e[eIndex].x0) / (e[eIndex].y1 - e[eIndex].y0); if(z == null) { return z; } z.fdx = dxdy; z.fdy = dxdy != 0.0 ? 1.0 / dxdy : 0.0; z.fx = e[eIndex].x0 + dxdy * (start_point - e[eIndex].y0); z.fx -= off_x; z.direction = e[eIndex].invert ? 1.0 : -1.0; z.sy = e[eIndex].y0; z.ey = e[eIndex].y1; z.next = null; return z; }; kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge = function(scanline,scanlineIndex,x,e,x0,y0,x1,y1) { if(y0 == y1) { return; } if(!(y0 < y1)) { throw new js__$Boot_HaxeError("Error"); } if(!(e.sy <= e.ey)) { throw new js__$Boot_HaxeError("Error"); } if(y0 > e.ey) { return; } if(y1 < e.sy) { return; } if(y0 < e.sy) { x0 += (x1 - x0) * (e.sy - y0) / (y1 - y0); y0 = e.sy; } if(y1 > e.ey) { x1 += (x1 - x0) * (e.ey - y1) / (y1 - y0); y1 = e.ey; } if(x0 == x) { if(!(x1 <= x + 1)) { throw new js__$Boot_HaxeError("Error"); } } else if(x0 == x + 1) { if(!(x1 >= x)) { throw new js__$Boot_HaxeError("Error"); } } else if(x0 <= x) { if(!(x1 <= x)) { throw new js__$Boot_HaxeError("Error"); } } else if(x0 >= x + 1) { if(!(x1 >= x + 1)) { throw new js__$Boot_HaxeError("Error"); } } else if(!(x1 >= x && x1 <= x + 1)) { throw new js__$Boot_HaxeError("Error"); } if(x0 <= x && x1 <= x) { var _g = scanlineIndex + x; var _g1 = scanline; _g1[_g] = _g1[_g] + e.direction * (y1 - y0); } else if(!(x0 >= x + 1 && x1 >= x + 1)) { if(!(x0 >= x && x0 <= x + 1 && x1 >= x && x1 <= x + 1)) { throw new js__$Boot_HaxeError("Error"); } var _g2 = scanlineIndex + x; var _g11 = scanline; _g11[_g2] = _g11[_g2] + e.direction * (y1 - y0) * (1 - (x0 - x + (x1 - x)) / 2); } }; kha_graphics2_truetype_StbTruetype.stbtt__fill_active_edges_new = function(scanline,scanline_fill,scanline_fillIndex,len,e,y_top) { var y_bottom = y_top + 1; while(e != null) { if(!(e.ey >= y_top)) { throw new js__$Boot_HaxeError("Error"); } if(e.fdx == 0) { var x0 = e.fx; if(x0 < len) { if(x0 >= 0) { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x0 | 0,e,x0,y_top,x0,y_bottom); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline_fill,scanline_fillIndex - 1,x0 + 1 | 0,e,x0,y_top,x0,y_bottom); } else { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline_fill,scanline_fillIndex - 1,0,e,x0,y_top,x0,y_bottom); } } } else { var x01 = e.fx; var dx = e.fdx; var xb = x01 + dx; var x_top; var x_bottom; var sy0; var sy1; var dy = e.fdy; if(!(e.sy <= y_bottom && e.ey >= y_top)) { throw new js__$Boot_HaxeError("Error"); } if(e.sy > y_top) { x_top = x01 + dx * (e.sy - y_top); sy0 = e.sy; } else { x_top = x01; sy0 = y_top; } if(e.ey < y_bottom) { x_bottom = x01 + dx * (e.ey - y_top); sy1 = e.ey; } else { x_bottom = xb; sy1 = y_bottom; } if(x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { if((x_top | 0) == (x_bottom | 0)) { var height; var x = x_top | 0; height = sy1 - sy0; if(!(x >= 0 && x < len)) { throw new js__$Boot_HaxeError("Error"); } var _g = x; var _g1 = scanline; _g1[_g] = _g1[_g] + e.direction * (1 - (x_top - x + (x_bottom - x)) / 2) * height; var _g2 = scanline_fillIndex + x; var _g11 = scanline_fill; _g11[_g2] = _g11[_g2] + e.direction * height; } else { var x1; var x11; var x2; var y_crossing; var step; var sign; var area; if(x_top > x_bottom) { var t; sy0 = y_bottom - (sy0 - y_top); sy1 = y_bottom - (sy1 - y_top); t = sy0; sy0 = sy1; sy1 = t; t = x_bottom; x_bottom = x_top; x_top = t; dx = -dx; dy = -dy; t = x01; x01 = xb; xb = t; } x11 = x_top | 0; x2 = x_bottom | 0; y_crossing = (x11 + 1 - x01) * dy + y_top; sign = e.direction; area = sign * (y_crossing - sy0); var _g3 = x11; var _g12 = scanline; _g12[_g3] = _g12[_g3] + area * (1 - (x_top - x11 + (x11 + 1 - x11)) / 2); step = sign * dy; var _g13 = x11 + 1; var _g4 = x2; while(_g13 < _g4) { var x3 = _g13++; var _g21 = x3; var _g31 = scanline; _g31[_g21] = _g31[_g21] + (area + step / 2); area += step; } y_crossing += dy * (x2 - (x11 + 1)); if(!(Math.abs(area) <= 1.01)) { throw new js__$Boot_HaxeError("Error"); } var _g5 = x2; var _g14 = scanline; _g14[_g5] = _g14[_g5] + (area + sign * (1 - (x2 - x2 + (x_bottom - x2)) / 2) * (sy1 - y_crossing)); var _g6 = scanline_fillIndex + x2; var _g15 = scanline_fill; _g15[_g6] = _g15[_g6] + sign * (sy1 - sy0); } } else { var _g16 = 0; var _g7 = len; while(_g16 < _g7) { var x4 = _g16++; var y0 = y_top; var x12 = x4; var x21 = x4 + 1; var x31 = xb; var y3 = y_bottom; var y1; var y2; y1 = (x4 - x01) / dx + y_top; y2 = (x4 + 1 - x01) / dx + y_top; if(x01 < x12 && x31 > x21) { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x12,y1); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x21,y2); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x31,y3); } else if(x31 < x12 && x01 > x21) { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x21,y2); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x12,y1); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x31,y3); } else if(x01 < x12 && x31 > x12) { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x12,y1); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x31,y3); } else if(x31 < x12 && x01 > x12) { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x12,y1); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x31,y3); } else if(x01 < x21 && x31 > x21) { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x21,y2); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x31,y3); } else if(x31 < x21 && x01 > x21) { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x21,y2); kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x31,y3); } else { kha_graphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x31,y3); } } } } e = e.next; } }; kha_graphics2_truetype_StbTruetype.stbtt__rasterize_sorted_edges = function(result,e,n,vsubsample,off_x,off_y) { var active = null; var y; var j = 0; var i; var scanline; var scanline2; var scanline2Index = 0; var eIndex = 0; if(result.w > 64) { var length = result.w * 2 + 1; var this1 = new Array(length); scanline = this1; } else { var this2 = new Array(129); scanline = this2; } scanline2 = scanline; scanline2Index = result.w; y = off_y; e[eIndex + n].y0 = off_y + result.h + 1; while(j < result.h) { var scan_y_top = y + 0.0; var scan_y_bottom = y + 1.0; var step_value; var step_parent; step_value = active; step_parent = null; var _g1 = 0; var _g = result.w; while(_g1 < _g) { var i1 = _g1++; scanline[i1] = 0; } var _g11 = 0; var _g2 = result.w + 1; while(_g11 < _g2) { var i2 = _g11++; scanline2[scanline2Index + i2] = 0; } while(step_value != null) { var z = step_value; if(z.ey <= scan_y_top) { if(step_parent == null) { active = z.next; step_value = z.next; } else { step_parent.next = z.next; step_value = z.next; } if(z.direction == 0) { throw new js__$Boot_HaxeError("Error"); } z.direction = 0; } else { step_parent = step_value; step_value = step_value.next; } } while(e[eIndex].y0 <= scan_y_bottom) { if(e[eIndex].y0 != e[eIndex].y1) { var z1 = kha_graphics2_truetype_StbTruetype.stbtt__new_active(e,eIndex,off_x,scan_y_top); if(!(z1.ey >= scan_y_top)) { throw new js__$Boot_HaxeError("Error"); } z1.next = active; active = z1; } ++eIndex; } if(active != null) { kha_graphics2_truetype_StbTruetype.stbtt__fill_active_edges_new(scanline,scanline2,scanline2Index + 1,result.w,active,scan_y_top); } var sum = 0; var _g12 = 0; var _g3 = result.w; while(_g12 < _g3) { var i3 = _g12++; var k; var m; sum += scanline2[scanline2Index + i3]; k = scanline[i3] + sum; k = Math.abs(k) * 255.0 + 0.5; m = k | 0; if(m > 255) { m = 255; } result.pixels.writeU8(result.pixels_offset + j * result.stride + i3,m); } step_parent = null; step_value = active; while(step_value != null) { var z2 = step_value; z2.fx += z2.fdx; step_parent = step_value; step_value = step_value.next; } ++y; ++j; } }; kha_graphics2_truetype_StbTruetype.STBTT__COMPARE = function(a,b) { return a.y0 < b.y0; }; kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_ins_sort = function(p,n) { var i; var j; var _g1 = 1; var _g = n; while(_g1 < _g) { var i1 = _g1++; var t = p[i1]; var a = t; j = i1; while(j > 0) { var b = p[j - 1]; var c = kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(a,b); if(!c) { break; } p[j] = p[j - 1]; --j; } if(i1 != j) { p[j] = t; } } }; kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort = function(p,pIndex,n) { while(n > 12) { var t; var c01; var c12; var c; var m; var i; var j; m = n >> 1; c01 = kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex],p[pIndex + m]); c12 = kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex + m],p[pIndex + n - 1]); if(c01 != c12) { var z; c = kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex],p[pIndex + n - 1]); if(c == c12) { z = 0; } else { z = n - 1; } t = p[pIndex + z]; p[pIndex + z] = p[pIndex + m]; p[pIndex + m] = t; } t = p[pIndex]; p[pIndex] = p[pIndex + m]; p[pIndex + m] = t; i = 1; j = n - 1; while(true) { while(kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex + i],p[pIndex])) ++i; while(kha_graphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex],p[pIndex + j])) --j; if(i >= j) { break; } t = p[pIndex + i]; p[pIndex + i] = p[pIndex + j]; p[pIndex + j] = t; ++i; --j; } if(j < n - i) { kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,pIndex,j); pIndex += i; n -= i; } else { kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,pIndex + i,n - i); n = j; } } }; kha_graphics2_truetype_StbTruetype.stbtt__sort_edges = function(p,n) { kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,0,n); kha_graphics2_truetype_StbTruetype.stbtt__sort_edges_ins_sort(p,n); }; kha_graphics2_truetype_StbTruetype.stbtt__rasterize = function(result,pts,wcount,windings,scale_x,scale_y,shift_x,shift_y,off_x,off_y,invert) { var y_scale_inv = invert ? -scale_y : scale_y; var e; var n; var i; var j; var k; var m; var vsubsample = 1; var ptsIndex = 0; n = 0; var _g1 = 0; var _g = windings; while(_g1 < _g) { var i1 = _g1++; n += wcount[i1]; } var this1 = new Array(n + 1); e = this1; if(e == null) { return; } else { var _g11 = 0; var _g2 = e.length; while(_g11 < _g2) { var i2 = _g11++; e[i2] = new kha_graphics2_truetype_Stbtt_$_$edge(); } } n = 0; m = 0; var _g12 = 0; var _g3 = windings; while(_g12 < _g3) { var i3 = _g12++; var p = pts; var pIndex = ptsIndex + m; m += wcount[i3]; j = wcount[i3] - 1; var _g31 = 0; var _g21 = wcount[i3]; while(_g31 < _g21) { var k1 = _g31++; var a = k1; var b = j; if(p[pIndex + j].y == p[pIndex + k1].y) { j = k1; continue; } e[n].invert = false; if(invert ? p[pIndex + j].y > p[pIndex + k1].y : p[pIndex + j].y < p[pIndex + k1].y) { e[n].invert = true; a = j; b = k1; } e[n].x0 = p[pIndex + a].x * scale_x + shift_x; e[n].y0 = (p[pIndex + a].y * y_scale_inv + shift_y) * vsubsample; e[n].x1 = p[pIndex + b].x * scale_x + shift_x; e[n].y1 = (p[pIndex + b].y * y_scale_inv + shift_y) * vsubsample; ++n; j = k1; } } kha_graphics2_truetype_StbTruetype.stbtt__sort_edges(e,n); kha_graphics2_truetype_StbTruetype.stbtt__rasterize_sorted_edges(result,e,n,vsubsample,off_x,off_y); }; kha_graphics2_truetype_StbTruetype.stbtt__add_point = function(points,n,x,y) { if(points == null) { return; } points[n].x = x; points[n].y = y; }; kha_graphics2_truetype_StbTruetype.stbtt__tesselate_curve = function(points,num_points,x0,y0,x1,y1,x2,y2,objspace_flatness_squared,n) { var mx = (x0 + 2 * x1 + x2) / 4; var my = (y0 + 2 * y1 + y2) / 4; var dx = (x0 + x2) / 2 - mx; var dy = (y0 + y2) / 2 - my; if(n > 16) { return 1; } if(dx * dx + dy * dy > objspace_flatness_squared) { kha_graphics2_truetype_StbTruetype.stbtt__tesselate_curve(points,num_points,x0,y0,(x0 + x1) / 2.0,(y0 + y1) / 2.0,mx,my,objspace_flatness_squared,n + 1); kha_graphics2_truetype_StbTruetype.stbtt__tesselate_curve(points,num_points,mx,my,(x1 + x2) / 2.0,(y1 + y2) / 2.0,x2,y2,objspace_flatness_squared,n + 1); } else { kha_graphics2_truetype_StbTruetype.stbtt__add_point(points,num_points.value,x2,y2); num_points.value += 1; } return 1; }; kha_graphics2_truetype_StbTruetype.stbtt_FlattenCurves = function(vertices,num_verts,objspace_flatness,contour_lengths,num_contours) { var points = null; var num_points = 0; var objspace_flatness_squared = objspace_flatness * objspace_flatness; var i; var n = 0; var start = 0; var pass; var _g1 = 0; var _g = num_verts; while(_g1 < _g) { var i1 = _g1++; if(vertices[i1].type == 1) { ++n; } } num_contours.value = n; if(n == 0) { return null; } var this1 = new Array(n); contour_lengths.value = this1; if(contour_lengths.value == null) { num_contours.value = 0; return null; } var _g2 = 0; while(_g2 < 2) { var pass1 = _g2++; var x = 0; var y = 0; if(pass1 == 1) { var this2 = new Array(num_points); points = this2; if(points == null) { contour_lengths.value = null; num_contours.value = 0; return null; } else { var _g21 = 0; var _g11 = points.length; while(_g21 < _g11) { var i2 = _g21++; points[i2] = new kha_graphics2_truetype_Stbtt_$_$point(); } } } num_points = 0; n = -1; var _g22 = 0; var _g12 = num_verts; while(_g22 < _g12) { var i3 = _g22++; var _g3 = vertices[i3].type; switch(_g3) { case 1: if(n >= 0) { contour_lengths.value[n] = num_points - start; } ++n; start = num_points; x = vertices[i3].x; y = vertices[i3].y; kha_graphics2_truetype_StbTruetype.stbtt__add_point(points,num_points++,x,y); break; case 2: x = vertices[i3].x; y = vertices[i3].y; kha_graphics2_truetype_StbTruetype.stbtt__add_point(points,num_points++,x,y); break; case 3: var num_points_reference = { value : num_points}; kha_graphics2_truetype_StbTruetype.stbtt__tesselate_curve(points,num_points_reference,x,y,vertices[i3].cx,vertices[i3].cy,vertices[i3].x,vertices[i3].y,objspace_flatness_squared,0); num_points = num_points_reference.value; x = vertices[i3].x; y = vertices[i3].y; break; } } contour_lengths.value[n] = num_points - start; } return points; }; kha_graphics2_truetype_StbTruetype.stbtt_Rasterize = function(result,flatness_in_pixels,vertices,num_verts,scale_x,scale_y,shift_x,shift_y,x_off,y_off,invert) { var scale = scale_x > scale_y ? scale_y : scale_x; var winding_count = 0; var winding_lengths = null; var winding_count_reference = { value : winding_count}; var winding_lengths_reference = new kha_graphics2_truetype_VectorOfIntPointer(); var windings = kha_graphics2_truetype_StbTruetype.stbtt_FlattenCurves(vertices,num_verts,flatness_in_pixels / scale,winding_lengths_reference,winding_count_reference); winding_count = winding_count_reference.value; winding_lengths = winding_lengths_reference.value; if(windings != null) { kha_graphics2_truetype_StbTruetype.stbtt__rasterize(result,windings,winding_lengths,winding_count,scale_x,scale_y,shift_x,shift_y,x_off,y_off,invert); } }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapSubpixel = function(info,scale_x,scale_y,shift_x,shift_y,glyph,region) { var ix0; var iy0; var ix1; var iy1; var gbm = new kha_graphics2_truetype_Stbtt_$_$bitmap(); var vertices = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,glyph); var num_verts = vertices.length; if(scale_x == 0) { scale_x = scale_y; } if(scale_y == 0) { if(scale_x == 0) { return null; } scale_y = scale_x; } var rect = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,scale_x,scale_y,shift_x,shift_y); ix0 = rect.x0; iy0 = rect.y0; ix1 = rect.x1; iy1 = rect.y1; gbm.w = ix1 - ix0; gbm.h = iy1 - iy0; gbm.pixels = null; region.width = gbm.w; region.height = gbm.h; region.xoff = ix0; region.yoff = iy0; if(gbm.w != 0 && gbm.h != 0) { gbm.pixels = kha_internal_BytesBlob.alloc(gbm.w * gbm.h); if(gbm.pixels != null) { gbm.stride = gbm.w; kha_graphics2_truetype_StbTruetype.stbtt_Rasterize(gbm,0.35,vertices,num_verts,scale_x,scale_y,shift_x,shift_y,ix0,iy0,true); } } return gbm.pixels; }; kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmap = function(info,scale_x,scale_y,glyph,region) { return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapSubpixel(info,scale_x,scale_y,0.0,0.0,glyph,region); }; kha_graphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmapSubpixel = function(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,shift_x,shift_y,glyph) { var ix0 = 0; var iy0 = 0; var vertices = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,glyph); var num_verts = vertices == null ? 0 : vertices.length; var gbm = new kha_graphics2_truetype_Stbtt_$_$bitmap(); var rect = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,scale_x,scale_y,shift_x,shift_y); ix0 = rect.x0; iy0 = rect.y0; gbm.pixels = output; gbm.pixels_offset = output_offset; gbm.w = out_w; gbm.h = out_h; gbm.stride = out_stride; if(gbm.w != 0 && gbm.h != 0) { kha_graphics2_truetype_StbTruetype.stbtt_Rasterize(gbm,0.35,vertices,num_verts,scale_x,scale_y,shift_x,shift_y,ix0,iy0,true); } }; kha_graphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmap = function(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,glyph) { kha_graphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,0.0,0.0,glyph); }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapSubpixel = function(info,scale_x,scale_y,shift_x,shift_y,codepoint,region) { return kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapSubpixel(info,scale_x,scale_y,shift_x,shift_y,kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint),region); }; kha_graphics2_truetype_StbTruetype.stbtt_MakeCodepointBitmapSubpixel = function(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,shift_x,shift_y,codepoint) { kha_graphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,shift_x,shift_y,kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint)); }; kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointBitmap = function(info,scale_x,scale_y,codepoint,region) { return kha_graphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapSubpixel(info,scale_x,scale_y,0.0,0.0,codepoint,region); }; kha_graphics2_truetype_StbTruetype.stbtt_MakeCodepointBitmap = function(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,codepoint) { kha_graphics2_truetype_StbTruetype.stbtt_MakeCodepointBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,0.0,0.0,codepoint); }; kha_graphics2_truetype_StbTruetype.stbtt_BakeFontBitmap = function(data,offset,pixel_height,pixels,pw,ph,chars,chardata) { var scale; var x; var y; var bottom_y; var f = new kha_graphics2_truetype_Stbtt_$fontinfo(); if(!kha_graphics2_truetype_StbTruetype.stbtt_InitFont(f,data,offset)) { return -1; } var _g1 = 0; var _g = pw * ph; while(_g1 < _g) { var i = _g1++; pixels.writeU8(i,0); } y = 1; x = y; bottom_y = 1; scale = kha_graphics2_truetype_StbTruetype.stbtt_ScaleForPixelHeight(f,pixel_height); var i1 = 0; var _g2 = 0; while(_g2 < chars.length) { var index = chars[_g2]; ++_g2; var advance; var lsb; var x0; var y0; var x1; var y1; var gw; var gh; var g = kha_graphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(f,index); var metrics = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphHMetrics(f,g); advance = metrics.advanceWidth; lsb = metrics.leftSideBearing; var rect = kha_graphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBox(f,g,scale,scale); x0 = rect.x0; y0 = rect.y0; x1 = rect.x1; y1 = rect.y1; gw = x1 - x0; gh = y1 - y0; if(x + gw + 1 >= pw) { y = bottom_y; x = 1; } if(y + gh + 1 >= ph) { return -i1; } if(x + gw >= pw) { throw new js__$Boot_HaxeError("Error"); } if(y + gh >= ph) { throw new js__$Boot_HaxeError("Error"); } kha_graphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmap(f,pixels,x + y * pw,gw,gh,pw,scale,scale,g); chardata[i1].x0 = x; chardata[i1].y0 = y; chardata[i1].x1 = x + gw; chardata[i1].y1 = y + gh; chardata[i1].xadvance = scale * advance; chardata[i1].xoff = x0; chardata[i1].yoff = y0; x = x + gw + 1; if(y + gh + 1 > bottom_y) { bottom_y = y + gh + 1; } ++i1; } return bottom_y; }; kha_graphics2_truetype_StbTruetype.stbtt_GetBakedQuad = function(chardata,pw,ph,char_index,xpos,ypos,q,opengl_fillrule) { var d3d_bias = opengl_fillrule ? 0 : -0.5; var ipw = 1.0 / pw; var iph = 1.0 / ph; var b = chardata[char_index]; var round_x = Math.floor(xpos.value + b.xoff + 0.5); var round_y = Math.floor(ypos.value + b.yoff + 0.5); q.x0 = round_x + d3d_bias; q.y0 = round_y + d3d_bias; q.x1 = round_x + b.x1 - b.x0 + d3d_bias; q.y1 = round_y + b.y1 - b.y0 + d3d_bias; q.s0 = b.x0 * ipw; q.t0 = b.y0 * iph; q.s1 = b.x1 * ipw; q.t1 = b.y1 * iph; xpos.value += b.xadvance; }; var kha_graphics4_BlendingFactor = $hxClasses["kha.graphics4.BlendingFactor"] = { __ename__ : true, __constructs__ : ["Undefined","BlendOne","BlendZero","SourceAlpha","DestinationAlpha","InverseSourceAlpha","InverseDestinationAlpha","SourceColor","DestinationColor","InverseSourceColor","InverseDestinationColor"] }; kha_graphics4_BlendingFactor.Undefined = ["Undefined",0]; kha_graphics4_BlendingFactor.Undefined.toString = $estr; kha_graphics4_BlendingFactor.Undefined.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.BlendOne = ["BlendOne",1]; kha_graphics4_BlendingFactor.BlendOne.toString = $estr; kha_graphics4_BlendingFactor.BlendOne.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.BlendZero = ["BlendZero",2]; kha_graphics4_BlendingFactor.BlendZero.toString = $estr; kha_graphics4_BlendingFactor.BlendZero.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.SourceAlpha = ["SourceAlpha",3]; kha_graphics4_BlendingFactor.SourceAlpha.toString = $estr; kha_graphics4_BlendingFactor.SourceAlpha.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.DestinationAlpha = ["DestinationAlpha",4]; kha_graphics4_BlendingFactor.DestinationAlpha.toString = $estr; kha_graphics4_BlendingFactor.DestinationAlpha.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.InverseSourceAlpha = ["InverseSourceAlpha",5]; kha_graphics4_BlendingFactor.InverseSourceAlpha.toString = $estr; kha_graphics4_BlendingFactor.InverseSourceAlpha.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.InverseDestinationAlpha = ["InverseDestinationAlpha",6]; kha_graphics4_BlendingFactor.InverseDestinationAlpha.toString = $estr; kha_graphics4_BlendingFactor.InverseDestinationAlpha.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.SourceColor = ["SourceColor",7]; kha_graphics4_BlendingFactor.SourceColor.toString = $estr; kha_graphics4_BlendingFactor.SourceColor.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.DestinationColor = ["DestinationColor",8]; kha_graphics4_BlendingFactor.DestinationColor.toString = $estr; kha_graphics4_BlendingFactor.DestinationColor.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.InverseSourceColor = ["InverseSourceColor",9]; kha_graphics4_BlendingFactor.InverseSourceColor.toString = $estr; kha_graphics4_BlendingFactor.InverseSourceColor.__enum__ = kha_graphics4_BlendingFactor; kha_graphics4_BlendingFactor.InverseDestinationColor = ["InverseDestinationColor",10]; kha_graphics4_BlendingFactor.InverseDestinationColor.toString = $estr; kha_graphics4_BlendingFactor.InverseDestinationColor.__enum__ = kha_graphics4_BlendingFactor; var kha_graphics4_BlendingOperation = $hxClasses["kha.graphics4.BlendingOperation"] = { __ename__ : true, __constructs__ : ["Add","Subtract","ReverseSubtract","Min","Max"] }; kha_graphics4_BlendingOperation.Add = ["Add",0]; kha_graphics4_BlendingOperation.Add.toString = $estr; kha_graphics4_BlendingOperation.Add.__enum__ = kha_graphics4_BlendingOperation; kha_graphics4_BlendingOperation.Subtract = ["Subtract",1]; kha_graphics4_BlendingOperation.Subtract.toString = $estr; kha_graphics4_BlendingOperation.Subtract.__enum__ = kha_graphics4_BlendingOperation; kha_graphics4_BlendingOperation.ReverseSubtract = ["ReverseSubtract",2]; kha_graphics4_BlendingOperation.ReverseSubtract.toString = $estr; kha_graphics4_BlendingOperation.ReverseSubtract.__enum__ = kha_graphics4_BlendingOperation; kha_graphics4_BlendingOperation.Min = ["Min",3]; kha_graphics4_BlendingOperation.Min.toString = $estr; kha_graphics4_BlendingOperation.Min.__enum__ = kha_graphics4_BlendingOperation; kha_graphics4_BlendingOperation.Max = ["Max",4]; kha_graphics4_BlendingOperation.Max.toString = $estr; kha_graphics4_BlendingOperation.Max.__enum__ = kha_graphics4_BlendingOperation; var kha_graphics4_CompareMode = $hxClasses["kha.graphics4.CompareMode"] = { __ename__ : true, __constructs__ : ["Always","Never","Equal","NotEqual","Less","LessEqual","Greater","GreaterEqual"] }; kha_graphics4_CompareMode.Always = ["Always",0]; kha_graphics4_CompareMode.Always.toString = $estr; kha_graphics4_CompareMode.Always.__enum__ = kha_graphics4_CompareMode; kha_graphics4_CompareMode.Never = ["Never",1]; kha_graphics4_CompareMode.Never.toString = $estr; kha_graphics4_CompareMode.Never.__enum__ = kha_graphics4_CompareMode; kha_graphics4_CompareMode.Equal = ["Equal",2]; kha_graphics4_CompareMode.Equal.toString = $estr; kha_graphics4_CompareMode.Equal.__enum__ = kha_graphics4_CompareMode; kha_graphics4_CompareMode.NotEqual = ["NotEqual",3]; kha_graphics4_CompareMode.NotEqual.toString = $estr; kha_graphics4_CompareMode.NotEqual.__enum__ = kha_graphics4_CompareMode; kha_graphics4_CompareMode.Less = ["Less",4]; kha_graphics4_CompareMode.Less.toString = $estr; kha_graphics4_CompareMode.Less.__enum__ = kha_graphics4_CompareMode; kha_graphics4_CompareMode.LessEqual = ["LessEqual",5]; kha_graphics4_CompareMode.LessEqual.toString = $estr; kha_graphics4_CompareMode.LessEqual.__enum__ = kha_graphics4_CompareMode; kha_graphics4_CompareMode.Greater = ["Greater",6]; kha_graphics4_CompareMode.Greater.toString = $estr; kha_graphics4_CompareMode.Greater.__enum__ = kha_graphics4_CompareMode; kha_graphics4_CompareMode.GreaterEqual = ["GreaterEqual",7]; kha_graphics4_CompareMode.GreaterEqual.toString = $estr; kha_graphics4_CompareMode.GreaterEqual.__enum__ = kha_graphics4_CompareMode; var kha_graphics4_ConstantLocation = function() { }; $hxClasses["kha.graphics4.ConstantLocation"] = kha_graphics4_ConstantLocation; kha_graphics4_ConstantLocation.__name__ = true; var kha_graphics4_CubeMap = function(size,format,renderTarget,depthStencilFormat) { this.isDepthAttachment = false; this.depthTexture = null; this.texture = null; this.frameBuffer = null; this.myWidth = size; this.myHeight = size; this.format = format; this.renderTarget = renderTarget; this.depthStencilFormat = depthStencilFormat; if(renderTarget) { this.createTexture(); } }; $hxClasses["kha.graphics4.CubeMap"] = kha_graphics4_CubeMap; kha_graphics4_CubeMap.__name__ = true; kha_graphics4_CubeMap.__interfaces__ = [kha_Resource,kha_Canvas]; kha_graphics4_CubeMap.createRenderTarget = function(size,format,depthStencil,contextId) { if(contextId == null) { contextId = 0; } if(format == null) { format = kha_graphics4_TextureFormat.RGBA32; } if(depthStencil == null) { depthStencil = 0; } return new kha_graphics4_CubeMap(size,format,true,depthStencil); }; kha_graphics4_CubeMap.prototype = { myWidth: null ,myHeight: null ,format: null ,renderTarget: null ,depthStencilFormat: null ,graphics4: null ,frameBuffer: null ,texture: null ,depthTexture: null ,isDepthAttachment: null ,createTexture: function() { if(kha_SystemImpl.gl == null) { return; } this.texture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(34067,this.texture); kha_SystemImpl.gl.texParameteri(34067,10240,9729); kha_SystemImpl.gl.texParameteri(34067,10241,9729); kha_SystemImpl.gl.texParameteri(34067,10242,33071); kha_SystemImpl.gl.texParameteri(34067,10243,33071); if(this.renderTarget) { this.frameBuffer = kha_SystemImpl.gl.createFramebuffer(); kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); var _g = this.format; switch(_g[1]) { case 0: var _g1 = 0; while(_g1 < 6) { var i = _g1++; kha_SystemImpl.gl.texImage2D(34069 + i,0,6408,this.myWidth,this.myHeight,0,6408,5121,null); } break; case 2: var _g2 = 0; while(_g2 < 6) { var i1 = _g2++; kha_SystemImpl.gl.texImage2D(34069 + i1,0,kha_SystemImpl.gl2 ? 34836 : 6408,this.myWidth,this.myHeight,0,6408,5126,null); } break; case 3: var _g3 = 0; while(_g3 < 6) { var i2 = _g3++; kha_SystemImpl.gl.texImage2D(34069 + i2,0,kha_SystemImpl.gl2 ? 33189 : 6402,this.myWidth,this.myHeight,0,6402,5123,null); } break; case 4: var _g4 = 0; while(_g4 < 6) { var i3 = _g4++; kha_SystemImpl.gl.texImage2D(34069 + i3,0,kha_SystemImpl.gl2 ? 34842 : 6408,this.myWidth,this.myHeight,0,6408,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,null); } break; case 5: var _g5 = 0; while(_g5 < 6) { var i4 = _g5++; kha_SystemImpl.gl.texImage2D(34069 + i4,0,kha_SystemImpl.gl2 ? 33326 : 6406,this.myWidth,this.myHeight,0,6406,5126,null); } break; case 6: var _g6 = 0; while(_g6 < 6) { var i5 = _g6++; kha_SystemImpl.gl.texImage2D(34069 + i5,0,kha_SystemImpl.gl2 ? 33325 : 6406,this.myWidth,this.myHeight,0,6406,kha_SystemImpl.halfFloat.HALF_FLOAT_OES,null); } break; default: var _g7 = 0; while(_g7 < 6) { var i6 = _g7++; kha_SystemImpl.gl.texImage2D(34069 + i6,0,6408,this.myWidth,this.myHeight,0,6408,5121,null); } } if(this.format == kha_graphics4_TextureFormat.DEPTH16) { kha_SystemImpl.gl.texParameteri(34067,10240,9728); kha_SystemImpl.gl.texParameteri(34067,10241,9728); this.isDepthAttachment = true; if(navigator.appVersion.indexOf("Win") == -1) { var colortex = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(34067,colortex); var _g11 = 0; while(_g11 < 6) { var i7 = _g11++; kha_SystemImpl.gl.texImage2D(34069 + i7,0,6408,this.myWidth,this.myHeight,0,6408,5121,null); kha_SystemImpl.gl.framebufferTexture2D(36160,36064,34069 + i7,colortex,0); } kha_SystemImpl.gl.bindTexture(34067,this.texture); } } this.initDepthStencilBuffer(this.depthStencilFormat); kha_SystemImpl.gl.bindFramebuffer(36160,null); } kha_SystemImpl.gl.bindTexture(34067,null); } ,initDepthStencilBuffer: function(depthStencilFormat) { switch(depthStencilFormat) { case 0: break; case 1:case 5: this.depthTexture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(34067,this.depthTexture); if(depthStencilFormat == 1) { kha_SystemImpl.gl.texImage2D(34067,0,kha_SystemImpl.gl2 ? 33190 : 6402,this.myWidth,this.myHeight,0,6402,5125,null); } else { kha_SystemImpl.gl.texImage2D(34067,0,kha_SystemImpl.gl2 ? 33189 : 6402,this.myWidth,this.myHeight,0,6402,5123,null); } kha_SystemImpl.gl.texParameteri(34067,10240,9728); kha_SystemImpl.gl.texParameteri(34067,10241,9728); kha_SystemImpl.gl.texParameteri(34067,10242,33071); kha_SystemImpl.gl.texParameteri(34067,10243,33071); kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); kha_SystemImpl.gl.framebufferTexture2D(36160,36096,34067,this.depthTexture,0); break; case 2:case 3:case 4: this.depthTexture = kha_SystemImpl.gl.createTexture(); kha_SystemImpl.gl.bindTexture(34067,this.depthTexture); kha_SystemImpl.gl.texImage2D(34067,0,kha_SystemImpl.gl2 ? 35056 : 34041,this.myWidth,this.myHeight,0,34041,kha_SystemImpl.depthTexture.UNSIGNED_INT_24_8_WEBGL,null); kha_SystemImpl.gl.texParameteri(34067,10240,9728); kha_SystemImpl.gl.texParameteri(34067,10241,9728); kha_SystemImpl.gl.texParameteri(34067,10242,33071); kha_SystemImpl.gl.texParameteri(34067,10243,33071); kha_SystemImpl.gl.bindFramebuffer(36160,this.frameBuffer); kha_SystemImpl.gl.framebufferTexture2D(36160,33306,34067,this.depthTexture,0); break; } } ,set: function(stage) { kha_SystemImpl.gl.activeTexture(33984 + stage); kha_SystemImpl.gl.bindTexture(34067,this.texture); } ,setDepth: function(stage) { kha_SystemImpl.gl.activeTexture(33984 + stage); kha_SystemImpl.gl.bindTexture(34067,this.depthTexture); } ,unload: function() { } ,lock: function(level) { if(level == null) { level = 0; } return null; } ,unlock: function() { } ,width: null ,get_width: function() { return this.myWidth; } ,height: null ,get_height: function() { return this.myHeight; } ,g1: null ,get_g1: function() { return null; } ,g2: null ,get_g2: function() { return null; } ,g4: null ,get_g4: function() { if(this.graphics4 == null) { this.graphics4 = new kha_js_graphics4_Graphics(this); } return this.graphics4; } ,__class__: kha_graphics4_CubeMap }; var kha_graphics4_CullMode = $hxClasses["kha.graphics4.CullMode"] = { __ename__ : true, __constructs__ : ["Clockwise","CounterClockwise","None"] }; kha_graphics4_CullMode.Clockwise = ["Clockwise",0]; kha_graphics4_CullMode.Clockwise.toString = $estr; kha_graphics4_CullMode.Clockwise.__enum__ = kha_graphics4_CullMode; kha_graphics4_CullMode.CounterClockwise = ["CounterClockwise",1]; kha_graphics4_CullMode.CounterClockwise.toString = $estr; kha_graphics4_CullMode.CounterClockwise.__enum__ = kha_graphics4_CullMode; kha_graphics4_CullMode.None = ["None",2]; kha_graphics4_CullMode.None.toString = $estr; kha_graphics4_CullMode.None.__enum__ = kha_graphics4_CullMode; var kha_graphics4_FragmentShader = function(sources,files) { this.sources = []; var _g = 0; while(_g < sources.length) { var source = sources[_g]; ++_g; this.sources.push(source.toString()); } this.type = 35632; this.shader = null; this.files = files; }; $hxClasses["kha.graphics4.FragmentShader"] = kha_graphics4_FragmentShader; kha_graphics4_FragmentShader.__name__ = true; kha_graphics4_FragmentShader.fromSource = function(source) { var shader = new kha_graphics4_FragmentShader([],["runtime-string"]); shader.sources.push(source); return shader; }; kha_graphics4_FragmentShader.prototype = { sources: null ,type: null ,shader: null ,files: null ,'delete': function() { kha_SystemImpl.gl.deleteShader(this.shader); this.shader = null; this.sources = null; } ,__class__: kha_graphics4_FragmentShader }; var kha_graphics4_GeometryShader = function(source) { }; $hxClasses["kha.graphics4.GeometryShader"] = kha_graphics4_GeometryShader; kha_graphics4_GeometryShader.__name__ = true; kha_graphics4_GeometryShader.prototype = { 'delete': function() { } ,__class__: kha_graphics4_GeometryShader }; var kha_graphics4_Graphics = function() { }; $hxClasses["kha.graphics4.Graphics"] = kha_graphics4_Graphics; kha_graphics4_Graphics.__name__ = true; kha_graphics4_Graphics.prototype = { begin: null ,beginFace: null ,beginEye: null ,end: null ,vsynced: null ,refreshRate: null ,clear: null ,viewport: null ,scissor: null ,disableScissor: null ,setVertexBuffer: null ,setVertexBuffers: null ,setIndexBuffer: null ,setTexture: null ,setTextureDepth: null ,setVideoTexture: null ,setImageTexture: null ,setTextureParameters: null ,setTexture3DParameters: null ,setCubeMap: null ,setCubeMapDepth: null ,renderTargetsInvertedY: null ,instancedRenderingAvailable: null ,setPipeline: null ,setBool: null ,setInt: null ,setFloat: null ,setFloat2: null ,setFloat3: null ,setFloat4: null ,setFloats: null ,setVector2: null ,setVector3: null ,setVector4: null ,setMatrix: null ,setMatrix3: null ,drawIndexedVertices: null ,drawIndexedVerticesInstanced: null ,flush: null ,__class__: kha_graphics4_Graphics }; var kha_graphics4_ImageShaderPainter = function(g4) { this.destinationBlend = kha_graphics4_BlendingFactor.Undefined; this.sourceBlend = kha_graphics4_BlendingFactor.Undefined; this.myPipeline = null; this.bilinearMipmaps = false; this.bilinear = false; this.g = g4; this.bufferIndex = 0; kha_graphics4_ImageShaderPainter.initShaders(); this.initBuffers(); this.projectionLocation = kha_graphics4_ImageShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix"); this.textureLocation = kha_graphics4_ImageShaderPainter.shaderPipeline.getTextureUnit("tex"); }; $hxClasses["kha.graphics4.ImageShaderPainter"] = kha_graphics4_ImageShaderPainter; kha_graphics4_ImageShaderPainter.__name__ = true; kha_graphics4_ImageShaderPainter.initShaders = function() { if(kha_graphics4_ImageShaderPainter.shaderPipeline != null) { return; } kha_graphics4_ImageShaderPainter.shaderPipeline = new kha_graphics4_PipelineState(); kha_graphics4_ImageShaderPainter.shaderPipeline.fragmentShader = kha_Shaders.painter_image_frag; kha_graphics4_ImageShaderPainter.shaderPipeline.vertexShader = kha_Shaders.painter_image_vert; kha_graphics4_ImageShaderPainter.structure = new kha_graphics4_VertexStructure(); kha_graphics4_ImageShaderPainter.structure.add("vertexPosition",kha_graphics4_VertexData.Float3); kha_graphics4_ImageShaderPainter.structure.add("texPosition",kha_graphics4_VertexData.Float2); kha_graphics4_ImageShaderPainter.structure.add("vertexColor",kha_graphics4_VertexData.Float4); kha_graphics4_ImageShaderPainter.shaderPipeline.inputLayout = [kha_graphics4_ImageShaderPainter.structure]; kha_graphics4_ImageShaderPainter.shaderPipeline.blendSource = kha_graphics4_BlendingFactor.BlendOne; kha_graphics4_ImageShaderPainter.shaderPipeline.blendDestination = kha_graphics4_BlendingFactor.InverseSourceAlpha; kha_graphics4_ImageShaderPainter.shaderPipeline.alphaBlendSource = kha_graphics4_BlendingFactor.SourceAlpha; kha_graphics4_ImageShaderPainter.shaderPipeline.alphaBlendDestination = kha_graphics4_BlendingFactor.InverseSourceAlpha; kha_graphics4_ImageShaderPainter.shaderPipeline.compile(); }; kha_graphics4_ImageShaderPainter.prototype = { projectionMatrix: null ,projectionLocation: null ,textureLocation: null ,bufferIndex: null ,rectVertexBuffer: null ,rectVertices: null ,indexBuffer: null ,lastTexture: null ,bilinear: null ,bilinearMipmaps: null ,g: null ,myPipeline: null ,sourceBlend: null ,destinationBlend: null ,get_pipeline: function() { return this.myPipeline; } ,set_pipeline: function(pipe) { if(pipe == null) { this.projectionLocation = kha_graphics4_ImageShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix"); this.textureLocation = kha_graphics4_ImageShaderPainter.shaderPipeline.getTextureUnit("tex"); } else { this.projectionLocation = pipe.getConstantLocation("projectionMatrix"); this.textureLocation = pipe.getTextureUnit("tex"); } return this.myPipeline = pipe; } ,setProjection: function(projectionMatrix) { this.projectionMatrix = projectionMatrix; } ,initBuffers: function() { this.rectVertexBuffer = new kha_graphics4_VertexBuffer(kha_graphics4_ImageShaderPainter.bufferSize * 4,kha_graphics4_ImageShaderPainter.structure,kha_graphics4_Usage.DynamicUsage); this.rectVertices = this.rectVertexBuffer.lock(); this.indexBuffer = new kha_graphics4_IndexBuffer(kha_graphics4_ImageShaderPainter.bufferSize * 3 * 2,kha_graphics4_Usage.StaticUsage); var indices = this.indexBuffer.lock(); var _g1 = 0; var _g = kha_graphics4_ImageShaderPainter.bufferSize; while(_g1 < _g) { var i = _g1++; indices[i * 3 * 2] = i * 4; indices[i * 3 * 2 + 1] = i * 4 + 1; indices[i * 3 * 2 + 2] = i * 4 + 2; indices[i * 3 * 2 + 3] = i * 4; indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } this.indexBuffer.unlock(); } ,setRectVertices: function(bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty) { var baseIndex = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex] = bottomleftx; this.rectVertices[baseIndex + 1] = bottomlefty; this.rectVertices[baseIndex + 2] = -5.0; this.rectVertices[baseIndex + 9] = topleftx; this.rectVertices[baseIndex + 10] = toplefty; this.rectVertices[baseIndex + 11] = -5.0; this.rectVertices[baseIndex + 18] = toprightx; this.rectVertices[baseIndex + 19] = toprighty; this.rectVertices[baseIndex + 20] = -5.0; this.rectVertices[baseIndex + 27] = bottomrightx; this.rectVertices[baseIndex + 28] = bottomrighty; this.rectVertices[baseIndex + 29] = -5.0; } ,setRectTexCoords: function(left,top,right,bottom) { var baseIndex = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex + 3] = left; this.rectVertices[baseIndex + 4] = bottom; this.rectVertices[baseIndex + 12] = left; this.rectVertices[baseIndex + 13] = top; this.rectVertices[baseIndex + 21] = right; this.rectVertices[baseIndex + 22] = top; this.rectVertices[baseIndex + 30] = right; this.rectVertices[baseIndex + 31] = bottom; } ,setRectColor: function(r,g,b,a) { var baseIndex = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex + 5] = r; this.rectVertices[baseIndex + 6] = g; this.rectVertices[baseIndex + 7] = b; this.rectVertices[baseIndex + 8] = a; this.rectVertices[baseIndex + 14] = r; this.rectVertices[baseIndex + 15] = g; this.rectVertices[baseIndex + 16] = b; this.rectVertices[baseIndex + 17] = a; this.rectVertices[baseIndex + 23] = r; this.rectVertices[baseIndex + 24] = g; this.rectVertices[baseIndex + 25] = b; this.rectVertices[baseIndex + 26] = a; this.rectVertices[baseIndex + 32] = r; this.rectVertices[baseIndex + 33] = g; this.rectVertices[baseIndex + 34] = b; this.rectVertices[baseIndex + 35] = a; } ,drawBuffer: function() { this.rectVertexBuffer.unlock(); this.g.setVertexBuffer(this.rectVertexBuffer); this.g.setIndexBuffer(this.indexBuffer); this.g.setPipeline(this.get_pipeline() == null ? kha_graphics4_ImageShaderPainter.shaderPipeline : this.get_pipeline()); this.g.setTexture(this.textureLocation,this.lastTexture); this.g.setTextureParameters(this.textureLocation,kha_graphics4_TextureAddressing.Clamp,kha_graphics4_TextureAddressing.Clamp,this.bilinear ? kha_graphics4_TextureFilter.LinearFilter : kha_graphics4_TextureFilter.PointFilter,this.bilinear ? kha_graphics4_TextureFilter.LinearFilter : kha_graphics4_TextureFilter.PointFilter,this.bilinearMipmaps ? kha_graphics4_MipMapFilter.LinearMipFilter : kha_graphics4_MipMapFilter.NoMipFilter); this.g.setMatrix(this.projectionLocation,this.projectionMatrix); this.g.drawIndexedVertices(0,this.bufferIndex * 2 * 3); this.g.setTexture(this.textureLocation,null); this.bufferIndex = 0; this.rectVertices = this.rectVertexBuffer.lock(); } ,setBilinearFilter: function(bilinear) { this.end(); this.bilinear = bilinear; } ,setBilinearMipmapFilter: function(bilinear) { this.end(); this.bilinearMipmaps = bilinear; } ,drawImage: function(img,bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty,opacity,color) { var tex = img; if(this.bufferIndex + 1 >= kha_graphics4_ImageShaderPainter.bufferSize || this.lastTexture != null && tex != this.lastTexture) { this.drawBuffer(); } var r = ((color & 16711680) >>> 16) * 0.00392156862745098; var g = ((color & 65280) >>> 8) * 0.00392156862745098; var b = (color & 255) * 0.00392156862745098; var a = (color >>> 24) * 0.00392156862745098 * opacity; var baseIndex = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex + 5] = r; this.rectVertices[baseIndex + 6] = g; this.rectVertices[baseIndex + 7] = b; this.rectVertices[baseIndex + 8] = a; this.rectVertices[baseIndex + 14] = r; this.rectVertices[baseIndex + 15] = g; this.rectVertices[baseIndex + 16] = b; this.rectVertices[baseIndex + 17] = a; this.rectVertices[baseIndex + 23] = r; this.rectVertices[baseIndex + 24] = g; this.rectVertices[baseIndex + 25] = b; this.rectVertices[baseIndex + 26] = a; this.rectVertices[baseIndex + 32] = r; this.rectVertices[baseIndex + 33] = g; this.rectVertices[baseIndex + 34] = b; this.rectVertices[baseIndex + 35] = a; var right = tex.get_width() / tex.get_realWidth(); var bottom = tex.get_height() / tex.get_realHeight(); var baseIndex1 = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex1 + 3] = 0; this.rectVertices[baseIndex1 + 4] = bottom; this.rectVertices[baseIndex1 + 12] = 0; this.rectVertices[baseIndex1 + 13] = 0; this.rectVertices[baseIndex1 + 21] = right; this.rectVertices[baseIndex1 + 22] = 0; this.rectVertices[baseIndex1 + 30] = right; this.rectVertices[baseIndex1 + 31] = bottom; var baseIndex2 = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex2] = bottomleftx; this.rectVertices[baseIndex2 + 1] = bottomlefty; this.rectVertices[baseIndex2 + 2] = -5.0; this.rectVertices[baseIndex2 + 9] = topleftx; this.rectVertices[baseIndex2 + 10] = toplefty; this.rectVertices[baseIndex2 + 11] = -5.0; this.rectVertices[baseIndex2 + 18] = toprightx; this.rectVertices[baseIndex2 + 19] = toprighty; this.rectVertices[baseIndex2 + 20] = -5.0; this.rectVertices[baseIndex2 + 27] = bottomrightx; this.rectVertices[baseIndex2 + 28] = bottomrighty; this.rectVertices[baseIndex2 + 29] = -5.0; ++this.bufferIndex; this.lastTexture = tex; } ,drawImage2: function(img,sx,sy,sw,sh,bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty,opacity,color) { var tex = img; if(this.bufferIndex + 1 >= kha_graphics4_ImageShaderPainter.bufferSize || this.lastTexture != null && tex != this.lastTexture) { this.drawBuffer(); } var left = sx / tex.get_realWidth(); var top = sy / tex.get_realHeight(); var right = (sx + sw) / tex.get_realWidth(); var bottom = (sy + sh) / tex.get_realHeight(); var baseIndex = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex + 3] = left; this.rectVertices[baseIndex + 4] = bottom; this.rectVertices[baseIndex + 12] = left; this.rectVertices[baseIndex + 13] = top; this.rectVertices[baseIndex + 21] = right; this.rectVertices[baseIndex + 22] = top; this.rectVertices[baseIndex + 30] = right; this.rectVertices[baseIndex + 31] = bottom; var r = ((color & 16711680) >>> 16) * 0.00392156862745098; var g = ((color & 65280) >>> 8) * 0.00392156862745098; var b = (color & 255) * 0.00392156862745098; var a = (color >>> 24) * 0.00392156862745098 * opacity; var baseIndex1 = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex1 + 5] = r; this.rectVertices[baseIndex1 + 6] = g; this.rectVertices[baseIndex1 + 7] = b; this.rectVertices[baseIndex1 + 8] = a; this.rectVertices[baseIndex1 + 14] = r; this.rectVertices[baseIndex1 + 15] = g; this.rectVertices[baseIndex1 + 16] = b; this.rectVertices[baseIndex1 + 17] = a; this.rectVertices[baseIndex1 + 23] = r; this.rectVertices[baseIndex1 + 24] = g; this.rectVertices[baseIndex1 + 25] = b; this.rectVertices[baseIndex1 + 26] = a; this.rectVertices[baseIndex1 + 32] = r; this.rectVertices[baseIndex1 + 33] = g; this.rectVertices[baseIndex1 + 34] = b; this.rectVertices[baseIndex1 + 35] = a; var baseIndex2 = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex2] = bottomleftx; this.rectVertices[baseIndex2 + 1] = bottomlefty; this.rectVertices[baseIndex2 + 2] = -5.0; this.rectVertices[baseIndex2 + 9] = topleftx; this.rectVertices[baseIndex2 + 10] = toplefty; this.rectVertices[baseIndex2 + 11] = -5.0; this.rectVertices[baseIndex2 + 18] = toprightx; this.rectVertices[baseIndex2 + 19] = toprighty; this.rectVertices[baseIndex2 + 20] = -5.0; this.rectVertices[baseIndex2 + 27] = bottomrightx; this.rectVertices[baseIndex2 + 28] = bottomrighty; this.rectVertices[baseIndex2 + 29] = -5.0; ++this.bufferIndex; this.lastTexture = tex; } ,drawImageScale: function(img,sx,sy,sw,sh,left,top,right,bottom,opacity,color) { var tex = img; if(this.bufferIndex + 1 >= kha_graphics4_ImageShaderPainter.bufferSize || this.lastTexture != null && tex != this.lastTexture) { this.drawBuffer(); } var left1 = sx / tex.get_realWidth(); var top1 = sy / tex.get_realHeight(); var right1 = (sx + sw) / tex.get_realWidth(); var bottom1 = (sy + sh) / tex.get_realHeight(); var baseIndex = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex + 3] = left1; this.rectVertices[baseIndex + 4] = bottom1; this.rectVertices[baseIndex + 12] = left1; this.rectVertices[baseIndex + 13] = top1; this.rectVertices[baseIndex + 21] = right1; this.rectVertices[baseIndex + 22] = top1; this.rectVertices[baseIndex + 30] = right1; this.rectVertices[baseIndex + 31] = bottom1; var r = ((color & 16711680) >>> 16) * 0.00392156862745098; var g = ((color & 65280) >>> 8) * 0.00392156862745098; var b = (color & 255) * 0.00392156862745098; var baseIndex1 = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex1 + 5] = r; this.rectVertices[baseIndex1 + 6] = g; this.rectVertices[baseIndex1 + 7] = b; this.rectVertices[baseIndex1 + 8] = opacity; this.rectVertices[baseIndex1 + 14] = r; this.rectVertices[baseIndex1 + 15] = g; this.rectVertices[baseIndex1 + 16] = b; this.rectVertices[baseIndex1 + 17] = opacity; this.rectVertices[baseIndex1 + 23] = r; this.rectVertices[baseIndex1 + 24] = g; this.rectVertices[baseIndex1 + 25] = b; this.rectVertices[baseIndex1 + 26] = opacity; this.rectVertices[baseIndex1 + 32] = r; this.rectVertices[baseIndex1 + 33] = g; this.rectVertices[baseIndex1 + 34] = b; this.rectVertices[baseIndex1 + 35] = opacity; var baseIndex2 = this.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; this.rectVertices[baseIndex2] = left; this.rectVertices[baseIndex2 + 1] = bottom; this.rectVertices[baseIndex2 + 2] = -5.0; this.rectVertices[baseIndex2 + 9] = left; this.rectVertices[baseIndex2 + 10] = top; this.rectVertices[baseIndex2 + 11] = -5.0; this.rectVertices[baseIndex2 + 18] = right; this.rectVertices[baseIndex2 + 19] = top; this.rectVertices[baseIndex2 + 20] = -5.0; this.rectVertices[baseIndex2 + 27] = right; this.rectVertices[baseIndex2 + 28] = bottom; this.rectVertices[baseIndex2 + 29] = -5.0; ++this.bufferIndex; this.lastTexture = tex; } ,end: function() { if(this.bufferIndex > 0) { this.drawBuffer(); } this.lastTexture = null; } ,__class__: kha_graphics4_ImageShaderPainter }; var kha_graphics4_ColoredShaderPainter = function(g4) { this.destinationBlend = kha_graphics4_BlendingFactor.Undefined; this.sourceBlend = kha_graphics4_BlendingFactor.Undefined; this.myPipeline = null; this.g = g4; this.bufferIndex = 0; this.triangleBufferIndex = 0; kha_graphics4_ColoredShaderPainter.initShaders(); this.initBuffers(); this.projectionLocation = kha_graphics4_ColoredShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix"); }; $hxClasses["kha.graphics4.ColoredShaderPainter"] = kha_graphics4_ColoredShaderPainter; kha_graphics4_ColoredShaderPainter.__name__ = true; kha_graphics4_ColoredShaderPainter.initShaders = function() { if(kha_graphics4_ColoredShaderPainter.shaderPipeline != null) { return; } kha_graphics4_ColoredShaderPainter.shaderPipeline = new kha_graphics4_PipelineState(); kha_graphics4_ColoredShaderPainter.shaderPipeline.fragmentShader = kha_Shaders.painter_colored_frag; kha_graphics4_ColoredShaderPainter.shaderPipeline.vertexShader = kha_Shaders.painter_colored_vert; kha_graphics4_ColoredShaderPainter.structure = new kha_graphics4_VertexStructure(); kha_graphics4_ColoredShaderPainter.structure.add("vertexPosition",kha_graphics4_VertexData.Float3); kha_graphics4_ColoredShaderPainter.structure.add("vertexColor",kha_graphics4_VertexData.Float4); kha_graphics4_ColoredShaderPainter.shaderPipeline.inputLayout = [kha_graphics4_ColoredShaderPainter.structure]; kha_graphics4_ColoredShaderPainter.shaderPipeline.blendSource = kha_graphics4_BlendingFactor.SourceAlpha; kha_graphics4_ColoredShaderPainter.shaderPipeline.blendDestination = kha_graphics4_BlendingFactor.InverseSourceAlpha; kha_graphics4_ColoredShaderPainter.shaderPipeline.alphaBlendSource = kha_graphics4_BlendingFactor.SourceAlpha; kha_graphics4_ColoredShaderPainter.shaderPipeline.alphaBlendDestination = kha_graphics4_BlendingFactor.InverseSourceAlpha; kha_graphics4_ColoredShaderPainter.shaderPipeline.compile(); }; kha_graphics4_ColoredShaderPainter.prototype = { projectionMatrix: null ,projectionLocation: null ,bufferIndex: null ,rectVertexBuffer: null ,rectVertices: null ,indexBuffer: null ,triangleBufferIndex: null ,triangleVertexBuffer: null ,triangleVertices: null ,triangleIndexBuffer: null ,g: null ,myPipeline: null ,sourceBlend: null ,destinationBlend: null ,get_pipeline: function() { return this.myPipeline; } ,set_pipeline: function(pipe) { if(pipe == null) { this.projectionLocation = kha_graphics4_ColoredShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix"); } else { this.projectionLocation = pipe.getConstantLocation("projectionMatrix"); } return this.myPipeline = pipe; } ,setProjection: function(projectionMatrix) { this.projectionMatrix = projectionMatrix; } ,initBuffers: function() { this.rectVertexBuffer = new kha_graphics4_VertexBuffer(kha_graphics4_ColoredShaderPainter.bufferSize * 4,kha_graphics4_ColoredShaderPainter.structure,kha_graphics4_Usage.DynamicUsage); this.rectVertices = this.rectVertexBuffer.lock(); this.indexBuffer = new kha_graphics4_IndexBuffer(kha_graphics4_ColoredShaderPainter.bufferSize * 3 * 2,kha_graphics4_Usage.StaticUsage); var indices = this.indexBuffer.lock(); var _g1 = 0; var _g = kha_graphics4_ColoredShaderPainter.bufferSize; while(_g1 < _g) { var i = _g1++; indices[i * 3 * 2] = i * 4; indices[i * 3 * 2 + 1] = i * 4 + 1; indices[i * 3 * 2 + 2] = i * 4 + 2; indices[i * 3 * 2 + 3] = i * 4; indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } this.indexBuffer.unlock(); this.triangleVertexBuffer = new kha_graphics4_VertexBuffer(kha_graphics4_ColoredShaderPainter.triangleBufferSize * 3,kha_graphics4_ColoredShaderPainter.structure,kha_graphics4_Usage.DynamicUsage); this.triangleVertices = this.triangleVertexBuffer.lock(); this.triangleIndexBuffer = new kha_graphics4_IndexBuffer(kha_graphics4_ColoredShaderPainter.triangleBufferSize * 3,kha_graphics4_Usage.StaticUsage); var triIndices = this.triangleIndexBuffer.lock(); var _g11 = 0; var _g2 = kha_graphics4_ColoredShaderPainter.bufferSize; while(_g11 < _g2) { var i1 = _g11++; triIndices[i1 * 3] = i1 * 3; triIndices[i1 * 3 + 1] = i1 * 3 + 1; triIndices[i1 * 3 + 2] = i1 * 3 + 2; } this.triangleIndexBuffer.unlock(); } ,setRectVertices: function(bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty) { var baseIndex = this.bufferIndex * 7 * 4; this.rectVertices[baseIndex] = bottomleftx; this.rectVertices[baseIndex + 1] = bottomlefty; this.rectVertices[baseIndex + 2] = -5.0; this.rectVertices[baseIndex + 7] = topleftx; this.rectVertices[baseIndex + 8] = toplefty; this.rectVertices[baseIndex + 9] = -5.0; this.rectVertices[baseIndex + 14] = toprightx; this.rectVertices[baseIndex + 15] = toprighty; this.rectVertices[baseIndex + 16] = -5.0; this.rectVertices[baseIndex + 21] = bottomrightx; this.rectVertices[baseIndex + 22] = bottomrighty; this.rectVertices[baseIndex + 23] = -5.0; } ,setRectColors: function(opacity,color) { var baseIndex = this.bufferIndex * 7 * 4; var a = opacity * ((color >>> 24) * 0.00392156862745098); this.rectVertices[baseIndex + 3] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 4] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 5] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 6] = a; this.rectVertices[baseIndex + 10] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 11] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 12] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 13] = a; this.rectVertices[baseIndex + 17] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 18] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 19] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 20] = a; this.rectVertices[baseIndex + 24] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 25] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 26] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 27] = a; } ,setTriVertices: function(x1,y1,x2,y2,x3,y3) { var baseIndex = this.triangleBufferIndex * 7 * 3; this.triangleVertices[baseIndex] = x1; this.triangleVertices[baseIndex + 1] = y1; this.triangleVertices[baseIndex + 2] = -5.0; this.triangleVertices[baseIndex + 7] = x2; this.triangleVertices[baseIndex + 8] = y2; this.triangleVertices[baseIndex + 9] = -5.0; this.triangleVertices[baseIndex + 14] = x3; this.triangleVertices[baseIndex + 15] = y3; this.triangleVertices[baseIndex + 16] = -5.0; } ,setTriColors: function(opacity,color) { var baseIndex = this.triangleBufferIndex * 7 * 3; var a = opacity * ((color >>> 24) * 0.00392156862745098); this.triangleVertices[baseIndex + 3] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.triangleVertices[baseIndex + 4] = ((color & 65280) >>> 8) * 0.00392156862745098; this.triangleVertices[baseIndex + 5] = (color & 255) * 0.00392156862745098; this.triangleVertices[baseIndex + 6] = a; this.triangleVertices[baseIndex + 10] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.triangleVertices[baseIndex + 11] = ((color & 65280) >>> 8) * 0.00392156862745098; this.triangleVertices[baseIndex + 12] = (color & 255) * 0.00392156862745098; this.triangleVertices[baseIndex + 13] = a; this.triangleVertices[baseIndex + 17] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.triangleVertices[baseIndex + 18] = ((color & 65280) >>> 8) * 0.00392156862745098; this.triangleVertices[baseIndex + 19] = (color & 255) * 0.00392156862745098; this.triangleVertices[baseIndex + 20] = a; } ,drawBuffer: function(trisDone) { if(!trisDone) { if(this.triangleBufferIndex > 0) { this.drawTriBuffer(true); } } this.rectVertexBuffer.unlock(); this.g.setVertexBuffer(this.rectVertexBuffer); this.g.setIndexBuffer(this.indexBuffer); this.g.setPipeline(this.get_pipeline() == null ? kha_graphics4_ColoredShaderPainter.shaderPipeline : this.get_pipeline()); this.g.setMatrix(this.projectionLocation,this.projectionMatrix); this.g.drawIndexedVertices(0,this.bufferIndex * 2 * 3); this.bufferIndex = 0; this.rectVertices = this.rectVertexBuffer.lock(); } ,drawTriBuffer: function(rectsDone) { if(!rectsDone) { if(this.bufferIndex > 0) { this.drawBuffer(true); } } this.triangleVertexBuffer.unlock(); this.g.setVertexBuffer(this.triangleVertexBuffer); this.g.setIndexBuffer(this.triangleIndexBuffer); this.g.setPipeline(this.get_pipeline() == null ? kha_graphics4_ColoredShaderPainter.shaderPipeline : this.get_pipeline()); this.g.setMatrix(this.projectionLocation,this.projectionMatrix); this.g.drawIndexedVertices(0,this.triangleBufferIndex * 3); this.triangleBufferIndex = 0; this.triangleVertices = this.triangleVertexBuffer.lock(); } ,fillRect: function(opacity,color,bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty) { if(this.triangleBufferIndex > 0) { this.drawTriBuffer(true); } if(this.bufferIndex + 1 >= kha_graphics4_ColoredShaderPainter.bufferSize) { this.drawBuffer(false); } this.setRectColors(opacity,color); this.setRectVertices(bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty); ++this.bufferIndex; } ,fillTriangle: function(opacity,color,x1,y1,x2,y2,x3,y3) { if(this.bufferIndex > 0) { this.drawBuffer(true); } if(this.triangleBufferIndex + 1 >= kha_graphics4_ColoredShaderPainter.triangleBufferSize) { this.drawTriBuffer(false); } this.setTriColors(opacity,color); this.setTriVertices(x1,y1,x2,y2,x3,y3); ++this.triangleBufferIndex; } ,endTris: function(rectsDone) { if(this.triangleBufferIndex > 0) { this.drawTriBuffer(rectsDone); } } ,endRects: function(trisDone) { if(this.bufferIndex > 0) { this.drawBuffer(trisDone); } } ,end: function() { if(this.triangleBufferIndex > 0) { this.drawTriBuffer(false); } if(this.bufferIndex > 0) { this.drawBuffer(false); } } ,__class__: kha_graphics4_ColoredShaderPainter }; var kha_graphics4_TextShaderPainter = function(g4) { this.destinationBlend = kha_graphics4_BlendingFactor.Undefined; this.sourceBlend = kha_graphics4_BlendingFactor.Undefined; this.bilinear = false; this.myPipeline = null; this.g = g4; this.bufferIndex = 0; kha_graphics4_TextShaderPainter.initShaders(); this.initBuffers(); this.projectionLocation = kha_graphics4_TextShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix"); this.textureLocation = kha_graphics4_TextShaderPainter.shaderPipeline.getTextureUnit("tex"); }; $hxClasses["kha.graphics4.TextShaderPainter"] = kha_graphics4_TextShaderPainter; kha_graphics4_TextShaderPainter.__name__ = true; kha_graphics4_TextShaderPainter.initShaders = function() { if(kha_graphics4_TextShaderPainter.shaderPipeline != null) { return; } kha_graphics4_TextShaderPainter.shaderPipeline = new kha_graphics4_PipelineState(); kha_graphics4_TextShaderPainter.shaderPipeline.fragmentShader = kha_Shaders.painter_text_frag; kha_graphics4_TextShaderPainter.shaderPipeline.vertexShader = kha_Shaders.painter_text_vert; kha_graphics4_TextShaderPainter.structure = new kha_graphics4_VertexStructure(); kha_graphics4_TextShaderPainter.structure.add("vertexPosition",kha_graphics4_VertexData.Float3); kha_graphics4_TextShaderPainter.structure.add("texPosition",kha_graphics4_VertexData.Float2); kha_graphics4_TextShaderPainter.structure.add("vertexColor",kha_graphics4_VertexData.Float4); kha_graphics4_TextShaderPainter.shaderPipeline.inputLayout = [kha_graphics4_TextShaderPainter.structure]; kha_graphics4_TextShaderPainter.shaderPipeline.blendSource = kha_graphics4_BlendingFactor.SourceAlpha; kha_graphics4_TextShaderPainter.shaderPipeline.blendDestination = kha_graphics4_BlendingFactor.InverseSourceAlpha; kha_graphics4_TextShaderPainter.shaderPipeline.alphaBlendSource = kha_graphics4_BlendingFactor.SourceAlpha; kha_graphics4_TextShaderPainter.shaderPipeline.alphaBlendDestination = kha_graphics4_BlendingFactor.InverseSourceAlpha; kha_graphics4_TextShaderPainter.shaderPipeline.compile(); }; kha_graphics4_TextShaderPainter.findIndex = function(charcode,fontGlyphs) { var _g1 = 0; var _g = fontGlyphs.length; while(_g1 < _g) { var i = _g1++; if(fontGlyphs[i] == charcode) { return i; } } return 0; }; kha_graphics4_TextShaderPainter.prototype = { projectionMatrix: null ,projectionLocation: null ,textureLocation: null ,bufferIndex: null ,rectVertexBuffer: null ,rectVertices: null ,indexBuffer: null ,font: null ,lastTexture: null ,g: null ,myPipeline: null ,fontSize: null ,bilinear: null ,sourceBlend: null ,destinationBlend: null ,get_pipeline: function() { return this.myPipeline; } ,set_pipeline: function(pipe) { if(pipe == null) { this.projectionLocation = kha_graphics4_TextShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix"); this.textureLocation = kha_graphics4_TextShaderPainter.shaderPipeline.getTextureUnit("tex"); } else { this.projectionLocation = pipe.getConstantLocation("projectionMatrix"); this.textureLocation = pipe.getTextureUnit("tex"); } return this.myPipeline = pipe; } ,setProjection: function(projectionMatrix) { this.projectionMatrix = projectionMatrix; } ,initBuffers: function() { this.rectVertexBuffer = new kha_graphics4_VertexBuffer(kha_graphics4_TextShaderPainter.bufferSize * 4,kha_graphics4_TextShaderPainter.structure,kha_graphics4_Usage.DynamicUsage); this.rectVertices = this.rectVertexBuffer.lock(); this.indexBuffer = new kha_graphics4_IndexBuffer(kha_graphics4_TextShaderPainter.bufferSize * 3 * 2,kha_graphics4_Usage.StaticUsage); var indices = this.indexBuffer.lock(); var _g1 = 0; var _g = kha_graphics4_TextShaderPainter.bufferSize; while(_g1 < _g) { var i = _g1++; indices[i * 3 * 2] = i * 4; indices[i * 3 * 2 + 1] = i * 4 + 1; indices[i * 3 * 2 + 2] = i * 4 + 2; indices[i * 3 * 2 + 3] = i * 4; indices[i * 3 * 2 + 4] = i * 4 + 2; indices[i * 3 * 2 + 5] = i * 4 + 3; } this.indexBuffer.unlock(); } ,setRectVertices: function(bottomleftx,bottomlefty,topleftx,toplefty,toprightx,toprighty,bottomrightx,bottomrighty) { var baseIndex = this.bufferIndex * 9 * 4; this.rectVertices[baseIndex] = bottomleftx; this.rectVertices[baseIndex + 1] = bottomlefty; this.rectVertices[baseIndex + 2] = -5.0; this.rectVertices[baseIndex + 9] = topleftx; this.rectVertices[baseIndex + 10] = toplefty; this.rectVertices[baseIndex + 11] = -5.0; this.rectVertices[baseIndex + 18] = toprightx; this.rectVertices[baseIndex + 19] = toprighty; this.rectVertices[baseIndex + 20] = -5.0; this.rectVertices[baseIndex + 27] = bottomrightx; this.rectVertices[baseIndex + 28] = bottomrighty; this.rectVertices[baseIndex + 29] = -5.0; } ,setRectTexCoords: function(left,top,right,bottom) { var baseIndex = this.bufferIndex * 9 * 4; this.rectVertices[baseIndex + 3] = left; this.rectVertices[baseIndex + 4] = bottom; this.rectVertices[baseIndex + 12] = left; this.rectVertices[baseIndex + 13] = top; this.rectVertices[baseIndex + 21] = right; this.rectVertices[baseIndex + 22] = top; this.rectVertices[baseIndex + 30] = right; this.rectVertices[baseIndex + 31] = bottom; } ,setRectColors: function(opacity,color) { var baseIndex = this.bufferIndex * 9 * 4; var a = opacity * ((color >>> 24) * 0.00392156862745098); this.rectVertices[baseIndex + 5] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 6] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 7] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 8] = a; this.rectVertices[baseIndex + 14] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 15] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 16] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 17] = a; this.rectVertices[baseIndex + 23] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 24] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 25] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 26] = a; this.rectVertices[baseIndex + 32] = ((color & 16711680) >>> 16) * 0.00392156862745098; this.rectVertices[baseIndex + 33] = ((color & 65280) >>> 8) * 0.00392156862745098; this.rectVertices[baseIndex + 34] = (color & 255) * 0.00392156862745098; this.rectVertices[baseIndex + 35] = a; } ,drawBuffer: function() { this.rectVertexBuffer.unlock(); this.g.setVertexBuffer(this.rectVertexBuffer); this.g.setIndexBuffer(this.indexBuffer); this.g.setPipeline(this.get_pipeline() == null ? kha_graphics4_TextShaderPainter.shaderPipeline : this.get_pipeline()); this.g.setTexture(this.textureLocation,this.lastTexture); this.g.setMatrix(this.projectionLocation,this.projectionMatrix); this.g.setTextureParameters(this.textureLocation,kha_graphics4_TextureAddressing.Clamp,kha_graphics4_TextureAddressing.Clamp,this.bilinear ? kha_graphics4_TextureFilter.LinearFilter : kha_graphics4_TextureFilter.PointFilter,this.bilinear ? kha_graphics4_TextureFilter.LinearFilter : kha_graphics4_TextureFilter.PointFilter,kha_graphics4_MipMapFilter.NoMipFilter); this.g.drawIndexedVertices(0,this.bufferIndex * 2 * 3); this.g.setTexture(this.textureLocation,null); this.bufferIndex = 0; this.rectVertices = this.rectVertexBuffer.lock(); } ,setBilinearFilter: function(bilinear) { this.end(); this.bilinear = bilinear; } ,setFont: function(font) { this.font = js_Boot.__cast(font , kha_Kravur); } ,text: null ,startString: function(text) { this.text = text; } ,charCodeAt: function(position) { return HxOverrides.cca(this.text,position); } ,stringLength: function() { return this.text.length; } ,endString: function() { this.text = null; } ,drawString: function(text,opacity,color,x,y,transformation,fontGlyphs) { var font = this.font._get(this.fontSize,fontGlyphs); var tex = font.getTexture(); if(this.lastTexture != null && tex != this.lastTexture) { this.drawBuffer(); } this.lastTexture = tex; var xpos = x; var ypos = y; this.startString(text); var _g1 = 0; var _g = this.stringLength(); while(_g1 < _g) { var i = _g1++; var q = font.getBakedQuad(kha_graphics4_TextShaderPainter.findIndex(this.charCodeAt(i),fontGlyphs),xpos,ypos); if(q != null) { if(this.bufferIndex + 1 >= kha_graphics4_TextShaderPainter.bufferSize) { this.drawBuffer(); } this.setRectColors(opacity,color); this.setRectTexCoords(q.s0 * tex.get_width() / tex.get_realWidth(),q.t0 * tex.get_height() / tex.get_realHeight(),q.s1 * tex.get_width() / tex.get_realWidth(),q.t1 * tex.get_height() / tex.get_realHeight()); var p0_y; var p0_x; var value_y; var value_x = q.x0; value_y = q.y1; var w = transformation._02 * value_x + transformation._12 * value_y + transformation._22; var x1 = (transformation._00 * value_x + transformation._10 * value_y + transformation._20) / w; var y1 = (transformation._01 * value_x + transformation._11 * value_y + transformation._21) / w; p0_x = x1; p0_y = y1; var p1_y; var p1_x; var value_y1; var value_x1 = q.x0; value_y1 = q.y0; var w1 = transformation._02 * value_x1 + transformation._12 * value_y1 + transformation._22; var x2 = (transformation._00 * value_x1 + transformation._10 * value_y1 + transformation._20) / w1; var y2 = (transformation._01 * value_x1 + transformation._11 * value_y1 + transformation._21) / w1; p1_x = x2; p1_y = y2; var p2_y; var p2_x; var value_y2; var value_x2 = q.x1; value_y2 = q.y0; var w2 = transformation._02 * value_x2 + transformation._12 * value_y2 + transformation._22; var x3 = (transformation._00 * value_x2 + transformation._10 * value_y2 + transformation._20) / w2; var y3 = (transformation._01 * value_x2 + transformation._11 * value_y2 + transformation._21) / w2; p2_x = x3; p2_y = y3; var p3_y; var p3_x; var value_y3; var value_x3 = q.x1; value_y3 = q.y1; var w3 = transformation._02 * value_x3 + transformation._12 * value_y3 + transformation._22; var x4 = (transformation._00 * value_x3 + transformation._10 * value_y3 + transformation._20) / w3; var y4 = (transformation._01 * value_x3 + transformation._11 * value_y3 + transformation._21) / w3; p3_x = x4; p3_y = y4; this.setRectVertices(p0_x,p0_y,p1_x,p1_y,p2_x,p2_y,p3_x,p3_y); xpos += q.xadvance; ++this.bufferIndex; } } this.endString(); } ,end: function() { if(this.bufferIndex > 0) { this.drawBuffer(); } this.lastTexture = null; } ,__class__: kha_graphics4_TextShaderPainter }; var kha_graphics4_Graphics2 = function(canvas) { this.myMipmapScaleQuality = kha_graphics2_ImageScaleQuality.High; this.myImageScaleQuality = kha_graphics2_ImageScaleQuality.High; kha_graphics2_Graphics.call(this); this.set_color(-1); this.canvas = canvas; this.g = canvas.get_g4(); this.imagePainter = new kha_graphics4_ImageShaderPainter(this.g); this.coloredPainter = new kha_graphics4_ColoredShaderPainter(this.g); this.textPainter = new kha_graphics4_TextShaderPainter(this.g); this.textPainter.fontSize = this.get_fontSize(); this.setProjection(); if(kha_graphics4_Graphics2.videoPipeline == null) { kha_graphics4_Graphics2.videoPipeline = new kha_graphics4_PipelineState(); kha_graphics4_Graphics2.videoPipeline.fragmentShader = kha_Shaders.painter_video_frag; kha_graphics4_Graphics2.videoPipeline.vertexShader = kha_Shaders.painter_video_vert; var structure = new kha_graphics4_VertexStructure(); structure.add("vertexPosition",kha_graphics4_VertexData.Float3); structure.add("texPosition",kha_graphics4_VertexData.Float2); structure.add("vertexColor",kha_graphics4_VertexData.Float4); kha_graphics4_Graphics2.videoPipeline.inputLayout = [structure]; kha_graphics4_Graphics2.videoPipeline.compile(); } }; $hxClasses["kha.graphics4.Graphics2"] = kha_graphics4_Graphics2; kha_graphics4_Graphics2.__name__ = true; kha_graphics4_Graphics2.upperPowerOfTwo = function(v) { --v; v |= v >>> 1; v |= v >>> 2; v |= v >>> 4; v |= v >>> 8; v |= v >>> 16; return ++v; }; kha_graphics4_Graphics2.__super__ = kha_graphics2_Graphics; kha_graphics4_Graphics2.prototype = $extend(kha_graphics2_Graphics.prototype,{ myColor: null ,myFont: null ,projectionMatrix: null ,imagePainter: null ,coloredPainter: null ,textPainter: null ,canvas: null ,g: null ,setProjection: function() { var width = this.canvas.get_width(); var height = this.canvas.get_height(); if(js_Boot.__instanceof(this.canvas,kha_Framebuffer)) { this.projectionMatrix = kha_math_FastMatrix4.orthogonalProjection(0,width,height,0,0.1,1000); } else { if(!kha_Image.get_nonPow2Supported()) { width = kha_graphics4_Graphics2.upperPowerOfTwo(width); height = kha_graphics4_Graphics2.upperPowerOfTwo(height); } if(this.g.renderTargetsInvertedY()) { this.projectionMatrix = kha_math_FastMatrix4.orthogonalProjection(0,width,0,height,0.1,1000); } else { this.projectionMatrix = kha_math_FastMatrix4.orthogonalProjection(0,width,height,0,0.1,1000); } } this.imagePainter.setProjection(this.projectionMatrix); this.coloredPainter.setProjection(this.projectionMatrix); this.textPainter.setProjection(this.projectionMatrix); } ,drawImage: function(img,x,y) { var _this = this.coloredPainter; if(_this.triangleBufferIndex > 0) { _this.drawTriBuffer(false); } if(_this.bufferIndex > 0) { _this.drawBuffer(false); } this.textPainter.end(); var xw = x + img.get_width(); var yh = y + img.get_height(); var p1_y; var p1_x; var _this1 = this.transformations[this.transformations.length - 1]; var value_y; var value_x = x; value_y = yh; var w = _this1._02 * value_x + _this1._12 * value_y + _this1._22; var x1 = (_this1._00 * value_x + _this1._10 * value_y + _this1._20) / w; var y1 = (_this1._01 * value_x + _this1._11 * value_y + _this1._21) / w; p1_x = x1; p1_y = y1; var p2_y; var p2_x; var _this2 = this.transformations[this.transformations.length - 1]; var value_y1; var value_x1 = x; value_y1 = y; var w1 = _this2._02 * value_x1 + _this2._12 * value_y1 + _this2._22; var x2 = (_this2._00 * value_x1 + _this2._10 * value_y1 + _this2._20) / w1; var y2 = (_this2._01 * value_x1 + _this2._11 * value_y1 + _this2._21) / w1; p2_x = x2; p2_y = y2; var p3_y; var p3_x; var _this3 = this.transformations[this.transformations.length - 1]; var value_y2; var value_x2 = xw; value_y2 = y; var w2 = _this3._02 * value_x2 + _this3._12 * value_y2 + _this3._22; var x3 = (_this3._00 * value_x2 + _this3._10 * value_y2 + _this3._20) / w2; var y3 = (_this3._01 * value_x2 + _this3._11 * value_y2 + _this3._21) / w2; p3_x = x3; p3_y = y3; var p4_y; var p4_x; var _this4 = this.transformations[this.transformations.length - 1]; var value_y3; var value_x3 = xw; value_y3 = yh; var w3 = _this4._02 * value_x3 + _this4._12 * value_y3 + _this4._22; var x4 = (_this4._00 * value_x3 + _this4._10 * value_y3 + _this4._20) / w3; var y4 = (_this4._01 * value_x3 + _this4._11 * value_y3 + _this4._21) / w3; p4_x = x4; p4_y = y4; var _this5 = this.imagePainter; var opacity = this.get_opacity(); var color = this.get_color(); var tex = img; if(_this5.bufferIndex + 1 >= kha_graphics4_ImageShaderPainter.bufferSize || _this5.lastTexture != null && tex != _this5.lastTexture) { _this5.drawBuffer(); } var r = ((color & 16711680) >>> 16) * 0.00392156862745098; var g = ((color & 65280) >>> 8) * 0.00392156862745098; var b = (color & 255) * 0.00392156862745098; var a = (color >>> 24) * 0.00392156862745098 * opacity; var baseIndex = _this5.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; _this5.rectVertices[baseIndex + 5] = r; _this5.rectVertices[baseIndex + 6] = g; _this5.rectVertices[baseIndex + 7] = b; _this5.rectVertices[baseIndex + 8] = a; _this5.rectVertices[baseIndex + 14] = r; _this5.rectVertices[baseIndex + 15] = g; _this5.rectVertices[baseIndex + 16] = b; _this5.rectVertices[baseIndex + 17] = a; _this5.rectVertices[baseIndex + 23] = r; _this5.rectVertices[baseIndex + 24] = g; _this5.rectVertices[baseIndex + 25] = b; _this5.rectVertices[baseIndex + 26] = a; _this5.rectVertices[baseIndex + 32] = r; _this5.rectVertices[baseIndex + 33] = g; _this5.rectVertices[baseIndex + 34] = b; _this5.rectVertices[baseIndex + 35] = a; var right = tex.get_width() / tex.get_realWidth(); var bottom = tex.get_height() / tex.get_realHeight(); var baseIndex1 = _this5.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; _this5.rectVertices[baseIndex1 + 3] = 0; _this5.rectVertices[baseIndex1 + 4] = bottom; _this5.rectVertices[baseIndex1 + 12] = 0; _this5.rectVertices[baseIndex1 + 13] = 0; _this5.rectVertices[baseIndex1 + 21] = right; _this5.rectVertices[baseIndex1 + 22] = 0; _this5.rectVertices[baseIndex1 + 30] = right; _this5.rectVertices[baseIndex1 + 31] = bottom; var baseIndex2 = _this5.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; _this5.rectVertices[baseIndex2] = p1_x; _this5.rectVertices[baseIndex2 + 1] = p1_y; _this5.rectVertices[baseIndex2 + 2] = -5.0; _this5.rectVertices[baseIndex2 + 9] = p2_x; _this5.rectVertices[baseIndex2 + 10] = p2_y; _this5.rectVertices[baseIndex2 + 11] = -5.0; _this5.rectVertices[baseIndex2 + 18] = p3_x; _this5.rectVertices[baseIndex2 + 19] = p3_y; _this5.rectVertices[baseIndex2 + 20] = -5.0; _this5.rectVertices[baseIndex2 + 27] = p4_x; _this5.rectVertices[baseIndex2 + 28] = p4_y; _this5.rectVertices[baseIndex2 + 29] = -5.0; ++_this5.bufferIndex; _this5.lastTexture = tex; } ,drawScaledSubImage: function(img,sx,sy,sw,sh,dx,dy,dw,dh) { var _this = this.coloredPainter; if(_this.triangleBufferIndex > 0) { _this.drawTriBuffer(false); } if(_this.bufferIndex > 0) { _this.drawBuffer(false); } this.textPainter.end(); var p1_y; var p1_x; var _this1 = this.transformations[this.transformations.length - 1]; var value_y; var value_x = dx; value_y = dy + dh; var w = _this1._02 * value_x + _this1._12 * value_y + _this1._22; var x = (_this1._00 * value_x + _this1._10 * value_y + _this1._20) / w; var y = (_this1._01 * value_x + _this1._11 * value_y + _this1._21) / w; p1_x = x; p1_y = y; var p2_y; var p2_x; var _this2 = this.transformations[this.transformations.length - 1]; var value_y1; var value_x1 = dx; value_y1 = dy; var w1 = _this2._02 * value_x1 + _this2._12 * value_y1 + _this2._22; var x1 = (_this2._00 * value_x1 + _this2._10 * value_y1 + _this2._20) / w1; var y1 = (_this2._01 * value_x1 + _this2._11 * value_y1 + _this2._21) / w1; p2_x = x1; p2_y = y1; var p3_y; var p3_x; var _this3 = this.transformations[this.transformations.length - 1]; var value_y2; var value_x2 = dx + dw; value_y2 = dy; var w2 = _this3._02 * value_x2 + _this3._12 * value_y2 + _this3._22; var x2 = (_this3._00 * value_x2 + _this3._10 * value_y2 + _this3._20) / w2; var y2 = (_this3._01 * value_x2 + _this3._11 * value_y2 + _this3._21) / w2; p3_x = x2; p3_y = y2; var p4_y; var p4_x; var _this4 = this.transformations[this.transformations.length - 1]; var value_y3; var value_x3 = dx + dw; value_y3 = dy + dh; var w3 = _this4._02 * value_x3 + _this4._12 * value_y3 + _this4._22; var x3 = (_this4._00 * value_x3 + _this4._10 * value_y3 + _this4._20) / w3; var y3 = (_this4._01 * value_x3 + _this4._11 * value_y3 + _this4._21) / w3; p4_x = x3; p4_y = y3; var _this5 = this.imagePainter; var opacity = this.get_opacity(); var color = this.get_color(); var tex = img; if(_this5.bufferIndex + 1 >= kha_graphics4_ImageShaderPainter.bufferSize || _this5.lastTexture != null && tex != _this5.lastTexture) { _this5.drawBuffer(); } var left = sx / tex.get_realWidth(); var top = sy / tex.get_realHeight(); var right = (sx + sw) / tex.get_realWidth(); var bottom = (sy + sh) / tex.get_realHeight(); var baseIndex = _this5.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; _this5.rectVertices[baseIndex + 3] = left; _this5.rectVertices[baseIndex + 4] = bottom; _this5.rectVertices[baseIndex + 12] = left; _this5.rectVertices[baseIndex + 13] = top; _this5.rectVertices[baseIndex + 21] = right; _this5.rectVertices[baseIndex + 22] = top; _this5.rectVertices[baseIndex + 30] = right; _this5.rectVertices[baseIndex + 31] = bottom; var r = ((color & 16711680) >>> 16) * 0.00392156862745098; var g = ((color & 65280) >>> 8) * 0.00392156862745098; var b = (color & 255) * 0.00392156862745098; var a = (color >>> 24) * 0.00392156862745098 * opacity; var baseIndex1 = _this5.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; _this5.rectVertices[baseIndex1 + 5] = r; _this5.rectVertices[baseIndex1 + 6] = g; _this5.rectVertices[baseIndex1 + 7] = b; _this5.rectVertices[baseIndex1 + 8] = a; _this5.rectVertices[baseIndex1 + 14] = r; _this5.rectVertices[baseIndex1 + 15] = g; _this5.rectVertices[baseIndex1 + 16] = b; _this5.rectVertices[baseIndex1 + 17] = a; _this5.rectVertices[baseIndex1 + 23] = r; _this5.rectVertices[baseIndex1 + 24] = g; _this5.rectVertices[baseIndex1 + 25] = b; _this5.rectVertices[baseIndex1 + 26] = a; _this5.rectVertices[baseIndex1 + 32] = r; _this5.rectVertices[baseIndex1 + 33] = g; _this5.rectVertices[baseIndex1 + 34] = b; _this5.rectVertices[baseIndex1 + 35] = a; var baseIndex2 = _this5.bufferIndex * kha_graphics4_ImageShaderPainter.vertexSize * 4; _this5.rectVertices[baseIndex2] = p1_x; _this5.rectVertices[baseIndex2 + 1] = p1_y; _this5.rectVertices[baseIndex2 + 2] = -5.0; _this5.rectVertices[baseIndex2 + 9] = p2_x; _this5.rectVertices[baseIndex2 + 10] = p2_y; _this5.rectVertices[baseIndex2 + 11] = -5.0; _this5.rectVertices[baseIndex2 + 18] = p3_x; _this5.rectVertices[baseIndex2 + 19] = p3_y; _this5.rectVertices[baseIndex2 + 20] = -5.0; _this5.rectVertices[baseIndex2 + 27] = p4_x; _this5.rectVertices[baseIndex2 + 28] = p4_y; _this5.rectVertices[baseIndex2 + 29] = -5.0; ++_this5.bufferIndex; _this5.lastTexture = tex; } ,get_color: function() { return this.myColor; } ,set_color: function(color) { return this.myColor = color; } ,drawRect: function(x,y,width,height,strength) { if(strength == null) { strength = 1.0; } this.imagePainter.end(); this.textPainter.end(); var _this = this.transformations[this.transformations.length - 1]; var value_y; var value_x = x - strength / 2; value_y = y + strength / 2; var w = _this._02 * value_x + _this._12 * value_y + _this._22; var x1 = (_this._00 * value_x + _this._10 * value_y + _this._20) / w; var y1 = (_this._01 * value_x + _this._11 * value_y + _this._21) / w; var p1 = new kha_math_FastVector2(x1,y1); var _this1 = this.transformations[this.transformations.length - 1]; var value_y1; var value_x1 = x - strength / 2; value_y1 = y - strength / 2; var w1 = _this1._02 * value_x1 + _this1._12 * value_y1 + _this1._22; var x2 = (_this1._00 * value_x1 + _this1._10 * value_y1 + _this1._20) / w1; var y2 = (_this1._01 * value_x1 + _this1._11 * value_y1 + _this1._21) / w1; var p2 = new kha_math_FastVector2(x2,y2); var _this2 = this.transformations[this.transformations.length - 1]; var value_y2; var value_x2 = x + width + strength / 2; value_y2 = y - strength / 2; var w2 = _this2._02 * value_x2 + _this2._12 * value_y2 + _this2._22; var x3 = (_this2._00 * value_x2 + _this2._10 * value_y2 + _this2._20) / w2; var y3 = (_this2._01 * value_x2 + _this2._11 * value_y2 + _this2._21) / w2; var p3 = new kha_math_FastVector2(x3,y3); var _this3 = this.transformations[this.transformations.length - 1]; var value_y3; var value_x3 = x + width + strength / 2; value_y3 = y + strength / 2; var w3 = _this3._02 * value_x3 + _this3._12 * value_y3 + _this3._22; var x4 = (_this3._00 * value_x3 + _this3._10 * value_y3 + _this3._20) / w3; var y4 = (_this3._01 * value_x3 + _this3._11 * value_y3 + _this3._21) / w3; var p4 = new kha_math_FastVector2(x4,y4); this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y); var _this4 = this.transformations[this.transformations.length - 1]; var value_y4; var value_x4 = x - strength / 2; value_y4 = y + height + strength / 2; var w4 = _this4._02 * value_x4 + _this4._12 * value_y4 + _this4._22; var x5 = (_this4._00 * value_x4 + _this4._10 * value_y4 + _this4._20) / w4; var y5 = (_this4._01 * value_x4 + _this4._11 * value_y4 + _this4._21) / w4; p1 = new kha_math_FastVector2(x5,y5); var _this5 = this.transformations[this.transformations.length - 1]; var value_y5; var value_x5 = x + strength / 2; value_y5 = y - strength / 2; var w5 = _this5._02 * value_x5 + _this5._12 * value_y5 + _this5._22; var x6 = (_this5._00 * value_x5 + _this5._10 * value_y5 + _this5._20) / w5; var y6 = (_this5._01 * value_x5 + _this5._11 * value_y5 + _this5._21) / w5; p3 = new kha_math_FastVector2(x6,y6); var _this6 = this.transformations[this.transformations.length - 1]; var value_y6; var value_x6 = x + strength / 2; value_y6 = y + height + strength / 2; var w6 = _this6._02 * value_x6 + _this6._12 * value_y6 + _this6._22; var x7 = (_this6._00 * value_x6 + _this6._10 * value_y6 + _this6._20) / w6; var y7 = (_this6._01 * value_x6 + _this6._11 * value_y6 + _this6._21) / w6; p4 = new kha_math_FastVector2(x7,y7); this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y); var _this7 = this.transformations[this.transformations.length - 1]; var value_y7; var value_x7 = x - strength / 2; value_y7 = y + height - strength / 2; var w7 = _this7._02 * value_x7 + _this7._12 * value_y7 + _this7._22; var x8 = (_this7._00 * value_x7 + _this7._10 * value_y7 + _this7._20) / w7; var y8 = (_this7._01 * value_x7 + _this7._11 * value_y7 + _this7._21) / w7; p2 = new kha_math_FastVector2(x8,y8); var _this8 = this.transformations[this.transformations.length - 1]; var value_y8; var value_x8 = x + width + strength / 2; value_y8 = y + height - strength / 2; var w8 = _this8._02 * value_x8 + _this8._12 * value_y8 + _this8._22; var x9 = (_this8._00 * value_x8 + _this8._10 * value_y8 + _this8._20) / w8; var y9 = (_this8._01 * value_x8 + _this8._11 * value_y8 + _this8._21) / w8; p3 = new kha_math_FastVector2(x9,y9); var _this9 = this.transformations[this.transformations.length - 1]; var value_y9; var value_x9 = x + width + strength / 2; value_y9 = y + height + strength / 2; var w9 = _this9._02 * value_x9 + _this9._12 * value_y9 + _this9._22; var x10 = (_this9._00 * value_x9 + _this9._10 * value_y9 + _this9._20) / w9; var y10 = (_this9._01 * value_x9 + _this9._11 * value_y9 + _this9._21) / w9; p4 = new kha_math_FastVector2(x10,y10); this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y); var _this10 = this.transformations[this.transformations.length - 1]; var value_y10; var value_x10 = x + width - strength / 2; value_y10 = y + height + strength / 2; var w10 = _this10._02 * value_x10 + _this10._12 * value_y10 + _this10._22; var x11 = (_this10._00 * value_x10 + _this10._10 * value_y10 + _this10._20) / w10; var y11 = (_this10._01 * value_x10 + _this10._11 * value_y10 + _this10._21) / w10; p1 = new kha_math_FastVector2(x11,y11); var _this11 = this.transformations[this.transformations.length - 1]; var value_y11; var value_x11 = x + width - strength / 2; value_y11 = y - strength / 2; var w11 = _this11._02 * value_x11 + _this11._12 * value_y11 + _this11._22; var x12 = (_this11._00 * value_x11 + _this11._10 * value_y11 + _this11._20) / w11; var y12 = (_this11._01 * value_x11 + _this11._11 * value_y11 + _this11._21) / w11; p2 = new kha_math_FastVector2(x12,y12); var _this12 = this.transformations[this.transformations.length - 1]; var value_y12; var value_x12 = x + width + strength / 2; value_y12 = y - strength / 2; var w12 = _this12._02 * value_x12 + _this12._12 * value_y12 + _this12._22; var x13 = (_this12._00 * value_x12 + _this12._10 * value_y12 + _this12._20) / w12; var y13 = (_this12._01 * value_x12 + _this12._11 * value_y12 + _this12._21) / w12; p3 = new kha_math_FastVector2(x13,y13); var _this13 = this.transformations[this.transformations.length - 1]; var value_y13; var value_x13 = x + width + strength / 2; value_y13 = y + height + strength / 2; var w13 = _this13._02 * value_x13 + _this13._12 * value_y13 + _this13._22; var x14 = (_this13._00 * value_x13 + _this13._10 * value_y13 + _this13._20) / w13; var y14 = (_this13._01 * value_x13 + _this13._11 * value_y13 + _this13._21) / w13; p4 = new kha_math_FastVector2(x14,y14); this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1.x,p1.y,p2.x,p2.y,p3.x,p3.y,p4.x,p4.y); } ,fillRect: function(x,y,width,height) { this.imagePainter.end(); this.textPainter.end(); var p1_y; var p1_x; var _this = this.transformations[this.transformations.length - 1]; var value_y; var value_x = x; value_y = y + height; var w = _this._02 * value_x + _this._12 * value_y + _this._22; var x1 = (_this._00 * value_x + _this._10 * value_y + _this._20) / w; var y1 = (_this._01 * value_x + _this._11 * value_y + _this._21) / w; p1_x = x1; p1_y = y1; var p2_y; var p2_x; var _this1 = this.transformations[this.transformations.length - 1]; var value_y1; var value_x1 = x; value_y1 = y; var w1 = _this1._02 * value_x1 + _this1._12 * value_y1 + _this1._22; var x2 = (_this1._00 * value_x1 + _this1._10 * value_y1 + _this1._20) / w1; var y2 = (_this1._01 * value_x1 + _this1._11 * value_y1 + _this1._21) / w1; p2_x = x2; p2_y = y2; var p3_y; var p3_x; var _this2 = this.transformations[this.transformations.length - 1]; var value_y2; var value_x2 = x + width; value_y2 = y; var w2 = _this2._02 * value_x2 + _this2._12 * value_y2 + _this2._22; var x3 = (_this2._00 * value_x2 + _this2._10 * value_y2 + _this2._20) / w2; var y3 = (_this2._01 * value_x2 + _this2._11 * value_y2 + _this2._21) / w2; p3_x = x3; p3_y = y3; var p4_y; var p4_x; var _this3 = this.transformations[this.transformations.length - 1]; var value_y3; var value_x3 = x + width; value_y3 = y + height; var w3 = _this3._02 * value_x3 + _this3._12 * value_y3 + _this3._22; var x4 = (_this3._00 * value_x3 + _this3._10 * value_y3 + _this3._20) / w3; var y4 = (_this3._01 * value_x3 + _this3._11 * value_y3 + _this3._21) / w3; p4_x = x4; p4_y = y4; this.coloredPainter.fillRect(this.get_opacity(),this.get_color(),p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y); } ,drawString: function(text,x,y) { this.imagePainter.end(); var _this = this.coloredPainter; if(_this.triangleBufferIndex > 0) { _this.drawTriBuffer(false); } if(_this.bufferIndex > 0) { _this.drawBuffer(false); } this.textPainter.drawString(text,this.get_opacity(),this.get_color(),x,y,this.transformations[this.transformations.length - 1],this.get_fontGlyphs()); } ,get_font: function() { return this.myFont; } ,set_font: function(font) { this.textPainter.setFont(font); return this.myFont = font; } ,set_fontSize: function(value) { return kha_graphics2_Graphics.prototype.set_fontSize.call(this,this.textPainter.fontSize = value); } ,drawLine: function(x1,y1,x2,y2,strength) { if(strength == null) { strength = 1.0; } this.imagePainter.end(); this.textPainter.end(); var vec; if(y2 == y1) { vec = new kha_math_FastVector2(0,-1); } else { vec = new kha_math_FastVector2(1,-(x2 - x1) / (y2 - y1)); } vec.set_length(strength); var p1 = new kha_math_FastVector2(x1 + 0.5 * vec.x,y1 + 0.5 * vec.y); var p2 = new kha_math_FastVector2(x2 + 0.5 * vec.x,y2 + 0.5 * vec.y); var p3 = new kha_math_FastVector2(p1.x - vec.x,p1.y - vec.y); var p4 = new kha_math_FastVector2(p2.x - vec.x,p2.y - vec.y); var _this = this.transformations[this.transformations.length - 1]; var w = _this._02 * p1.x + _this._12 * p1.y + _this._22; var x = (_this._00 * p1.x + _this._10 * p1.y + _this._20) / w; var y = (_this._01 * p1.x + _this._11 * p1.y + _this._21) / w; p1 = new kha_math_FastVector2(x,y); var _this1 = this.transformations[this.transformations.length - 1]; var w1 = _this1._02 * p2.x + _this1._12 * p2.y + _this1._22; var x3 = (_this1._00 * p2.x + _this1._10 * p2.y + _this1._20) / w1; var y3 = (_this1._01 * p2.x + _this1._11 * p2.y + _this1._21) / w1; p2 = new kha_math_FastVector2(x3,y3); var _this2 = this.transformations[this.transformations.length - 1]; var w2 = _this2._02 * p3.x + _this2._12 * p3.y + _this2._22; var x4 = (_this2._00 * p3.x + _this2._10 * p3.y + _this2._20) / w2; var y4 = (_this2._01 * p3.x + _this2._11 * p3.y + _this2._21) / w2; p3 = new kha_math_FastVector2(x4,y4); var _this3 = this.transformations[this.transformations.length - 1]; var w3 = _this3._02 * p4.x + _this3._12 * p4.y + _this3._22; var x5 = (_this3._00 * p4.x + _this3._10 * p4.y + _this3._20) / w3; var y5 = (_this3._01 * p4.x + _this3._11 * p4.y + _this3._21) / w3; p4 = new kha_math_FastVector2(x5,y5); this.coloredPainter.fillTriangle(this.get_opacity(),this.get_color(),p1.x,p1.y,p2.x,p2.y,p3.x,p3.y); this.coloredPainter.fillTriangle(this.get_opacity(),this.get_color(),p3.x,p3.y,p2.x,p2.y,p4.x,p4.y); } ,fillTriangle: function(x1,y1,x2,y2,x3,y3) { this.imagePainter.end(); this.textPainter.end(); var p1_y; var p1_x; var _this = this.transformations[this.transformations.length - 1]; var value_y; var value_x = x1; value_y = y1; var w = _this._02 * value_x + _this._12 * value_y + _this._22; var x = (_this._00 * value_x + _this._10 * value_y + _this._20) / w; var y = (_this._01 * value_x + _this._11 * value_y + _this._21) / w; p1_x = x; p1_y = y; var p2_y; var p2_x; var _this1 = this.transformations[this.transformations.length - 1]; var value_y1; var value_x1 = x2; value_y1 = y2; var w1 = _this1._02 * value_x1 + _this1._12 * value_y1 + _this1._22; var x4 = (_this1._00 * value_x1 + _this1._10 * value_y1 + _this1._20) / w1; var y4 = (_this1._01 * value_x1 + _this1._11 * value_y1 + _this1._21) / w1; p2_x = x4; p2_y = y4; var p3_y; var p3_x; var _this2 = this.transformations[this.transformations.length - 1]; var value_y2; var value_x2 = x3; value_y2 = y3; var w2 = _this2._02 * value_x2 + _this2._12 * value_y2 + _this2._22; var x5 = (_this2._00 * value_x2 + _this2._10 * value_y2 + _this2._20) / w2; var y5 = (_this2._01 * value_x2 + _this2._11 * value_y2 + _this2._21) / w2; p3_x = x5; p3_y = y5; this.coloredPainter.fillTriangle(this.get_opacity(),this.get_color(),p1_x,p1_y,p2_x,p2_y,p3_x,p3_y); } ,myImageScaleQuality: null ,get_imageScaleQuality: function() { return this.myImageScaleQuality; } ,set_imageScaleQuality: function(value) { this.imagePainter.setBilinearFilter(value == kha_graphics2_ImageScaleQuality.High); this.textPainter.setBilinearFilter(value == kha_graphics2_ImageScaleQuality.High); return this.myImageScaleQuality = value; } ,myMipmapScaleQuality: null ,get_mipmapScaleQuality: function() { return this.myMipmapScaleQuality; } ,set_mipmapScaleQuality: function(value) { this.imagePainter.setBilinearMipmapFilter(value == kha_graphics2_ImageScaleQuality.High); return this.myMipmapScaleQuality = value; } ,setPipeline: function(pipeline) { this.flush(); this.imagePainter.set_pipeline(pipeline); this.coloredPainter.set_pipeline(pipeline); this.textPainter.set_pipeline(pipeline); if(pipeline != null) { this.g.setPipeline(pipeline); } } ,scissor: function(x,y,width,height) { this.flush(); this.g.scissor(x,y,width,height); } ,disableScissor: function() { this.flush(); this.g.disableScissor(); } ,begin: function(clear,clearColor) { if(clear == null) { clear = true; } this.g.begin(); if(clear) { this.clear(clearColor); } this.setProjection(); } ,clear: function(color) { this.flush(); this.g.clear(color == null ? -16777216 : color); } ,flush: function() { this.imagePainter.end(); this.textPainter.end(); var _this = this.coloredPainter; if(_this.triangleBufferIndex > 0) { _this.drawTriBuffer(false); } if(_this.bufferIndex > 0) { _this.drawBuffer(false); } } ,end: function() { this.flush(); this.g.end(); } ,drawVideoInternal: function(video,x,y,width,height) { } ,drawVideo: function(video,x,y,width,height) { this.setPipeline(kha_graphics4_Graphics2.videoPipeline); this.drawVideoInternal(video,x,y,width,height); this.setPipeline(null); } ,__class__: kha_graphics4_Graphics2 }); var kha_graphics4_IndexBuffer = function(indexCount,usage,canRead) { if(canRead == null) { canRead = false; } this.usage = usage; this.mySize = indexCount; this.buffer = kha_SystemImpl.gl.createBuffer(); var this1 = new Uint32Array(indexCount); this._data = this1; }; $hxClasses["kha.graphics4.IndexBuffer"] = kha_graphics4_IndexBuffer; kha_graphics4_IndexBuffer.__name__ = true; kha_graphics4_IndexBuffer.prototype = { buffer: null ,_data: null ,mySize: null ,usage: null ,'delete': function() { this._data = null; kha_SystemImpl.gl.deleteBuffer(this.buffer); } ,lock: function(start,count) { if(start == null) { start = 0; } if(count == null) { count = this.mySize; } return this._data.subarray(start,start + count); } ,unlock: function() { kha_SystemImpl.gl.bindBuffer(34963,this.buffer); var glData = kha_SystemImpl.elementIndexUint == null ? new Uint16Array(this._data) : this._data; kha_SystemImpl.gl.bufferData(34963,glData,this.usage == kha_graphics4_Usage.DynamicUsage ? 35048 : 35044); } ,set: function() { kha_SystemImpl.gl.bindBuffer(34963,this.buffer); } ,count: function() { return this.mySize; } ,__class__: kha_graphics4_IndexBuffer }; var kha_graphics4_MipMapFilter = $hxClasses["kha.graphics4.MipMapFilter"] = { __ename__ : true, __constructs__ : ["NoMipFilter","PointMipFilter","LinearMipFilter"] }; kha_graphics4_MipMapFilter.NoMipFilter = ["NoMipFilter",0]; kha_graphics4_MipMapFilter.NoMipFilter.toString = $estr; kha_graphics4_MipMapFilter.NoMipFilter.__enum__ = kha_graphics4_MipMapFilter; kha_graphics4_MipMapFilter.PointMipFilter = ["PointMipFilter",1]; kha_graphics4_MipMapFilter.PointMipFilter.toString = $estr; kha_graphics4_MipMapFilter.PointMipFilter.__enum__ = kha_graphics4_MipMapFilter; kha_graphics4_MipMapFilter.LinearMipFilter = ["LinearMipFilter",2]; kha_graphics4_MipMapFilter.LinearMipFilter.toString = $estr; kha_graphics4_MipMapFilter.LinearMipFilter.__enum__ = kha_graphics4_MipMapFilter; var kha_graphics4_PipelineStateBase = function() { this.inputLayout = null; this.vertexShader = null; this.fragmentShader = null; this.geometryShader = null; this.tessellationControlShader = null; this.tessellationEvaluationShader = null; this.cullMode = kha_graphics4_CullMode.None; this.depthWrite = false; this.depthMode = kha_graphics4_CompareMode.Always; this.stencilMode = kha_graphics4_CompareMode.Always; this.stencilBothPass = kha_graphics4_StencilAction.Keep; this.stencilDepthFail = kha_graphics4_StencilAction.Keep; this.stencilFail = kha_graphics4_StencilAction.Keep; this.stencilReferenceValue = 0; this.stencilReadMask = 255; this.stencilWriteMask = 255; this.blendSource = kha_graphics4_BlendingFactor.BlendOne; this.blendDestination = kha_graphics4_BlendingFactor.BlendZero; this.blendOperation = kha_graphics4_BlendingOperation.Add; this.alphaBlendSource = kha_graphics4_BlendingFactor.BlendOne; this.alphaBlendDestination = kha_graphics4_BlendingFactor.BlendZero; this.alphaBlendOperation = kha_graphics4_BlendingOperation.Add; this.colorWriteMaskRed = this.colorWriteMaskBlue = this.colorWriteMaskGreen = this.colorWriteMaskAlpha = true; this.conservativeRasterization = false; }; $hxClasses["kha.graphics4.PipelineStateBase"] = kha_graphics4_PipelineStateBase; kha_graphics4_PipelineStateBase.__name__ = true; kha_graphics4_PipelineStateBase.prototype = { inputLayout: null ,vertexShader: null ,fragmentShader: null ,geometryShader: null ,tessellationControlShader: null ,tessellationEvaluationShader: null ,cullMode: null ,depthWrite: null ,depthMode: null ,stencilMode: null ,stencilBothPass: null ,stencilDepthFail: null ,stencilFail: null ,stencilReferenceValue: null ,stencilReadMask: null ,stencilWriteMask: null ,blendSource: null ,blendDestination: null ,blendOperation: null ,alphaBlendSource: null ,alphaBlendDestination: null ,alphaBlendOperation: null ,colorWriteMaskRed: null ,colorWriteMaskGreen: null ,colorWriteMaskBlue: null ,colorWriteMaskAlpha: null ,set_colorWriteMask: function(value) { return this.colorWriteMaskRed = this.colorWriteMaskBlue = this.colorWriteMaskGreen = this.colorWriteMaskAlpha = value; } ,conservativeRasterization: null ,__class__: kha_graphics4_PipelineStateBase }; var kha_graphics4_PipelineState = function() { kha_graphics4_PipelineStateBase.call(this); this.program = kha_SystemImpl.gl.createProgram(); this.textures = []; this.textureValues = []; }; $hxClasses["kha.graphics4.PipelineState"] = kha_graphics4_PipelineState; kha_graphics4_PipelineState.__name__ = true; kha_graphics4_PipelineState.__super__ = kha_graphics4_PipelineStateBase; kha_graphics4_PipelineState.prototype = $extend(kha_graphics4_PipelineStateBase.prototype,{ program: null ,textures: null ,textureValues: null ,'delete': function() { kha_SystemImpl.gl.deleteProgram(this.program); } ,compile: function() { this.compileShader(this.vertexShader); this.compileShader(this.fragmentShader); kha_SystemImpl.gl.attachShader(this.program,this.vertexShader.shader); kha_SystemImpl.gl.attachShader(this.program,this.fragmentShader.shader); var index = 0; var _g = 0; var _g1 = this.inputLayout; while(_g < _g1.length) { var structure = _g1[_g]; ++_g; var _g2 = 0; var _g3 = structure.elements; while(_g2 < _g3.length) { var element = _g3[_g2]; ++_g2; kha_SystemImpl.gl.bindAttribLocation(this.program,index,element.name); if(element.data == kha_graphics4_VertexData.Float4x4) { index += 4; } else { ++index; } } } kha_SystemImpl.gl.linkProgram(this.program); if(!kha_SystemImpl.gl.getProgramParameter(this.program,35714)) { throw new js__$Boot_HaxeError("Could not link the shader program:\n" + kha_SystemImpl.gl.getProgramInfoLog(this.program)); } } ,set: function() { kha_SystemImpl.gl.useProgram(this.program); var _g1 = 0; var _g = this.textureValues.length; while(_g1 < _g) { var index = _g1++; kha_SystemImpl.gl.uniform1i(this.textureValues[index],index); } kha_SystemImpl.gl.colorMask(this.colorWriteMaskRed,this.colorWriteMaskGreen,this.colorWriteMaskBlue,this.colorWriteMaskAlpha); } ,compileShader: function(shader) { if(shader.shader != null) { return; } var s = kha_SystemImpl.gl.createShader(shader.type); var highp = kha_SystemImpl.gl.getShaderPrecisionFormat(35632,36338); var highpSupported = highp.precision != 0; var files = shader.files; var _g1 = 0; var _g = files.length; while(_g1 < _g) { var i = _g1++; if(kha_SystemImpl.gl2) { if(files[i].indexOf("-webgl2") >= 0 || files[i].indexOf("runtime-string") >= 0) { kha_SystemImpl.gl.shaderSource(s,shader.sources[i]); break; } } else { if(!highpSupported && files[i].indexOf("-relaxed") >= 0) { kha_SystemImpl.gl.shaderSource(s,shader.sources[i]); break; } if(highpSupported && files[i].indexOf("-relaxed") < 0) { kha_SystemImpl.gl.shaderSource(s,shader.sources[i]); break; } } } kha_SystemImpl.gl.compileShader(s); if(!kha_SystemImpl.gl.getShaderParameter(s,35713)) { throw new js__$Boot_HaxeError("Could not compile shader:\n" + kha_SystemImpl.gl.getShaderInfoLog(s)); } shader.shader = s; } ,getConstantLocation: function(name) { var location = kha_SystemImpl.gl.getUniformLocation(this.program,name); var type = 5126; var count = kha_SystemImpl.gl.getProgramParameter(this.program,35718); var _g1 = 0; var _g = count; while(_g1 < _g) { var i = _g1++; var info = kha_SystemImpl.gl.getActiveUniform(this.program,i); if(info.name == name || info.name == name + "[0]") { type = info.type; break; } } return new kha_js_graphics4_ConstantLocation(location,type); } ,getTextureUnit: function(name) { var index = this.findTexture(name); if(index < 0) { var location = kha_SystemImpl.gl.getUniformLocation(this.program,name); index = this.textures.length; this.textureValues.push(location); this.textures.push(name); } return new kha_js_graphics4_TextureUnit(index); } ,findTexture: function(name) { var _g1 = 0; var _g = this.textures.length; while(_g1 < _g) { var index = _g1++; if(this.textures[index] == name) { return index; } } return -1; } ,__class__: kha_graphics4_PipelineState }); var kha_graphics4_StencilAction = $hxClasses["kha.graphics4.StencilAction"] = { __ename__ : true, __constructs__ : ["Keep","Zero","Replace","Increment","IncrementWrap","Decrement","DecrementWrap","Invert"] }; kha_graphics4_StencilAction.Keep = ["Keep",0]; kha_graphics4_StencilAction.Keep.toString = $estr; kha_graphics4_StencilAction.Keep.__enum__ = kha_graphics4_StencilAction; kha_graphics4_StencilAction.Zero = ["Zero",1]; kha_graphics4_StencilAction.Zero.toString = $estr; kha_graphics4_StencilAction.Zero.__enum__ = kha_graphics4_StencilAction; kha_graphics4_StencilAction.Replace = ["Replace",2]; kha_graphics4_StencilAction.Replace.toString = $estr; kha_graphics4_StencilAction.Replace.__enum__ = kha_graphics4_StencilAction; kha_graphics4_StencilAction.Increment = ["Increment",3]; kha_graphics4_StencilAction.Increment.toString = $estr; kha_graphics4_StencilAction.Increment.__enum__ = kha_graphics4_StencilAction; kha_graphics4_StencilAction.IncrementWrap = ["IncrementWrap",4]; kha_graphics4_StencilAction.IncrementWrap.toString = $estr; kha_graphics4_StencilAction.IncrementWrap.__enum__ = kha_graphics4_StencilAction; kha_graphics4_StencilAction.Decrement = ["Decrement",5]; kha_graphics4_StencilAction.Decrement.toString = $estr; kha_graphics4_StencilAction.Decrement.__enum__ = kha_graphics4_StencilAction; kha_graphics4_StencilAction.DecrementWrap = ["DecrementWrap",6]; kha_graphics4_StencilAction.DecrementWrap.toString = $estr; kha_graphics4_StencilAction.DecrementWrap.__enum__ = kha_graphics4_StencilAction; kha_graphics4_StencilAction.Invert = ["Invert",7]; kha_graphics4_StencilAction.Invert.toString = $estr; kha_graphics4_StencilAction.Invert.__enum__ = kha_graphics4_StencilAction; var kha_graphics4_TessellationControlShader = function(source,file) { }; $hxClasses["kha.graphics4.TessellationControlShader"] = kha_graphics4_TessellationControlShader; kha_graphics4_TessellationControlShader.__name__ = true; kha_graphics4_TessellationControlShader.prototype = { 'delete': function() { } ,__class__: kha_graphics4_TessellationControlShader }; var kha_graphics4_TessellationEvaluationShader = function(source,file) { }; $hxClasses["kha.graphics4.TessellationEvaluationShader"] = kha_graphics4_TessellationEvaluationShader; kha_graphics4_TessellationEvaluationShader.__name__ = true; kha_graphics4_TessellationEvaluationShader.prototype = { 'delete': function() { } ,__class__: kha_graphics4_TessellationEvaluationShader }; var kha_graphics4_TexDir = $hxClasses["kha.graphics4.TexDir"] = { __ename__ : true, __constructs__ : ["U","V"] }; kha_graphics4_TexDir.U = ["U",0]; kha_graphics4_TexDir.U.toString = $estr; kha_graphics4_TexDir.U.__enum__ = kha_graphics4_TexDir; kha_graphics4_TexDir.V = ["V",1]; kha_graphics4_TexDir.V.toString = $estr; kha_graphics4_TexDir.V.__enum__ = kha_graphics4_TexDir; var kha_graphics4_TextureAddressing = $hxClasses["kha.graphics4.TextureAddressing"] = { __ename__ : true, __constructs__ : ["Repeat","Mirror","Clamp"] }; kha_graphics4_TextureAddressing.Repeat = ["Repeat",0]; kha_graphics4_TextureAddressing.Repeat.toString = $estr; kha_graphics4_TextureAddressing.Repeat.__enum__ = kha_graphics4_TextureAddressing; kha_graphics4_TextureAddressing.Mirror = ["Mirror",1]; kha_graphics4_TextureAddressing.Mirror.toString = $estr; kha_graphics4_TextureAddressing.Mirror.__enum__ = kha_graphics4_TextureAddressing; kha_graphics4_TextureAddressing.Clamp = ["Clamp",2]; kha_graphics4_TextureAddressing.Clamp.toString = $estr; kha_graphics4_TextureAddressing.Clamp.__enum__ = kha_graphics4_TextureAddressing; var kha_graphics4_TextureFilter = $hxClasses["kha.graphics4.TextureFilter"] = { __ename__ : true, __constructs__ : ["PointFilter","LinearFilter","AnisotropicFilter"] }; kha_graphics4_TextureFilter.PointFilter = ["PointFilter",0]; kha_graphics4_TextureFilter.PointFilter.toString = $estr; kha_graphics4_TextureFilter.PointFilter.__enum__ = kha_graphics4_TextureFilter; kha_graphics4_TextureFilter.LinearFilter = ["LinearFilter",1]; kha_graphics4_TextureFilter.LinearFilter.toString = $estr; kha_graphics4_TextureFilter.LinearFilter.__enum__ = kha_graphics4_TextureFilter; kha_graphics4_TextureFilter.AnisotropicFilter = ["AnisotropicFilter",2]; kha_graphics4_TextureFilter.AnisotropicFilter.toString = $estr; kha_graphics4_TextureFilter.AnisotropicFilter.__enum__ = kha_graphics4_TextureFilter; var kha_graphics4_TextureFormat = $hxClasses["kha.graphics4.TextureFormat"] = { __ename__ : true, __constructs__ : ["RGBA32","L8","RGBA128","DEPTH16","RGBA64","A32","A16"] }; kha_graphics4_TextureFormat.RGBA32 = ["RGBA32",0]; kha_graphics4_TextureFormat.RGBA32.toString = $estr; kha_graphics4_TextureFormat.RGBA32.__enum__ = kha_graphics4_TextureFormat; kha_graphics4_TextureFormat.L8 = ["L8",1]; kha_graphics4_TextureFormat.L8.toString = $estr; kha_graphics4_TextureFormat.L8.__enum__ = kha_graphics4_TextureFormat; kha_graphics4_TextureFormat.RGBA128 = ["RGBA128",2]; kha_graphics4_TextureFormat.RGBA128.toString = $estr; kha_graphics4_TextureFormat.RGBA128.__enum__ = kha_graphics4_TextureFormat; kha_graphics4_TextureFormat.DEPTH16 = ["DEPTH16",3]; kha_graphics4_TextureFormat.DEPTH16.toString = $estr; kha_graphics4_TextureFormat.DEPTH16.__enum__ = kha_graphics4_TextureFormat; kha_graphics4_TextureFormat.RGBA64 = ["RGBA64",4]; kha_graphics4_TextureFormat.RGBA64.toString = $estr; kha_graphics4_TextureFormat.RGBA64.__enum__ = kha_graphics4_TextureFormat; kha_graphics4_TextureFormat.A32 = ["A32",5]; kha_graphics4_TextureFormat.A32.toString = $estr; kha_graphics4_TextureFormat.A32.__enum__ = kha_graphics4_TextureFormat; kha_graphics4_TextureFormat.A16 = ["A16",6]; kha_graphics4_TextureFormat.A16.toString = $estr; kha_graphics4_TextureFormat.A16.__enum__ = kha_graphics4_TextureFormat; var kha_graphics4_TextureUnit = function() { }; $hxClasses["kha.graphics4.TextureUnit"] = kha_graphics4_TextureUnit; kha_graphics4_TextureUnit.__name__ = true; var kha_graphics4_Usage = $hxClasses["kha.graphics4.Usage"] = { __ename__ : true, __constructs__ : ["StaticUsage","DynamicUsage","ReadableUsage"] }; kha_graphics4_Usage.StaticUsage = ["StaticUsage",0]; kha_graphics4_Usage.StaticUsage.toString = $estr; kha_graphics4_Usage.StaticUsage.__enum__ = kha_graphics4_Usage; kha_graphics4_Usage.DynamicUsage = ["DynamicUsage",1]; kha_graphics4_Usage.DynamicUsage.toString = $estr; kha_graphics4_Usage.DynamicUsage.__enum__ = kha_graphics4_Usage; kha_graphics4_Usage.ReadableUsage = ["ReadableUsage",2]; kha_graphics4_Usage.ReadableUsage.toString = $estr; kha_graphics4_Usage.ReadableUsage.__enum__ = kha_graphics4_Usage; var kha_graphics4_VertexBuffer = function(vertexCount,structure,usage,instanceDataStepRate,canRead) { if(canRead == null) { canRead = false; } if(instanceDataStepRate == null) { instanceDataStepRate = 0; } this.usage = usage; this.instanceDataStepRate = instanceDataStepRate; this.mySize = vertexCount; this.myStride = 0; var _g = 0; var _g1 = structure.elements; while(_g < _g1.length) { var element = _g1[_g]; ++_g; var _g2 = element.data; switch(_g2[1]) { case 0: this.myStride += 4; break; case 1: this.myStride += 8; break; case 2: this.myStride += 12; break; case 3: this.myStride += 16; break; case 4: this.myStride += 64; break; } } this.buffer = kha_SystemImpl.gl.createBuffer(); var this1 = new Float32Array(vertexCount * this.myStride / 4 | 0); this._data = this1; this.sizes = []; this.offsets = []; this.sizes[structure.elements.length - 1] = 0; this.offsets[structure.elements.length - 1] = 0; var offset = 0; var index = 0; var _g3 = 0; var _g11 = structure.elements; while(_g3 < _g11.length) { var element1 = _g11[_g3]; ++_g3; var size; var _g21 = element1.data; switch(_g21[1]) { case 0: size = 1; break; case 1: size = 2; break; case 2: size = 3; break; case 3: size = 4; break; case 4: size = 16; break; } this.sizes[index] = size; this.offsets[index] = offset; var _g31 = element1.data; switch(_g31[1]) { case 0: offset += 4; break; case 1: offset += 8; break; case 2: offset += 12; break; case 3: offset += 16; break; case 4: offset += 64; break; } ++index; } }; $hxClasses["kha.graphics4.VertexBuffer"] = kha_graphics4_VertexBuffer; kha_graphics4_VertexBuffer.__name__ = true; kha_graphics4_VertexBuffer.prototype = { buffer: null ,_data: null ,mySize: null ,myStride: null ,sizes: null ,offsets: null ,usage: null ,instanceDataStepRate: null ,'delete': function() { this._data = null; kha_SystemImpl.gl.deleteBuffer(this.buffer); } ,lock: function(start,count) { if(start == null) { start = 0; } if(count == null) { count = this.mySize; } return this._data.subarray(start * this.stride(),(start + count) * this.stride()); } ,unlock: function() { kha_SystemImpl.gl.bindBuffer(34962,this.buffer); kha_SystemImpl.gl.bufferData(34962,this._data,this.usage == kha_graphics4_Usage.DynamicUsage ? 35048 : 35044); } ,stride: function() { return this.myStride; } ,count: function() { return this.mySize; } ,set: function(offset) { var ext = kha_SystemImpl.gl2 ? true : kha_SystemImpl.gl.getExtension("ANGLE_instanced_arrays"); kha_SystemImpl.gl.bindBuffer(34962,this.buffer); var attributesOffset = 0; var _g1 = 0; var _g = this.sizes.length; while(_g1 < _g) { var i = _g1++; if(this.sizes[i] > 4) { var size = this.sizes[i]; var addonOffset = 0; while(size > 0) { kha_SystemImpl.gl.enableVertexAttribArray(offset + attributesOffset); kha_SystemImpl.gl.vertexAttribPointer(offset + attributesOffset,4,5126,false,this.myStride,this.offsets[i] + addonOffset); if(ext) { if(kha_SystemImpl.gl2) { kha_SystemImpl.gl.vertexAttribDivisor(offset + attributesOffset,this.instanceDataStepRate); } else { ext.vertexAttribDivisorANGLE(offset + attributesOffset,this.instanceDataStepRate); } } size -= 4; addonOffset += 16; ++attributesOffset; } } else { kha_SystemImpl.gl.enableVertexAttribArray(offset + attributesOffset); kha_SystemImpl.gl.vertexAttribPointer(offset + attributesOffset,this.sizes[i],5126,false,this.myStride,this.offsets[i]); if(ext) { if(kha_SystemImpl.gl2) { kha_SystemImpl.gl.vertexAttribDivisor(offset + attributesOffset,this.instanceDataStepRate); } else { ext.vertexAttribDivisorANGLE(offset + attributesOffset,this.instanceDataStepRate); } } ++attributesOffset; } } return attributesOffset; } ,__class__: kha_graphics4_VertexBuffer }; var kha_graphics4_VertexData = $hxClasses["kha.graphics4.VertexData"] = { __ename__ : true, __constructs__ : ["Float1","Float2","Float3","Float4","Float4x4"] }; kha_graphics4_VertexData.Float1 = ["Float1",0]; kha_graphics4_VertexData.Float1.toString = $estr; kha_graphics4_VertexData.Float1.__enum__ = kha_graphics4_VertexData; kha_graphics4_VertexData.Float2 = ["Float2",1]; kha_graphics4_VertexData.Float2.toString = $estr; kha_graphics4_VertexData.Float2.__enum__ = kha_graphics4_VertexData; kha_graphics4_VertexData.Float3 = ["Float3",2]; kha_graphics4_VertexData.Float3.toString = $estr; kha_graphics4_VertexData.Float3.__enum__ = kha_graphics4_VertexData; kha_graphics4_VertexData.Float4 = ["Float4",3]; kha_graphics4_VertexData.Float4.toString = $estr; kha_graphics4_VertexData.Float4.__enum__ = kha_graphics4_VertexData; kha_graphics4_VertexData.Float4x4 = ["Float4x4",4]; kha_graphics4_VertexData.Float4x4.toString = $estr; kha_graphics4_VertexData.Float4x4.__enum__ = kha_graphics4_VertexData; var kha_graphics4_VertexElement = function(name,data) { this.name = name; this.data = data; }; $hxClasses["kha.graphics4.VertexElement"] = kha_graphics4_VertexElement; kha_graphics4_VertexElement.__name__ = true; kha_graphics4_VertexElement.prototype = { name: null ,data: null ,__class__: kha_graphics4_VertexElement }; var kha_graphics4_VertexShader = function(sources,files) { this.sources = []; var _g = 0; while(_g < sources.length) { var source = sources[_g]; ++_g; this.sources.push(source.toString()); } this.type = 35633; this.shader = null; this.files = files; }; $hxClasses["kha.graphics4.VertexShader"] = kha_graphics4_VertexShader; kha_graphics4_VertexShader.__name__ = true; kha_graphics4_VertexShader.fromSource = function(source) { var shader = new kha_graphics4_VertexShader([],["runtime-string"]); shader.sources.push(source); return shader; }; kha_graphics4_VertexShader.prototype = { sources: null ,type: null ,shader: null ,files: null ,'delete': function() { kha_SystemImpl.gl.deleteShader(this.shader); this.shader = null; this.sources = null; } ,__class__: kha_graphics4_VertexShader }; var kha_graphics4_VertexStructure = function() { this.elements = []; }; $hxClasses["kha.graphics4.VertexStructure"] = kha_graphics4_VertexStructure; kha_graphics4_VertexStructure.__name__ = true; kha_graphics4_VertexStructure.prototype = { elements: null ,add: function(name,data) { this.elements.push(new kha_graphics4_VertexElement(name,data)); } ,size: function() { return this.elements.length; } ,byteSize: function() { var byteSize = 0; var _g1 = 0; var _g = this.elements.length; while(_g1 < _g) { var i = _g1++; byteSize += this.dataByteSize(this.elements[i].data); } return byteSize; } ,dataByteSize: function(data) { switch(data[1]) { case 0: return 4; case 1: return 8; case 2: return 12; case 3: return 16; case 4: return 64; } } ,get: function(index) { return this.elements[index]; } ,__class__: kha_graphics4_VertexStructure }; var kha_input_Gamepad = $hx_exports["kha"]["input"]["Gamepad"] = function(index,id) { if(id == null) { id = "unknown"; } if(index == null) { index = 0; } this.index = index; this.axisListeners = []; this.buttonListeners = []; kha_input_Gamepad.instances[index] = this; }; $hxClasses["kha.input.Gamepad"] = kha_input_Gamepad; kha_input_Gamepad.__name__ = true; kha_input_Gamepad.get = function(index) { if(index == null) { index = 0; } if(index >= kha_input_Gamepad.instances.length) { return null; } return kha_input_Gamepad.instances[index]; }; kha_input_Gamepad.prototype = { index: null ,notify: function(axisListener,buttonListener) { if(axisListener != null) { this.axisListeners.push(axisListener); } if(buttonListener != null) { this.buttonListeners.push(buttonListener); } } ,remove: function(axisListener,buttonListener) { if(axisListener != null) { HxOverrides.remove(this.axisListeners,axisListener); } if(buttonListener != null) { HxOverrides.remove(this.buttonListeners,buttonListener); } } ,axisListeners: null ,buttonListeners: null ,id: null ,get_id: function() { return kha_SystemImpl.getGamepadId(this.index); } ,sendAxisEvent: function(axis,value) { var _g = 0; var _g1 = this.axisListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(axis,value); } } ,sendButtonEvent: function(button,value) { var _g = 0; var _g1 = this.buttonListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(button,value); } } ,__class__: kha_input_Gamepad }; var kha_network_Controller = function() { this.__id = kha_network_ControllerBuilder.nextId++; this._inputBuffer = new haxe_io_Bytes(new ArrayBuffer(1)); }; $hxClasses["kha.network.Controller"] = kha_network_Controller; kha_network_Controller.__name__ = true; kha_network_Controller.prototype = { __id: null ,_inputBufferIndex: null ,_inputBuffer: null ,_id: function() { return this.__id; } ,_receive: function(bytes) { } ,__class__: kha_network_Controller }; var kha_input_Keyboard = $hx_exports["kha"]["input"]["Keyboard"] = function() { kha_network_Controller.call(this); this.downListeners = []; this.upListeners = []; kha_input_Keyboard.instance = this; }; $hxClasses["kha.input.Keyboard"] = kha_input_Keyboard; kha_input_Keyboard.__name__ = true; kha_input_Keyboard.get = function(num) { if(num == null) { num = 0; } return kha_SystemImpl.getKeyboard(num); }; kha_input_Keyboard.__super__ = kha_network_Controller; kha_input_Keyboard.prototype = $extend(kha_network_Controller.prototype,{ notify: function(downListener,upListener) { if(downListener != null) { this.downListeners.push(downListener); } if(upListener != null) { this.upListeners.push(upListener); } } ,remove: function(downListener,upListener) { if(downListener != null) { HxOverrides.remove(this.downListeners,downListener); } if(upListener != null) { HxOverrides.remove(this.upListeners,upListener); } } ,show: function() { } ,hide: function() { } ,downListeners: null ,upListeners: null ,sendDownEvent: function(key,$char) { if(kha_network_Session.the() != null) { var bytes = new haxe_io_Bytes(new ArrayBuffer(6)); bytes.setInt32(0,0); bytes.b[4] = key[1] & 255; var v = HxOverrides.cca($char,0); bytes.b[5] = v & 255; kha_network_Session.the().sendControllerUpdate(this._id(),bytes); } var _g = 0; var _g1 = this.downListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(key,$char); } } ,sendUpEvent: function(key,$char) { if(kha_network_Session.the() != null) { var bytes = new haxe_io_Bytes(new ArrayBuffer(6)); bytes.setInt32(0,1); bytes.b[4] = key[1] & 255; var v = HxOverrides.cca($char,0); bytes.b[5] = v & 255; kha_network_Session.the().sendControllerUpdate(this._id(),bytes); } var _g = 0; var _g1 = this.upListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(key,$char); } } ,_receive: function(bytes) { var funcindex = bytes.getInt32(0); if(funcindex == 0) { var input0 = Type.createEnumIndex(kha_Key,bytes.b[4],null); var input1 = String.fromCharCode(bytes.b[5]); this.sendDownEvent(input0,input1); return; } if(funcindex == 1) { var input01 = Type.createEnumIndex(kha_Key,bytes.b[4],null); var input11 = String.fromCharCode(bytes.b[5]); this.sendUpEvent(input01,input11); return; } } ,__class__: kha_input_Keyboard }); var kha_input_Mouse = $hx_exports["kha"]["input"]["Mouse"] = function() { kha_network_Controller.call(this); kha_input_Mouse.instance = this; }; $hxClasses["kha.input.Mouse"] = kha_input_Mouse; kha_input_Mouse.__name__ = true; kha_input_Mouse.get = function(num) { if(num == null) { num = 0; } return kha_SystemImpl.getMouse(num); }; kha_input_Mouse.__super__ = kha_network_Controller; kha_input_Mouse.prototype = $extend(kha_network_Controller.prototype,{ notify: function(downListener,upListener,moveListener,wheelListener,leaveListener) { this.notifyWindowed(0,downListener,upListener,moveListener,wheelListener,leaveListener); } ,remove: function(downListener,upListener,moveListener,wheelListener,leaveListener) { this.removeWindowed(0,downListener,upListener,moveListener,wheelListener,leaveListener); } ,notifyWindowed: function(windowId,downListener,upListener,moveListener,wheelListener,leaveListener) { if(downListener != null) { if(this.windowDownListeners == null) { this.windowDownListeners = []; } while(this.windowDownListeners.length <= windowId) this.windowDownListeners.push([]); this.windowDownListeners[windowId].push(downListener); } if(upListener != null) { if(this.windowUpListeners == null) { this.windowUpListeners = []; } while(this.windowUpListeners.length <= windowId) this.windowUpListeners.push([]); this.windowUpListeners[windowId].push(upListener); } if(moveListener != null) { if(this.windowMoveListeners == null) { this.windowMoveListeners = []; } while(this.windowMoveListeners.length <= windowId) this.windowMoveListeners.push([]); this.windowMoveListeners[windowId].push(moveListener); } if(wheelListener != null) { if(this.windowWheelListeners == null) { this.windowWheelListeners = []; } while(this.windowWheelListeners.length <= windowId) this.windowWheelListeners.push([]); this.windowWheelListeners[windowId].push(wheelListener); } if(leaveListener != null) { if(this.windowLeaveListeners == null) { this.windowLeaveListeners = []; } while(this.windowLeaveListeners.length <= windowId) this.windowLeaveListeners.push([]); this.windowLeaveListeners[windowId].push(leaveListener); } } ,removeWindowed: function(windowId,downListener,upListener,moveListener,wheelListener,leaveListener) { if(downListener != null) { if(this.windowDownListeners != null) { if(windowId < this.windowDownListeners.length) { HxOverrides.remove(this.windowDownListeners[windowId],downListener); } else { haxe_Log.trace("no downListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.hx", lineNumber : 88, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } else { haxe_Log.trace("no downListeners were ever registered",{ fileName : "Mouse.hx", lineNumber : 91, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } if(upListener != null) { if(this.windowUpListeners != null) { if(windowId < this.windowUpListeners.length) { HxOverrides.remove(this.windowUpListeners[windowId],upListener); } else { haxe_Log.trace("no upListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.hx", lineNumber : 100, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } else { haxe_Log.trace("no upListeners were ever registered",{ fileName : "Mouse.hx", lineNumber : 103, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } if(moveListener != null) { if(this.windowMoveListeners != null) { if(windowId < this.windowMoveListeners.length) { HxOverrides.remove(this.windowMoveListeners[windowId],moveListener); } else { haxe_Log.trace("no moveListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.hx", lineNumber : 112, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } else { haxe_Log.trace("no moveListeners were ever registered",{ fileName : "Mouse.hx", lineNumber : 115, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } if(wheelListener != null) { if(this.windowWheelListeners != null) { if(windowId < this.windowWheelListeners.length) { HxOverrides.remove(this.windowWheelListeners[windowId],wheelListener); } else { haxe_Log.trace("no wheelListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.hx", lineNumber : 124, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } else { haxe_Log.trace("no wheelListeners were ever registered",{ fileName : "Mouse.hx", lineNumber : 127, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } if(leaveListener != null) { if(this.windowLeaveListeners != null) { if(windowId < this.windowLeaveListeners.length) { HxOverrides.remove(this.windowLeaveListeners[windowId],leaveListener); } else { haxe_Log.trace("no leaveListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.hx", lineNumber : 136, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } else { haxe_Log.trace("no leaveListeners were ever registered",{ fileName : "Mouse.hx", lineNumber : 139, className : "kha.input.Mouse", methodName : "removeWindowed"}); } } } ,lock: function() { } ,unlock: function() { } ,canLock: function() { return false; } ,isLocked: function() { return false; } ,notifyOnLockChange: function(func,error) { } ,removeFromLockChange: function(func,error) { } ,hideSystemCursor: function() { } ,showSystemCursor: function() { } ,windowDownListeners: null ,windowUpListeners: null ,windowMoveListeners: null ,windowWheelListeners: null ,windowLeaveListeners: null ,sendLeaveEvent: function(windowId) { if(kha_network_Session.the() != null) { var bytes = new haxe_io_Bytes(new ArrayBuffer(8)); bytes.setInt32(0,0); bytes.setInt32(4,windowId); kha_network_Session.the().sendControllerUpdate(this._id(),bytes); } if(this.windowLeaveListeners != null) { var _g = 0; var _g1 = this.windowLeaveListeners[windowId]; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(); } } } ,sendDownEvent: function(windowId,button,x,y) { if(kha_network_Session.the() != null) { var bytes = new haxe_io_Bytes(new ArrayBuffer(20)); bytes.setInt32(0,1); bytes.setInt32(4,windowId); bytes.setInt32(8,button); bytes.setInt32(12,x); bytes.setInt32(16,y); kha_network_Session.the().sendControllerUpdate(this._id(),bytes); } if(this.windowDownListeners != null) { var _g = 0; var _g1 = this.windowDownListeners[windowId]; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(button,x,y); } } } ,sendUpEvent: function(windowId,button,x,y) { if(kha_network_Session.the() != null) { var bytes = new haxe_io_Bytes(new ArrayBuffer(20)); bytes.setInt32(0,2); bytes.setInt32(4,windowId); bytes.setInt32(8,button); bytes.setInt32(12,x); bytes.setInt32(16,y); kha_network_Session.the().sendControllerUpdate(this._id(),bytes); } if(this.windowUpListeners != null) { var _g = 0; var _g1 = this.windowUpListeners[windowId]; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(button,x,y); } } } ,sendMoveEvent: function(windowId,x,y,movementX,movementY) { if(kha_network_Session.the() != null) { var bytes = new haxe_io_Bytes(new ArrayBuffer(24)); bytes.setInt32(0,3); bytes.setInt32(4,windowId); bytes.setInt32(8,x); bytes.setInt32(12,y); bytes.setInt32(16,movementX); bytes.setInt32(20,movementY); kha_network_Session.the().sendControllerUpdate(this._id(),bytes); } if(this.windowMoveListeners != null) { var _g = 0; var _g1 = this.windowMoveListeners[windowId]; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(x,y,movementX,movementY); } } } ,sendWheelEvent: function(windowId,delta) { if(kha_network_Session.the() != null) { var bytes = new haxe_io_Bytes(new ArrayBuffer(12)); bytes.setInt32(0,4); bytes.setInt32(4,windowId); bytes.setInt32(8,delta); kha_network_Session.the().sendControllerUpdate(this._id(),bytes); } if(this.windowWheelListeners != null) { var _g = 0; var _g1 = this.windowWheelListeners[windowId]; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(delta); } } } ,_receive: function(bytes) { var funcindex = bytes.getInt32(0); if(funcindex == 0) { var input0 = bytes.getInt32(4); this.sendLeaveEvent(input0); return; } if(funcindex == 1) { var input01 = bytes.getInt32(4); var input1 = bytes.getInt32(8); var input2 = bytes.getInt32(12); var input3 = bytes.getInt32(16); this.sendDownEvent(input01,input1,input2,input3); return; } if(funcindex == 2) { var input02 = bytes.getInt32(4); var input11 = bytes.getInt32(8); var input21 = bytes.getInt32(12); var input31 = bytes.getInt32(16); this.sendUpEvent(input02,input11,input21,input31); return; } if(funcindex == 3) { var input03 = bytes.getInt32(4); var input12 = bytes.getInt32(8); var input22 = bytes.getInt32(12); var input32 = bytes.getInt32(16); var input4 = bytes.getInt32(20); this.sendMoveEvent(input03,input12,input22,input32,input4); return; } if(funcindex == 4) { var input04 = bytes.getInt32(4); var input13 = bytes.getInt32(8); this.sendWheelEvent(input04,input13); return; } } ,__class__: kha_input_Mouse }); var kha_input_MouseImpl = function() { kha_input_Mouse.call(this); }; $hxClasses["kha.input.MouseImpl"] = kha_input_MouseImpl; kha_input_MouseImpl.__name__ = true; kha_input_MouseImpl.__super__ = kha_input_Mouse; kha_input_MouseImpl.prototype = $extend(kha_input_Mouse.prototype,{ hideSystemCursor: function() { kha_SystemImpl.khanvas.style.cursor = "none"; } ,showSystemCursor: function() { kha_SystemImpl.khanvas.style.cursor = "default"; } ,_receive: function(bytes) { var funcindex = bytes.getInt32(0); } ,__class__: kha_input_MouseImpl }); var kha_input_Surface = $hx_exports["kha"]["input"]["Surface"] = function() { this.touchStartListeners = []; this.touchEndListeners = []; this.moveListeners = []; kha_input_Surface.instance = this; }; $hxClasses["kha.input.Surface"] = kha_input_Surface; kha_input_Surface.__name__ = true; kha_input_Surface.get = function(num) { if(num == null) { num = 0; } if(num != 0) { return null; } return kha_input_Surface.instance; }; kha_input_Surface.prototype = { notify: function(touchStartListener,touchEndListener,moveListener) { if(touchStartListener != null) { this.touchStartListeners.push(touchStartListener); } if(touchEndListener != null) { this.touchEndListeners.push(touchEndListener); } if(moveListener != null) { this.moveListeners.push(moveListener); } } ,remove: function(touchStartListener,touchEndListener,moveListener) { if(touchStartListener != null) { HxOverrides.remove(this.touchStartListeners,touchStartListener); } if(touchEndListener != null) { HxOverrides.remove(this.touchEndListeners,touchEndListener); } if(moveListener != null) { this.moveListeners.push(moveListener); } } ,touchStartListeners: null ,touchEndListeners: null ,moveListeners: null ,sendTouchStartEvent: function(index,x,y) { var _g = 0; var _g1 = this.touchStartListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(index,x,y); } } ,sendTouchEndEvent: function(index,x,y) { var _g = 0; var _g1 = this.touchEndListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(index,x,y); } } ,sendMoveEvent: function(index,x,y) { var _g = 0; var _g1 = this.moveListeners; while(_g < _g1.length) { var listener = _g1[_g]; ++_g; listener(index,x,y); } } ,__class__: kha_input_Surface }; var kha_internal_BytesBlob = function(bytes) { this.myFirstLine = true; this.bytes = bytes; this.buffer = []; }; $hxClasses["kha.internal.BytesBlob"] = kha_internal_BytesBlob; kha_internal_BytesBlob.__name__ = true; kha_internal_BytesBlob.__interfaces__ = [kha_Resource]; kha_internal_BytesBlob.fromBytes = function(bytes) { return new kha_internal_BytesBlob(bytes); }; kha_internal_BytesBlob.alloc = function(size) { return new kha_internal_BytesBlob(new haxe_io_Bytes(new ArrayBuffer(size))); }; kha_internal_BytesBlob.readF32 = function(i) { var sign = (i & -2147483648) == 0 ? 1 : -1; var exp = i >> 23 & 255; var man = i & 8388607; switch(exp) { case 0: return 0.0; case 255: if(man != 0) { return NaN; } else if(sign > 0) { return Infinity; } else { return -Infinity; } break; default: return sign * ((man + 8388608) / 8388608.0) * Math.pow(2,exp - 127); } }; kha_internal_BytesBlob.bit = function(value,position) { var b = (value >>> position & 1) == 1; if(b) { var a = 3; ++a; return true; } else { var c = 4; --c; return false; } }; kha_internal_BytesBlob.prototype = { bytes: null ,buffer: null ,myFirstLine: null ,sub: function(start,length) { return new kha_internal_BytesBlob(this.bytes.sub(start,length)); } ,length: null ,get_length: function() { return this.bytes.length; } ,writeU8: function(position,value) { this.bytes.b[position] = value & 255; } ,readU8: function(position) { var $byte = this.bytes.b[position]; ++position; return $byte; } ,readS8: function(position) { var $byte = this.bytes.b[position]; ++position; var sign = ($byte & 128) == 0 ? 1 : -1; $byte &= 127; return sign * $byte; } ,readU16BE: function(position) { var first = this.bytes.b[position]; var second = this.bytes.b[position + 1]; position += 2; return first * 256 + second; } ,readU16LE: function(position) { var first = this.bytes.b[position]; var second = this.bytes.b[position + 1]; position += 2; return second * 256 + first; } ,readU32LE: function(position) { var fourth = this.bytes.b[position]; var third = this.bytes.b[position + 1]; var second = this.bytes.b[position + 2]; var first = this.bytes.b[position + 3]; position += 4; return fourth + third * 256 + second * 256 * 256 + first * 256 * 256 * 256; } ,readU32BE: function(position) { var fourth = this.bytes.b[position]; var third = this.bytes.b[position + 1]; var second = this.bytes.b[position + 2]; var first = this.bytes.b[position + 3]; position += 4; return first + second * 256 + third * 256 * 256 + fourth * 256 * 256 * 256; } ,readS16BE: function(position) { var first = this.bytes.b[position]; var second = this.bytes.b[position + 1]; position += 2; var sign = (first & 128) == 0 ? 1 : -1; first &= 127; if(sign == -1) { return -32767 + first * 256 + second; } else { return first * 256 + second; } } ,readS16LE: function(position) { var first = this.bytes.b[position]; var second = this.bytes.b[position + 1]; var sign = (second & 128) == 0 ? 1 : -1; second &= 127; position += 2; if(sign == -1) { return -32767 + second * 256 + first; } else { return second * 256 + first; } } ,readS32LE: function(position) { var fourth = this.bytes.b[position]; var third = this.bytes.b[position + 1]; var second = this.bytes.b[position + 2]; var first = this.bytes.b[position + 3]; var sign = (first & 128) == 0 ? 1 : -1; first &= 127; position += 4; if(sign == -1) { return -2147483647 + fourth + third * 256 + second * 256 * 256 + first * 256 * 256 * 256; } else { return fourth + third * 256 + second * 256 * 256 + first * 256 * 256 * 256; } } ,readS32BE: function(position) { var fourth = this.bytes.b[position]; var third = this.bytes.b[position + 1]; var second = this.bytes.b[position + 2]; var first = this.bytes.b[position + 3]; var sign = (fourth & 128) == 0 ? 1 : -1; fourth &= 127; position += 4; if(sign == -1) { return -2147483647 + first + second * 256 + third * 256 * 256 + fourth * 256 * 256 * 256; } return first + second * 256 + third * 256 * 256 + fourth * 256 * 256 * 256; } ,readF32LE: function(position) { return kha_internal_BytesBlob.readF32(this.readS32LE(position)); } ,readF32BE: function(position) { return kha_internal_BytesBlob.readF32(this.readS32BE(position)); } ,toString: function() { return this.bytes.toString(); } ,readUtf8Char: function(position) { if(position.value >= this.get_length()) { return -1; } var c = this.readU8(position.value); ++position.value; var value = 0; if(!kha_internal_BytesBlob.bit(c,7)) { value = c; } else if(kha_internal_BytesBlob.bit(c,7) && kha_internal_BytesBlob.bit(c,6) && !kha_internal_BytesBlob.bit(c,5)) { var a = c & 31; var c2 = this.readU8(position.value); ++position.value; var b = c2 & 63; value = a << 6 | b; } else if(kha_internal_BytesBlob.bit(c,7) && kha_internal_BytesBlob.bit(c,6) && kha_internal_BytesBlob.bit(c,5) && !kha_internal_BytesBlob.bit(c,4)) { position.value += 2; } else if(kha_internal_BytesBlob.bit(c,7) && kha_internal_BytesBlob.bit(c,6) && kha_internal_BytesBlob.bit(c,5) && kha_internal_BytesBlob.bit(c,4) && !kha_internal_BytesBlob.bit(c,3)) { position.value += 3; } return value; } ,readUtf8Block: function(position) { var bufferindex = 0; if(position.value >= this.get_length()) { return ""; } while(bufferindex < 2000) { var c = this.readUtf8Char(position); if(c < 0) { break; } this.buffer[bufferindex] = c; ++bufferindex; } if(this.myFirstLine) { this.myFirstLine = false; if(bufferindex > 2 && this.buffer[0] == 239 && this.buffer[1] == 187 && this.buffer[2] == 191) { var chars = []; var _g1 = 3; var _g = bufferindex - 3; while(_g1 < _g) { var i = _g1++; chars[i - 3] = this.buffer[i]; } return this.toText(chars,bufferindex - 3); } } var chars1 = []; var _g11 = 0; var _g2 = bufferindex; while(_g11 < _g2) { var i1 = _g11++; chars1[i1] = this.buffer[i1]; } return this.toText(chars1,bufferindex); } ,toText: function(chars,length) { var value = ""; var _g1 = 0; var _g = length; while(_g1 < _g) { var i = _g1++; value += String.fromCharCode(chars[i]); } return value; } ,readUtf8String: function() { var text = ""; var position = { value : 0}; while(position.value < this.get_length()) text += this.readUtf8Block(position); return text; } ,toBytes: function() { return this.bytes; } ,unload: function() { this.bytes = null; } ,__class__: kha_internal_BytesBlob }; var kha_internal_HdrFormat = function() { }; $hxClasses["kha.internal.HdrFormat"] = kha_internal_HdrFormat; kha_internal_HdrFormat.__name__ = true; kha_internal_HdrFormat.readBuf = function(buf) { var bytesRead = 0; while(true) { buf[bytesRead++] = kha_internal_HdrFormat.buffer[kha_internal_HdrFormat.fileOffset] & 255; if(!(++kha_internal_HdrFormat.fileOffset < kha_internal_HdrFormat.bufferLength && bytesRead < buf.length)) { break; } } return bytesRead; }; kha_internal_HdrFormat.readBufOffset = function(buf,offset,length) { var bytesRead = 0; while(true) { buf[offset + bytesRead++] = kha_internal_HdrFormat.buffer[kha_internal_HdrFormat.fileOffset] & 255; if(!(++kha_internal_HdrFormat.fileOffset < kha_internal_HdrFormat.bufferLength && bytesRead < length)) { break; } } return bytesRead; }; kha_internal_HdrFormat.readPixelsRaw = function(buffer,data,offset,numpixels) { var numExpected = 4 * numpixels; var numRead = kha_internal_HdrFormat.readBufOffset(data,offset,numExpected); if(numRead < numExpected) { haxe_Log.trace("Error reading raw pixels: got " + numRead + " bytes, expected " + numExpected,{ fileName : "HdrFormat.hx", lineNumber : 43, className : "kha.internal.HdrFormat", methodName : "readPixelsRaw"}); return; } }; kha_internal_HdrFormat.readPixelsRawRLE = function(buffer,data,offset,scanline_width,num_scanlines) { var this1 = new Uint8Array(4); var rgbe = this1; var scanline_buffer = null; var ptr; var ptr_end; var count; var this2 = new Uint8Array(2); var buf = this2; var bufferLength = buffer.length; while(num_scanlines > 0) { if(kha_internal_HdrFormat.readBuf(rgbe) < rgbe.length) { haxe_Log.trace("Error reading bytes: expected " + rgbe.length,{ fileName : "HdrFormat.hx", lineNumber : 59, className : "kha.internal.HdrFormat", methodName : "readPixelsRawRLE"}); return; } if(rgbe[0] != 2 || rgbe[1] != 2 || (rgbe[2] & 128) != 0) { data[offset++] = rgbe[0] & 255; data[offset++] = rgbe[1] & 255; data[offset++] = rgbe[2] & 255; data[offset++] = rgbe[3] & 255; kha_internal_HdrFormat.readPixelsRaw(buffer,data,offset,scanline_width * num_scanlines - 1); return; } if(((rgbe[2] & 255) << 8 | rgbe[3] & 255) != scanline_width) { haxe_Log.trace("Wrong scanline width " + ((rgbe[2] & 255) << 8 | rgbe[3] & 255) + ", expected " + scanline_width,{ fileName : "HdrFormat.hx", lineNumber : 74, className : "kha.internal.HdrFormat", methodName : "readPixelsRawRLE"}); return; } if(scanline_buffer == null) { var this3 = new Uint8Array(4 * scanline_width); scanline_buffer = this3; } ptr = 0; var _g = 0; while(_g < 4) { var i = _g++; ptr_end = (i + 1) * scanline_width; while(ptr < ptr_end) { if(kha_internal_HdrFormat.readBuf(buf) < buf.length) { haxe_Log.trace("Error reading 2-byte buffer",{ fileName : "HdrFormat.hx", lineNumber : 88, className : "kha.internal.HdrFormat", methodName : "readPixelsRawRLE"}); return; } if((buf[0] & 255) > 128) { count = (buf[0] & 255) - 128; if(count == 0 || count > ptr_end - ptr) { haxe_Log.trace("Bad scanline data",{ fileName : "HdrFormat.hx", lineNumber : 95, className : "kha.internal.HdrFormat", methodName : "readPixelsRawRLE"}); return; } while(count-- > 0) scanline_buffer[ptr++] = buf[1] & 255; } else { count = buf[0] & 255; if(count == 0 || count > ptr_end - ptr) { haxe_Log.trace("Bad scanline data",{ fileName : "HdrFormat.hx", lineNumber : 106, className : "kha.internal.HdrFormat", methodName : "readPixelsRawRLE"}); return; } scanline_buffer[ptr++] = buf[1] & 255; if(--count > 0) { if(kha_internal_HdrFormat.readBufOffset(scanline_buffer,ptr,count) < count) { haxe_Log.trace("Error reading non-run data",{ fileName : "HdrFormat.hx", lineNumber : 112, className : "kha.internal.HdrFormat", methodName : "readPixelsRawRLE"}); return; } ptr += count; } } } } var _g1 = 0; var _g2 = scanline_width; while(_g1 < _g2) { var i1 = _g1++; data[offset] = scanline_buffer[i1] & 255; data[offset + 1] = scanline_buffer[i1 + scanline_width] & 255; data[offset + 2] = scanline_buffer[i1 + 2 * scanline_width] & 255; data[offset + 3] = scanline_buffer[i1 + 3 * scanline_width] & 255; offset += 4; } --num_scanlines; } }; kha_internal_HdrFormat.readLine = function() { var buf = ""; while(true) { var b = kha_internal_HdrFormat.buffer[kha_internal_HdrFormat.fileOffset]; if(b == 10) { ++kha_internal_HdrFormat.fileOffset; break; } buf += String.fromCharCode(b); if(!(++kha_internal_HdrFormat.fileOffset < kha_internal_HdrFormat.bufferLength)) { break; } } return buf; }; kha_internal_HdrFormat.parse = function(bytes) { kha_internal_HdrFormat.buffer = haxe_io__$UInt8Array_UInt8Array_$Impl_$.fromBytes(bytes); kha_internal_HdrFormat.bufferLength = kha_internal_HdrFormat.buffer.length; kha_internal_HdrFormat.fileOffset = 0; var width = 0; var height = 0; var exposure = 1.0; var gamma = 1.0; var rle = false; var _g = 0; while(_g < 20) { var i = _g++; var line = kha_internal_HdrFormat.readLine(); if(kha_internal_HdrFormat.formatPattern.match(line)) { rle = true; } else if(kha_internal_HdrFormat.exposurePattern.match(line)) { exposure = parseFloat(kha_internal_HdrFormat.exposurePattern.matched(1)); } else if(kha_internal_HdrFormat.widthHeightPattern.match(line)) { height = Std.parseInt(kha_internal_HdrFormat.widthHeightPattern.matched(1)); width = Std.parseInt(kha_internal_HdrFormat.widthHeightPattern.matched(2)); break; } } if(!rle) { haxe_Log.trace("File is not run length encoded!",{ fileName : "HdrFormat.hx", lineNumber : 175, className : "kha.internal.HdrFormat", methodName : "parse"}); return null; } var this1 = new Uint8Array(width * height * 4); var data = this1; var scanline_width = width; var num_scanlines = height; kha_internal_HdrFormat.readPixelsRawRLE(kha_internal_HdrFormat.buffer,data,0,scanline_width,num_scanlines); var this2 = new Float32Array(width * height * 4); var floatData = this2; var offset = 0; while(offset < data.length) { var r = data[offset] / 255; var g = data[offset + 1] / 255; var b = data[offset + 2] / 255; var e = data[offset + 3]; var f = Math.pow(2.0,e - 128.0); r *= f; g *= f; b *= f; floatData[offset] = r; floatData[offset + 1] = g; floatData[offset + 2] = b; floatData[offset + 3] = 1.0; offset += 4; } return { width : width, height : height, data : floatData}; }; kha_internal_HdrFormat.prototype = { __class__: kha_internal_HdrFormat }; var kha_js_AEAudioChannel = function(element) { this.stopped = false; this.element = element; }; $hxClasses["kha.js.AEAudioChannel"] = kha_js_AEAudioChannel; kha_js_AEAudioChannel.__name__ = true; kha_js_AEAudioChannel.__interfaces__ = [kha_audio1_AudioChannel]; kha_js_AEAudioChannel.prototype = { element: null ,stopped: null ,play: function() { this.stopped = false; if(kha_SystemImpl.mobile) { if(kha_SystemImpl.insideInputEvent) { this.element.play(); kha_SystemImpl.mobileAudioPlaying = true; } else if(kha_SystemImpl.mobileAudioPlaying) { this.element.play(); } else { kha_js_AEAudioChannel.todo.push(this); } } else { this.element.play(); } } ,pause: function() { try { this.element.pause(); } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; haxe_Log.trace(e,{ fileName : "AEAudioChannel.hx", lineNumber : 39, className : "kha.js.AEAudioChannel", methodName : "pause"}); } } ,stop: function() { try { this.element.pause(); this.element.currentTime = 0; this.stopped = true; } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; haxe_Log.trace(e,{ fileName : "AEAudioChannel.hx", lineNumber : 50, className : "kha.js.AEAudioChannel", methodName : "stop"}); } } ,length: null ,get_length: function() { if(isFinite(this.element.duration)) { return this.element.duration; } else { return Infinity; } } ,position: null ,get_position: function() { return this.element.currentTime; } ,get_volume: function() { return this.element.volume; } ,set_volume: function(value) { return this.element.volume = value; } ,finished: null ,get_finished: function() { if(!this.stopped) { return this.get_position() >= this.get_length(); } else { return true; } } ,__class__: kha_js_AEAudioChannel }; var kha_js_AudioElementAudio = function() { }; $hxClasses["kha.js.AudioElementAudio"] = kha_js_AudioElementAudio; kha_js_AudioElementAudio.__name__ = true; kha_js_AudioElementAudio._compile = function() { }; kha_js_AudioElementAudio.play = function(sound,loop) { if(loop == null) { loop = false; } return kha_js_AudioElementAudio.stream(sound,loop); }; kha_js_AudioElementAudio.stream = function(sound,loop) { if(loop == null) { loop = false; } sound.element.loop = loop; var channel = new kha_js_AEAudioChannel(sound.element); channel.play(); return channel; }; var kha_js_CanvasGraphics = function(canvas) { kha_graphics2_Graphics.call(this); this.canvas = canvas; kha_js_CanvasGraphics.instance = this; this.myColor = kha__$Color_Color_$Impl_$.fromBytes(0,0,0); canvas.save(); }; $hxClasses["kha.js.CanvasGraphics"] = kha_js_CanvasGraphics; kha_js_CanvasGraphics.__name__ = true; kha_js_CanvasGraphics.stringWidth = function(font,text) { if(kha_js_CanvasGraphics.instance == null) { return 5 * text.length; } else { kha_js_CanvasGraphics.instance.set_font(font); return kha_js_CanvasGraphics.instance.canvas.measureText(text).width; } }; kha_js_CanvasGraphics.__super__ = kha_graphics2_Graphics; kha_js_CanvasGraphics.prototype = $extend(kha_graphics2_Graphics.prototype,{ canvas: null ,webfont: null ,myColor: null ,scaleQuality: null ,begin: function(clear,clearColor) { if(clear == null) { clear = true; } if(clear) { this.clear(clearColor); } } ,clear: function(color) { if(color == null) { color = 0; } this.canvas.strokeStyle = "rgba(" + ((color & 16711680) >>> 16) + "," + ((color & 65280) >>> 8) + "," + (color & 255) + "," + (color >>> 24) * 0.00392156862745098 + ")"; this.canvas.fillStyle = "rgba(" + ((color & 16711680) >>> 16) + "," + ((color & 65280) >>> 8) + "," + (color & 255) + "," + (color >>> 24) * 0.00392156862745098 + ")"; if((color >>> 24) * 0.00392156862745098 == 0) { this.canvas.clearRect(0,0,this.canvas.canvas.width,this.canvas.canvas.height); } else { this.canvas.fillRect(0,0,this.canvas.canvas.width,this.canvas.canvas.height); } this.set_color(this.myColor); } ,end: function() { } ,drawImage: function(img,x,y) { this.canvas.globalAlpha = this.get_opacity(); this.canvas.drawImage((js_Boot.__cast(img , kha_CanvasImage)).image,x,y); this.canvas.globalAlpha = 1; } ,drawScaledSubImage: function(image,sx,sy,sw,sh,dx,dy,dw,dh) { this.canvas.globalAlpha = this.get_opacity(); try { if(dw < 0 || dh < 0) { this.canvas.save(); this.canvas.translate(dx,dy); var x = 0.0; var y = 0.0; if(dw < 0) { this.canvas.scale(-1,1); x = -dw; } if(dh < 0) { this.canvas.scale(1,-1); y = -dh; } this.canvas.drawImage((js_Boot.__cast(image , kha_CanvasImage)).image,sx,sy,sw,sh,x,y,dw,dh); this.canvas.restore(); } else { this.canvas.drawImage((js_Boot.__cast(image , kha_CanvasImage)).image,sx,sy,sw,sh,dx,dy,dw,dh); } } catch( ex ) { } this.canvas.globalAlpha = 1; } ,set_color: function(color) { this.myColor = color; this.canvas.strokeStyle = "rgba(" + ((color & 16711680) >>> 16) + "," + ((color & 65280) >>> 8) + "," + (color & 255) + "," + (color >>> 24) * 0.00392156862745098 + ")"; this.canvas.fillStyle = "rgba(" + ((color & 16711680) >>> 16) + "," + ((color & 65280) >>> 8) + "," + (color & 255) + "," + (color >>> 24) * 0.00392156862745098 + ")"; return color; } ,get_color: function() { return this.myColor; } ,get_imageScaleQuality: function() { return this.scaleQuality; } ,set_imageScaleQuality: function(value) { if(value == kha_graphics2_ImageScaleQuality.Low) { this.canvas.mozImageSmoothingEnabled = false; this.canvas.webkitImageSmoothingEnabled = false; this.canvas.msImageSmoothingEnabled = false; this.canvas.imageSmoothingEnabled = false; } else { this.canvas.mozImageSmoothingEnabled = true; this.canvas.webkitImageSmoothingEnabled = true; this.canvas.msImageSmoothingEnabled = true; this.canvas.imageSmoothingEnabled = true; } return this.scaleQuality = value; } ,drawRect: function(x,y,width,height,strength) { if(strength == null) { strength = 1.0; } this.canvas.beginPath(); var oldStrength = this.canvas.lineWidth; this.canvas.lineWidth = Math.round(strength); this.canvas.rect(x,y,width,height); this.canvas.stroke(); this.canvas.lineWidth = oldStrength; } ,fillRect: function(x,y,width,height) { var tmp = this.get_opacity(); this.canvas.globalAlpha = tmp * ((this.myColor >>> 24) * 0.00392156862745098); this.canvas.fillRect(x,y,width,height); this.canvas.globalAlpha = this.get_opacity(); } ,drawCircle: function(cx,cy,radius,strength) { if(strength == null) { strength = 1.0; } this.canvas.beginPath(); var oldStrength = this.canvas.lineWidth; this.canvas.lineWidth = Math.round(strength); this.canvas.arc(cx,cy,radius,0,2 * Math.PI,false); this.canvas.stroke(); this.canvas.lineWidth = oldStrength; } ,fillCircle: function(cx,cy,radius) { this.canvas.beginPath(); this.canvas.arc(cx,cy,radius,0,2 * Math.PI,false); this.canvas.fill(); } ,drawString: function(text,x,y) { var image = this.webfont.getImage(this.get_fontSize(),this.myColor); if(image.width > 0) { var xpos = x; var ypos = y; var _g1 = 0; var _g = text.length; while(_g1 < _g) { var i = _g1++; var q = this.webfont.kravur._get(this.get_fontSize()).getBakedQuad(HxOverrides.cca(text,i) - 32,xpos,ypos); if(q != null) { if(q.s1 - q.s0 > 0 && q.t1 - q.t0 > 0 && q.x1 - q.x0 > 0 && q.y1 - q.y0 > 0) { this.canvas.drawImage(image,q.s0 * image.width,q.t0 * image.height,(q.s1 - q.s0) * image.width,(q.t1 - q.t0) * image.height,q.x0,q.y0,q.x1 - q.x0,q.y1 - q.y0); } xpos += q.xadvance; } } } } ,set_font: function(font) { this.webfont = js_Boot.__cast(font , kha_js_Font); return this.webfont; } ,get_font: function() { return this.webfont; } ,drawLine: function(x1,y1,x2,y2,strength) { if(strength == null) { strength = 1.0; } this.canvas.beginPath(); var oldWith = this.canvas.lineWidth; this.canvas.lineWidth = Math.round(strength); this.canvas.moveTo(x1,y1); this.canvas.lineTo(x2,y2); this.canvas.moveTo(0,0); this.canvas.stroke(); this.canvas.lineWidth = oldWith; } ,fillTriangle: function(x1,y1,x2,y2,x3,y3) { this.canvas.beginPath(); this.canvas.closePath(); this.canvas.fill(); } ,scissor: function(x,y,width,height) { this.canvas.beginPath(); this.canvas.rect(x,y,width,height); this.canvas.clip(); } ,disableScissor: function() { this.canvas.restore(); } ,drawVideo: function(video,x,y,width,height) { this.canvas.drawImage((js_Boot.__cast(video , kha_js_Video)).element,x,y,width,height); } ,setTransformation: function(transformation) { this.canvas.setTransform(transformation._00,transformation._01,transformation._10,transformation._11,transformation._20,transformation._21); } ,__class__: kha_js_CanvasGraphics }); var kha_js_URLParser = function(url) { this._parts = null; this._parts = ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]; this.url = url; var r = new EReg("^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\\d*))?)(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))(?:\\?([^#]*))?(?:#(.*))?)",""); r.match(url); var _g1 = 0; var _g = this._parts.length; while(_g1 < _g) { var i = _g1++; this[this._parts[i]] = r.matched(i); } }; $hxClasses["kha.js.URLParser"] = kha_js_URLParser; kha_js_URLParser.__name__ = true; kha_js_URLParser.parse = function(url) { return new kha_js_URLParser(url); }; kha_js_URLParser.prototype = { url: null ,source: null ,protocol: null ,authority: null ,userInfo: null ,user: null ,password: null ,host: null ,port: null ,relative: null ,path: null ,directory: null ,file: null ,query: null ,anchor: null ,_parts: null ,toString: function() { var s = "For Url -> " + this.url + "\n"; var _g1 = 0; var _g = this._parts.length; while(_g1 < _g) { var i = _g1++; s += this._parts[i] + ": " + Std.string(Reflect.field(this,this._parts[i])) + (i == this._parts.length - 1 ? "" : "\n"); } return s; } ,__class__: kha_js_URLParser }; var kha_js_EnvironmentVariables = function() { kha_EnvironmentVariables.call(this); }; $hxClasses["kha.js.EnvironmentVariables"] = kha_js_EnvironmentVariables; kha_js_EnvironmentVariables.__name__ = true; kha_js_EnvironmentVariables.__super__ = kha_EnvironmentVariables; kha_js_EnvironmentVariables.prototype = $extend(kha_EnvironmentVariables.prototype,{ getVariable: function(name) { var parser = new kha_js_URLParser(window.location.href); var query = parser.query; var parts = query.split("&"); var _g = 0; while(_g < parts.length) { var part = parts[_g]; ++_g; var subparts = part.split("="); if(subparts[0] == name) { return subparts[1]; } } haxe_Log.trace("Environment variables requested.",{ fileName : "EnvironmentVariables.hx", lineNumber : 90, className : "kha.js.EnvironmentVariables", methodName : "getVariable"}); return ""; } ,__class__: kha_js_EnvironmentVariables }); var kha_js_Font = function(kravur) { this.images = new haxe_ds_IntMap(); this.kravur = kravur; }; $hxClasses["kha.js.Font"] = kha_js_Font; kha_js_Font.__name__ = true; kha_js_Font.__interfaces__ = [kha_Font]; kha_js_Font.prototype = { kravur: null ,images: null ,height: function(fontSize) { return this.kravur._get(fontSize).getHeight(); } ,width: function(fontSize,str) { return this.kravur._get(fontSize).stringWidth(str); } ,baseline: function(fontSize) { return this.kravur._get(fontSize).getBaselinePosition(); } ,getImage: function(fontSize,color) { if(!this.images.h.hasOwnProperty(fontSize)) { var this1 = this.images; var v = new haxe_ds_IntMap(); this1.h[fontSize] = v; } if(!this.images.h[fontSize].h.hasOwnProperty(color)) { var kravur = this.kravur._get(fontSize); var canvas = window.document.createElement("canvas"); canvas.width = kravur.width; canvas.height = kravur.height; var ctx = canvas.getContext("2d"); ctx.fillStyle = "black"; ctx.fillRect(0,0,kravur.width,kravur.height); var imageData = ctx.getImageData(0,0,kravur.width,kravur.height); var bytes = (js_Boot.__cast(kravur.getTexture() , kha_CanvasImage)).bytes; var _g1 = 0; var _g = bytes.length; while(_g1 < _g) { var i = _g1++; imageData.data[i * 4] = (color & 16711680) >>> 16; imageData.data[i * 4 + 1] = (color & 65280) >>> 8; imageData.data[i * 4 + 2] = color & 255; imageData.data[i * 4 + 3] = bytes.b[i]; } ctx.putImageData(imageData,0,0); var img = window.document.createElement("img"); img.src = canvas.toDataURL("image/png"); this.images.h[fontSize].h[color] = img; return img; } return this.images.h[fontSize].h[color]; } ,unload: function() { this.kravur = null; this.images = null; } ,__class__: kha_js_Font }; var kha_js_MobileWebAudio = function() { }; $hxClasses["kha.js.MobileWebAudio"] = kha_js_MobileWebAudio; kha_js_MobileWebAudio.__name__ = true; kha_js_MobileWebAudio._init = function() { try { kha_js_MobileWebAudio._context = new AudioContext(); return; } catch( e ) { } try { this._context = new webkitAudioContext(); return; } catch( e1 ) { } }; kha_js_MobileWebAudio.play = function(sound,loop) { if(loop == null) { loop = false; } var channel = new kha_js_MobileWebAudioChannel(sound,loop); channel.play(); return channel; }; kha_js_MobileWebAudio.stream = function(sound,loop) { if(loop == null) { loop = false; } return kha_js_MobileWebAudio.play(sound,loop); }; var kha_js_MobileWebAudioChannel = function(sound,loop) { this.stopped = false; this.paused = false; this.buffer = sound._buffer; this.loop = loop; this.createSource(); }; $hxClasses["kha.js.MobileWebAudioChannel"] = kha_js_MobileWebAudioChannel; kha_js_MobileWebAudioChannel.__name__ = true; kha_js_MobileWebAudioChannel.__interfaces__ = [kha_audio1_AudioChannel]; kha_js_MobileWebAudioChannel.prototype = { buffer: null ,loop: null ,source: null ,gain: null ,startTime: null ,pauseTime: null ,paused: null ,stopped: null ,createSource: function() { var _gthis = this; this.source = kha_js_MobileWebAudio._context.createBufferSource(); this.source.loop = this.loop; this.source.buffer = this.buffer; this.source.onended = function() { _gthis.stopped = true; }; this.gain = kha_js_MobileWebAudio._context.createGain(); this.source.connect(this.gain); this.gain.connect(kha_js_MobileWebAudio._context.destination); } ,play: function() { if(this.paused || this.stopped) { this.createSource(); } this.stopped = false; if(this.paused) { this.paused = false; this.startTime = kha_js_MobileWebAudio._context.currentTime - this.pauseTime; this.source.start(0,this.pauseTime); } else { this.startTime = kha_js_MobileWebAudio._context.currentTime; this.source.start(); } } ,pause: function() { this.pauseTime = kha_js_MobileWebAudio._context.currentTime - this.startTime; this.paused = true; this.source.stop(); } ,stop: function() { this.paused = false; this.stopped = true; this.source.stop(); } ,length: null ,get_length: function() { return this.source.buffer.duration; } ,position: null ,get_position: function() { if(this.stopped) { return this.get_length(); } if(this.paused) { return this.pauseTime; } else { return kha_js_MobileWebAudio._context.currentTime - this.startTime; } } ,get_volume: function() { return this.gain.gain.value; } ,set_volume: function(value) { return this.gain.gain.value = value; } ,finished: null ,get_finished: function() { return this.stopped; } ,__class__: kha_js_MobileWebAudioChannel }; var kha_js_MobileWebAudioSound = function(filename,done) { var _gthis = this; kha_Sound.call(this); var request = new XMLHttpRequest(); request.open("GET",filename,true); request.responseType = "arraybuffer"; request.onerror = function() { haxe_Log.trace("Error loading " + filename,{ fileName : "MobileWebAudioSound.hx", lineNumber : 25, className : "kha.js.MobileWebAudioSound", methodName : "new"}); }; request.onload = function() { _gthis.compressedData = haxe_io_Bytes.ofData(request.response); _gthis.uncompressedData = null; kha_js_MobileWebAudio._context.decodeAudioData(_gthis.compressedData.b.bufferValue,function(buffer) { _gthis._buffer = buffer; done(_gthis); },function() { throw new js__$Boot_HaxeError("Audio format not supported"); }); }; request.send(null); }; $hxClasses["kha.js.MobileWebAudioSound"] = kha_js_MobileWebAudioSound; kha_js_MobileWebAudioSound.__name__ = true; kha_js_MobileWebAudioSound.__super__ = kha_Sound; kha_js_MobileWebAudioSound.prototype = $extend(kha_Sound.prototype,{ _buffer: null ,uncompress: function(done) { done(); } ,__class__: kha_js_MobileWebAudioSound }); var kha_js_Sound = function(filenames,done) { kha_Sound.call(this); this.done = done; kha_js_Sound.loading.push(this); this.element = window.document.createElement("audio"); this.filenames = []; var _g = 0; while(_g < filenames.length) { var filename = filenames[_g]; ++_g; if(this.element.canPlayType("audio/ogg") != "" && StringTools.endsWith(filename,".ogg")) { this.filenames.push(filename); } if(this.element.canPlayType("audio/mp4") != "" && StringTools.endsWith(filename,".mp4")) { this.filenames.push(filename); } } this.element.addEventListener("error",$bind(this,this.errorListener),false); this.element.addEventListener("canplay",$bind(this,this.canPlayThroughListener),false); this.element.src = this.filenames[0]; this.element.preload = "auto"; this.element.load(); }; $hxClasses["kha.js.Sound"] = kha_js_Sound; kha_js_Sound.__name__ = true; kha_js_Sound.__super__ = kha_Sound; kha_js_Sound.prototype = $extend(kha_Sound.prototype,{ filenames: null ,done: null ,element: null ,errorListener: function(eventInfo) { if(this.element.error.code == 4) { var _g1 = 0; var _g = this.filenames.length - 1; while(_g1 < _g) { var i = _g1++; if(this.element.src == this.filenames[i]) { this.element.src = this.filenames[i + 1]; return; } } } haxe_Log.trace("Error loading " + this.element.src,{ fileName : "Sound.hx", lineNumber : 108, className : "kha.js.Sound", methodName : "errorListener"}); window.console.log("loadSound failed"); this.finishAsset(); } ,canPlayThroughListener: function(eventInfo) { this.finishAsset(); } ,finishAsset: function() { this.element.removeEventListener("error",$bind(this,this.errorListener),false); this.element.removeEventListener("canplaythrough",$bind(this,this.canPlayThroughListener),false); this.done(this); HxOverrides.remove(kha_js_Sound.loading,this); } ,uncompress: function(done) { done(); } ,__class__: kha_js_Sound }); var kha_js_Video = function(filenames,done) { kha_Video.call(this); this.done = done; kha_js_Video.loading.add(this); this.element = window.document.createElement("video"); this.filenames = []; var _g = 0; while(_g < filenames.length) { var filename = filenames[_g]; ++_g; if(this.element.canPlayType("video/webm") != "" && StringTools.endsWith(filename,".webm")) { this.filenames.push(filename); } if(this.element.canPlayType("video/mp4") != "" && StringTools.endsWith(filename,".mp4")) { this.filenames.push(filename); } } this.element.addEventListener("error",$bind(this,this.errorListener),false); this.element.addEventListener("canplaythrough",$bind(this,this.canPlayThroughListener),false); this.element.preload = "auto"; this.element.src = this.filenames[0]; }; $hxClasses["kha.js.Video"] = kha_js_Video; kha_js_Video.__name__ = true; kha_js_Video.__super__ = kha_Video; kha_js_Video.prototype = $extend(kha_Video.prototype,{ filenames: null ,element: null ,done: null ,texture: null ,width: function() { return this.element.videoWidth; } ,height: function() { return this.element.videoHeight; } ,play: function(loop) { if(loop == null) { loop = false; } try { this.element.loop = loop; this.element.play(); } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; haxe_Log.trace(e,{ fileName : "Video.hx", lineNumber : 55, className : "kha.js.Video", methodName : "play"}); } } ,pause: function() { try { this.element.pause(); } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; haxe_Log.trace(e,{ fileName : "Video.hx", lineNumber : 64, className : "kha.js.Video", methodName : "pause"}); } } ,stop: function() { try { this.element.pause(); this.element.currentTime = 0; } catch( e ) { if (e instanceof js__$Boot_HaxeError) e = e.val; haxe_Log.trace(e,{ fileName : "Video.hx", lineNumber : 74, className : "kha.js.Video", methodName : "stop"}); } } ,getCurrentPos: function() { return Math.ceil(this.element.currentTime * 1000); } ,get_position: function() { return Math.ceil(this.element.currentTime * 1000); } ,set_position: function(value) { this.element.currentTime = value / 1000; return value; } ,getLength: function() { if(isFinite(this.element.duration)) { return Math.floor(this.element.duration * 1000); } else { return -1; } } ,errorListener: function(eventInfo) { if(this.element.error.code == 4) { var _g1 = 0; var _g = this.filenames.length - 1; while(_g1 < _g) { var i = _g1++; if(this.element.src == this.filenames[i]) { this.element.src = this.filenames[i + 1]; return; } } } haxe_Log.trace("Error loading " + this.element.src,{ fileName : "Video.hx", lineNumber : 111, className : "kha.js.Video", methodName : "errorListener"}); this.finishAsset(); } ,canPlayThroughListener: function(eventInfo) { this.finishAsset(); } ,finishAsset: function() { this.element.removeEventListener("error",$bind(this,this.errorListener),false); this.element.removeEventListener("canplaythrough",$bind(this,this.canPlayThroughListener),false); if(kha_SystemImpl.gl != null) { this.texture = kha_Image.fromVideo(this); } this.done(this); kha_js_Video.loading.remove(this); } ,__class__: kha_js_Video }); var kha_js_WebAudioSound = function(filename,done) { var _gthis = this; kha_Sound.call(this); var request = new XMLHttpRequest(); request.open("GET",filename,true); request.responseType = "arraybuffer"; request.onerror = function() { haxe_Log.trace("Error loading " + filename,{ fileName : "WebAudioSound.hx", lineNumber : 76, className : "kha.js.WebAudioSound", methodName : "new"}); }; request.onload = function() { _gthis.compressedData = haxe_io_Bytes.ofData(request.response); _gthis.uncompressedData = null; done(_gthis); }; request.send(null); }; $hxClasses["kha.js.WebAudioSound"] = kha_js_WebAudioSound; kha_js_WebAudioSound.__name__ = true; kha_js_WebAudioSound.__super__ = kha_Sound; kha_js_WebAudioSound.prototype = $extend(kha_Sound.prototype,{ superUncompress: function(done) { kha_Sound.prototype.uncompress.call(this,done); } ,uncompress: function(done) { var _gthis = this; kha_audio2_Audio._context.decodeAudioData(this.compressedData.b.bufferValue,function(buffer) { var length = buffer.getChannelData(0).length * 2; var this1 = new Array(length); _gthis.uncompressedData = this1; if(buffer.numberOfChannels == 1) { var _g1 = 0; var _g = buffer.getChannelData(0).length; while(_g1 < _g) { var i = _g1++; _gthis.uncompressedData[i * 2] = buffer.getChannelData(0)[i]; _gthis.uncompressedData[i * 2 + 1] = buffer.getChannelData(0)[i]; } } else { var _g11 = 0; var _g2 = buffer.getChannelData(0).length; while(_g11 < _g2) { var i1 = _g11++; _gthis.uncompressedData[i1 * 2] = buffer.getChannelData(0)[i1]; _gthis.uncompressedData[i1 * 2 + 1] = buffer.getChannelData(1)[i1]; } } _gthis.compressedData = null; done(); },function() { _gthis.superUncompress(done); }); } ,__class__: kha_js_WebAudioSound }); var kha_js_graphics4_ConstantLocation = function(value,type) { this.value = value; this.type = type; }; $hxClasses["kha.js.graphics4.ConstantLocation"] = kha_js_graphics4_ConstantLocation; kha_js_graphics4_ConstantLocation.__name__ = true; kha_js_graphics4_ConstantLocation.__interfaces__ = [kha_graphics4_ConstantLocation]; kha_js_graphics4_ConstantLocation.prototype = { value: null ,type: null ,__class__: kha_js_graphics4_ConstantLocation }; var kha_js_graphics4_Graphics = function(renderTarget) { var this1 = new Array(9); this.matrix3Cache = this1; var this11 = new Array(16); this.matrixCache = this11; this.isDepthAttachment = false; this.isCubeMap = false; this.colorMaskAlpha = true; this.colorMaskBlue = true; this.colorMaskGreen = true; this.colorMaskRed = true; this.depthMask = false; this.depthTest = false; this.renderTarget = renderTarget; this.init(); if(kha_SystemImpl.gl2) { this.instancedExtension = true; } else { this.instancedExtension = kha_SystemImpl.gl.getExtension("ANGLE_instanced_arrays"); this.blendMinMaxExtension = kha_SystemImpl.gl.getExtension("EXT_blend_minmax"); } }; $hxClasses["kha.js.graphics4.Graphics"] = kha_js_graphics4_Graphics; kha_js_graphics4_Graphics.__name__ = true; kha_js_graphics4_Graphics.__interfaces__ = [kha_graphics4_Graphics]; kha_js_graphics4_Graphics.getBlendFunc = function(factor) { switch(factor[1]) { case 0:case 2: return 0; case 1: return 1; case 3: return 770; case 4: return 772; case 5: return 771; case 6: return 773; case 7: return 768; case 8: return 774; case 9: return 769; case 10: return 775; } }; kha_js_graphics4_Graphics.getBlendOp = function(op) { switch(op[1]) { case 0: return 32774; case 1: return 32778; case 2: return 32779; case 3: return 32775; case 4: return 32776; } }; kha_js_graphics4_Graphics.prototype = { depthTest: null ,depthMask: null ,colorMaskRed: null ,colorMaskGreen: null ,colorMaskBlue: null ,colorMaskAlpha: null ,indicesCount: null ,renderTarget: null ,renderTargetFrameBuffer: null ,renderTargetTexture: null ,isCubeMap: null ,isDepthAttachment: null ,instancedExtension: null ,blendMinMaxExtension: null ,init: function() { if(this.renderTarget == null) { return; } this.isCubeMap = js_Boot.__instanceof(this.renderTarget,kha_graphics4_CubeMap); if(this.isCubeMap) { var cubeMap = js_Boot.__cast(this.renderTarget , kha_graphics4_CubeMap); this.renderTargetFrameBuffer = cubeMap.frameBuffer; this.renderTargetTexture = cubeMap.texture; this.isDepthAttachment = cubeMap.isDepthAttachment; } else { var image = js_Boot.__cast(this.renderTarget , kha_WebGLImage); this.renderTargetFrameBuffer = image.frameBuffer; this.renderTargetTexture = image.texture; } } ,begin: function(additionalRenderTargets) { kha_SystemImpl.gl.enable(3042); kha_SystemImpl.gl.blendFunc(770,771); if(this.renderTarget == null) { kha_SystemImpl.gl.bindFramebuffer(36160,null); kha_SystemImpl.gl.viewport(0,0,kha_System.windowWidth(),kha_System.windowHeight()); } else { kha_SystemImpl.gl.bindFramebuffer(36160,this.renderTargetFrameBuffer); kha_SystemImpl.gl.viewport(0,0,this.renderTarget.get_width(),this.renderTarget.get_height()); if(additionalRenderTargets != null) { kha_SystemImpl.gl.framebufferTexture2D(36160,kha_SystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL,3553,this.renderTargetTexture,0); var _g1 = 0; var _g = additionalRenderTargets.length; while(_g1 < _g) { var i = _g1++; kha_SystemImpl.gl.framebufferTexture2D(36160,kha_SystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL + i + 1,3553,(js_Boot.__cast(additionalRenderTargets[i] , kha_WebGLImage)).texture,0); } var attachments = [kha_SystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL]; var _g11 = 0; var _g2 = additionalRenderTargets.length; while(_g11 < _g2) { var i1 = _g11++; attachments.push(kha_SystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL + i1 + 1); } if(kha_SystemImpl.gl2) { kha_SystemImpl.gl.drawBuffers(attachments); } else { kha_SystemImpl.drawBuffers.drawBuffersWEBGL(attachments); } } } } ,beginFace: function(face) { kha_SystemImpl.gl.enable(3042); kha_SystemImpl.gl.blendFunc(770,771); kha_SystemImpl.gl.bindFramebuffer(36160,this.renderTargetFrameBuffer); kha_SystemImpl.gl.framebufferTexture2D(36160,this.isDepthAttachment ? 36096 : 36064,34069 + face,this.renderTargetTexture,0); kha_SystemImpl.gl.viewport(0,0,this.renderTarget.get_width(),this.renderTarget.get_height()); } ,beginEye: function(eye) { kha_SystemImpl.gl.enable(3042); kha_SystemImpl.gl.blendFunc(770,771); kha_SystemImpl.gl.bindFramebuffer(36160,null); if(eye == 0) { kha_SystemImpl.gl.viewport(0,0,kha_System.windowWidth() * 0.5 | 0,kha_System.windowHeight()); } else { kha_SystemImpl.gl.viewport(kha_System.windowWidth() * 0.5 | 0,0,kha_System.windowWidth() * 0.5 | 0,kha_System.windowHeight()); } } ,end: function() { var error = kha_SystemImpl.gl.getError(); switch(error) { case 0: break; case 1280: haxe_Log.trace("WebGL error: Invalid enum",{ fileName : "Graphics.hx", lineNumber : 130, className : "kha.js.graphics4.Graphics", methodName : "end"}); break; case 1281: haxe_Log.trace("WebGL error: Invalid value",{ fileName : "Graphics.hx", lineNumber : 132, className : "kha.js.graphics4.Graphics", methodName : "end"}); break; case 1282: haxe_Log.trace("WebGL error: Invalid operation",{ fileName : "Graphics.hx", lineNumber : 134, className : "kha.js.graphics4.Graphics", methodName : "end"}); break; case 1285: haxe_Log.trace("WebGL error: Out of memory",{ fileName : "Graphics.hx", lineNumber : 138, className : "kha.js.graphics4.Graphics", methodName : "end"}); break; case 1286: haxe_Log.trace("WebGL error: Invalid framebuffer operation",{ fileName : "Graphics.hx", lineNumber : 136, className : "kha.js.graphics4.Graphics", methodName : "end"}); break; case 37442: haxe_Log.trace("WebGL error: Context lost",{ fileName : "Graphics.hx", lineNumber : 140, className : "kha.js.graphics4.Graphics", methodName : "end"}); break; default: haxe_Log.trace("Unknown WebGL error",{ fileName : "Graphics.hx", lineNumber : 142, className : "kha.js.graphics4.Graphics", methodName : "end"}); } } ,flush: function() { } ,vsynced: function() { return true; } ,refreshRate: function() { return 60; } ,clear: function(color,depth,stencil) { var clearMask = 0; if(color != null) { clearMask |= 16384; kha_SystemImpl.gl.colorMask(true,true,true,true); kha_SystemImpl.gl.clearColor(((color & 16711680) >>> 16) * 0.00392156862745098,((color & 65280) >>> 8) * 0.00392156862745098,(color & 255) * 0.00392156862745098,(color >>> 24) * 0.00392156862745098); } if(depth != null) { clearMask |= 256; kha_SystemImpl.gl.enable(2929); kha_SystemImpl.gl.depthMask(true); kha_SystemImpl.gl.clearDepth(depth); } if(stencil != null) { clearMask |= 1024; kha_SystemImpl.gl.enable(2960); kha_SystemImpl.gl.stencilMask(255); kha_SystemImpl.gl.clearStencil(stencil); } kha_SystemImpl.gl.clear(clearMask); kha_SystemImpl.gl.colorMask(this.colorMaskRed,this.colorMaskGreen,this.colorMaskBlue,this.colorMaskAlpha); if(this.depthTest) { kha_SystemImpl.gl.enable(2929); } else { kha_SystemImpl.gl.disable(2929); } kha_SystemImpl.gl.depthMask(this.depthMask); } ,viewport: function(x,y,width,height) { var h = this.renderTarget == null ? kha_System.windowHeight(0) : this.renderTarget.get_height(); kha_SystemImpl.gl.viewport(x,h - y - height,width,height); } ,setDepthMode: function(write,mode) { switch(mode[1]) { case 0: if(write) { kha_SystemImpl.gl.enable(2929); } else { kha_SystemImpl.gl.disable(2929); } this.depthTest = write; kha_SystemImpl.gl.depthFunc(519); break; case 1: kha_SystemImpl.gl.enable(2929); this.depthTest = true; kha_SystemImpl.gl.depthFunc(512); break; case 2: kha_SystemImpl.gl.enable(2929); this.depthTest = true; kha_SystemImpl.gl.depthFunc(514); break; case 3: kha_SystemImpl.gl.enable(2929); this.depthTest = true; kha_SystemImpl.gl.depthFunc(517); break; case 4: kha_SystemImpl.gl.enable(2929); this.depthTest = true; kha_SystemImpl.gl.depthFunc(513); break; case 5: kha_SystemImpl.gl.enable(2929); this.depthTest = true; kha_SystemImpl.gl.depthFunc(515); break; case 6: kha_SystemImpl.gl.enable(2929); this.depthTest = true; kha_SystemImpl.gl.depthFunc(516); break; case 7: kha_SystemImpl.gl.enable(2929); this.depthTest = true; kha_SystemImpl.gl.depthFunc(518); break; } kha_SystemImpl.gl.depthMask(write); this.depthMask = write; } ,setBlendingMode: function(source,destination,operation,alphaSource,alphaDestination,alphaOperation) { if(source == kha_graphics4_BlendingFactor.BlendOne && destination == kha_graphics4_BlendingFactor.BlendZero) { kha_SystemImpl.gl.disable(3042); } else { kha_SystemImpl.gl.enable(3042); kha_SystemImpl.gl.blendFuncSeparate(kha_js_graphics4_Graphics.getBlendFunc(source),kha_js_graphics4_Graphics.getBlendFunc(destination),kha_js_graphics4_Graphics.getBlendFunc(alphaSource),kha_js_graphics4_Graphics.getBlendFunc(alphaDestination)); kha_SystemImpl.gl.blendEquationSeparate(kha_js_graphics4_Graphics.getBlendOp(operation),kha_js_graphics4_Graphics.getBlendOp(alphaOperation)); } } ,createVertexBuffer: function(vertexCount,structure,usage,canRead) { if(canRead == null) { canRead = false; } return new kha_graphics4_VertexBuffer(vertexCount,structure,usage); } ,setVertexBuffer: function(vertexBuffer) { (js_Boot.__cast(vertexBuffer , kha_graphics4_VertexBuffer)).set(0); } ,setVertexBuffers: function(vertexBuffers) { var offset = 0; var _g = 0; while(_g < vertexBuffers.length) { var vertexBuffer = vertexBuffers[_g]; ++_g; offset += (js_Boot.__cast(vertexBuffer , kha_graphics4_VertexBuffer)).set(offset); } } ,createIndexBuffer: function(indexCount,usage,canRead) { if(canRead == null) { canRead = false; } return new kha_graphics4_IndexBuffer(indexCount,usage); } ,setIndexBuffer: function(indexBuffer) { this.indicesCount = indexBuffer.count(); (js_Boot.__cast(indexBuffer , kha_graphics4_IndexBuffer)).set(); } ,setTexture: function(stage,texture) { if(texture == null) { kha_SystemImpl.gl.activeTexture(33984 + (js_Boot.__cast(stage , kha_js_graphics4_TextureUnit)).value); kha_SystemImpl.gl.bindTexture(3553,null); } else { (js_Boot.__cast(texture , kha_WebGLImage)).set((js_Boot.__cast(stage , kha_js_graphics4_TextureUnit)).value); } } ,setTextureDepth: function(stage,texture) { (js_Boot.__cast(texture , kha_WebGLImage)).setDepth((js_Boot.__cast(stage , kha_js_graphics4_TextureUnit)).value); } ,setVideoTexture: function(unit,texture) { if(texture == null) { kha_SystemImpl.gl.activeTexture(33984 + (js_Boot.__cast(unit , kha_js_graphics4_TextureUnit)).value); kha_SystemImpl.gl.bindTexture(3553,null); } else { (js_Boot.__cast((js_Boot.__cast(texture , kha_js_Video)).texture , kha_WebGLImage)).set((js_Boot.__cast(unit , kha_js_graphics4_TextureUnit)).value); } } ,setImageTexture: function(unit,texture) { } ,setTextureParameters: function(texunit,uAddressing,vAddressing,minificationFilter,magnificationFilter,mipmapFilter) { kha_SystemImpl.gl.activeTexture(33984 + (js_Boot.__cast(texunit , kha_js_graphics4_TextureUnit)).value); switch(uAddressing[1]) { case 0: kha_SystemImpl.gl.texParameteri(3553,10242,10497); break; case 1: kha_SystemImpl.gl.texParameteri(3553,10242,33648); break; case 2: kha_SystemImpl.gl.texParameteri(3553,10242,33071); break; } switch(vAddressing[1]) { case 0: kha_SystemImpl.gl.texParameteri(3553,10243,10497); break; case 1: kha_SystemImpl.gl.texParameteri(3553,10243,33648); break; case 2: kha_SystemImpl.gl.texParameteri(3553,10243,33071); break; } switch(minificationFilter[1]) { case 0: switch(mipmapFilter[1]) { case 0: kha_SystemImpl.gl.texParameteri(3553,10241,9728); break; case 1: kha_SystemImpl.gl.texParameteri(3553,10241,9984); break; case 2: kha_SystemImpl.gl.texParameteri(3553,10241,9986); break; } break; case 1:case 2: switch(mipmapFilter[1]) { case 0: kha_SystemImpl.gl.texParameteri(3553,10241,9729); break; case 1: kha_SystemImpl.gl.texParameteri(3553,10241,9985); break; case 2: kha_SystemImpl.gl.texParameteri(3553,10241,9987); break; } if(minificationFilter == kha_graphics4_TextureFilter.AnisotropicFilter) { kha_SystemImpl.gl.texParameteri(3553,kha_SystemImpl.anisotropicFilter.TEXTURE_MAX_ANISOTROPY_EXT,4); } break; } switch(magnificationFilter[1]) { case 0: kha_SystemImpl.gl.texParameteri(3553,10240,9728); break; case 1:case 2: kha_SystemImpl.gl.texParameteri(3553,10240,9729); break; } } ,setTexture3DParameters: function(texunit,uAddressing,vAddressing,wAddressing,minificationFilter,magnificationFilter,mipmapFilter) { } ,setCubeMap: function(stage,cubeMap) { if(cubeMap == null) { kha_SystemImpl.gl.activeTexture(33984 + (js_Boot.__cast(stage , kha_js_graphics4_TextureUnit)).value); kha_SystemImpl.gl.bindTexture(34067,null); } else { cubeMap.set((js_Boot.__cast(stage , kha_js_graphics4_TextureUnit)).value); } } ,setCubeMapDepth: function(stage,cubeMap) { cubeMap.setDepth((js_Boot.__cast(stage , kha_js_graphics4_TextureUnit)).value); } ,setCullMode: function(mode) { switch(mode[1]) { case 0: kha_SystemImpl.gl.enable(2884); kha_SystemImpl.gl.cullFace(1029); break; case 1: kha_SystemImpl.gl.enable(2884); kha_SystemImpl.gl.cullFace(1028); break; case 2: kha_SystemImpl.gl.disable(2884); break; } } ,setPipeline: function(pipe) { this.setCullMode(pipe.cullMode); this.setDepthMode(pipe.depthWrite,pipe.depthMode); this.setStencilParameters(pipe.stencilMode,pipe.stencilBothPass,pipe.stencilDepthFail,pipe.stencilFail,pipe.stencilReferenceValue,pipe.stencilReadMask,pipe.stencilWriteMask); this.setBlendingMode(pipe.blendSource,pipe.blendDestination,pipe.blendOperation,pipe.alphaBlendSource,pipe.alphaBlendDestination,pipe.alphaBlendOperation); pipe.set(); this.colorMaskRed = pipe.colorWriteMaskRed; this.colorMaskGreen = pipe.colorWriteMaskGreen; this.colorMaskBlue = pipe.colorWriteMaskBlue; this.colorMaskAlpha = pipe.colorWriteMaskAlpha; } ,setBool: function(location,value) { kha_SystemImpl.gl.uniform1i((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value ? 1 : 0); } ,setInt: function(location,value) { kha_SystemImpl.gl.uniform1i((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value); } ,setFloat: function(location,value) { kha_SystemImpl.gl.uniform1f((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value); } ,setFloat2: function(location,value1,value2) { kha_SystemImpl.gl.uniform2f((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value1,value2); } ,setFloat3: function(location,value1,value2,value3) { kha_SystemImpl.gl.uniform3f((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value1,value2,value3); } ,setFloat4: function(location,value1,value2,value3,value4) { kha_SystemImpl.gl.uniform4f((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value1,value2,value3,value4); } ,setFloats: function(location,values) { var webglLocation = js_Boot.__cast(location , kha_js_graphics4_ConstantLocation); var _g = webglLocation.type; switch(_g) { case 35664: kha_SystemImpl.gl.uniform2fv(webglLocation.value,values); break; case 35665: kha_SystemImpl.gl.uniform3fv(webglLocation.value,values); break; case 35666: kha_SystemImpl.gl.uniform4fv(webglLocation.value,values); break; default: kha_SystemImpl.gl.uniform1fv(webglLocation.value,values); } } ,setVector2: function(location,value) { kha_SystemImpl.gl.uniform2f((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value.x,value.y); } ,setVector3: function(location,value) { kha_SystemImpl.gl.uniform3f((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value.x,value.y,value.z); } ,setVector4: function(location,value) { kha_SystemImpl.gl.uniform4f((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,value.x,value.y,value.z,value.w); } ,matrixCache: null ,setMatrix: function(location,matrix) { this.matrixCache[0] = matrix._00; this.matrixCache[1] = matrix._01; this.matrixCache[2] = matrix._02; this.matrixCache[3] = matrix._03; this.matrixCache[4] = matrix._10; this.matrixCache[5] = matrix._11; this.matrixCache[6] = matrix._12; this.matrixCache[7] = matrix._13; this.matrixCache[8] = matrix._20; this.matrixCache[9] = matrix._21; this.matrixCache[10] = matrix._22; this.matrixCache[11] = matrix._23; this.matrixCache[12] = matrix._30; this.matrixCache[13] = matrix._31; this.matrixCache[14] = matrix._32; this.matrixCache[15] = matrix._33; kha_SystemImpl.gl.uniformMatrix4fv((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,false,this.matrixCache); } ,matrix3Cache: null ,setMatrix3: function(location,matrix) { this.matrix3Cache[0] = matrix._00; this.matrix3Cache[1] = matrix._01; this.matrix3Cache[2] = matrix._02; this.matrix3Cache[3] = matrix._10; this.matrix3Cache[4] = matrix._11; this.matrix3Cache[5] = matrix._12; this.matrix3Cache[6] = matrix._20; this.matrix3Cache[7] = matrix._21; this.matrix3Cache[8] = matrix._22; kha_SystemImpl.gl.uniformMatrix3fv((js_Boot.__cast(location , kha_js_graphics4_ConstantLocation)).value,false,this.matrix3Cache); } ,drawIndexedVertices: function(start,count) { if(count == null) { count = -1; } if(start == null) { start = 0; } var type = kha_SystemImpl.elementIndexUint == null ? 5123 : 5125; var size = type == 5123 ? 2 : 4; kha_SystemImpl.gl.drawElements(4,count == -1 ? this.indicesCount : count,type,start * size); } ,convertStencilAction: function(action) { switch(action[1]) { case 0: return 7680; case 1: return 0; case 2: return 7681; case 3: return 7682; case 4: return 34055; case 5: return 7683; case 6: return 34056; case 7: return 5386; } } ,setStencilParameters: function(compareMode,bothPass,depthFail,stencilFail,referenceValue,readMask,writeMask) { if(writeMask == null) { writeMask = 255; } if(readMask == null) { readMask = 255; } if(compareMode == kha_graphics4_CompareMode.Always && bothPass == kha_graphics4_StencilAction.Keep && depthFail == kha_graphics4_StencilAction.Keep && stencilFail == kha_graphics4_StencilAction.Keep) { kha_SystemImpl.gl.disable(2960); } else { kha_SystemImpl.gl.enable(2960); var stencilFunc = 0; switch(compareMode[1]) { case 0: stencilFunc = 519; break; case 1: stencilFunc = 512; break; case 2: stencilFunc = 514; break; case 3: stencilFunc = 517; break; case 4: stencilFunc = 513; break; case 5: stencilFunc = 515; break; case 6: stencilFunc = 516; break; case 7: stencilFunc = 518; break; } kha_SystemImpl.gl.stencilMask(writeMask); kha_SystemImpl.gl.stencilOp(this.convertStencilAction(stencilFail),this.convertStencilAction(depthFail),this.convertStencilAction(bothPass)); kha_SystemImpl.gl.stencilFunc(stencilFunc,referenceValue,readMask); } } ,scissor: function(x,y,width,height) { kha_SystemImpl.gl.enable(3089); if(this.renderTarget == null) { kha_SystemImpl.gl.scissor(x,kha_System.windowHeight(0) - y - height,width,height); } else { kha_SystemImpl.gl.scissor(x,y,width,height); } } ,disableScissor: function() { kha_SystemImpl.gl.disable(3089); } ,renderTargetsInvertedY: function() { return true; } ,drawIndexedVerticesInstanced: function(instanceCount,start,count) { if(count == null) { count = -1; } if(start == null) { start = 0; } if(this.instancedRenderingAvailable()) { var type = kha_SystemImpl.elementIndexUint == null ? 5123 : 5125; var typeSize = kha_SystemImpl.elementIndexUint == null ? 2 : 4; if(kha_SystemImpl.gl2) { kha_SystemImpl.gl.drawElementsInstanced(4,count == -1 ? this.indicesCount : count,type,start * typeSize,instanceCount); } else { this.instancedExtension.drawElementsInstancedANGLE(4,count == -1 ? this.indicesCount : count,type,start * typeSize,instanceCount); } } } ,instancedRenderingAvailable: function() { return this.instancedExtension; } ,__class__: kha_js_graphics4_Graphics }; var kha_js_graphics4_Graphics2 = function(canvas) { kha_graphics4_Graphics2.call(this,canvas); }; $hxClasses["kha.js.graphics4.Graphics2"] = kha_js_graphics4_Graphics2; kha_js_graphics4_Graphics2.__name__ = true; kha_js_graphics4_Graphics2.__super__ = kha_graphics4_Graphics2; kha_js_graphics4_Graphics2.prototype = $extend(kha_graphics4_Graphics2.prototype,{ drawVideoInternal: function(video,x,y,width,height) { var v = js_Boot.__cast(video , kha_js_Video); this.drawScaledSubImage(v.texture,0,0,v.texture.get_width(),v.texture.get_height(),x,y,width,height); } ,begin: function(clear,clearColor) { if(clear == null) { clear = true; } kha_SystemImpl.gl.colorMask(true,true,true,true); kha_SystemImpl.gl.disable(2929); kha_SystemImpl.gl.depthFunc(519); kha_graphics4_Graphics2.prototype.begin.call(this,clear,clearColor); } ,__class__: kha_js_graphics4_Graphics2 }); var kha_js_graphics4_TextureUnit = function(value) { this.value = value; }; $hxClasses["kha.js.graphics4.TextureUnit"] = kha_js_graphics4_TextureUnit; kha_js_graphics4_TextureUnit.__name__ = true; kha_js_graphics4_TextureUnit.__interfaces__ = [kha_graphics4_TextureUnit]; kha_js_graphics4_TextureUnit.prototype = { value: null ,__class__: kha_js_graphics4_TextureUnit }; var kha_vr_VrInterface = function() { }; $hxClasses["kha.vr.VrInterface"] = kha_vr_VrInterface; kha_vr_VrInterface.__name__ = true; kha_vr_VrInterface.prototype = { GetSensorState: function() { return null; } ,GetPredictedSensorState: function(time) { return null; } ,WarpSwapBlack: function() { return; } ,WarpSwapLoadingIcon: function() { return; } ,WarpSwap: function(parms) { return; } ,IsPresenting: function() { return false; } ,IsVrEnabled: function() { return false; } ,GetTimeInSeconds: function() { return 0.0; } ,GetProjectionMatrix: function(eye) { return null; } ,GetViewMatrix: function(eye) { return null; } ,onVRRequestPresent: function() { return; } ,onVRExitPresent: function() { return; } ,onResetPose: function() { return; } ,__class__: kha_vr_VrInterface }; var kha_js_vr_VrInterface = function() { this.vrHeight = 0; this.vrWidth = 0; this.height = 0; this.width = 0; this.rightViewMatrix = new kha_math_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); this.leftViewMatrix = new kha_math_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); this.rightProjectionMatrix = new kha_math_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); this.leftProjectionMatrix = new kha_math_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); this.vrEnabled = false; kha_vr_VrInterface.call(this); var displayEnabled = navigator.getVRDisplays; if(displayEnabled) { this.vrEnabled = true; this.getVRDisplays(); haxe_Log.trace("Display enabled.",{ fileName : "VrInterface.hx", lineNumber : 36, className : "kha.js.vr.VrInterface", methodName : "new"}); } }; $hxClasses["kha.js.vr.VrInterface"] = kha_js_vr_VrInterface; kha_js_vr_VrInterface.__name__ = true; kha_js_vr_VrInterface.__super__ = kha_vr_VrInterface; kha_js_vr_VrInterface.prototype = $extend(kha_vr_VrInterface.prototype,{ vrEnabled: null ,vrDisplay: null ,frameData: null ,leftProjectionMatrix: null ,rightProjectionMatrix: null ,leftViewMatrix: null ,rightViewMatrix: null ,width: null ,height: null ,vrWidth: null ,vrHeight: null ,getVRDisplays: function() { var _gthis = this; var vrDisplayInstance = navigator.getVRDisplays(); vrDisplayInstance.then(function(displays) { if(displays.length > 0) { _gthis.frameData = new VRFrameData(); _gthis.vrDisplay = displays[0]; _gthis.vrDisplay.depthNear = 0.1; _gthis.vrDisplay.depthFar = 1024.0; var leftEye = _gthis.vrDisplay.getEyeParameters("left"); var rightEye = _gthis.vrDisplay.getEyeParameters("right"); _gthis.width = kha_SystemImpl.khanvas.width; _gthis.height = kha_SystemImpl.khanvas.height; _gthis.vrWidth = Math.max(leftEye.renderWidth,rightEye.renderWidth) * 2 | 0; _gthis.vrHeight = Math.max(leftEye.renderHeight,rightEye.renderHeight) | 0; } else { haxe_Log.trace("There are no VR displays connected.",{ fileName : "VrInterface.hx", lineNumber : 56, className : "kha.js.vr.VrInterface", methodName : "getVRDisplays"}); } }); } ,onVRRequestPresent: function() { var _gthis = this; try { this.vrDisplay.requestPresent([{ source : kha_SystemImpl.khanvas}]).then(function() { _gthis.onResize(); _gthis.vrDisplay.requestAnimationFrame($bind(_gthis,_gthis.onAnimationFrame)); }); } catch( err ) { if (err instanceof js__$Boot_HaxeError) err = err.val; haxe_Log.trace("Failed to requestPresent.",{ fileName : "VrInterface.hx", lineNumber : 68, className : "kha.js.vr.VrInterface", methodName : "onVRRequestPresent"}); haxe_Log.trace(err,{ fileName : "VrInterface.hx", lineNumber : 69, className : "kha.js.vr.VrInterface", methodName : "onVRRequestPresent"}); } } ,onVRExitPresent: function() { var _gthis = this; try { this.vrDisplay.exitPresent([{ source : kha_SystemImpl.khanvas}]).then(function() { _gthis.onResize(); }); } catch( err ) { if (err instanceof js__$Boot_HaxeError) err = err.val; haxe_Log.trace("Failed to exitPresent.",{ fileName : "VrInterface.hx", lineNumber : 79, className : "kha.js.vr.VrInterface", methodName : "onVRExitPresent"}); haxe_Log.trace(err,{ fileName : "VrInterface.hx", lineNumber : 80, className : "kha.js.vr.VrInterface", methodName : "onVRExitPresent"}); } } ,onResetPose: function() { try { this.vrDisplay.resetPose(); } catch( err ) { if (err instanceof js__$Boot_HaxeError) err = err.val; haxe_Log.trace("Failed to resetPose",{ fileName : "VrInterface.hx", lineNumber : 88, className : "kha.js.vr.VrInterface", methodName : "onResetPose"}); haxe_Log.trace(err,{ fileName : "VrInterface.hx", lineNumber : 89, className : "kha.js.vr.VrInterface", methodName : "onResetPose"}); } } ,onAnimationFrame: function(timestamp) { if(this.vrDisplay != null && this.vrDisplay.isPresenting) { this.vrDisplay.requestAnimationFrame($bind(this,this.onAnimationFrame)); this.vrDisplay.getFrameData(this.frameData); this.leftProjectionMatrix = this.createMatrixFromArray(this.frameData.leftProjectionMatrix); this.leftViewMatrix = this.createMatrixFromArray(this.frameData.leftViewMatrix); this.rightProjectionMatrix = this.createMatrixFromArray(this.frameData.rightProjectionMatrix); this.rightViewMatrix = this.createMatrixFromArray(this.frameData.rightViewMatrix); this.vrDisplay.submitFrame(); } } ,onResize: function() { if(this.vrDisplay != null && this.vrDisplay.isPresenting) { kha_SystemImpl.khanvas.width = this.vrWidth; kha_SystemImpl.khanvas.height = this.vrHeight; } else { kha_SystemImpl.khanvas.width = this.width; kha_SystemImpl.khanvas.height = this.height; } } ,GetSensorState: function() { return this.GetPredictedSensorState(0.0); } ,GetPredictedSensorState: function(time) { var result = new kha_vr_SensorState(); result.Predicted = new kha_vr_PoseState(); result.Recorded = result.Predicted; result.Predicted.AngularAcceleration = new kha_math_Vector3(); result.Predicted.AngularVelocity = new kha_math_Vector3(); result.Predicted.LinearAcceleration = new kha_math_Vector3(); result.Predicted.LinearVelocity = new kha_math_Vector3(); result.Predicted.TimeInSeconds = time; result.Predicted.Pose = new kha_vr_Pose(); result.Predicted.Pose.Orientation = new kha_math_Quaternion(); result.Predicted.Pose.Position = new kha_math_Vector3(); var mPose = this.frameData.pose; if(mPose != null) { result.Predicted.AngularVelocity = this.createVectorFromArray(mPose.angularVelocity); result.Predicted.AngularAcceleration = this.createVectorFromArray(mPose.angularAcceleration); result.Predicted.LinearVelocity = this.createVectorFromArray(mPose.linearVelocity); result.Predicted.LinearAcceleration = this.createVectorFromArray(mPose.linearAcceleration); result.Predicted.Pose.Orientation = this.createQuaternion(mPose.orientation); result.Predicted.Pose.Position = this.createVectorFromArray(mPose.position); } return result; } ,WarpSwapBlack: function() { } ,WarpSwapLoadingIcon: function() { } ,WarpSwap: function(parms) { } ,IsPresenting: function() { if(this.vrDisplay != null) { return this.vrDisplay.isPresenting; } return false; } ,IsVrEnabled: function() { return this.vrEnabled; } ,GetTimeInSeconds: function() { return kha_Scheduler.time(); } ,GetProjectionMatrix: function(eye) { if(eye == 0) { return this.leftProjectionMatrix; } else { return this.rightProjectionMatrix; } } ,GetViewMatrix: function(eye) { if(eye == 0) { return this.leftViewMatrix; } else { return this.rightViewMatrix; } } ,createMatrixFromArray: function(array) { var matrix = new kha_math_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); matrix._00 = array[0]; matrix._01 = array[1]; matrix._02 = array[2]; matrix._03 = array[3]; matrix._10 = array[4]; matrix._11 = array[5]; matrix._12 = array[6]; matrix._13 = array[7]; matrix._20 = array[8]; matrix._21 = array[9]; matrix._22 = array[10]; matrix._23 = array[11]; matrix._30 = array[12]; matrix._31 = array[13]; matrix._32 = array[14]; matrix._33 = array[15]; return matrix; } ,createVectorFromArray: function(array) { var vector = new kha_math_Vector3(0,0,0); if(array != null) { vector.x = array[0]; vector.y = array[1]; vector.z = array[2]; } return vector; } ,createQuaternion: function(array) { var quaternion = new kha_math_Quaternion(0,0,0,0); if(array != null) { quaternion.set_x(array[0]); quaternion.set_y(array[1]); quaternion.set_z(array[2]); quaternion.set_w(array[3]); } return quaternion; } ,__class__: kha_js_vr_VrInterface }); var kha_math_FastMatrix3 = function(_00,_10,_20,_01,_11,_21,_02,_12,_22) { this._00 = _00; this._10 = _10; this._20 = _20; this._01 = _01; this._11 = _11; this._21 = _21; this._02 = _02; this._12 = _12; this._22 = _22; }; $hxClasses["kha.math.FastMatrix3"] = kha_math_FastMatrix3; kha_math_FastMatrix3.__name__ = true; kha_math_FastMatrix3.fromMatrix3 = function(m) { return new kha_math_FastMatrix3(m._00,m._10,m._20,m._01,m._11,m._21,m._02,m._12,m._22); }; kha_math_FastMatrix3.prototype = { _00: null ,_10: null ,_20: null ,_01: null ,_11: null ,_21: null ,_02: null ,_12: null ,_22: null ,__class__: kha_math_FastMatrix3 }; var kha_math_FastMatrix4 = function(_00,_10,_20,_30,_01,_11,_21,_31,_02,_12,_22,_32,_03,_13,_23,_33) { this._00 = _00; this._10 = _10; this._20 = _20; this._30 = _30; this._01 = _01; this._11 = _11; this._21 = _21; this._31 = _31; this._02 = _02; this._12 = _12; this._22 = _22; this._32 = _32; this._03 = _03; this._13 = _13; this._23 = _23; this._33 = _33; }; $hxClasses["kha.math.FastMatrix4"] = kha_math_FastMatrix4; kha_math_FastMatrix4.__name__ = true; kha_math_FastMatrix4.fromMatrix4 = function(m) { return new kha_math_FastMatrix4(m._00,m._10,m._20,m._30,m._01,m._11,m._21,m._31,m._02,m._12,m._22,m._32,m._03,m._13,m._23,m._33); }; kha_math_FastMatrix4.orthogonalProjection = function(left,right,bottom,top,zn,zf) { var tx = -(right + left) / (right - left); var ty = -(top + bottom) / (top - bottom); var tz = -(zf + zn) / (zf - zn); return new kha_math_FastMatrix4(2 / (right - left),0,0,tx,0,2 / (top - bottom),0,ty,0,0,-2 / (zf - zn),tz,0,0,0,1); }; kha_math_FastMatrix4.perspectiveProjection = function(fovY,aspect,zn,zf) { var uh = 1.0 / Math.tan(fovY / 2); var uw = uh / aspect; return new kha_math_FastMatrix4(uw,0,0,0,0,uh,0,0,0,0,(zf + zn) / (zn - zf),2 * zf * zn / (zn - zf),0,0,-1,0); }; kha_math_FastMatrix4.lookAt = function(eye,at,up) { var zaxis = new kha_math_FastVector3(at.x - eye.x,at.y - eye.y,at.z - eye.z); zaxis.set_length(1); var _x = zaxis.y * up.z - zaxis.z * up.y; var _y = zaxis.z * up.x - zaxis.x * up.z; var _z = zaxis.x * up.y - zaxis.y * up.x; var xaxis = new kha_math_FastVector3(_x,_y,_z); xaxis.set_length(1); var yaxis_z; var yaxis_y; var yaxis_x; var _x1 = xaxis.y * zaxis.z - xaxis.z * zaxis.y; var _y1 = xaxis.z * zaxis.x - xaxis.x * zaxis.z; var _z1 = xaxis.x * zaxis.y - xaxis.y * zaxis.x; yaxis_x = _x1; yaxis_y = _y1; yaxis_z = _z1; return new kha_math_FastMatrix4(xaxis.x,xaxis.y,xaxis.z,-(xaxis.x * eye.x + xaxis.y * eye.y + xaxis.z * eye.z),yaxis_x,yaxis_y,yaxis_z,-(yaxis_x * eye.x + yaxis_y * eye.y + yaxis_z * eye.z),-zaxis.x,-zaxis.y,-zaxis.z,zaxis.x * eye.x + zaxis.y * eye.y + zaxis.z * eye.z,0,0,0,1); }; kha_math_FastMatrix4.prototype = { _00: null ,_10: null ,_20: null ,_30: null ,_01: null ,_11: null ,_21: null ,_31: null ,_02: null ,_12: null ,_22: null ,_32: null ,_03: null ,_13: null ,_23: null ,_33: null ,__class__: kha_math_FastMatrix4 }; var kha_math_FastVector2 = function(x,y) { if(y == null) { y = 0; } if(x == null) { x = 0; } this.x = x; this.y = y; }; $hxClasses["kha.math.FastVector2"] = kha_math_FastVector2; kha_math_FastVector2.__name__ = true; kha_math_FastVector2.fromVector2 = function(v) { return new kha_math_FastVector2(v.x,v.y); }; kha_math_FastVector2.prototype = { x: null ,y: null ,get_length: function() { return Math.sqrt(this.x * this.x + this.y * this.y); } ,set_length: function(length) { var currentLength = this.get_length(); if(currentLength == 0) { return 0; } var mul = length / currentLength; this.x *= mul; this.y *= mul; return length; } ,toString: function() { return "FastVector2(" + this.x + ", " + this.y + ")"; } ,__class__: kha_math_FastVector2 }; var kha_math_FastVector3 = function(x,y,z) { if(z == null) { z = 0; } if(y == null) { y = 0; } if(x == null) { x = 0; } this.x = x; this.y = y; this.z = z; }; $hxClasses["kha.math.FastVector3"] = kha_math_FastVector3; kha_math_FastVector3.__name__ = true; kha_math_FastVector3.fromVector3 = function(v) { return new kha_math_FastVector3(v.x,v.y,v.z); }; kha_math_FastVector3.prototype = { x: null ,y: null ,z: null ,get_length: function() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } ,set_length: function(length) { var currentLength = this.get_length(); if(currentLength == 0) { return 0; } var mul = length / currentLength; this.x *= mul; this.y *= mul; this.z *= mul; return length; } ,toString: function() { return "FastVector3(" + this.x + ", " + this.y + ", " + this.z + ")"; } ,__class__: kha_math_FastVector3 }; var kha_math_FastVector4 = function(x,y,z,w) { if(w == null) { w = 1; } if(z == null) { z = 0; } if(y == null) { y = 0; } if(x == null) { x = 0; } this.x = x; this.y = y; this.z = z; this.w = w; }; $hxClasses["kha.math.FastVector4"] = kha_math_FastVector4; kha_math_FastVector4.__name__ = true; kha_math_FastVector4.fromVector4 = function(v) { return new kha_math_FastVector4(v.x,v.y,v.z,v.w); }; kha_math_FastVector4.prototype = { x: null ,y: null ,z: null ,w: null ,get_length: function() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } ,set_length: function(length) { var currentLength = this.get_length(); if(currentLength == 0) { return 0; } var mul = length / currentLength; this.x *= mul; this.y *= mul; this.z *= mul; this.w *= mul; return length; } ,toString: function() { return "FastVector4(" + this.x + ", " + this.y + ", " + this.z + ", " + this.w + ")"; } ,__class__: kha_math_FastVector4 }; var kha_math_Matrix3 = function(_00,_10,_20,_01,_11,_21,_02,_12,_22) { this._00 = _00; this._10 = _10; this._20 = _20; this._01 = _01; this._11 = _11; this._21 = _21; this._02 = _02; this._12 = _12; this._22 = _22; }; $hxClasses["kha.math.Matrix3"] = kha_math_Matrix3; kha_math_Matrix3.__name__ = true; kha_math_Matrix3.prototype = { _00: null ,_10: null ,_20: null ,_01: null ,_11: null ,_21: null ,_02: null ,_12: null ,_22: null ,__class__: kha_math_Matrix3 }; var kha_math_Matrix4 = function(_00,_10,_20,_30,_01,_11,_21,_31,_02,_12,_22,_32,_03,_13,_23,_33) { this._00 = _00; this._10 = _10; this._20 = _20; this._30 = _30; this._01 = _01; this._11 = _11; this._21 = _21; this._31 = _31; this._02 = _02; this._12 = _12; this._22 = _22; this._32 = _32; this._03 = _03; this._13 = _13; this._23 = _23; this._33 = _33; }; $hxClasses["kha.math.Matrix4"] = kha_math_Matrix4; kha_math_Matrix4.__name__ = true; kha_math_Matrix4.orthogonalProjection = function(left,right,bottom,top,zn,zf) { var tx = -(right + left) / (right - left); var ty = -(top + bottom) / (top - bottom); var tz = -(zf + zn) / (zf - zn); return new kha_math_Matrix4(2 / (right - left),0,0,tx,0,2 / (top - bottom),0,ty,0,0,-2 / (zf - zn),tz,0,0,0,1); }; kha_math_Matrix4.perspectiveProjection = function(fovY,aspect,zn,zf) { var uh = 1.0 / Math.tan(fovY / 2); var uw = uh / aspect; return new kha_math_Matrix4(uw,0,0,0,0,uh,0,0,0,0,(zf + zn) / (zn - zf),2 * zf * zn / (zn - zf),0,0,-1,0); }; kha_math_Matrix4.lookAt = function(eye,at,up) { var zaxis = new kha_math_Vector3(at.x - eye.x,at.y - eye.y,at.z - eye.z); zaxis.set_length(1); var _x = zaxis.y * up.z - zaxis.z * up.y; var _y = zaxis.z * up.x - zaxis.x * up.z; var _z = zaxis.x * up.y - zaxis.y * up.x; var xaxis = new kha_math_Vector3(_x,_y,_z); xaxis.set_length(1); var yaxis_z; var yaxis_y; var yaxis_x; var _x1 = xaxis.y * zaxis.z - xaxis.z * zaxis.y; var _y1 = xaxis.z * zaxis.x - xaxis.x * zaxis.z; var _z1 = xaxis.x * zaxis.y - xaxis.y * zaxis.x; yaxis_x = _x1; yaxis_y = _y1; yaxis_z = _z1; return new kha_math_Matrix4(xaxis.x,xaxis.y,xaxis.z,-(xaxis.x * eye.x + xaxis.y * eye.y + xaxis.z * eye.z),yaxis_x,yaxis_y,yaxis_z,-(yaxis_x * eye.x + yaxis_y * eye.y + yaxis_z * eye.z),-zaxis.x,-zaxis.y,-zaxis.z,zaxis.x * eye.x + zaxis.y * eye.y + zaxis.z * eye.z,0,0,0,1); }; kha_math_Matrix4.prototype = { _00: null ,_10: null ,_20: null ,_30: null ,_01: null ,_11: null ,_21: null ,_31: null ,_02: null ,_12: null ,_22: null ,_32: null ,_03: null ,_13: null ,_23: null ,_33: null ,__class__: kha_math_Matrix4 }; var kha_math_Quaternion = function(x,y,z,w) { if(w == null) { w = 1; } if(z == null) { z = 0; } if(y == null) { y = 0; } if(x == null) { x = 0; } this.values = []; this.values.push(x); this.values.push(y); this.values.push(z); this.values.push(w); }; $hxClasses["kha.math.Quaternion"] = kha_math_Quaternion; kha_math_Quaternion.__name__ = true; kha_math_Quaternion.fromAxisAngle = function(axis,radians) { var q = new kha_math_Quaternion(); q.set_w(Math.cos(radians / 2.0)); q.set_x(q.set_y(q.set_z(Math.sin(radians / 2.0)))); var _g = q; _g.set_x(_g.get_x() * axis.x); var _g1 = q; _g1.set_y(_g1.get_y() * axis.y); var _g2 = q; _g2.set_z(_g2.get_z() * axis.z); return q; }; kha_math_Quaternion.prototype = { values: null ,slerp: function(t,q) { var epsilon = 0.0005; var dot = this.dot(q); if(dot > 1 - epsilon) { var result = q.add(this.sub(q).scaled(t)); result.normalize(); return result; } if(dot < 0) { dot = 0; } if(dot > 1) { dot = 1; } var theta0 = Math.acos(dot); var theta = theta0 * t; var q2 = q.sub(this.scaled(dot)); q2.normalize(); var result1 = this.scaled(Math.cos(theta)).add(q2.scaled(Math.sin(theta))); result1.normalize(); return result1; } ,rotated: function(b) { var q = new kha_math_Quaternion(); q.set_w(this.get_w() * b.get_w() - this.get_x() * b.get_x() - this.get_y() * b.get_y() - this.get_z() * b.get_z()); q.set_x(this.get_w() * b.get_x() + this.get_x() * b.get_w() + this.get_y() * b.get_z() - this.get_z() * b.get_y()); q.set_y(this.get_w() * b.get_y() + this.get_y() * b.get_w() + this.get_z() * b.get_x() - this.get_x() * b.get_z()); q.set_z(this.get_w() * b.get_z() + this.get_z() * b.get_w() + this.get_x() * b.get_y() - this.get_y() * b.get_x()); q.normalize(); return q; } ,scaled: function(scale) { return new kha_math_Quaternion(this.get_x() * scale,this.get_y() * scale,this.get_z() * scale,this.get_w() * scale); } ,scale: function(scale) { this.set_x(this.get_x() * scale); this.set_y(this.get_y() * scale); this.set_z(this.get_z() * scale); this.set_w(this.get_w() * scale); } ,matrix: function() { var s = 2.0; var xs = this.get_x() * s; var ys = this.get_y() * s; var zs = this.get_z() * s; var wx = this.get_w() * xs; var wy = this.get_w() * ys; var wz = this.get_w() * zs; var xx = this.get_x() * xs; var xy = this.get_x() * ys; var xz = this.get_x() * zs; var yy = this.get_y() * ys; var yz = this.get_y() * zs; var zz = this.get_z() * zs; return new kha_math_Matrix4(1 - (yy + zz),xy - wz,xz + wy,0,xy + wz,1 - (xx + zz),yz - wx,0,xz - wy,yz + wx,1 - (xx + yy),0,0,0,0,1); } ,get: function(index) { return this.values[index]; } ,set: function(index,value) { this.values[index] = value; } ,get_x: function() { return this.values[0]; } ,set_x: function(value) { return this.values[0] = value; } ,get_y: function() { return this.values[1]; } ,set_y: function(value) { return this.values[1] = value; } ,get_z: function() { return this.values[2]; } ,set_z: function(value) { return this.values[2] = value; } ,get_w: function() { return this.values[3]; } ,set_w: function(value) { return this.values[3] = value; } ,get_length: function() { return Math.sqrt(this.get_x() * this.get_x() + this.get_y() * this.get_y() + this.get_z() * this.get_z() + this.get_w() * this.get_w()); } ,set_length: function(length) { if(this.get_length() == 0) { return 0; } var mul = length / this.get_length(); var _g = this; _g.set_x(_g.get_x() * mul); var _g1 = this; _g1.set_y(_g1.get_y() * mul); var _g2 = this; _g2.set_z(_g2.get_z() * mul); return length; } ,addVector: function(vec) { var result = new kha_math_Quaternion(this.get_x(),this.get_y(),this.get_z(),this.get_w()); var q1 = new kha_math_Quaternion(0,vec.x,vec.y,vec.z); q1 = q1.mult(result); var _g = result; _g.set_x(_g.get_x() + q1.get_x() * 0.5); var _g1 = result; _g1.set_y(_g1.get_y() + q1.get_y() * 0.5); var _g2 = result; _g2.set_z(_g2.get_z() + q1.get_z() * 0.5); var _g3 = result; _g3.set_w(_g3.get_w() + q1.get_w() * 0.5); return result; } ,add: function(q) { return new kha_math_Quaternion(this.get_x() + q.get_x(),this.get_y() + q.get_y(),this.get_z() + q.get_z(),this.get_w() + q.get_w()); } ,sub: function(q) { return new kha_math_Quaternion(this.get_x() - q.get_x(),this.get_y() - q.get_y(),this.get_z() - q.get_z(),this.get_w() - q.get_w()); } ,mult: function(r) { var q = new kha_math_Quaternion(); q.set_x(this.get_w() * r.get_x() + this.get_x() * r.get_w() + this.get_y() * r.get_z() - this.get_z() * r.get_y()); q.set_y(this.get_w() * r.get_y() - this.get_x() * r.get_z() + this.get_y() * r.get_w() + this.get_z() * r.get_x()); q.set_z(this.get_w() * r.get_z() + this.get_x() * r.get_y() - this.get_y() * r.get_x() + this.get_z() * r.get_w()); q.set_w(this.get_w() * r.get_w() - this.get_x() * r.get_x() - this.get_y() * r.get_y() - this.get_z() * r.get_z()); return q; } ,normalize: function() { this.scale(1.0 / this.get_length()); } ,dot: function(q) { return this.get_x() * q.get_x() + this.get_y() * q.get_y() + this.get_z() * q.get_z() + this.get_w() * q.get_w(); } ,getEulerAngles: function(A1,A2,A3,S,D) { if(D == null) { D = 1; } if(S == null) { S = 1; } var result = new kha_math_Vector3(); var Q = []; Q[0] = this.get_x(); Q[1] = this.get_y(); Q[2] = this.get_z(); var ww = this.get_w() * this.get_w(); var Q11 = Q[A1] * Q[A1]; var Q22 = Q[A2] * Q[A2]; var Q33 = Q[A3] * Q[A3]; var psign = -1; var SingularityRadius = 0.0000001; var PiOver2 = Math.PI / 2.0; if((A1 + 1) % 3 == A2 && (A2 + 1) % 3 == A3) { psign = 1; } var s2 = psign * 2.0 * (psign * this.get_w() * Q[A2] + Q[A1] * Q[A3]); if(s2 < -1 + SingularityRadius) { result.x = 0; result.y = -S * D * PiOver2; result.z = S * D * Math.atan2(2 * (psign * Q[A1] * Q[A2] + this.get_w() * Q[A3]),ww + Q22 - Q11 - Q33); } else if(s2 > 1 - SingularityRadius) { result.x = 0; result.y = S * D * PiOver2; result.z = S * D * Math.atan2(2 * (psign * Q[A1] * Q[A2] + this.get_w() * Q[A3]),ww + Q22 - Q11 - Q33); } else { result.x = -S * D * Math.atan2(-2 * (this.get_w() * Q[A1] - psign * Q[A2] * Q[A3]),ww + Q33 - Q11 - Q22); result.y = S * D * Math.asin(s2); result.z = S * D * Math.atan2(2 * (this.get_w() * Q[A3] - psign * Q[A1] * Q[A2]),ww + Q11 - Q22 - Q33); } return result; } ,__class__: kha_math_Quaternion }; var kha_math_Vector2 = function(x,y) { if(y == null) { y = 0; } if(x == null) { x = 0; } this.x = x; this.y = y; }; $hxClasses["kha.math.Vector2"] = kha_math_Vector2; kha_math_Vector2.__name__ = true; kha_math_Vector2.prototype = { x: null ,y: null ,get_length: function() { return Math.sqrt(this.x * this.x + this.y * this.y); } ,set_length: function(length) { var currentLength = this.get_length(); if(currentLength == 0) { return 0; } var mul = length / currentLength; this.x *= mul; this.y *= mul; return length; } ,__class__: kha_math_Vector2 }; var kha_math_Vector3 = function(x,y,z) { if(z == null) { z = 0; } if(y == null) { y = 0; } if(x == null) { x = 0; } this.x = x; this.y = y; this.z = z; }; $hxClasses["kha.math.Vector3"] = kha_math_Vector3; kha_math_Vector3.__name__ = true; kha_math_Vector3.prototype = { x: null ,y: null ,z: null ,get_length: function() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } ,set_length: function(length) { var currentLength = this.get_length(); if(currentLength == 0) { return 0; } var mul = length / currentLength; this.x *= mul; this.y *= mul; this.z *= mul; return length; } ,__class__: kha_math_Vector3 }; var kha_math_Vector4 = function(x,y,z,w) { if(w == null) { w = 1; } if(z == null) { z = 0; } if(y == null) { y = 0; } if(x == null) { x = 0; } this.x = x; this.y = y; this.z = z; this.w = w; }; $hxClasses["kha.math.Vector4"] = kha_math_Vector4; kha_math_Vector4.__name__ = true; kha_math_Vector4.prototype = { x: null ,y: null ,z: null ,w: null ,get_length: function() { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); } ,set_length: function(length) { var currentLength = this.get_length(); if(currentLength == 0) { return 0; } var mul = length / currentLength; this.x *= mul; this.y *= mul; this.z *= mul; this.w *= mul; return length; } ,__class__: kha_math_Vector4 }; var kha_network_Client = function() { }; $hxClasses["kha.network.Client"] = kha_network_Client; kha_network_Client.__name__ = true; kha_network_Client.prototype = { get_id: null ,id: null ,send: null ,receive: null ,onClose: null ,__class__: kha_network_Client }; var kha_network_ControllerBuilder = function() { }; $hxClasses["kha.network.ControllerBuilder"] = kha_network_ControllerBuilder; kha_network_ControllerBuilder.__name__ = true; var kha_network_Entity = function() { }; $hxClasses["kha.network.Entity"] = kha_network_Entity; kha_network_Entity.__name__ = true; kha_network_Entity.prototype = { _id: null ,_size: null ,_send: null ,_receive: null ,__class__: kha_network_Entity }; var kha_network_LocalClient = function(id) { this.myId = id; }; $hxClasses["kha.network.LocalClient"] = kha_network_LocalClient; kha_network_LocalClient.__name__ = true; kha_network_LocalClient.__interfaces__ = [kha_network_Client]; kha_network_LocalClient.prototype = { myId: null ,send: function(bytes,mandatory) { } ,receive: function(receiver) { } ,onClose: function(close) { } ,controllers: null ,get_controllers: function() { return null; } ,id: null ,get_id: function() { return this.myId; } ,__class__: kha_network_LocalClient }; var kha_network_Network = function(url,port,errorCallback,closeCallback) { this.open = false; var _gthis = this; this.socket = new WebSocket("ws://" + url + ":" + port); this.socket.onerror = function(error) { haxe_Log.trace("Network error: " + error,{ fileName : "Network.hx", lineNumber : 14, className : "kha.network.Network", methodName : "new"}); errorCallback(); }; this.socket.binaryType = "arraybuffer"; this.socket.onopen = function() { _gthis.open = true; }; this.socket.onclose = function(event) { haxe_Log.trace("Network connection closed",{ fileName : "Network.hx", lineNumber : 22, className : "kha.network.Network", methodName : "new"}); closeCallback(); }; }; $hxClasses["kha.network.Network"] = kha_network_Network; kha_network_Network.__name__ = true; kha_network_Network.prototype = { socket: null ,open: null ,send: function(bytes,mandatory) { if(this.open) { this.socket.send(bytes.b.bufferValue); } } ,listen: function(listener) { this.socket.onmessage = function(message) { var tmp = haxe_io_Bytes.ofData(message.data); listener(tmp); }; } ,__class__: kha_network_Network }; var kha_network_State = function(time,data) { this.time = time; this.data = data; }; $hxClasses["kha.network.State"] = kha_network_State; kha_network_State.__name__ = true; kha_network_State.prototype = { time: null ,data: null ,__class__: kha_network_State }; var kha_network_Session = function(maxPlayers,address,port) { this.ping = 1; this.currentPlayers = 0; this.controllers = new haxe_ds_IntMap(); this.entities = new haxe_ds_IntMap(); kha_network_Session.instance = this; this.maxPlayers = maxPlayers; this.address = address; this.port = port; }; $hxClasses["kha.network.Session"] = kha_network_Session; kha_network_Session.__name__ = true; kha_network_Session.the = function() { return kha_network_Session.instance; }; kha_network_Session.prototype = { entities: null ,controllers: null ,maxPlayers: null ,currentPlayers: null ,ping: null ,address: null ,port: null ,startCallback: null ,refusedCallback: null ,resetCallback: null ,localClient: null ,network: null ,updateTaskId: null ,pingTaskId: null ,me: null ,get_me: function() { return this.localClient; } ,addEntity: function(entity) { var this1 = this.entities; var key = entity._id(); this1.h[key] = entity; } ,addController: function(controller) { haxe_Log.trace("Adding controller id " + controller._id(),{ fileName : "Session.hx", lineNumber : 88, className : "kha.network.Session", methodName : "addController"}); controller._inputBufferIndex = 0; var this1 = this.controllers; var key = controller._id(); this1.h[key] = controller; } ,sendControllerUpdate: function(id,bytes) { if(this.controllers.h.hasOwnProperty(id)) { if(this.controllers.h[id]._inputBuffer.length < this.controllers.h[id]._inputBufferIndex + 4 + bytes.length) { var newBuffer = new haxe_io_Bytes(new ArrayBuffer(this.controllers.h[id]._inputBufferIndex + 4 + bytes.length)); newBuffer.blit(0,this.controllers.h[id]._inputBuffer,0,this.controllers.h[id]._inputBufferIndex); this.controllers.h[id]._inputBuffer = newBuffer; } this.controllers.h[id]._inputBuffer.setInt32(this.controllers.h[id]._inputBufferIndex,bytes.length); this.controllers.h[id]._inputBuffer.blit(this.controllers.h[id]._inputBufferIndex + 4,bytes,0,bytes.length); this.controllers.h[id]._inputBufferIndex += 4 + bytes.length; } } ,sendPing: function() { var bytes = new haxe_io_Bytes(new ArrayBuffer(5)); bytes.b[0] = 4; bytes.setFloat(1,kha_Scheduler.realTime()); this.sendToServer(bytes); } ,sendPlayerUpdate: function() { } ,receive: function(bytes,client) { var _g = bytes.b[0]; switch(_g) { case 0: var index = bytes.b[1]; this.localClient = new kha_network_LocalClient(index); kha_Scheduler.resetTime(); this.startCallback(); break; case 1: var time = bytes.getDouble(1); var offset = 9; var entity = this.entities.iterator(); while(entity.hasNext()) { var entity1 = entity.next(); entity1._receive(offset,bytes); offset += entity1._size(); } kha_Scheduler.back(time); break; case 3: var _g1 = bytes.b[1]; switch(_g1) { case 0: break; case 1: this.executeRPC(bytes); break; } break; case 4: var sendTime = bytes.getFloat(1); this.ping = kha_Scheduler.realTime() - sendTime; break; case 5: this.refusedCallback(); break; case 6: this.currentPlayers = bytes.getInt32(1); break; } } ,executeRPC: function(bytes) { var args = []; var syncId = bytes.getInt32(2); var index = 6; var classnamelength = bytes.getUInt16(index); index += 2; var classname = ""; var _g1 = 0; var _g = classnamelength; while(_g1 < _g) { var i = _g1++; classname += String.fromCharCode(bytes.b[index]); ++index; } var methodnamelength = bytes.getUInt16(index); index += 2; var methodname = ""; var _g11 = 0; var _g2 = methodnamelength; while(_g11 < _g2) { var i1 = _g11++; methodname += String.fromCharCode(bytes.b[index]); ++index; } while(index < bytes.length) { var type = bytes.b[index]; ++index; switch(type) { case 66: var value = bytes.b[index] == 1; ++index; haxe_Log.trace("Bool: " + (value == null ? "null" : "" + value),{ fileName : "Session.hx", lineNumber : 288, className : "kha.network.Session", methodName : "executeRPC"}); args.push(value); break; case 70: var value1 = bytes.getDouble(index); index += 8; haxe_Log.trace("Float: " + value1,{ fileName : "Session.hx", lineNumber : 293, className : "kha.network.Session", methodName : "executeRPC"}); args.push(value1); break; case 73: var value2 = bytes.getInt32(index); index += 4; haxe_Log.trace("Int: " + value2,{ fileName : "Session.hx", lineNumber : 298, className : "kha.network.Session", methodName : "executeRPC"}); args.push(value2); break; case 83: var length = bytes.getUInt16(index); index += 2; var str = ""; var _g12 = 0; var _g3 = length; while(_g12 < _g3) { var i2 = _g12++; str += String.fromCharCode(bytes.b[index]); ++index; } haxe_Log.trace("String: " + str,{ fileName : "Session.hx", lineNumber : 308, className : "kha.network.Session", methodName : "executeRPC"}); args.push(str); break; default: haxe_Log.trace("Unknown argument type.",{ fileName : "Session.hx", lineNumber : 311, className : "kha.network.Session", methodName : "executeRPC"}); } } if(syncId == -1) { Reflect.field(Type.resolveClass(classname),methodname + "_remotely").apply(null,args); } else { var o = kha_network_SyncBuilder.objects[syncId]; Reflect.field(kha_network_SyncBuilder.objects[syncId],methodname + "_remotely").apply(o,args); } } ,waitForStart: function(callback,refuseCallback,errorCallback,closeCallback,resCallback) { var _gthis = this; this.startCallback = callback; this.refusedCallback = refuseCallback; this.resetCallback = resCallback; this.network = new kha_network_Network(this.address,this.port,errorCallback,function() { closeCallback(); _gthis.reset(); }); this.network.listen(function(bytes) { _gthis.receive(bytes); }); this.updateTaskId = kha_Scheduler.addFrameTask($bind(this,this.update),0); this.ping = 1; this.pingTaskId = kha_Scheduler.addTimeTask($bind(this,this.sendPing),0,1); } ,reset: function() { kha_Scheduler.removeFrameTask(this.updateTaskId); kha_Scheduler.removeTimeTask(this.pingTaskId); this.currentPlayers = 0; this.ping = 1; this.controllers = new haxe_ds_IntMap(); this.entities = new haxe_ds_IntMap(); this.resetCallback(); } ,update: function() { var controller = this.controllers.iterator(); while(controller.hasNext()) { var controller1 = controller.next(); if(controller1._inputBufferIndex > 0) { var bytes = new haxe_io_Bytes(new ArrayBuffer(22 + controller1._inputBufferIndex)); bytes.b[0] = 2; bytes.setInt32(1,controller1._id()); bytes.setDouble(5,kha_Scheduler.realTime()); bytes.setInt32(13,kha_System.windowWidth(0)); bytes.setInt32(17,kha_System.windowHeight(0)); var v = kha_System.get_screenRotation()[1]; bytes.b[21] = v & 255; bytes.blit(22,controller1._inputBuffer,0,controller1._inputBufferIndex); this.sendToServer(bytes); controller1._inputBufferIndex = 0; } } } ,sendToServer: function(bytes) { this.network.send(bytes,false); } ,__class__: kha_network_Session }; var kha_network_SyncBuilder = function() { }; $hxClasses["kha.network.SyncBuilder"] = kha_network_SyncBuilder; kha_network_SyncBuilder.__name__ = true; var kha_simd_Float32x4 = function(_0,_1,_2,_3) { this._0 = _0; this._1 = _1; this._2 = _2; this._3 = _3; }; $hxClasses["kha.simd.Float32x4"] = kha_simd_Float32x4; kha_simd_Float32x4.__name__ = true; kha_simd_Float32x4.create = function() { return new kha_simd_Float32x4(0,0,0,0); }; kha_simd_Float32x4.loadAllFast = function(t) { return new kha_simd_Float32x4(t,t,t,t); }; kha_simd_Float32x4.load = function(a,b,c,d) { return new kha_simd_Float32x4(a,b,c,d); }; kha_simd_Float32x4.loadFast = function(a,b,c,d) { return new kha_simd_Float32x4(a,b,c,d); }; kha_simd_Float32x4.get = function(t,index) { var value = 0; switch(index) { case 0: value = t._0; break; case 1: value = t._1; break; case 2: value = t._2; break; case 3: value = t._3; break; } return value; }; kha_simd_Float32x4.getFast = function(t,index) { switch(index) { case 0: return t._0; case 1: return t._1; case 2: return t._2; case 3: return t._3; } return 0; }; kha_simd_Float32x4.abs = function(t) { return new kha_simd_Float32x4(Math.abs(t._0),Math.abs(t._1),Math.abs(t._2),Math.abs(t._3)); }; kha_simd_Float32x4.add = function(a,b) { return new kha_simd_Float32x4(a._0 + b._0,a._1 + b._1,a._2 + b._2,a._3 + b._3); }; kha_simd_Float32x4.div = function(a,b) { return new kha_simd_Float32x4(a._0 / b._0,a._1 / b._1,a._2 / b._2,a._3 / b._3); }; kha_simd_Float32x4.mul = function(a,b) { return new kha_simd_Float32x4(a._0 * b._0,a._1 * b._1,a._2 * b._2,a._3 * b._3); }; kha_simd_Float32x4.neg = function(t) { return new kha_simd_Float32x4(-t._0,-t._1,-t._2,-t._3); }; kha_simd_Float32x4.reciprocalApproximation = function(t) { return new kha_simd_Float32x4(0,0,0,0); }; kha_simd_Float32x4.reciprocalSqrtApproximation = function(t) { return new kha_simd_Float32x4(0,0,0,0); }; kha_simd_Float32x4.sub = function(a,b) { return new kha_simd_Float32x4(a._0 - b._0,a._1 - b._1,a._2 - b._2,a._3 - b._3); }; kha_simd_Float32x4.sqrt = function(t) { return new kha_simd_Float32x4(Math.sqrt(t._0),Math.sqrt(t._1),Math.sqrt(t._2),Math.sqrt(t._3)); }; kha_simd_Float32x4.prototype = { _0: null ,_1: null ,_2: null ,_3: null ,__class__: kha_simd_Float32x4 }; var kha_vr_Pose = function() { this.Orientation = new kha_math_Quaternion(); this.Position = new kha_math_Vector3(); }; $hxClasses["kha.vr.Pose"] = kha_vr_Pose; kha_vr_Pose.__name__ = true; kha_vr_Pose.prototype = { Orientation: null ,Position: null ,__class__: kha_vr_Pose }; var kha_vr_PoseState = function() { }; $hxClasses["kha.vr.PoseState"] = kha_vr_PoseState; kha_vr_PoseState.__name__ = true; kha_vr_PoseState.prototype = { Pose: null ,AngularVelocity: null ,LinearVelocity: null ,AngularAcceleration: null ,LinearAcceleration: null ,TimeInSeconds: null ,__class__: kha_vr_PoseState }; var kha_vr_SensorState = function() { }; $hxClasses["kha.vr.SensorState"] = kha_vr_SensorState; kha_vr_SensorState.__name__ = true; kha_vr_SensorState.prototype = { Predicted: null ,Recorded: null ,Temperature: null ,Status: null ,__class__: kha_vr_SensorState }; var kha_vr_TimeWarpImage = function() { }; $hxClasses["kha.vr.TimeWarpImage"] = kha_vr_TimeWarpImage; kha_vr_TimeWarpImage.__name__ = true; kha_vr_TimeWarpImage.prototype = { Image: null ,TexCoordsFromTanAngles: null ,Pose: null ,__class__: kha_vr_TimeWarpImage }; var kha_vr_TimeWarpParms = function() { }; $hxClasses["kha.vr.TimeWarpParms"] = kha_vr_TimeWarpParms; kha_vr_TimeWarpParms.__name__ = true; kha_vr_TimeWarpParms.prototype = { LeftImage: null ,RightImage: null ,LeftOverlay: null ,RightOverlay: null ,__class__: kha_vr_TimeWarpParms }; var zui_Canvas = function() { }; $hxClasses["zui.Canvas"] = zui_Canvas; zui_Canvas.__name__ = true; zui_Canvas.draw = function(ui,canvas,g) { ui.begin(g); ui.g = g; var _g = 0; var _g1 = canvas.elements; while(_g < _g1.length) { var elem = _g1[_g]; ++_g; zui_Canvas.drawElement(ui,canvas,elem); } ui.end(); }; zui_Canvas.getAsset = function(canvas,asset) { var _g = 0; var _g1 = canvas.assets; while(_g < _g1.length) { var a = _g1[_g]; ++_g; if(a.name == asset) { return a.image; } } return null; }; zui_Canvas.drawElement = function(ui,canvas,element) { ui._x = canvas.x + element.x; ui._y = canvas.y + element.y; ui._w = element.width; var _g = element.type; switch(_g) { case 0: var size = ui.fontSmallSize; ui.fontSmallSize = element.height; ui.text(element.text); ui.fontSmallSize = size; break; case 1: if(element.image == null) { element.image = zui_Canvas.getAsset(canvas,element.asset); } if(element.image != null) { ui.image(element.image); } break; case 2: ui.button(element.text); break; } if(element.children != null) { var _g1 = 0; var _g2 = element.children; while(_g1 < _g2.length) { var c = _g2[_g1]; ++_g1; zui_Canvas.drawElement(ui,canvas,c); } } }; var zui_Id = function() { }; $hxClasses["zui.Id"] = zui_Id; zui_Id.__name__ = true; var zui_Themes = function() { }; $hxClasses["zui.Themes"] = zui_Themes; zui_Themes.__name__ = true; var zui_Zui = function(ops) { this.textToSubmit = ""; this.submitTextHandle = null; this.textSelectedHandle = null; this.scrollEnabled = true; this.scrollingHandle = null; this.windowEnded = true; this.curRatio = -1; this.cursorY = 0; this.cursorX = 0; this.isKeyDown = false; this.isTyping = false; this.isScrolling = false; if(ops.theme == null) { ops.theme = zui_Themes.dark; } this.t = ops.theme; if(ops.khaWindowId == null) { ops.khaWindowId = 0; } if(ops.scaleFactor == null) { ops.scaleFactor = 1.0; } if(ops.scaleTexture == null) { ops.scaleTexture = 1.0; } if(ops.autoNotifyInput == null) { ops.autoNotifyInput = true; } this.ops = ops; this.setScaleFactor(ops.scaleFactor); if(ops.autoNotifyInput) { kha_input_Mouse.get().notifyWindowed(ops.khaWindowId,$bind(this,this.onMouseDown),$bind(this,this.onMouseUp),$bind(this,this.onMouseMove),$bind(this,this.onMouseWheel)); kha_input_Keyboard.get().notify($bind(this,this.onKeyDown),$bind(this,this.onKeyUp)); } }; $hxClasses["zui.Zui"] = zui_Zui; zui_Zui.__name__ = true; zui_Zui.prototype = { t: null ,SCALE: null ,isScrolling: null ,isTyping: null ,inputX: null ,inputY: null ,inputInitialX: null ,inputInitialY: null ,inputDX: null ,inputDY: null ,inputWheelDelta: null ,inputStarted: null ,inputReleased: null ,inputDown: null ,inputDownR: null ,isKeyDown: null ,key: null ,'char': null ,cursorX: null ,cursorY: null ,ratios: null ,curRatio: null ,xBeforeSplit: null ,wBeforeSplit: null ,globalG: null ,g: null ,ops: null ,fontSize: null ,fontSmallSize: null ,fontOffsetY: null ,fontSmallOffsetY: null ,arrowOffsetX: null ,arrowOffsetY: null ,titleOffsetX: null ,buttonOffsetY: null ,checkOffsetX: null ,checkOffsetY: null ,checkSelectOffsetX: null ,checkSelectOffsetY: null ,radioOffsetX: null ,radioOffsetY: null ,radioSelectOffsetX: null ,radioSelectOffsetY: null ,scrollAlign: null ,_x: null ,_y: null ,_w: null ,_h: null ,_windowX: null ,_windowY: null ,_windowW: null ,_windowH: null ,currentWindow: null ,windowEnded: null ,scrollingHandle: null ,scrollEnabled: null ,textSelectedHandle: null ,textSelectedCurrentText: null ,submitTextHandle: null ,textToSubmit: null ,setScaleFactor: function(scaleFactor) { this.SCALE = this.ops.scaleFactor = scaleFactor * this.ops.scaleTexture; this.fontSize = this.t._FONT_SIZE * this.ops.scaleFactor | 0; this.fontSmallSize = this.t._FONT_SMALL_SIZE * this.ops.scaleFactor | 0; var fontHeight = this.ops.font.height(this.fontSize); var fontSmallHeight = this.ops.font.height(this.fontSmallSize); this.fontOffsetY = (this.t._ELEMENT_H * this.SCALE - fontHeight) / 2; this.fontSmallOffsetY = (this.t._ELEMENT_H * this.SCALE - fontSmallHeight) / 2; this.arrowOffsetY = (this.t._ELEMENT_H * this.SCALE - this.t._ARROW_H * this.SCALE) / 2; this.arrowOffsetX = this.arrowOffsetY; this.titleOffsetX = (this.arrowOffsetX * 2 + this.t._ARROW_W * this.SCALE) / this.SCALE; this.buttonOffsetY = (this.t._ELEMENT_H * this.SCALE - this.t._BUTTON_H * this.SCALE) / 2; this.checkOffsetY = (this.t._ELEMENT_H * this.SCALE - this.t._CHECK_H * this.SCALE) / 2; this.checkOffsetX = this.checkOffsetY; this.checkSelectOffsetY = (this.t._CHECK_H * this.SCALE - this.t._CHECK_SELECT_H * this.SCALE) / 2; this.checkSelectOffsetX = this.checkSelectOffsetY; this.radioOffsetY = (this.t._ELEMENT_H * this.SCALE - this.t._RADIO_H * this.SCALE) / 2; this.radioOffsetX = this.radioOffsetY; this.radioSelectOffsetY = (this.t._RADIO_H * this.SCALE - this.t._RADIO_SELECT_H * this.SCALE) / 2; this.radioSelectOffsetX = this.radioSelectOffsetY; this.scrollAlign = 0; } ,bakeElements: function() { zui_Zui.elementsBaked = true; zui_Zui.checkSelectImage = kha_Image.createRenderTarget(this.t._CHECK_SELECT_W * this.SCALE | 0,this.t._CHECK_SELECT_H * this.SCALE | 0,null,0,1,this.ops.khaWindowId); var g = zui_Zui.checkSelectImage.get_g2(); g.begin(true,0); g.set_color(this.t.CHECK_SELECT_COL); g.drawLine(0,0,this.t._CHECK_SELECT_W * this.SCALE,this.t._CHECK_SELECT_H * this.SCALE,2); g.drawLine(this.t._CHECK_SELECT_W * this.SCALE,0,0,this.t._CHECK_SELECT_H * this.SCALE,2); g.end(); } ,remove: function() { if(this.ops.autoNotifyInput) { kha_input_Mouse.get().removeWindowed(this.ops.khaWindowId,$bind(this,this.onMouseDown),$bind(this,this.onMouseUp),$bind(this,this.onMouseMove),$bind(this,this.onMouseWheel)); kha_input_Keyboard.get().remove($bind(this,this.onKeyDown),$bind(this,this.onKeyUp)); } } ,begin: function(g) { if(!zui_Zui.elementsBaked) { this.bakeElements(); } this.SCALE = this.ops.scaleFactor; this.globalG = g; this._x = 0; this._y = 0; this._w = 0; this._h = 0; } ,end: function() { if(!this.windowEnded) { this.endWindow(); } this.isKeyDown = false; this.inputStarted = false; this.inputReleased = false; this.inputDX = 0; this.inputDY = 0; this.inputWheelDelta = 0; } ,beginLayout: function(g,x,y,w) { this.currentWindow = null; this.g = g; this.SCALE = 1.0; this._windowX = 0; this._windowY = 0; this._windowW = w; this._x = x; this._y = y; this._w = w; } ,endLayout: function() { } ,window: function(handle,x,y,w,h,drag) { if(drag == null) { drag = false; } w = w | 0; h = h | 0; if(handle.texture == null || w != handle.texture.get_width() || h != handle.texture.get_height()) { this.resize(handle,w,h,this.ops.khaWindowId); } if(!this.windowEnded) { this.endWindow(); } this.windowEnded = false; this.g = handle.texture.get_g2(); this.currentWindow = handle; this._windowX = x + handle.dragX; this._windowY = y + handle.dragY; this._windowW = w; this._windowH = h; if(this.getInputInRect(this._windowX,this._windowY,this._windowW,this._windowH)) { handle.redraws = 2; } this._x = 0; this._y = handle.scrollOffset; if(handle.layout == 1) { w = this.t._ELEMENT_W * this.SCALE | 0; } this._w = !handle.scrollEnabled ? w : w - (this.t._SCROLL_W * this.SCALE | 0); this._h = h; if(handle.redraws == 0 && !this.isScrolling && !this.isTyping) { return false; } if(this.t.FILL_WINDOW_BG) { this.g.begin(true,this.t.WINDOW_BG_COL); } else { this.g.begin(true,0); this.g.set_color(this.t.WINDOW_BG_COL); this.g.fillRect(this._x,this._y - handle.scrollOffset,handle.lastMaxX,handle.lastMaxY); } handle.dragEnabled = drag; if(drag) { if(this.inputStarted && this.getInputInRect(this._windowX,this._windowY,this._windowW,15)) { handle.dragging = true; } else if(this.inputReleased) { handle.dragging = false; } if(handle.dragging) { handle.redraws = 2; handle.dragX += this.inputDX | 0; handle.dragY += this.inputDY | 0; } this._y += 15; } return true; } ,endWindow: function() { var handle = this.currentWindow; if(handle.redraws > 0 || this.isScrolling || this.isTyping) { if(handle.dragEnabled) { this.g.set_color(this.t.SEPARATOR_COL); this.g.fillRect(0,0,this._windowW,15); } var fullHeight = this._y - handle.scrollOffset; if(fullHeight < this._windowH || handle.layout == 1 || !this.scrollEnabled) { handle.scrollEnabled = false; handle.scrollOffset = 0; } else { handle.scrollEnabled = true; var amountToScroll = fullHeight - this._windowH; var amountScrolled = -handle.scrollOffset; var ratio = amountScrolled / amountToScroll; var barH = this._windowH * Math.abs(this._windowH / fullHeight); barH = Math.max(barH,this.t._ELEMENT_H * this.SCALE); var totalScrollableArea = this._windowH - barH; var e = amountToScroll / totalScrollableArea; var barY = totalScrollableArea * ratio; if(this.inputStarted && this.getInputInRect(this._windowX + this._windowW - this.t._SCROLL_BAR_W * this.SCALE,barY + this._windowY,this.t._SCROLL_BAR_W * this.SCALE,barH)) { handle.scrolling = true; this.scrollingHandle = handle; this.isScrolling = true; } if(handle.scrolling) { this.scroll(this.inputDY * e,fullHeight); } else if(this.inputWheelDelta != 0) { this.scroll(this.inputWheelDelta * (this.t._ELEMENT_H * this.SCALE),fullHeight); } if(handle.scrollOffset > 0) { handle.scrollOffset = 0; } else if(fullHeight + handle.scrollOffset < this._windowH) { handle.scrollOffset = this._windowH - fullHeight; } this.g.set_color(this.t.SCROLL_BG_COL); this.g.fillRect(this._windowW - (this.t._SCROLL_W * this.SCALE | 0),this._windowY,this.t._SCROLL_W * this.SCALE | 0,this._windowH); this.g.set_color(this.t.SCROLL_COL); this.g.drawRect(this._windowW - this.t._SCROLL_BAR_W * this.SCALE - this.scrollAlign,barY,this.t._SCROLL_BAR_W * this.SCALE,barH); } handle.lastMaxX = this._x; handle.lastMaxY = this._y; if(handle.layout == 0) { handle.lastMaxX += this._windowW; } else { handle.lastMaxY += this._windowH; } handle.redraws--; this.g.end(); } this.windowEnded = true; this.globalG.begin(false); this.globalG.set_color(this.t.WINDOW_TINT_COL); this.globalG.drawScaledImage(handle.texture,this._windowX,this._windowY,handle.texture.get_width() / this.ops.scaleTexture,handle.texture.get_height() / this.ops.scaleTexture); this.globalG.end(); } ,scroll: function(delta,fullHeight) { this.currentWindow.scrollOffset -= delta; } ,panel: function(handle,text,accent) { if(accent == null) { accent = 0; } if(!this.isVisible()) { this.endElement(); return handle.selected; } if(this.getReleased()) { handle.selected = !handle.selected; } var hover = this.getHover(); if(accent > 0) { this.g.set_color(accent == 1 ? this.t.PANEL_BG1_COL : this.t.PANEL_BG2_COL); this.g.fillRect(this._x,this._y,this._w,this.t._ELEMENT_H * this.SCALE); } this.drawArrow(handle.selected,hover); this.g.set_color(hover ? this.t.PANEL_TEXT_COL_HOVER : this.t.PANEL_TEXT_COL); this.g.set_opacity(1.0); if(accent > 0) { this.drawString(this.g,text,this.titleOffsetX,0); } else { this.drawStringSmall(this.g,text,this.titleOffsetX,0); } this.endElement(); return handle.selected; } ,image: function(image) { var w = this._w - this.buttonOffsetY * 2; var ratio = w / image.get_width(); var h = image.get_height() * ratio; if(!this.isVisible()) { this.endElement(h); return; } this.g.set_color(this.t.WINDOW_TINT_COL); this.g.drawScaledImage(image,this._x + this.buttonOffsetY,this._y,w,h); this.endElement(h); } ,text: function(text,align,bg) { if(bg == null) { bg = 0; } if(align == null) { align = 0; } if(!this.isVisible()) { this.endElement(); return; } if(bg != 0) { this.g.set_color(bg); this.g.fillRect(this._x + this.buttonOffsetY,this._y + this.buttonOffsetY,this._w - this.buttonOffsetY * 2,this.t._BUTTON_H * this.SCALE); } this.g.set_color(this.t.TEXT_COL); this.drawStringSmall(this.g,text,this.t._DEFAULT_TEXT_OFFSET_X * this.SCALE,0,align); this.endElement(); } ,textInput: function(handle,label,align) { if(align == null) { align = 0; } if(label == null) { label = ""; } if(!this.isVisible()) { this.endElement(); return handle.text; } if(this.submitTextHandle == handle) { handle.text = this.textToSubmit; this.textToSubmit = ""; this.submitTextHandle = null; this.textSelectedCurrentText = ""; } var hover = this.getHover(); this.g.set_color(hover ? this.t.TEXT_INPUT_BG_COL_HOVER : this.t.TEXT_INPUT_BG_COL); var g = this.g; var x = this._x + this.buttonOffsetY; var y = this._y + this.buttonOffsetY; var w = this._w - this.buttonOffsetY * 2; var h = this.t._BUTTON_H * this.SCALE; if(this.t.FILL_TEXT_INPUT_BG) { g.fillRect(x,y,w,h); } else { g.drawRect(x,y,w,h,this.t._LINE_STRENGTH * this.SCALE); } if(this.textSelectedHandle != handle && this.getReleased()) { this.isTyping = true; this.submitTextHandle = this.textSelectedHandle; this.textToSubmit = this.textSelectedCurrentText; this.textSelectedHandle = handle; this.textSelectedCurrentText = handle.text; this.cursorX = handle.text.length; this.cursorY = 0; if(kha_input_Keyboard.get() != null) { kha_input_Keyboard.get().show(); } } if(this.textSelectedHandle == handle) { var text = this.textSelectedCurrentText; if(this.isKeyDown) { if(this.key == kha_Key.LEFT) { if(this.cursorX > 0) { this.cursorX--; } } else if(this.key == kha_Key.RIGHT) { if(this.cursorX < text.length) { this.cursorX++; } } else if(this.key == kha_Key.BACKSPACE) { if(this.cursorX > 0) { text = HxOverrides.substr(text,0,this.cursorX - 1) + HxOverrides.substr(text,this.cursorX,null); this.cursorX--; } } else if(this.key == kha_Key.ENTER) { this.deselectText(); } else if(this.key == kha_Key.CHAR) { text = HxOverrides.substr(text,0,this.cursorX) + this["char"] + HxOverrides.substr(text,this.cursorX,null); this.cursorX++; } } var time = kha_Scheduler.time(); if(time % (this.t.TEXT_CURSOR_FLASH_SPEED * 2.0) < this.t.TEXT_CURSOR_FLASH_SPEED) { this.g.set_color(this.t.TEXT_CURSOR_COL); var cursorHeight = this.t._ELEMENT_H * this.SCALE - this.buttonOffsetY * 3.0; var lineHeight = this.t._ELEMENT_H * this.SCALE; var str = align == 0 ? HxOverrides.substr(text,0,this.cursorX) : text.substring(this.cursorX,text.length); var strw = this.g.get_font().width(this.g.get_fontSize(),str); var off = this.t._DEFAULT_TEXT_OFFSET_X * this.SCALE; var cursorX = align == 0 ? this._x + strw + off : this._x + this._w - strw - off; this.g.fillRect(cursorX,this._y + this.cursorY * lineHeight + this.buttonOffsetY * 1.5,this.SCALE,cursorHeight); } this.textSelectedCurrentText = text; } if(label != "") { this.g.set_color(this.t.DEFAULT_LABEL_COL); var labelAlign = align == 2 ? 0 : 2; var xOffset = labelAlign == 0 ? 7 : 0; this.drawStringSmall(this.g,label,xOffset,0,labelAlign); } this.g.set_color(this.t.TEXT_COL); if(this.textSelectedHandle != handle) { this.drawStringSmall(this.g,handle.text,null,0,align); } else { this.drawStringSmall(this.g,this.textSelectedCurrentText,null,0,align); } this.endElement(); return handle.text; } ,deselectText: function() { this.submitTextHandle = this.textSelectedHandle; this.textToSubmit = this.textSelectedCurrentText; this.textSelectedHandle = null; this.isTyping = false; if(this.currentWindow != null) { this.currentWindow.redraws = 2; } if(kha_input_Keyboard.get() != null) { kha_input_Keyboard.get().hide(); } } ,button: function(text) { if(!this.isVisible()) { this.endElement(); return false; } var wasPressed = this.getReleased(); var pushed = this.getPushed(); var hover = this.getHover(); this.g.set_color(pushed ? this.t.BUTTON_BG_COL_PRESSED : hover ? this.t.BUTTON_BG_COL_HOVER : this.t.BUTTON_BG_COL); var g = this.g; var x = this._x + this.buttonOffsetY; var y = this._y + this.buttonOffsetY; var w = this._w - this.buttonOffsetY * 2; var h = this.t._BUTTON_H * this.SCALE; if(this.t.FILL_BUTTON_BG) { g.fillRect(x,y,w,h); } else { g.drawRect(x,y,w,h,this.t._LINE_STRENGTH * this.SCALE); } this.g.set_color(this.t.BUTTON_TEXT_COL); this.drawStringSmall(this.g,text,0,0,1); this.endElement(); return wasPressed; } ,check: function(handle,text) { if(!this.isVisible()) { this.endElement(); return handle.selected; } if(this.getReleased()) { handle.selected = !handle.selected; } var hover = this.getHover(); this.drawCheck(handle.selected,hover); this.g.set_color(hover ? this.t.TEXT_COL_HOVER : this.t.TEXT_COL); this.drawStringSmall(this.g,text,this.titleOffsetX,0,0); this.endElement(); return handle.selected; } ,radio: function(handle,position,text) { if(!this.isVisible()) { this.endElement(); return handle.position == position; } if(this.getReleased()) { handle.position = position; } var hover = this.getHover(); this.drawRadio(handle.position == position,hover); this.g.set_color(hover ? this.t.TEXT_COL_HOVER : this.t.TEXT_COL); this.drawStringSmall(this.g,text,this.titleOffsetX,0); this.endElement(); return handle.position == position; } ,inlineRadio: function(handle,texts) { if(!this.isVisible()) { this.endElement(); return handle.position; } if(this.getReleased()) { if(++handle.position >= texts.length) { handle.position = 0; } } var hover = this.getHover(); this.drawInlineRadio(texts[handle.position],hover); this.endElement(); return handle.position; } ,slider: function(handle,text,from,to,filled,precision,displayValue) { if(displayValue == null) { displayValue = true; } if(precision == null) { precision = 100; } if(filled == null) { filled = false; } if(to == null) { to = 1.0; } if(from == null) { from = 0.0; } if(!this.isVisible()) { this.endElement(); return handle.value; } if(this.getStarted()) { handle.scrolling = true; this.scrollingHandle = handle; this.isScrolling = true; } if(handle.scrolling) { var range = to - from; var sliderX = this._x + this._windowX + this.buttonOffsetY; var sliderW = this._w - this.buttonOffsetY * 2; var step = range / sliderW; var value = from + (this.inputX - sliderX) * step; handle.value = (value * precision | 0) / precision; if(handle.value < from) { handle.value = from; } else if(handle.value > to) { handle.value = to; } } var hover = this.getHover(); this.drawSlider(handle.value,from,to,filled,hover); this.g.set_color(this.t.DEFAULT_LABEL_COL); this.drawStringSmall(this.g,text,0,0,2); if(displayValue) { this.g.set_color(this.t.TEXT_COL); this.drawStringSmall(this.g,handle.value + ""); } this.endElement(); return handle.value; } ,separator: function() { if(!this.isVisible()) { this._y += 2; return; } this.g.set_color(this.t.SEPARATOR_COL); this.g.fillRect(this._x,this._y,this._w - this.t._DEFAULT_TEXT_OFFSET_X * this.SCALE,this.t._LINE_STRENGTH * this.SCALE); this._y += 2; } ,drawArrow: function(selected,hover) { var x = this._x + this.arrowOffsetX; var y = this._y + this.arrowOffsetY; this.g.set_color(hover ? this.t.ARROW_COL_HOVER : this.t.ARROW_COL); if(selected) { this.g.fillTriangle(x,y,x + this.t._ARROW_W * this.SCALE,y,x + this.t._ARROW_W * this.SCALE / 2,y + this.t._ARROW_H * this.SCALE); } else { this.g.fillTriangle(x,y,x,y + this.t._ARROW_H * this.SCALE,x + this.t._ARROW_W * this.SCALE,y + this.t._ARROW_H * this.SCALE / 2); } } ,drawCheck: function(selected,hover) { var x = this._x + this.checkOffsetX; var y = this._y + this.checkOffsetY; this.g.set_color(hover ? this.t.CHECK_COL_HOVER : this.t.CHECK_COL); var g = this.g; var w = this.t._CHECK_W * this.SCALE; var h = this.t._CHECK_H * this.SCALE; if(this.t.FILL_CHECK_BG) { g.fillRect(x,y,w,h); } else { g.drawRect(x,y,w,h,this.t._LINE_STRENGTH * this.SCALE); } if(selected) { this.g.set_color(-1); this.g.drawImage(zui_Zui.checkSelectImage,x + this.checkSelectOffsetX,y + this.checkSelectOffsetY); } } ,drawRadio: function(selected,hover) { var x = this._x + this.radioOffsetX; var y = this._y + this.radioOffsetY; this.g.set_color(hover ? this.t.RADIO_COL_HOVER : this.t.RADIO_COL); var g = this.g; var w = this.t._RADIO_W * this.SCALE; var h = this.t._RADIO_H * this.SCALE; if(this.t.FILL_RADIO_BG) { g.fillRect(x,y,w,h); } else { g.drawRect(x,y,w,h,this.t._LINE_STRENGTH * this.SCALE); } if(selected) { this.g.set_color(this.t.RADIO_SELECT_COL); this.g.fillRect(x + this.radioSelectOffsetX,y + this.radioSelectOffsetY,this.t._RADIO_SELECT_W * this.SCALE,this.t._RADIO_SELECT_H * this.SCALE); } } ,drawInlineRadio: function(text,hover) { if(hover) { this.g.set_color(this.t.RADIO_COL_HOVER); this.g.fillRect(this._x + 5,this._y + 5,this._w - 10,this.t._ELEMENT_H * this.SCALE - 10); } var x = this._x + this.arrowOffsetX; var y = this._y + this.arrowOffsetY; this.g.set_color(hover ? this.t.ARROW_COL_HOVER : this.t.ARROW_COL); this.g.fillTriangle(x,y,x,y + this.t._ARROW_H * this.SCALE,x - this.t._ARROW_W * this.SCALE / 2,y + this.t._ARROW_H * this.SCALE / 2); var x1 = this._x + this._w - this.arrowOffsetX - 5; this.g.fillTriangle(x1,y,x1,y + this.t._ARROW_H * this.SCALE,x1 + this.t._ARROW_W * this.SCALE / 2,y + this.t._ARROW_H * this.SCALE / 2); this.g.set_color(hover ? this.t.TEXT_COL_HOVER : this.t.TEXT_COL); this.drawStringSmall(this.g,text,this.titleOffsetX,0,1); } ,drawSlider: function(value,from,to,filled,hover) { var x = this._x + this.buttonOffsetY; var y = this._y + this.buttonOffsetY; var w = this._w - this.buttonOffsetY * 2; this.g.set_color(hover ? this.t.CHECK_COL_HOVER : this.t.CHECK_COL); var g = this.g; var h = this.t._BUTTON_H * this.SCALE; if(this.t.FILL_SLIDER_BG) { g.fillRect(x,y,w,h); } else { g.drawRect(x,y,w,h,this.t._LINE_STRENGTH * this.SCALE); } this.g.set_color(hover ? this.t.SLIDER_COL_HOVER : this.t.SLIDER_COL); var offset = (value - from) / (to - from); var barW = 8 * this.SCALE; var sliderX = filled ? x : x + (w - barW) * offset; var sliderW = filled ? w * offset : barW; this.g.fillRect(sliderX,y,sliderW,this.t._BUTTON_H * this.SCALE); } ,drawString: function(g,text,xOffset,yOffset,align) { if(align == null) { align = 0; } if(yOffset == null) { yOffset = 0; } if(xOffset == null) { xOffset = this.t._DEFAULT_TEXT_OFFSET_X; } xOffset *= this.SCALE; g.set_font(this.ops.font); g.set_fontSize(this.fontSize); if(align == 1) { xOffset = this._w / 2 - this.ops.font.width(this.fontSize,text) / 2; } else if(align == 2) { xOffset = this._w - this.ops.font.width(this.fontSize,text) - this.t._DEFAULT_TEXT_OFFSET_X * this.SCALE; } g.drawString(text,this._x + xOffset,this._y + this.fontOffsetY + yOffset); } ,drawStringSmall: function(g,text,xOffset,yOffset,align) { if(align == null) { align = 0; } if(yOffset == null) { yOffset = 0; } if(xOffset == null) { xOffset = this.t._DEFAULT_TEXT_OFFSET_X; } xOffset *= this.SCALE; g.set_font(this.ops.font); g.set_fontSize(this.fontSmallSize); if(align == 1) { xOffset = this._w / 2 - this.ops.font.width(this.fontSmallSize,text) / 2; } else if(align == 2) { xOffset = this._w - this.ops.font.width(this.fontSmallSize,text) - this.t._DEFAULT_TEXT_OFFSET_X * this.SCALE; } g.drawString(text,this._x + xOffset,this._y + this.fontSmallOffsetY + yOffset); } ,endElement: function(elementSize) { if(this.currentWindow == null) { this._y += this.t._ELEMENT_H * this.SCALE + this.t._ELEMENT_SEPARATOR_SIZE * this.SCALE; return; } if(this.currentWindow.layout == 0) { if(this.curRatio == -1 || this.ratios != null && this.curRatio == this.ratios.length - 1) { if(elementSize == null) { elementSize = this.t._ELEMENT_H * this.SCALE + this.t._ELEMENT_SEPARATOR_SIZE * this.SCALE; } this._y += elementSize; if(this.ratios != null && this.curRatio == this.ratios.length - 1) { this.curRatio = -1; this.ratios = null; this._x = this.xBeforeSplit; this._w = this.wBeforeSplit; } } else { this.curRatio++; this._x += this._w; this._w = this.wBeforeSplit * this.ratios[this.curRatio] | 0; } } else { this._x += this._w + this.t._ELEMENT_SEPARATOR_SIZE * this.SCALE; } } ,row: function(ratios) { this.ratios = ratios; this.curRatio = 0; this.xBeforeSplit = this._x; this.wBeforeSplit = this._w; this._w = this._w * ratios[this.curRatio] | 0; } ,indent: function() { this._x += this.t._TAB_W * this.SCALE | 0; this._w -= this.t._TAB_W * this.SCALE | 0; } ,unindent: function() { this._x -= this.t._TAB_W * this.SCALE | 0; this._w += this.t._TAB_W * this.SCALE | 0; } ,drawRect: function(g,fill,x,y,w,h,strength) { if(strength == null) { strength = 1.0; } if(fill) { g.fillRect(x,y,w,h); } else { g.drawRect(x,y,w,h,this.t._LINE_STRENGTH * this.SCALE); } } ,isVisible: function() { if(this.currentWindow == null) { return true; } if(this._y + this.t._ELEMENT_H * this.SCALE > 0) { return this._y < this.currentWindow.texture.get_height(); } else { return false; } } ,getReleased: function() { if(this.inputReleased && this.getHover()) { return this.getInitialHover(); } else { return false; } } ,getPushed: function() { if(this.inputDown && this.getHover()) { return this.getInitialHover(); } else { return false; } } ,getStarted: function() { if(this.inputStarted) { return this.getHover(); } else { return false; } } ,getInitialHover: function() { if(this.inputInitialX >= this._windowX + this._x && this.inputInitialX < this._windowX + this._x + this._w && this.inputInitialY >= this._windowY + this._y) { return this.inputInitialY < this._windowY + this._y + this.t._ELEMENT_H * this.SCALE; } else { return false; } } ,getHover: function() { if(this.inputX >= this._windowX + this._x && this.inputX < this._windowX + this._x + this._w && this.inputY >= this._windowY + this._y) { return this.inputY < this._windowY + this._y + this.t._ELEMENT_H * this.SCALE; } else { return false; } } ,getInputInRect: function(x,y,w,h,scale) { if(scale == null) { scale = 1.0; } if(this.inputX >= x * scale && this.inputX < (x + w) * scale && this.inputY >= y * scale) { return this.inputY < (y + h) * scale; } else { return false; } } ,onMouseDown: function(button,x,y) { this.inputStarted = true; if(button == 0) { this.inputDown = true; } else { this.inputDownR = true; } this.setInitialInputPosition(x * this.ops.scaleTexture | 0,y * this.ops.scaleTexture | 0); } ,onMouseUp: function(button,x,y) { if(this.isScrolling) { this.isScrolling = false; if(this.scrollingHandle != null) { this.scrollingHandle.scrolling = false; } } else { this.inputReleased = true; } if(button == 0) { this.inputDown = false; } else { this.inputDownR = false; } this.setInputPosition(x * this.ops.scaleTexture | 0,y * this.ops.scaleTexture | 0); this.deselectText(); } ,onMouseMove: function(x,y,movementX,movementY) { this.setInputPosition(x * this.ops.scaleTexture | 0,y * this.ops.scaleTexture | 0); } ,onMouseWheel: function(delta) { this.inputWheelDelta = delta; } ,setInitialInputPosition: function(inputX,inputY) { this.setInputPosition(inputX,inputY); this.inputInitialX = inputX; this.inputInitialY = inputY; } ,setInputPosition: function(inputX,inputY) { this.inputDX += inputX - this.inputX; this.inputDY += inputY - this.inputY; this.inputX = inputX; this.inputY = inputY; } ,onKeyDown: function(key,$char) { this.isKeyDown = true; this.key = key; this["char"] = $char; } ,onKeyUp: function(key,$char) { } ,ELEMENT_W: function() { return this.t._ELEMENT_W * this.SCALE; } ,ELEMENT_H: function() { return this.t._ELEMENT_H * this.SCALE; } ,ELEMENT_SEPARATOR_SIZE: function() { return this.t._ELEMENT_SEPARATOR_SIZE * this.SCALE; } ,ARROW_W: function() { return this.t._ARROW_W * this.SCALE; } ,ARROW_H: function() { return this.t._ARROW_H * this.SCALE; } ,BUTTON_H: function() { return this.t._BUTTON_H * this.SCALE; } ,CHECK_W: function() { return this.t._CHECK_W * this.SCALE; } ,CHECK_H: function() { return this.t._CHECK_H * this.SCALE; } ,CHECK_SELECT_W: function() { return this.t._CHECK_SELECT_W * this.SCALE; } ,CHECK_SELECT_H: function() { return this.t._CHECK_SELECT_H * this.SCALE; } ,RADIO_W: function() { return this.t._RADIO_W * this.SCALE; } ,RADIO_H: function() { return this.t._RADIO_H * this.SCALE; } ,RADIO_SELECT_W: function() { return this.t._RADIO_SELECT_W * this.SCALE; } ,RADIO_SELECT_H: function() { return this.t._RADIO_SELECT_H * this.SCALE; } ,SCROLL_W: function() { return this.t._SCROLL_W * this.SCALE | 0; } ,SCROLL_BAR_W: function() { return this.t._SCROLL_BAR_W * this.SCALE; } ,DEFAULT_TEXT_OFFSET_X: function() { return this.t._DEFAULT_TEXT_OFFSET_X * this.SCALE; } ,TAB_W: function() { return this.t._TAB_W * this.SCALE | 0; } ,LINE_STRENGTH: function() { return this.t._LINE_STRENGTH * this.SCALE; } ,resize: function(handle,w,h,khaWindowId) { if(khaWindowId == null) { khaWindowId = 0; } handle.redraws = 2; if(handle.texture != null) { handle.texture.unload(); } handle.texture = kha_Image.createRenderTarget(w,h,kha_graphics4_TextureFormat.RGBA32,0,1,khaWindowId); handle.texture.get_g2().set_imageScaleQuality(kha_graphics2_ImageScaleQuality.High); } ,__class__: zui_Zui }; var zui_Handle = function(ops) { this.dragY = 0; this.dragX = 0; this.dragEnabled = false; this.dragging = false; this.lastMaxY = 0.0; this.lastMaxX = 0.0; this.layout = 0; this.scrollEnabled = false; this.scrollOffset = 0.0; this.scrolling = false; this.redraws = 2; this.texture = null; this.text = ""; this.value = 0.0; this.color = -1; this.position = 0; this.selected = false; if(ops != null) { if(ops.selected != null) { this.selected = ops.selected; } if(ops.position != null) { this.position = ops.position; } if(ops.value != null) { this.value = ops.value; } if(ops.text != null) { this.text = ops.text; } if(ops.color != null) { this.color = ops.color; } if(ops.layout != null) { this.layout = ops.layout; } } }; $hxClasses["zui.Handle"] = zui_Handle; zui_Handle.__name__ = true; zui_Handle.prototype = { selected: null ,position: null ,color: null ,value: null ,text: null ,texture: null ,redraws: null ,scrolling: null ,scrollOffset: null ,scrollEnabled: null ,layout: null ,lastMaxX: null ,lastMaxY: null ,dragging: null ,dragEnabled: null ,dragX: null ,dragY: null ,children: null ,nest: function(i,ops) { if(this.children == null) { this.children = []; } while(this.children.length <= i) this.children.push(null); if(this.children[i] == null) { this.children[i] = new zui_Handle(ops); } return this.children[i]; } ,__class__: zui_Handle }; function $iterator(o) { if( o instanceof Array ) return function() { return HxOverrides.iter(o); }; return typeof(o.iterator) == 'function' ? $bind(o,o.iterator) : o.iterator; } var $_, $fid = 0; function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.hx__closures__[m.__id__] = f; } return f; } $hxClasses["Math"] = Math; String.prototype.__class__ = $hxClasses["String"] = String; String.__name__ = true; $hxClasses["Array"] = Array; Array.__name__ = true; Date.prototype.__class__ = $hxClasses["Date"] = Date; Date.__name__ = ["Date"]; var Int = $hxClasses["Int"] = { __name__ : ["Int"]}; var Dynamic = $hxClasses["Dynamic"] = { __name__ : ["Dynamic"]}; var Float = $hxClasses["Float"] = Number; Float.__name__ = ["Float"]; var Bool = $hxClasses["Bool"] = Boolean; Bool.__ename__ = ["Bool"]; var Class = $hxClasses["Class"] = { __name__ : ["Class"]}; var Enum = { }; var __map_reserved = {} var ArrayBuffer = $global.ArrayBuffer || js_html_compat_ArrayBuffer; if(ArrayBuffer.prototype.slice == null) { ArrayBuffer.prototype.slice = js_html_compat_ArrayBuffer.sliceImpl; } var DataView = $global.DataView || js_html_compat_DataView; var Float32Array = $global.Float32Array || js_html_compat_Float32Array._new; var Uint8Array = $global.Uint8Array || js_html_compat_Uint8Array._new; haxe_Unserializer.DEFAULT_RESOLVER = new haxe__$Unserializer_DefaultResolver(); haxe_Unserializer.BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:"; haxe_crypto_Base64.CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; haxe_crypto_Base64.BYTES = haxe_io_Bytes.ofString(haxe_crypto_Base64.CHARS); haxe_ds_ObjectMap.count = 0; haxe_io_FPHelper.i64tmp = (function($this) { var $r; var this1 = new haxe__$Int64__$_$_$Int64(0,0); $r = this1; return $r; }(this)); js_Boot.__toStr = ({ }).toString; js_html_compat_Float32Array.BYTES_PER_ELEMENT = 4; js_html_compat_Uint8Array.BYTES_PER_ELEMENT = 1; kha_Assets.images = new kha__$Assets_ImageList(); kha_Assets.sounds = new kha__$Assets_SoundList(); kha_Assets.blobs = new kha__$Assets_BlobList(); kha_Assets.fonts = new kha__$Assets_FontList(); kha_Assets.videos = new kha__$Assets_VideoList(); kha__$Color_Color_$Impl_$.Black = -16777216; kha__$Color_Color_$Impl_$.White = -1; kha__$Color_Color_$Impl_$.Red = -65536; kha__$Color_Color_$Impl_$.Blue = -16776961; kha__$Color_Color_$Impl_$.Green = -16711936; kha__$Color_Color_$Impl_$.Magenta = -65281; kha__$Color_Color_$Impl_$.Yellow = -256; kha__$Color_Color_$Impl_$.Cyan = -16711681; kha__$Color_Color_$Impl_$.Purple = -8388480; kha__$Color_Color_$Impl_$.Pink = -16181; kha__$Color_Color_$Impl_$.Orange = -23296; kha__$Color_Color_$Impl_$.Transparent = 0; kha__$Color_Color_$Impl_$.invMaxChannelValue = 0.00392156862745098; kha_CompilerDefines.js = "1"; kha_CompilerDefines.kha_a1 = "1"; kha_CompilerDefines.kha_g3 = "1"; kha_CompilerDefines.kha_g4 = "1"; kha_CompilerDefines.kha_html5_js = "1"; kha_CompilerDefines["source-header"] = "Generated by Haxe 3.4.2"; kha_CompilerDefines.sys_g3 = "1"; kha_CompilerDefines.kha_g1 = "1"; kha_CompilerDefines.sys_a1 = "1"; kha_CompilerDefines.haxe_ver = "3.402"; kha_CompilerDefines.jquery_ver = "11204"; kha_CompilerDefines.kha_js = "1"; kha_CompilerDefines.sys_html5 = "1"; kha_CompilerDefines.canvas_id = "khanvas"; kha_CompilerDefines.kha_version = "1611"; kha_CompilerDefines.sys_g4 = "1"; kha_CompilerDefines.js_es = "5"; kha_CompilerDefines.kha_html5 = "1"; kha_CompilerDefines.zui = "1"; kha_CompilerDefines["js-es5"] = "1"; kha_CompilerDefines.js_es5 = "1"; kha_CompilerDefines.sys_a2 = "1"; kha_CompilerDefines.dce = "std"; kha_CompilerDefines.sys_g1 = "1"; kha_CompilerDefines["true"] = "1"; kha_CompilerDefines.sys_g2 = "1"; kha_CompilerDefines.kha_webgl = "1"; kha_CompilerDefines.kha = "1"; kha_CompilerDefines.kha_g2 = "1"; kha_CompilerDefines.haxe3 = "1"; kha_CompilerDefines.kha_a2 = "1"; kha_CompilerDefines.script_name = "kha"; kha_FontStyle.Default = new kha_FontStyle(false,false,false); kha_Scheduler.timeWarpSaveTime = 1.0; kha_Scheduler.DIF_COUNT = 3; kha_Scheduler.maxframetime = 0.5; kha_Scheduler.startTime = 0; kha_Shaders.painter_colored_fragData0 = "s198:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdmFyeWluZyBoaWdocCB2ZWM0IGZyYWdtZW50Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9GcmFnRGF0YVswXSA9IGZyYWdtZW50Q29sb3I7Cn0KCg"; kha_Shaders.painter_colored_fragData1 = "s192:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp2YXJ5aW5nIHZlYzQgZnJhZ21lbnRDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX0ZyYWdEYXRhWzBdID0gZnJhZ21lbnRDb2xvcjsKfQoK"; kha_Shaders.painter_colored_fragData2 = "s210:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7CgpvdXQgdmVjNCBGcmFnQ29sb3I7CmluIHZlYzQgZnJhZ21lbnRDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIEZyYWdDb2xvciA9IGZyYWdtZW50Q29sb3I7Cn0KCg"; kha_Shaders.painter_colored_vertData0 = "s331:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgZnJhZ21lbnRDb2xvcjsKYXR0cmlidXRlIHZlYzQgdmVydGV4Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9Qb3NpdGlvbiA9IHByb2plY3Rpb25NYXRyaXggKiB2ZWM0KHZlcnRleFBvc2l0aW9uLCAxLjApOwogICAgZnJhZ21lbnRDb2xvciA9IHZlcnRleENvbG9yOwp9Cgo"; kha_Shaders.painter_colored_vertData1 = "s374:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzQgZnJhZ21lbnRDb2xvcjsKYXR0cmlidXRlIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICBmcmFnbWVudENvbG9yID0gdmVydGV4Q29sb3I7Cn0KCg"; kha_Shaders.painter_colored_vertData2 = "s354:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWM0IGZyYWdtZW50Q29sb3I7CmluIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICBmcmFnbWVudENvbG9yID0gdmVydGV4Q29sb3I7Cn0KCg"; kha_Shaders.painter_image_fragData0 = "s471:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdW5pZm9ybSBoaWdocCBzYW1wbGVyMkQgdGV4OwoKdmFyeWluZyBoaWdocCB2ZWMyIHRleENvb3JkOwp2YXJ5aW5nIGhpZ2hwIHZlYzQgY29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBoaWdocCB2ZWM0IHRleGNvbG9yID0gdGV4dHVyZTJEKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICBoaWdocCB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBnbF9GcmFnRGF0YVswXSA9IHRleGNvbG9yOwp9Cgo"; kha_Shaders.painter_image_fragData1 = "s444:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCnZhcnlpbmcgdmVjMiB0ZXhDb29yZDsKdmFyeWluZyB2ZWM0IGNvbG9yOwoKdm9pZCBtYWluKCkKewogICAgdmVjNCB0ZXhjb2xvciA9IHRleHR1cmUyRCh0ZXgsIHRleENvb3JkKSAqIGNvbG9yOwogICAgdmVjMyBfMzIgPSB0ZXhjb2xvci54eXogKiBjb2xvci53OwogICAgdGV4Y29sb3IgPSB2ZWM0KF8zMi54LCBfMzIueSwgXzMyLnosIHRleGNvbG9yLncpOwogICAgZ2xfRnJhZ0RhdGFbMF0gPSB0ZXhjb2xvcjsKfQoK"; kha_Shaders.painter_image_fragData2 = "s452:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCmluIHZlYzIgdGV4Q29vcmQ7CmluIHZlYzQgY29sb3I7Cm91dCB2ZWM0IEZyYWdDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIHZlYzQgdGV4Y29sb3IgPSB0ZXh0dXJlKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBGcmFnQ29sb3IgPSB0ZXhjb2xvcjsKfQoK"; kha_Shaders.painter_image_vertData0 = "s415:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSB2ZWMyIHRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgY29sb3I7CmF0dHJpYnV0ZSB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo"; kha_Shaders.painter_image_vertData1 = "s479:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247CnZhcnlpbmcgbWVkaXVtcCB2ZWM0IGNvbG9yOwphdHRyaWJ1dGUgbWVkaXVtcCB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo"; kha_Shaders.painter_image_vertData2 = "s444:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWMyIHRleENvb3JkOwppbiBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247Cm91dCBtZWRpdW1wIHZlYzQgY29sb3I7CmluIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICB0ZXhDb29yZCA9IHRleFBvc2l0aW9uOwogICAgY29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK"; kha_Shaders.painter_text_fragData0 = "s351:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdW5pZm9ybSBoaWdocCBzYW1wbGVyMkQgdGV4OwoKdmFyeWluZyBoaWdocCB2ZWM0IGZyYWdtZW50Q29sb3I7CnZhcnlpbmcgaGlnaHAgdmVjMiB0ZXhDb29yZDsKCnZvaWQgbWFpbigpCnsKICAgIGdsX0ZyYWdEYXRhWzBdID0gdmVjNChmcmFnbWVudENvbG9yLnh5eiwgdGV4dHVyZTJEKHRleCwgdGV4Q29vcmQpLnggKiBmcmFnbWVudENvbG9yLncpOwp9Cgo"; kha_Shaders.painter_text_fragData1 = "s340:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCnZhcnlpbmcgdmVjNCBmcmFnbWVudENvbG9yOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9GcmFnRGF0YVswXSA9IHZlYzQoZnJhZ21lbnRDb2xvci54eXosIHRleHR1cmUyRCh0ZXgsIHRleENvb3JkKS54ICogZnJhZ21lbnRDb2xvci53KTsKfQoK"; kha_Shaders.painter_text_fragData2 = "s348:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCm91dCB2ZWM0IEZyYWdDb2xvcjsKaW4gdmVjNCBmcmFnbWVudENvbG9yOwppbiB2ZWMyIHRleENvb3JkOwoKdm9pZCBtYWluKCkKewogICAgRnJhZ0NvbG9yID0gdmVjNChmcmFnbWVudENvbG9yLnh5eiwgdGV4dHVyZSh0ZXgsIHRleENvb3JkKS54ICogZnJhZ21lbnRDb2xvci53KTsKfQoK"; kha_Shaders.painter_text_vertData0 = "s436:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSB2ZWMyIHRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgZnJhZ21lbnRDb2xvcjsKYXR0cmlidXRlIHZlYzQgdmVydGV4Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9Qb3NpdGlvbiA9IHByb2plY3Rpb25NYXRyaXggKiB2ZWM0KHZlcnRleFBvc2l0aW9uLCAxLjApOwogICAgdGV4Q29vcmQgPSB0ZXhQb3NpdGlvbjsKICAgIGZyYWdtZW50Q29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK"; kha_Shaders.painter_text_vertData1 = "s500:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247CnZhcnlpbmcgbWVkaXVtcCB2ZWM0IGZyYWdtZW50Q29sb3I7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzQgdmVydGV4Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9Qb3NpdGlvbiA9IHByb2plY3Rpb25NYXRyaXggKiB2ZWM0KHZlcnRleFBvc2l0aW9uLCAxLjApOwogICAgdGV4Q29vcmQgPSB0ZXhQb3NpdGlvbjsKICAgIGZyYWdtZW50Q29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK"; kha_Shaders.painter_text_vertData2 = "s466:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWMyIHRleENvb3JkOwppbiBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247Cm91dCBtZWRpdW1wIHZlYzQgZnJhZ21lbnRDb2xvcjsKaW4gbWVkaXVtcCB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBmcmFnbWVudENvbG9yID0gdmVydGV4Q29sb3I7Cn0KCg"; kha_Shaders.painter_video_fragData0 = "s471:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdW5pZm9ybSBoaWdocCBzYW1wbGVyMkQgdGV4OwoKdmFyeWluZyBoaWdocCB2ZWMyIHRleENvb3JkOwp2YXJ5aW5nIGhpZ2hwIHZlYzQgY29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBoaWdocCB2ZWM0IHRleGNvbG9yID0gdGV4dHVyZTJEKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICBoaWdocCB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBnbF9GcmFnRGF0YVswXSA9IHRleGNvbG9yOwp9Cgo"; kha_Shaders.painter_video_fragData1 = "s444:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCnZhcnlpbmcgdmVjMiB0ZXhDb29yZDsKdmFyeWluZyB2ZWM0IGNvbG9yOwoKdm9pZCBtYWluKCkKewogICAgdmVjNCB0ZXhjb2xvciA9IHRleHR1cmUyRCh0ZXgsIHRleENvb3JkKSAqIGNvbG9yOwogICAgdmVjMyBfMzIgPSB0ZXhjb2xvci54eXogKiBjb2xvci53OwogICAgdGV4Y29sb3IgPSB2ZWM0KF8zMi54LCBfMzIueSwgXzMyLnosIHRleGNvbG9yLncpOwogICAgZ2xfRnJhZ0RhdGFbMF0gPSB0ZXhjb2xvcjsKfQoK"; kha_Shaders.painter_video_fragData2 = "s452:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCmluIHZlYzIgdGV4Q29vcmQ7CmluIHZlYzQgY29sb3I7Cm91dCB2ZWM0IEZyYWdDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIHZlYzQgdGV4Y29sb3IgPSB0ZXh0dXJlKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBGcmFnQ29sb3IgPSB0ZXhjb2xvcjsKfQoK"; kha_Shaders.painter_video_vertData0 = "s415:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSB2ZWMyIHRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgY29sb3I7CmF0dHJpYnV0ZSB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo"; kha_Shaders.painter_video_vertData1 = "s479:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247CnZhcnlpbmcgbWVkaXVtcCB2ZWM0IGNvbG9yOwphdHRyaWJ1dGUgbWVkaXVtcCB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo"; kha_Shaders.painter_video_vertData2 = "s444:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWMyIHRleENvb3JkOwppbiBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247Cm91dCBtZWRpdW1wIHZlYzQgY29sb3I7CmluIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICB0ZXhDb29yZCA9IHRleFBvc2l0aW9uOwogICAgY29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK"; kha_System.renderListeners = []; kha_System.foregroundListeners = []; kha_System.resumeListeners = []; kha_System.pauseListeners = []; kha_System.backgroundListeners = []; kha_System.shutdownListeners = []; kha_SystemImpl.mobile = false; kha_SystemImpl.mobileAudioPlaying = false; kha_SystemImpl.chrome = false; kha_SystemImpl.insideInputEvent = false; kha_SystemImpl.maxGamepads = 4; kha_SystemImpl.leftMouseCtrlDown = false; kha_SystemImpl.minimumScroll = 999; kha_SystemImpl.lastFirstTouchX = 0; kha_SystemImpl.lastFirstTouchY = 0; kha_SystemImpl.iosSoundEnabled = false; kha_WebGLImage.GL_RGBA16F = 34842; kha_WebGLImage.GL_RGBA32F = 34836; kha_WebGLImage.GL_R16F = 33325; kha_WebGLImage.GL_R32F = 33326; kha_WebGLImage.GL_DEPTH_COMPONENT24 = 33190; kha_WebGLImage.GL_DEPTH24_STENCIL8 = 35056; kha_WebGLImage.GL_DEPTH32F_STENCIL8 = 36013; kha_audio2_Audio1.channelCount = 16; kha_audio2_ogg_tools_Crc32.POLY = 79764919; kha_audio2_ogg_vorbis_VorbisDecodeState.INVALID_BITS = -1; kha_audio2_ogg_vorbis_VorbisTools.EOP = -1; kha_audio2_ogg_vorbis_VorbisTools.M__PI = 3.14159265358979323846264; kha_audio2_ogg_vorbis_VorbisTools.DIVTAB_NUMER = 32; kha_audio2_ogg_vorbis_VorbisTools.DIVTAB_DENOM = 64; kha_audio2_ogg_vorbis_VorbisTools.INVERSE_DB_TABLE = [1.0649863e-07,1.1341951e-07,1.2079015e-07,1.2863978e-07,1.3699951e-07,1.4590251e-07,1.5538408e-07,1.6548181e-07,1.7623575e-07,1.8768855e-07,1.9988561e-07,2.1287530e-07,2.2670913e-07,2.4144197e-07,2.5713223e-07,2.7384213e-07,2.9163793e-07,3.1059021e-07,3.3077411e-07,3.5226968e-07,3.7516214e-07,3.9954229e-07,4.2550680e-07,4.5315863e-07,4.8260743e-07,5.1396998e-07,5.4737065e-07,5.8294187e-07,6.2082472e-07,6.6116941e-07,7.0413592e-07,7.4989464e-07,7.9862701e-07,8.5052630e-07,9.0579828e-07,9.6466216e-07,1.0273513e-06,1.0941144e-06,1.1652161e-06,1.2409384e-06,1.3215816e-06,1.4074654e-06,1.4989305e-06,1.5963394e-06,1.7000785e-06,1.8105592e-06,1.9282195e-06,2.0535261e-06,2.1869758e-06,2.3290978e-06,2.4804557e-06,2.6416497e-06,2.8133190e-06,2.9961443e-06,3.1908506e-06,3.3982101e-06,3.6190449e-06,3.8542308e-06,4.1047004e-06,4.3714470e-06,4.6555282e-06,4.9580707e-06,5.2802740e-06,5.6234160e-06,5.9888572e-06,6.3780469e-06,6.7925283e-06,7.2339451e-06,7.7040476e-06,8.2047000e-06,8.7378876e-06,9.3057248e-06,9.9104632e-06,1.0554501e-05,1.1240392e-05,1.1970856e-05,1.2748789e-05,1.3577278e-05,1.4459606e-05,1.5399272e-05,1.6400004e-05,1.7465768e-05,1.8600792e-05,1.9809576e-05,2.1096914e-05,2.2467911e-05,2.3928002e-05,2.5482978e-05,2.7139006e-05,2.8902651e-05,3.0780908e-05,3.2781225e-05,3.4911534e-05,3.7180282e-05,3.9596466e-05,4.2169667e-05,4.4910090e-05,4.7828601e-05,5.0936773e-05,5.4246931e-05,5.7772202e-05,6.1526565e-05,6.5524908e-05,6.9783085e-05,7.4317983e-05,7.9147585e-05,8.4291040e-05,8.9768747e-05,9.5602426e-05,0.00010181521,0.00010843174,0.00011547824,0.00012298267,0.00013097477,0.00013948625,0.00014855085,0.00015820453,0.00016848555,0.00017943469,0.00019109536,0.00020351382,0.00021673929,0.00023082423,0.00024582449,0.00026179955,0.00027881276,0.00029693158,0.00031622787,0.00033677814,0.00035866388,0.00038197188,0.00040679456,0.00043323036,0.00046138411,0.00049136745,0.00052329927,0.00055730621,0.00059352311,0.00063209358,0.00067317058,0.00071691700,0.00076350630,0.00081312324,0.00086596457,0.00092223983,0.00098217216,0.0010459992,0.0011139742,0.0011863665,0.0012634633,0.0013455702,0.0014330129,0.0015261382,0.0016253153,0.0017309374,0.0018434235,0.0019632195,0.0020908006,0.0022266726,0.0023713743,0.0025254795,0.0026895994,0.0028643847,0.0030505286,0.0032487691,0.0034598925,0.0036847358,0.0039241906,0.0041792066,0.0044507950,0.0047400328,0.0050480668,0.0053761186,0.0057254891,0.0060975636,0.0064938176,0.0069158225,0.0073652516,0.0078438871,0.0083536271,0.0088964928,0.009474637,0.010090352,0.010746080,0.011444421,0.012188144,0.012980198,0.013823725,0.014722068,0.015678791,0.016697687,0.017782797,0.018938423,0.020169149,0.021479854,0.022875735,0.024362330,0.025945531,0.027631618,0.029427276,0.031339626,0.033376252,0.035545228,0.037855157,0.040315199,0.042935108,0.045725273,0.048696758,0.051861348,0.055231591,0.058820850,0.062643361,0.066714279,0.071049749,0.075666962,0.080584227,0.085821044,0.091398179,0.097337747,0.10366330,0.11039993,0.11757434,0.12521498,0.13335215,0.14201813,0.15124727,0.16107617,0.17154380,0.18269168,0.19456402,0.20720788,0.22067342,0.23501402,0.25028656,0.26655159,0.28387361,0.30232132,0.32196786,0.34289114,0.36517414,0.38890521,0.41417847,0.44109412,0.46975890,0.50028648,0.53279791,0.56742212,0.60429640,0.64356699,0.68538959,0.72993007,0.77736504,0.82788260,0.88168307,0.9389798,1.0]; kha_audio2_ogg_vorbis_data_Codebook.NO_CODE = 255; kha_audio2_ogg_vorbis_data_Codebook.delay = 0; kha_audio2_ogg_vorbis_data_Header.PACKET_ID = 1; kha_audio2_ogg_vorbis_data_Header.PACKET_COMMENT = 3; kha_audio2_ogg_vorbis_data_Header.PACKET_SETUP = 5; kha_audio2_ogg_vorbis_data_PageFlag.CONTINUED_PACKET = 1; kha_audio2_ogg_vorbis_data_PageFlag.FIRST_PAGE = 2; kha_audio2_ogg_vorbis_data_PageFlag.LAST_PAGE = 4; kha_audio2_ogg_vorbis_data_Setting.MAX_CHANNELS = 16; kha_audio2_ogg_vorbis_data_Setting.PUSHDATA_CRC_COUNT = 4; kha_audio2_ogg_vorbis_data_Setting.FAST_HUFFMAN_LENGTH = 10; kha_audio2_ogg_vorbis_data_Setting.FAST_HUFFMAN_TABLE_SIZE = 1024; kha_audio2_ogg_vorbis_data_Setting.FAST_HUFFMAN_TABLE_MASK = 1023; kha_graphics2_truetype_StbTruetype.STBTT_vmove = 1; kha_graphics2_truetype_StbTruetype.STBTT_vline = 2; kha_graphics2_truetype_StbTruetype.STBTT_vcurve = 3; kha_graphics2_truetype_StbTruetype.STBTT_MACSTYLE_DONTCARE = 0; kha_graphics2_truetype_StbTruetype.STBTT_MACSTYLE_BOLD = 1; kha_graphics2_truetype_StbTruetype.STBTT_MACSTYLE_ITALIC = 2; kha_graphics2_truetype_StbTruetype.STBTT_MACSTYLE_UNDERSCORE = 4; kha_graphics2_truetype_StbTruetype.STBTT_MACSTYLE_NONE = 8; kha_graphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_UNICODE = 0; kha_graphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_MAC = 1; kha_graphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_ISO = 2; kha_graphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_MICROSOFT = 3; kha_graphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_1_0 = 0; kha_graphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_1_1 = 1; kha_graphics2_truetype_StbTruetype.STBTT_UNICODE_EID_ISO_10646 = 2; kha_graphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_2_0_BMP = 3; kha_graphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_2_0_FULL = 4; kha_graphics2_truetype_StbTruetype.STBTT_MS_EID_SYMBOL = 0; kha_graphics2_truetype_StbTruetype.STBTT_MS_EID_UNICODE_BMP = 1; kha_graphics2_truetype_StbTruetype.STBTT_MS_EID_SHIFTJIS = 2; kha_graphics2_truetype_StbTruetype.STBTT_MS_EID_UNICODE_FULL = 10; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_ROMAN = 0; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_ARABIC = 4; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_JAPANESE = 1; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_HEBREW = 5; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_CHINESE_TRAD = 2; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_GREEK = 6; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_KOREAN = 3; kha_graphics2_truetype_StbTruetype.STBTT_MAC_EID_RUSSIAN = 7; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_ENGLISH = 1033; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_ITALIAN = 1040; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_CHINESE = 2052; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_JAPANESE = 1041; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_DUTCH = 1043; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_KOREAN = 1042; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_FRENCH = 1036; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_RUSSIAN = 1049; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_GERMAN = 1031; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_SPANISH = 1033; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_HEBREW = 1037; kha_graphics2_truetype_StbTruetype.STBTT_MS_LANG_SWEDISH = 1053; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_ENGLISH = 0; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_JAPANESE = 11; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_ARABIC = 12; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_KOREAN = 23; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_DUTCH = 4; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_RUSSIAN = 32; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_FRENCH = 1; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_SPANISH = 6; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_GERMAN = 2; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_SWEDISH = 5; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_HEBREW = 10; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_CHINESE_SIMPLIFIED = 33; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_ITALIAN = 3; kha_graphics2_truetype_StbTruetype.STBTT_MAC_LANG_CHINESE_TRAD = 19; kha_graphics2_truetype_StbTruetype.STBTT_MAX_OVERSAMPLE = 8; kha_graphics2_truetype_StbTruetype.STBTT_RASTERIZER_VERSION = 2; kha_graphics4_CubeMap.GL_RGBA16F = 34842; kha_graphics4_CubeMap.GL_RGBA32F = 34836; kha_graphics4_CubeMap.GL_R16F = 33325; kha_graphics4_CubeMap.GL_R32F = 33326; kha_graphics4_CubeMap.GL_DEPTH_COMPONENT24 = 33190; kha_graphics4_CubeMap.GL_DEPTH24_STENCIL8 = 35056; kha_graphics4_CubeMap.GL_DEPTH32F_STENCIL8 = 36013; kha_graphics4_ImageShaderPainter.bufferSize = 1500; kha_graphics4_ImageShaderPainter.vertexSize = 9; kha_graphics4_ColoredShaderPainter.bufferSize = 100; kha_graphics4_ColoredShaderPainter.triangleBufferSize = 100; kha_graphics4_TextShaderPainter.bufferSize = 100; kha_input_Gamepad.__meta__ = { fields : { sendAxisEvent : { input : null}, sendButtonEvent : { input : null}}}; kha_input_Gamepad.instances = []; kha_input_Keyboard.__meta__ = { fields : { sendDownEvent : { input : null}, sendUpEvent : { input : null}}}; kha_input_Mouse.__meta__ = { fields : { sendLeaveEvent : { input : null}, sendDownEvent : { input : null}, sendUpEvent : { input : null}, sendMoveEvent : { input : null}, sendWheelEvent : { input : null}}}; kha_internal_HdrFormat.radiancePattern = new EReg("#\\?RADIANCE","i"); kha_internal_HdrFormat.commentPattern = new EReg("#.*","i"); kha_internal_HdrFormat.gammaPattern = new EReg("GAMMA=","i"); kha_internal_HdrFormat.exposurePattern = new EReg("EXPOSURE=\\s*([0-9]*[.][0-9]*)","i"); kha_internal_HdrFormat.formatPattern = new EReg("FORMAT=32-bit_rle_rgbe","i"); kha_internal_HdrFormat.widthHeightPattern = new EReg("-Y ([0-9]+) \\+X ([0-9]+)","i"); kha_js_AEAudioChannel.todo = []; kha_js_Sound.loading = []; kha_js_Video.loading = new List(); kha_math_FastMatrix3.width = 3; kha_math_FastMatrix3.height = 3; kha_math_FastMatrix4.width = 4; kha_math_FastMatrix4.height = 4; kha_math_Matrix3.width = 3; kha_math_Matrix3.height = 3; kha_math_Matrix4.width = 4; kha_math_Matrix4.height = 4; kha_math_Quaternion.AXIS_X = 0; kha_math_Quaternion.AXIS_Y = 1; kha_math_Quaternion.AXIS_Z = 2; kha_network_ControllerBuilder.nextId = 0; kha_network_Session.START = 0; kha_network_Session.ENTITY_UPDATES = 1; kha_network_Session.CONTROLLER_UPDATES = 2; kha_network_Session.REMOTE_CALL = 3; kha_network_Session.PING = 4; kha_network_Session.ERROR = 5; kha_network_Session.PLAYER_UPDATES = 6; kha_network_Session.RPC_SERVER = 0; kha_network_Session.RPC_ALL = 1; kha_network_SyncBuilder.nextId = 0; kha_network_SyncBuilder.objects = []; zui_Id.i = 0; zui_Themes.light = { _FONT_SIZE : 15, _FONT_SMALL_SIZE : 15, _ELEMENT_W : 100, _ELEMENT_H : 26, _ELEMENT_SEPARATOR_SIZE : 2, _ARROW_W : 9, _ARROW_H : 9, _BUTTON_H : 19, _CHECK_W : 15, _CHECK_H : 15, _CHECK_SELECT_W : 8, _CHECK_SELECT_H : 8, _RADIO_W : 15, _RADIO_H : 15, _RADIO_SELECT_W : 8, _RADIO_SELECT_H : 8, _SCROLL_W : 12, _SCROLL_BAR_W : 8, _DEFAULT_TEXT_OFFSET_X : 8, _TAB_W : 12, _LINE_STRENGTH : 1, WINDOW_BG_COL : -1776412, WINDOW_TINT_COL : -1, SCROLL_BG_COL : -1776412, SCROLL_COL : -15658735, SCROLL_HOVER_COL : -10055985, PANEL_BG1_COL : -16777216, PANEL_BG2_COL : -16777216, PANEL_TEXT_COL : -13421773, PANEL_TEXT_COL_HOVER : -13421773, BUTTON_BG_COL : -11175241, BUTTON_TEXT_COL : -15658735, BUTTON_BG_COL_HOVER : -10055985, BUTTON_BG_COL_PRESSED : -3299061, TEXT_INPUT_BG_COL : -13355978, TEXT_INPUT_BG_COL_HOVER : -12303290, TEXT_CURSOR_COL : -15658735, TEXT_CURSOR_FLASH_SPEED : 0.5, CHECK_COL : -13355978, CHECK_COL_HOVER : -7829368, CHECK_SELECT_COL : -13355978, RADIO_COL : -13355978, RADIO_COL_HOVER : -7829368, RADIO_SELECT_COL : -13355978, SLIDER_COL : -9069865, SLIDER_COL_HOVER : -10055985, TEXT_COL : -15658735, TEXT_COL_HOVER : -15658735, DEFAULT_LABEL_COL : -14540254, ARROW_COL : -4539977, ARROW_COL_HOVER : -3487289, SEPARATOR_COL : -5592406, FILL_WINDOW_BG : true, FILL_TEXT_INPUT_BG : false, FILL_BUTTON_BG : false, FILL_CHECK_BG : false, FILL_RADIO_BG : false, FILL_SLIDER_BG : false}; zui_Themes.dark = { _FONT_SIZE : 15, _FONT_SMALL_SIZE : 15, _ELEMENT_W : 100, _ELEMENT_H : 26, _ELEMENT_SEPARATOR_SIZE : 2, _ARROW_W : 9, _ARROW_H : 9, _BUTTON_H : 19, _CHECK_W : 15, _CHECK_H : 15, _CHECK_SELECT_W : 8, _CHECK_SELECT_H : 8, _RADIO_W : 15, _RADIO_H : 15, _RADIO_SELECT_W : 8, _RADIO_SELECT_H : 8, _SCROLL_W : 12, _SCROLL_BAR_W : 8, _DEFAULT_TEXT_OFFSET_X : 8, _TAB_W : 12, _LINE_STRENGTH : 1, WINDOW_BG_COL : -15658735, WINDOW_TINT_COL : -1, SCROLL_BG_COL : -15724528, SCROLL_COL : -11974327, SCROLL_HOVER_COL : -2894893, PANEL_BG1_COL : -16777216, PANEL_BG2_COL : -16777216, PANEL_TEXT_COL : -1118482, PANEL_TEXT_COL_HOVER : -1118482, BUTTON_BG_COL : -11175241, BUTTON_TEXT_COL : -3487289, BUTTON_BG_COL_HOVER : -10055985, BUTTON_BG_COL_PRESSED : -3299061, TEXT_INPUT_BG_COL : -13355978, TEXT_INPUT_BG_COL_HOVER : -12303290, TEXT_CURSOR_COL : -3487289, TEXT_CURSOR_FLASH_SPEED : 0.5, CHECK_COL : -13355978, CHECK_COL_HOVER : -12303290, CHECK_SELECT_COL : -2697514, RADIO_COL : -13355978, RADIO_COL_HOVER : -12303290, RADIO_SELECT_COL : -2697514, SLIDER_COL : -13355978, SLIDER_COL_HOVER : -12303290, TEXT_COL : -3487289, TEXT_COL_HOVER : -3487289, DEFAULT_LABEL_COL : -5592406, ARROW_COL : -3487289, ARROW_COL_HOVER : -3487289, SEPARATOR_COL : -14540513, FILL_WINDOW_BG : false, FILL_TEXT_INPUT_BG : false, FILL_BUTTON_BG : false, FILL_CHECK_BG : false, FILL_RADIO_BG : false, FILL_SLIDER_BG : false}; zui_Zui.elementsBaked = false; zui_Handle.global = new zui_Handle(); Main.main(); })(typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this, typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this);