Skip to content

Instantly share code, notes, and snippets.

@nanjizal
Created February 23, 2018 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanjizal/77f4b69115e0ad1d9df9bb308f25d517 to your computer and use it in GitHub Desktop.
Save nanjizal/77f4b69115e0ad1d9df9bb308f25d517 to your computer and use it in GitHub Desktop.
less $ _ Hx hx
This file has been truncated, but you can view the full file.
// Generated by Haxe 3.4.2
(function (xExport, $global) { "use strict";
xExport["wings"] = xExport["wings"] || {};
xExport["wings"]["jsCanvas"] = xExport["wings"]["jsCanvas"] || {};
;xExport["wings"]["core"] = xExport["wings"]["core"] || {};
xExport["kha"] = xExport["kha"] || {};
xExport["kha"]["input"] = xExport["kha"]["input"] || {};
;xExport["kha"]["_Color"] = xExport["kha"]["_Color"] || {};
xExport["xPixels"] = xExport["xPixels"] || {};
xExport["xPixels"]["_Pixels"] = xExport["xPixels"]["_Pixels"] || {};
xExport["xDaedalus"] = xExport["xDaedalus"] || {};
xExport["xDaedalus"]["view"] = xExport["xDaedalus"]["view"] || {};
;xExport["xDaedalus"]["iterators"] = xExport["xDaedalus"]["iterators"] || {};
;xExport["xDaedalus"]["factories"] = xExport["xDaedalus"]["factories"] || {};
;xExport["xDaedalus"]["data"] = xExport["xDaedalus"]["data"] || {};
xExport["xDaedalus"]["data"]["math"] = xExport["xDaedalus"]["data"]["math"] || {};
;xExport["xDaedalus"]["data"]["graph"] = xExport["xDaedalus"]["data"]["graph"] || {};
;xExport["xDaedalus"]["ai"] = xExport["xDaedalus"]["ai"] || {};
xExport["xDaedalus"]["ai"]["trajectory"] = xExport["xDaedalus"]["ai"]["trajectory"] || {};
var xClasses = {},$estr = function() { return jsBoot.__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 Basic = function() {
this.localHi = 0;
this.localWid = 0;
kAssets.loadEverything($bind(this,this.loadAll));
};
xClasses["Basic"] = Basic;
Basic.nom = true;
Basic.prototype = {
_mesh: null
,_view: null
,_object: null
,loadAll: function() {
this.setup();
kSystem.notifyOnRender($bind(this,this.render));
kScheduler.addTimeTask($bind(this,this.update),0,0.0166666666666666664);
}
,setup: function() {
this._view = new xDaedalus_view_KSimpleView();
this._mesh = xDaedalus_factories_RectMesh.buildRectangle(600,400);
var vertex = this._mesh.insertVertex(550,50);
var segment = this._mesh.insertConstraintSegment(70,300,530,320);
var shape = this._mesh.insertConstraintShape([50.,50.,100.,50.,100.,50.,100.,100.,100.,100.,50.,100.,50.,100.,50.,50.,20.,50.,130.,100.]);
var objectCoords = [];
this._object = new xDaedalus_data_Object();
this._object.set_coordinates([-50.,0.,50.,0.,0.,-50.,0.,50.,-30.,-30.,30.,30.,30.,-30.,-30.,30.]);
this._mesh.insertObject(this._object);
this._object.set_x(400);
this._object.set_y(200);
this._object.set_scaleX(2);
this._object.set_scaleY(2);
}
,update: function() {
var _g = this._object;
_g.set_rotation(_g.get_rotation() + 0.05);
this._mesh.updateObjects();
}
,renderDaedalus: function(g2) {
this._view.drawMesh(g2,this._mesh);
}
,localWid: null
,localHi: null
,render: function(framebuffer) {
var tmp = Main.hi != this.localHi || Main.wid != this.localWid;
var g2 = framebuffer.get_g2();
g2.begin();
g2.clear(kxColor_ColorxImplx._new(-3355444));
g2.set_color(-1);
g2.set_opacity(1.);
this._view.drawMesh(g2,this._mesh);
g2.end();
}
,__class__: Basic
};
var BitmapPathfinding = function() {
this.localHi = 0;
this.localWid = 0;
this.y = 0;
this.x = 0;
this._newPath = false;
kAssets.loadEverything($bind(this,this.loadAll));
};
xClasses["BitmapPathfinding"] = BitmapPathfinding;
BitmapPathfinding.nom = true;
BitmapPathfinding.prototype = {
imgColor: null
,imgBW: null
,_mesh: null
,_view: null
,_entityAI: null
,_pathfinder: null
,_path: null
,_pathSampler: null
,_newPath: null
,x: null
,y: null
,loadAll: function() {
this.setup();
kSystem.notifyOnRender($bind(this,this.render));
kScheduler.addTimeTask($bind(this,this.update),0,0.0166666666666666664);
kinput_Mouse.get().notify($bind(this,this.onMouseDown),$bind(this,this.onMouseUp),$bind(this,this.onMouseMove),null,null);
}
,setup: function() {
this.imgBW = kAssets.images.galapagosBW;
this.imgColor = kAssets.images.galapagosColor;
var this1 = new xPixels_xPixels_PixelsData(this.imgBW.get_width(),this.imgBW.get_height(),true);
var pixels = this1;
var _g1 = 0;
var _g = this.imgBW.get_height();
while(_g1 < _g) {
var y = _g1++;
var _g3 = 0;
var _g2 = this.imgBW.get_width();
while(_g3 < _g2) {
var x = _g3++;
xPixels_xPixels_PixelsxImplx.setPixel(pixels,x,y,this.imgBW.at(x,y));
}
}
this._mesh = xDaedalus_factories_RectMesh.buildRectangle(1024,780);
this._view = new xDaedalus_view_KSimpleView();
var object = xDaedalus_factories_BitmapObject.buildFromBmpData(pixels,1.8);
object.set_x(0);
object.set_y(0);
this._mesh.insertObject(object);
this._entityAI = new xDaedalus_ai_EntityAI();
this._entityAI.set_radius(4);
this._entityAI.x = 50;
this._entityAI.y = 50;
this._pathfinder = new xDaedalus_ai_PathFinder();
this._pathfinder.entity = this._entityAI;
this._pathfinder.set_mesh(this._mesh);
this._path = [];
this._pathSampler = new xDaedalus_ai_trajectory_LinearPathSampler();
this._pathSampler.entity = this._entityAI;
this._pathSampler.set_samplingDistance(10);
this._pathSampler.set_path(this._path);
}
,onMouseDown: function(button,x_,y_) {
if(button == 0) {
this.x = x_;
this.y = y_;
this._newPath = true;
}
}
,onMouseUp: function(button,x_,y_) {
if(button == 0) {
this.x = x_;
this.y = y_;
this._newPath = false;
}
}
,onMouseMove: function(x_,y_,cx,cy) {
if(this._newPath) {
this.x = x_;
this.y = y_;
}
}
,update: function() {
}
,renderDaedalus: function(g2) {
g2.drawImage(this.imgColor,0,0);
this._view.drawMesh(g2,this._mesh);
if(this._newPath) {
this._pathfinder.findPath(this.x,this.y,this._path);
this._view.drawPath(g2,this._path);
this._view.drawEntity(g2,this._entityAI);
this._pathSampler.reset();
}
if(this._pathSampler.get_hasNext()) {
this._pathSampler.next();
}
this._view.drawEntity(g2,this._entityAI);
}
,localWid: null
,localHi: null
,render: function(framebuffer) {
var tmp = Main.hi != this.localHi || Main.wid != this.localWid;
var g2 = framebuffer.get_g2();
g2.begin();
g2.clear(kxColor_ColorxImplx._new(-3355444));
g2.set_color(-1);
g2.set_opacity(1.);
g2.drawImage(this.imgColor,0,0);
this._view.drawMesh(g2,this._mesh);
if(this._newPath) {
this._pathfinder.findPath(this.x,this.y,this._path);
this._view.drawPath(g2,this._path);
this._view.drawEntity(g2,this._entityAI);
this._pathSampler.reset();
}
if(this._pathSampler.get_hasNext()) {
this._pathSampler.next();
}
this._view.drawEntity(g2,this._entityAI);
g2.end();
}
,__class__: BitmapPathfinding
};
var EReg = function(r,opt) {
this.r = new RegExp(r,opt.split("u").join(""));
};
xClasses["EReg"] = EReg;
EReg.nom = 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 jsxBoot_HaxeError("EReg::matched");
}
}
,__class__: EReg
};
var GridMaze = function() { };
xClasses["GridMaze"] = GridMaze;
GridMaze.nom = true;
GridMaze.generate = function(width,height,cols,rows,seed) {
if(seed == null) {
seed = 7459;
}
GridMaze.tileWidth = width / cols | 0;
GridMaze.tileHeight = height / rows | 0;
GridMaze.cols = cols;
GridMaze.rows = rows;
GridMaze.rng = new xDaedalus_data_math_RandGenerator(seed);
GridMaze.makeGrid();
GridMaze.traverseGrid();
GridMaze.populateObject();
};
GridMaze.makeGrid = function() {
GridMaze.grid = [];
var _g1 = 0;
var _g = GridMaze.cols;
while(_g1 < _g) {
var c = _g1++;
GridMaze.grid[c] = [];
var _g3 = 0;
var _g2 = GridMaze.rows;
while(_g3 < _g2) {
var r = _g3++;
var cell = new Cell(c,r);
GridMaze.grid[c][r] = cell;
var topLeft = [c * GridMaze.tileWidth,r * GridMaze.tileHeight];
var topRight = [(c + 1) * GridMaze.tileWidth,r * GridMaze.tileHeight];
var bottomLeft = [c * GridMaze.tileWidth,(r + 1) * GridMaze.tileHeight];
var bottomRight = [(c + 1) * GridMaze.tileWidth,(r + 1) * GridMaze.tileHeight];
cell.walls[0] = topLeft.concat(topRight);
cell.walls[1] = topRight.concat(bottomRight);
cell.walls[2] = bottomLeft.concat(bottomRight);
if(r != 0 || c != 0) {
cell.walls[3] = topLeft.concat(bottomLeft);
}
}
}
};
GridMaze.traverseGrid = function() {
var DX = [0,1,0,-1];
var DY = [-1,0,1,0];
var REVERSED_DIR = [2,3,0,1];
var c = GridMaze.rng.nextInRange(0,GridMaze.cols - 1);
var r = GridMaze.rng.nextInRange(0,GridMaze.rows - 1);
var cells = [GridMaze.grid[c][r]];
while(cells.length > 0) {
var idx = cells.length - 1;
var currCell = cells[idx];
currCell.visited = true;
var dirs = [0,1,2,3];
GridMaze.rng.shuffle(dirs);
var _g = 0;
while(_g < dirs.length) {
var dir = dirs[_g];
++_g;
var c1 = currCell.col + DX[dir];
var r1 = currCell.row + DY[dir];
if(c1 >= 0 && c1 < GridMaze.cols && r1 >= 0 && r1 < GridMaze.rows && !GridMaze.grid[c1][r1].visited) {
var chosenCell = GridMaze.grid[c1][r1];
currCell.walls[dir] = [];
chosenCell.walls[REVERSED_DIR[dir]] = [];
chosenCell.visited = true;
cells.push(chosenCell);
idx = -1;
break;
}
}
if(idx >= 0) {
cells.splice(idx,1);
}
}
};
GridMaze.populateObject = function() {
GridMaze.object = new xDaedalus_data_Object();
var coords = [];
var _g1 = 0;
var _g = GridMaze.cols;
while(_g1 < _g) {
var c = _g1++;
var _g3 = 0;
var _g2 = GridMaze.rows;
while(_g3 < _g2) {
var r = _g3++;
var cell = GridMaze.grid[c][r];
var _g4 = 0;
var _g5 = cell.walls;
while(_g4 < _g5.length) {
var wall = _g5[_g4];
++_g4;
var _g6 = 0;
while(_g6 < wall.length) {
var coord = wall[_g6];
++_g6;
coords.push(coord);
}
}
}
}
GridMaze.object.set_coordinates(coords);
};
var DIR = function() { };
xClasses["DIR"] = DIR;
DIR.nom = true;
var Cell = function(col,row) {
this.visited = false;
this.col = col;
this.row = row;
var _g = [];
var _g2 = 0;
var _g1 = 4;
while(_g2 < _g1) {
var i = _g2++;
_g.push([]);
}
this.walls = _g;
};
xClasses["Cell"] = Cell;
Cell.nom = true;
Cell.prototype = {
walls: null
,visited: null
,col: null
,row: null
,__class__: Cell
};
var xOverrides = function() { };
xClasses["xOverrides"] = xOverrides;
xOverrides.nom = true;
xOverrides.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 jsxBoot_HaxeError("Invalid date format : " + s);
}
};
xOverrides.cca = function(s,index) {
var x = s.charCodeAt(index);
if(x != x) {
return undefined;
}
return x;
};
xOverrides.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);
};
xOverrides.remove = function(a,obj) {
var i = a.indexOf(obj);
if(i == -1) {
return false;
}
a.splice(i,1);
return true;
};
xOverrides.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() { };
xClasses["Lambda"] = Lambda;
Lambda.nom = 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;
};
xClasses["List"] = List;
List.nom = true;
List.prototype = {
h: null
,q: null
,length: null
,add: function(item) {
var x = new xList_ListNode(item,null);
if(this.h == null) {
this.h = x;
} else {
this.q.next = x;
}
this.q = x;
this.length++;
}
,iterator: function() {
return new xList_ListIterator(this.h);
}
,__class__: List
};
var xList_ListNode = function(item,next) {
this.item = item;
this.next = next;
};
xClasses["_List.ListNode"] = xList_ListNode;
xList_ListNode.nom = true;
xList_ListNode.prototype = {
item: null
,next: null
,__class__: xList_ListNode
};
var xList_ListIterator = function(head) {
this.head = head;
};
xClasses["_List.ListIterator"] = xList_ListIterator;
xList_ListIterator.nom = true;
xList_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__: xList_ListIterator
};
var Main = function() { };
xClasses["Main"] = Main;
Main.nom = true;
Main.main = function() {
var document = window.document;
var $window = window;
document.documentElement.style.padding = "0";
document.documentElement.style.margin = "0";
document.body.style.padding = "0";
document.body.style.margin = "0";
document.body.style.color = "0x9B7031";
var canvas = jsBoot.__cast(document.getElementById("khanvas") , HTMLCanvasElement);
canvas.style.display = "block";
Main.resize = function() {
canvas.width = $window.innerWidth * $window.devicePixelRatio | 0;
canvas.height = $window.innerHeight * $window.devicePixelRatio | 0;
Main.wid = canvas.width / $window.devicePixelRatio | 0;
Main.hi = canvas.height / $window.devicePixelRatio | 0;
canvas.style.width = document.documentElement.clientWidth + "px";
canvas.style.height = document.documentElement.clientHeight + "px";
};
$window.onresize = Main.resize;
Main.resize();
kSystem.init({ title : "xDaedalus Basic", width : 1024, height : 768, samplesPerPixel : 4},function() {
new Basic();
});
};
Math.nom = true;
var Pathfinding = function() {
this.localHi = 0;
this.localWid = 0;
this.y = 0;
this.x = 0;
this._newPath = false;
kAssets.loadEverything($bind(this,this.loadAll));
};
xClasses["Pathfinding"] = Pathfinding;
Pathfinding.nom = true;
Pathfinding.prototype = {
_mesh: null
,_view: null
,_entityAI: null
,_pathfinder: null
,_path: null
,_pathSampler: null
,_newPath: null
,x: null
,y: null
,loadAll: function() {
this.setup();
kSystem.notifyOnRender($bind(this,this.render));
kScheduler.addTimeTask($bind(this,this.update),0,0.0166666666666666664);
kinput_Mouse.get().notify($bind(this,this.onMouseDown),$bind(this,this.onMouseUp),$bind(this,this.onMouseMove),null,null);
}
,setup: function() {
this._mesh = xDaedalus_factories_RectMesh.buildRectangle(600,600);
this._view = new xDaedalus_view_KSimpleView();
var randGen = new xDaedalus_data_math_RandGenerator();
randGen.set_seed(7259);
var object;
var shapeCoords;
var _g = 0;
while(_g < 50) {
var i = _g++;
object = new xDaedalus_data_Object();
shapeCoords = [];
shapeCoords = [-1,-1,1,-1,1,-1,1,1,1,1,-1,1,-1,1,-1,-1];
object.set_coordinates(shapeCoords);
randGen.rangeMin = 10;
randGen.rangeMax = 40;
object.set_scaleX(randGen.next());
object.set_scaleY(randGen.next());
randGen.rangeMin = 0;
randGen.rangeMax = 1000;
object.set_rotation(randGen.next() / 1000 * Math.PI / 2);
randGen.rangeMin = 50;
randGen.rangeMax = 600;
object.set_x(randGen.next());
object.set_y(randGen.next());
this._mesh.insertObject(object);
}
this._entityAI = new xDaedalus_ai_EntityAI();
this._entityAI.set_radius(4);
this._entityAI.x = 20;
this._entityAI.y = 20;
this._pathfinder = new xDaedalus_ai_PathFinder();
this._pathfinder.entity = this._entityAI;
this._pathfinder.set_mesh(this._mesh);
this._path = [];
this._pathSampler = new xDaedalus_ai_trajectory_LinearPathSampler();
this._pathSampler.entity = this._entityAI;
this._pathSampler.set_samplingDistance(10);
this._pathSampler.set_path(this._path);
}
,onMouseDown: function(button,x_,y_) {
if(button == 0) {
this.x = x_;
this.y = y_;
this._newPath = true;
}
}
,onMouseUp: function(button,x_,y_) {
if(button == 0) {
this.x = x_;
this.y = y_;
this._newPath = false;
}
}
,onMouseMove: function(x_,y_,cx,cy) {
if(this._newPath) {
this.x = x_;
this.y = y_;
}
}
,update: function() {
}
,renderDaedalus: function(g2) {
this._view.drawMesh(g2,this._mesh);
if(this._newPath) {
this._pathfinder.findPath(this.x,this.y,this._path);
this._view.drawPath(g2,this._path);
this._view.drawEntity(g2,this._entityAI);
this._pathSampler.reset();
}
if(this._pathSampler.get_hasNext()) {
this._pathSampler.next();
}
this._view.drawEntity(g2,this._entityAI);
}
,localWid: null
,localHi: null
,render: function(framebuffer) {
var tmp = Main.hi != this.localHi || Main.wid != this.localWid;
var g2 = framebuffer.get_g2();
g2.begin();
g2.clear(kxColor_ColorxImplx._new(-3355444));
g2.set_color(-1);
g2.set_opacity(1.);
this._view.drawMesh(g2,this._mesh);
if(this._newPath) {
this._pathfinder.findPath(this.x,this.y,this._path);
this._view.drawPath(g2,this._path);
this._view.drawEntity(g2,this._entityAI);
this._pathSampler.reset();
}
if(this._pathSampler.get_hasNext()) {
this._pathSampler.next();
}
this._view.drawEntity(g2,this._entityAI);
g2.end();
}
,__class__: Pathfinding
};
var PathfindingMaze = function() {
this.localHi = 0;
this.localWid = 0;
this.cols = 15;
this.rows = 15;
this.y = 0;
this.x = 0;
this._newPath = false;
kAssets.loadEverything($bind(this,this.loadAll));
};
xClasses["PathfindingMaze"] = PathfindingMaze;
PathfindingMaze.nom = true;
PathfindingMaze.prototype = {
_mesh: null
,_view: null
,_entityAI: null
,_pathfinder: null
,_path: null
,_pathSampler: null
,_newPath: null
,x: null
,y: null
,rows: null
,cols: null
,loadAll: function() {
this.setup();
kSystem.notifyOnRender($bind(this,this.render));
kScheduler.addTimeTask($bind(this,this.update),0,0.0166666666666666664);
kinput_Mouse.get().notify($bind(this,this.onMouseDown),$bind(this,this.onMouseUp),$bind(this,this.onMouseMove),null,null);
kinput_Keyboard.get().notify(null,null,$bind(this,this.pressListener));
}
,pressListener: function(str) {
if(str == " ") {
this.reset(true);
}
}
,setup: function() {
this._mesh = xDaedalus_factories_RectMesh.buildRectangle(600,600);
this._view = new xDaedalus_view_KSimpleView();
var object;
GridMaze.generate(600,600,this.cols,this.rows);
this._mesh.insertObject(GridMaze.object);
this._view.constraintsWidth = 4;
this._entityAI = new xDaedalus_ai_EntityAI();
this._entityAI.set_radius(GridMaze.tileWidth * .3);
this._entityAI.x = GridMaze.tileWidth / 2;
this._entityAI.y = GridMaze.tileHeight / 2;
this._pathfinder = new xDaedalus_ai_PathFinder();
this._pathfinder.entity = this._entityAI;
this._pathfinder.set_mesh(this._mesh);
this._path = [];
this._pathSampler = new xDaedalus_ai_trajectory_LinearPathSampler();
this._pathSampler.entity = this._entityAI;
this._pathSampler.set_samplingDistance(GridMaze.tileWidth * .7);
this._pathSampler.set_path(this._path);
}
,reset: function(newMaze) {
if(newMaze == null) {
newMaze = false;
}
var seed = Math.random() * 10000 + 1000 | 0;
if(newMaze) {
this._mesh = xDaedalus_factories_RectMesh.buildRectangle(600,600);
GridMaze.generate(600,600,30,30,seed);
GridMaze.object.set_scaleX(.92);
GridMaze.object.set_scaleY(.92);
GridMaze.object.set_x(23);
GridMaze.object.set_y(23);
this._mesh.insertObject(GridMaze.object);
}
this._entityAI.set_radius(GridMaze.tileWidth * .27);
this._pathSampler.set_samplingDistance(GridMaze.tileWidth * .7);
this._pathfinder.set_mesh(this._mesh);
this._entityAI.x = GridMaze.tileWidth / 2;
this._entityAI.y = GridMaze.tileHeight / 2;
this._path = [];
this._pathSampler.set_path(this._path);
}
,onMouseDown: function(button,x_,y_) {
if(button == 0) {
this.x = x_;
this.y = y_;
this._newPath = true;
}
}
,onMouseUp: function(button,x_,y_) {
if(button == 0) {
this.x = x_;
this.y = y_;
this._newPath = false;
}
}
,onMouseMove: function(x_,y_,cx,cy) {
if(this._newPath) {
this.x = x_;
this.y = y_;
}
}
,update: function() {
}
,renderDaedalus: function(g2) {
this._view.drawMesh(g2,this._mesh);
if(this._newPath) {
this._pathfinder.findPath(this.x,this.y,this._path);
this._view.drawPath(g2,this._path);
this._view.drawEntity(g2,this._entityAI);
this._pathSampler.reset();
}
if(this._pathSampler.get_hasNext()) {
this._pathSampler.next();
}
this._view.drawEntity(g2,this._entityAI);
}
,localWid: null
,localHi: null
,render: function(framebuffer) {
var tmp = Main.hi != this.localHi || Main.wid != this.localWid;
var g2 = framebuffer.get_g2();
g2.begin();
g2.clear(kxColor_ColorxImplx._new(-3355444));
g2.set_color(-1);
g2.set_opacity(1.);
this._view.drawMesh(g2,this._mesh);
if(this._newPath) {
this._pathfinder.findPath(this.x,this.y,this._path);
this._view.drawPath(g2,this._path);
this._view.drawEntity(g2,this._entityAI);
this._pathSampler.reset();
}
if(this._pathSampler.get_hasNext()) {
this._pathSampler.next();
}
this._view.drawEntity(g2,this._entityAI);
g2.end();
}
,__class__: PathfindingMaze
};
var Reflect = function() { };
xClasses["Reflect"] = Reflect;
Reflect.nom = true;
Reflect.field = function(o,field) {
try {
return o[field];
} catch( e ) {
return null;
}
};
Reflect.isFunction = function(f) {
if(typeof(f) == "function") {
return !(f.nom || f.__ename__);
} else {
return false;
}
};
var Std = function() { };
xClasses["Std"] = Std;
Std.nom = true;
Std.string = function(s) {
return jsBoot.__string_rec(s,"");
};
Std.parseInt = function(x) {
var v = parseInt(x,10);
if(v == 0 && (xOverrides.cca(x,1) == 120 || xOverrides.cca(x,1) == 88)) {
v = parseInt(x);
}
if(isNaN(v)) {
return null;
}
return v;
};
var StringTools = function() { };
xClasses["StringTools"] = StringTools;
StringTools.nom = true;
StringTools.endsWith = function(s,end) {
var elen = end.length;
var slen = s.length;
if(slen >= elen) {
return xOverrides.substr(s,slen - elen,elen) == end;
} else {
return false;
}
};
StringTools.hex = function(n,digits) {
var s = "";
var hexChars = "0123456789ABCDEF";
while(true) {
s = hexChars.charAt(n & 15) + s;
n >>>= 4;
if(!(n > 0)) {
break;
}
}
if(digits != null) {
while(s.length < digits) s = "0" + s;
}
return s;
};
var Type = function() { };
xClasses["Type"] = Type;
Type.nom = true;
Type.resolveClass = function(name) {
var cl = xClasses[name];
if(cl == null || !cl.nom) {
return null;
}
return cl;
};
Type.resolveEnum = function(name) {
var e = xClasses[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 jsxBoot_HaxeError("No such constructor " + constr);
}
if(Reflect.isFunction(f)) {
if(params == null) {
throw new jsxBoot_HaxeError("Constructor " + constr + " need parameters");
}
return f.apply(e,params);
}
if(params != null && params.length != 0) {
throw new jsxBoot_HaxeError("Constructor " + constr + " does not need parameters");
}
return f;
};
Type.getInstanceFields = function(c) {
var a = [];
for(var i in c.prototype) a.push(i);
xOverrides.remove(a,"__class__");
xOverrides.remove(a,"__properties__");
return a;
};
var xUInt_UIntxImplx = {};
xClasses["_UInt.UInt_Impl_"] = xUInt_UIntxImplx;
xUInt_UIntxImplx.nom = true;
xUInt_UIntxImplx.gt = function(a,b) {
var aNeg = a < 0;
var bNeg = b < 0;
if(aNeg != bNeg) {
return aNeg;
} else {
return a > b;
}
};
xUInt_UIntxImplx.gte = function(a,b) {
var aNeg = a < 0;
var bNeg = b < 0;
if(aNeg != bNeg) {
return aNeg;
} else {
return a >= b;
}
};
xUInt_UIntxImplx.toFloat = function(this1) {
var $int = this1;
if($int < 0) {
return 4294967296.0 + $int;
} else {
return $int + 0.0;
}
};
var haxe_IMap = function() { };
xClasses["haxe.IMap"] = haxe_IMap;
haxe_IMap.nom = true;
haxe_IMap.prototype = {
iterator: null
,__class__: haxe_IMap
};
var haxe_xInt64_xxxInt64 = function(high,low) {
this.high = high;
this.low = low;
};
xClasses["haxe._Int64.___Int64"] = haxe_xInt64_xxxInt64;
haxe_xInt64_xxxInt64.nom = true;
haxe_xInt64_xxxInt64.prototype = {
high: null
,low: null
,__class__: haxe_xInt64_xxxInt64
};
var haxe_Log = function() { };
xClasses["haxe.Log"] = haxe_Log;
haxe_Log.nom = true;
haxe_Log.trace = function(v,infos) {
jsBoot.__trace(v,infos);
};
var haxe_xUnserializer_DefaultResolver = function() {
};
xClasses["haxe._Unserializer.DefaultResolver"] = haxe_xUnserializer_DefaultResolver;
haxe_xUnserializer_DefaultResolver.nom = true;
haxe_xUnserializer_DefaultResolver.prototype = {
resolveClass: function(name) {
return Type.resolveClass(name);
}
,resolveEnum: function(name) {
return Type.resolveEnum(name);
}
,__class__: haxe_xUnserializer_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_xUnserializer_DefaultResolver();
haxe_Unserializer.DEFAULT_RESOLVER = r;
}
this.resolver = r;
};
xClasses["haxe.Unserializer"] = haxe_Unserializer;
haxe_Unserializer.nom = 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(xOverrides.substr(this.buf,p1,this.pos - p1));
}
,unserializeObject: function(o) {
while(true) {
if(this.pos >= this.length) {
throw new jsxBoot_HaxeError("Invalid object");
}
if(this.buf.charCodeAt(this.pos) == 103) {
break;
}
var k = this.unserialize();
if(typeof(k) != "string") {
throw new jsxBoot_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 jsxBoot_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 jsxBoot_HaxeError("Class not found " + name);
}
return cl;
case 66:
var name1 = this.unserialize();
var e = this.resolver.resolveEnum(name1);
if(e == null) {
throw new jsxBoot_HaxeError("Enum not found " + name1);
}
return e;
case 67:
var name2 = this.unserialize();
var cl1 = this.resolver.resolveClass(name2);
if(cl1 == null) {
throw new jsxBoot_HaxeError("Class not found " + name2);
}
var o = Type.createEmptyInstance(cl1);
this.cache.push(o);
o.xUnserialize(this);
if(this.buf.charCodeAt(this.pos++) != 103) {
throw new jsxBoot_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 jsxBoot_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 jsxBoot_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 jsxBoot_HaxeError("Enum not found " + name4);
}
this.pos++;
var index = this.readDigits();
var tag = edecl.__constructs__.slice()[index];
if(tag == null) {
throw new jsxBoot_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 jsxBoot_HaxeError("Invalid IntMap format");
}
return h2;
case 114:
var n2 = this.readDigits();
if(n2 < 0 || n2 >= this.cache.length) {
throw new jsxBoot_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 jsxBoot_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 = xOverrides.strDate(xOverrides.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 jsxBoot_HaxeError("Enum not found " + name5);
}
var e2 = this.unserializeEnum(edecl1,this.unserialize());
this.cache.push(e2);
return e2;
case 120:
throw jsxBoot_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 jsxBoot_HaxeError("Invalid string length");
}
var s2 = xOverrides.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 jsxBoot_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.xBytes = this;
data.bytes = this.b;
};
xClasses["haxe.io.Bytes"] = haxe_io_Bytes;
haxe_io_Bytes.nom = 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.xBytes;
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 jsxBoot_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 jsxBoot_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 jsxBoot_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() { };
xClasses["haxe.crypto.Base64"] = haxe_crypto_Base64;
haxe_crypto_Base64.nom = 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 jsxBoot_HaxeError("BaseCode : base length must be a power of two.");
}
this.base = base;
this.nbits = nbits;
};
xClasses["haxe.crypto.BaseCode"] = haxe_crypto_BaseCode;
haxe_crypto_BaseCode.nom = 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 = { };
};
xClasses["haxe.ds.IntMap"] = haxe_ds_IntMap;
haxe_ds_IntMap.nom = 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 xOverrides.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__ : { }};
};
xClasses["haxe.ds.ObjectMap"] = haxe_ds_ObjectMap;
haxe_ds_ObjectMap.nom = true;
haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap];
haxe_ds_ObjectMap.prototype = {
h: null
,set: function(key,value) {
var id = key.xid || (key.xid = ++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 xOverrides.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.xid];
}};
}
,__class__: haxe_ds_ObjectMap
};
var haxe_ds_xStringMap_StringMapIterator = function(map,keys) {
this.map = map;
this.keys = keys;
this.index = 0;
this.count = keys.length;
};
xClasses["haxe.ds._StringMap.StringMapIterator"] = haxe_ds_xStringMap_StringMapIterator;
haxe_ds_xStringMap_StringMapIterator.nom = true;
haxe_ds_xStringMap_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_xStringMap_StringMapIterator
};
var haxe_ds_StringMap = function() {
this.h = { };
};
xClasses["haxe.ds.StringMap"] = haxe_ds_StringMap;
haxe_ds_StringMap.nom = 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_xStringMap_StringMapIterator(this,this.arrayKeys());
}
,__class__: haxe_ds_StringMap
};
var haxe_io_BytesBuffer = function() {
this.b = [];
};
xClasses["haxe.io.BytesBuffer"] = haxe_io_BytesBuffer;
haxe_io_BytesBuffer.nom = 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() { };
xClasses["haxe.io.Input"] = haxe_io_Input;
haxe_io_Input.nom = true;
haxe_io_Input.prototype = {
bigEndian: null
,readByte: function() {
throw new jsxBoot_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 jsxBoot_HaxeError(haxe_io_Error.OutsideBounds);
}
try {
while(k > 0) {
b[pos] = this.readByte();
++pos;
--k;
}
} catch( eof ) {
if (eof instanceof jsxBoot_HaxeError) eof = eof.val;
if( jsBoot.__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 jsxBoot_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 jsxBoot_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 jsxBoot_HaxeError(haxe_io_Error.OutsideBounds);
}
this.b = b.b;
this.pos = pos;
this.len = len;
this.totlen = len;
};
xClasses["haxe.io.BytesInput"] = haxe_io_BytesInput;
haxe_io_BytesInput.nom = 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 jsxBoot_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 jsxBoot_HaxeError(haxe_io_Error.OutsideBounds);
}
if(this.len == 0 && len > 0) {
throw new jsxBoot_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() { };
xClasses["haxe.io.Output"] = haxe_io_Output;
haxe_io_Output.nom = true;
haxe_io_Output.prototype = {
bigEndian: null
,writeByte: function(c) {
throw new jsxBoot_HaxeError("Not implemented");
}
,writeBytes: function(s,pos,len) {
if(pos < 0 || len < 0 || pos + len > s.length) {
throw new jsxBoot_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 jsxBoot_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();
};
xClasses["haxe.io.BytesOutput"] = haxe_io_BytesOutput;
haxe_io_BytesOutput.nom = 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 jsxBoot_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() {
};
xClasses["haxe.io.Eof"] = haxe_io_Eof;
haxe_io_Eof.nom = true;
haxe_io_Eof.prototype = {
toString: function() {
return "Eof";
}
,__class__: haxe_io_Eof
};
var haxe_io_Error = xClasses["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() { };
xClasses["haxe.io.FPHelper"] = haxe_io_FPHelper;
haxe_io_FPHelper.nom = 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_xUInt8Array_UInt8ArrayxImplx = {};
xClasses["haxe.io._UInt8Array.UInt8Array_Impl_"] = haxe_io_xUInt8Array_UInt8ArrayxImplx;
haxe_io_xUInt8Array_UInt8ArrayxImplx.nom = true;
haxe_io_xUInt8Array_UInt8ArrayxImplx.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 xDaedalus_ai_AStar = xExport["xDaedalus"]["ai"]["AStar"] = function() {
this.iterEdge = new xDaedalus_iterators_FromFaceToInnerEdges();
};
xClasses["xDaedalus.ai.AStar"] = xDaedalus_ai_AStar;
xDaedalus_ai_AStar.nom = true;
xDaedalus_ai_AStar.prototype = {
_radius: null
,_mesh: null
,closedFaces: null
,sortedOpenedFaces: null
,openedFaces: null
,entryEdges: null
,entryX: null
,entryY: null
,scoreF: null
,scoreG: null
,scoreH: null
,predecessor: null
,iterEdge: null
,radiusSquared: null
,diameter: null
,diameterSquared: null
,fromFace: null
,toFace: null
,curFace: null
,dispose: function() {
this._mesh = null;
this.closedFaces = null;
this.sortedOpenedFaces = null;
this.openedFaces = null;
this.entryEdges = null;
this.entryX = null;
this.entryY = null;
this.scoreF = null;
this.scoreG = null;
this.scoreH = null;
this.predecessor = null;
}
,get_radius: function() {
return this._radius;
}
,set_radius: function(value) {
this._radius = value;
this.radiusSquared = this._radius * this._radius;
this.diameter = this._radius * 2;
this.diameterSquared = this.diameter * this.diameter;
return value;
}
,set_mesh: function(value) {
this._mesh = value;
return value;
}
,findPath: function(fromX,fromY,toX,toY,resultListFaces,resultListEdges) {
this.closedFaces = new haxe_ds_ObjectMap();
this.sortedOpenedFaces = [];
this.openedFaces = new haxe_ds_ObjectMap();
this.entryEdges = new haxe_ds_ObjectMap();
this.entryX = new haxe_ds_ObjectMap();
this.entryY = new haxe_ds_ObjectMap();
this.scoreF = new haxe_ds_ObjectMap();
this.scoreG = new haxe_ds_ObjectMap();
this.scoreH = new haxe_ds_ObjectMap();
this.predecessor = new haxe_ds_ObjectMap();
var loc;
var locEdge;
var locVertex;
var distance;
var p1;
var p2;
var p3;
loc = xDaedalus_data_math_Geom2D.locatePosition(fromX,fromY,this._mesh);
switch(loc[1]) {
case 0:
var vertex = loc[2];
locVertex = vertex;
return;
case 1:
var edge = loc[2];
locEdge = edge;
if(locEdge.get_isConstrained()) {
return;
}
this.fromFace = locEdge.get_leftFace();
break;
case 2:
var face = loc[2];
this.fromFace = face;
break;
case 3:
break;
}
loc = xDaedalus_data_math_Geom2D.locatePosition(toX,toY,this._mesh);
switch(loc[1]) {
case 0:
var vertex1 = loc[2];
locVertex = vertex1;
this.toFace = locVertex.get_edge().get_leftFace();
break;
case 1:
var edge1 = loc[2];
locEdge = edge1;
this.toFace = locEdge.get_leftFace();
break;
case 2:
var face1 = loc[2];
this.toFace = face1;
break;
case 3:
break;
}
this.sortedOpenedFaces.push(this.fromFace);
this.entryEdges.set(this.fromFace,null);
this.entryX.set(this.fromFace,fromX);
this.entryY.set(this.fromFace,fromY);
this.scoreG.set(this.fromFace,0);
var dist = Math.sqrt((toX - fromX) * (toX - fromX) + (toY - fromY) * (toY - fromY));
this.scoreH.set(this.fromFace,dist);
this.scoreF.set(this.fromFace,dist);
var innerEdge;
var neighbourFace;
var f;
var g;
var h;
var fromPoint = new xDaedalus_data_math_Point2D();
var entryPoint = new xDaedalus_data_math_Point2D();
var distancePoint = new xDaedalus_data_math_Point2D();
var fillDatas;
while(true) {
if(this.sortedOpenedFaces.length == 0) {
this.curFace = null;
break;
}
this.curFace = this.sortedOpenedFaces.pop();
if(this.curFace == this.toFace) {
break;
}
this.iterEdge.set_fromFace(this.curFace);
while(true) {
innerEdge = this.iterEdge.next();
if(!(innerEdge != null)) {
break;
}
if(innerEdge.get_isConstrained()) {
continue;
}
neighbourFace = innerEdge.get_rightFace();
if(!this.closedFaces.h[neighbourFace.xid]) {
if(this.curFace != this.fromFace && this._radius > 0 && !this.isWalkableByRadius(this.entryEdges.h[this.curFace.xid],this.curFace,innerEdge)) {
continue;
}
fromPoint.x = this.entryX.h[this.curFace.xid];
fromPoint.y = this.entryY.h[this.curFace.xid];
entryPoint.x = (innerEdge.get_originVertex().get_pos().x + innerEdge.get_destinationVertex().get_pos().x) / 2;
entryPoint.y = (innerEdge.get_originVertex().get_pos().y + innerEdge.get_destinationVertex().get_pos().y) / 2;
distancePoint.x = entryPoint.x - toX;
distancePoint.y = entryPoint.y - toY;
h = distancePoint.get_length();
distancePoint.x = fromPoint.x - entryPoint.x;
distancePoint.y = fromPoint.y - entryPoint.y;
g = this.scoreG.h[this.curFace.xid] + distancePoint.get_length();
f = h + g;
fillDatas = false;
if(this.openedFaces.h[neighbourFace.xid] == null || !this.openedFaces.h[neighbourFace.xid]) {
this.sortedOpenedFaces.push(neighbourFace);
this.openedFaces.set(neighbourFace,true);
fillDatas = true;
} else if(this.scoreF.h[neighbourFace.xid] > f) {
fillDatas = true;
}
if(fillDatas) {
this.entryEdges.set(neighbourFace,innerEdge);
var v = entryPoint.x;
this.entryX.set(neighbourFace,v);
var v1 = entryPoint.y;
this.entryY.set(neighbourFace,v1);
this.scoreF.set(neighbourFace,f);
this.scoreG.set(neighbourFace,g);
this.scoreH.set(neighbourFace,h);
var v2 = this.curFace;
this.predecessor.set(neighbourFace,v2);
}
}
}
this.openedFaces.set(this.curFace,false);
this.closedFaces.set(this.curFace,true);
this.sortedOpenedFaces.sort($bind(this,this.sortingFaces));
}
if(this.curFace == null) {
return;
}
resultListFaces.push(this.curFace);
while(this.curFace != this.fromFace) {
resultListEdges.unshift(this.entryEdges.h[this.curFace.xid]);
this.curFace = this.predecessor.h[this.curFace.xid];
resultListFaces.unshift(this.curFace);
}
}
,sortingFaces: function(a,b) {
if(this.scoreF.h[a.xid] == this.scoreF.h[b.xid]) {
return 0;
} else if(this.scoreF.h[a.xid] < this.scoreF.h[b.xid]) {
return 1;
} else {
return -1;
}
}
,isWalkableByRadius: function(fromEdge,throughFace,toEdge) {
var vA = null;
var vB = null;
var vC = null;
if(fromEdge.get_originVertex() == toEdge.get_originVertex()) {
vA = fromEdge.get_destinationVertex();
vB = toEdge.get_destinationVertex();
vC = fromEdge.get_originVertex();
} else if(fromEdge.get_destinationVertex() == toEdge.get_destinationVertex()) {
vA = fromEdge.get_originVertex();
vB = toEdge.get_originVertex();
vC = fromEdge.get_destinationVertex();
} else if(fromEdge.get_originVertex() == toEdge.get_destinationVertex()) {
vA = fromEdge.get_destinationVertex();
vB = toEdge.get_originVertex();
vC = fromEdge.get_originVertex();
} else if(fromEdge.get_destinationVertex() == toEdge.get_originVertex()) {
vA = fromEdge.get_originVertex();
vB = toEdge.get_destinationVertex();
vC = fromEdge.get_destinationVertex();
}
var dot;
var result;
var distSquared;
dot = (vC.get_pos().x - vA.get_pos().x) * (vB.get_pos().x - vA.get_pos().x) + (vC.get_pos().y - vA.get_pos().y) * (vB.get_pos().y - vA.get_pos().y);
if(dot <= 0) {
distSquared = (vC.get_pos().x - vA.get_pos().x) * (vC.get_pos().x - vA.get_pos().x) + (vC.get_pos().y - vA.get_pos().y) * (vC.get_pos().y - vA.get_pos().y);
if(distSquared >= this.diameterSquared) {
return true;
} else {
return false;
}
}
dot = (vC.get_pos().x - vB.get_pos().x) * (vA.get_pos().x - vB.get_pos().x) + (vC.get_pos().y - vB.get_pos().y) * (vA.get_pos().y - vB.get_pos().y);
if(dot <= 0) {
distSquared = (vC.get_pos().x - vB.get_pos().x) * (vC.get_pos().x - vB.get_pos().x) + (vC.get_pos().y - vB.get_pos().y) * (vC.get_pos().y - vB.get_pos().y);
if(distSquared >= this.diameterSquared) {
return true;
} else {
return false;
}
}
var adjEdge;
if(throughFace.get_edge() != fromEdge && throughFace.get_edge().get_oppositeEdge() != fromEdge && throughFace.get_edge() != toEdge && throughFace.get_edge().get_oppositeEdge() != toEdge) {
adjEdge = throughFace.get_edge();
} else if(throughFace.get_edge().get_nextLeftEdge() != fromEdge && throughFace.get_edge().get_nextLeftEdge().get_oppositeEdge() != fromEdge && throughFace.get_edge().get_nextLeftEdge() != toEdge && throughFace.get_edge().get_nextLeftEdge().get_oppositeEdge() != toEdge) {
adjEdge = throughFace.get_edge().get_nextLeftEdge();
} else {
adjEdge = throughFace.get_edge().get_prevLeftEdge();
}
if(adjEdge.get_isConstrained()) {
var proj = new xDaedalus_data_math_Point2D(vC.get_pos().x,vC.get_pos().y);
xDaedalus_data_math_Geom2D.projectOrthogonaly(proj,adjEdge);
distSquared = (proj.x - vC.get_pos().x) * (proj.x - vC.get_pos().x) + (proj.y - vC.get_pos().y) * (proj.y - vC.get_pos().y);
if(distSquared >= this.diameterSquared) {
return true;
} else {
return false;
}
} else {
var distSquaredA = (vC.get_pos().x - vA.get_pos().x) * (vC.get_pos().x - vA.get_pos().x) + (vC.get_pos().y - vA.get_pos().y) * (vC.get_pos().y - vA.get_pos().y);
var distSquaredB = (vC.get_pos().x - vB.get_pos().x) * (vC.get_pos().x - vB.get_pos().x) + (vC.get_pos().y - vB.get_pos().y) * (vC.get_pos().y - vB.get_pos().y);
if(distSquaredA < this.diameterSquared || distSquaredB < this.diameterSquared) {
return false;
} else {
var vFaceToCheck = [];
var vFaceIsFromEdge = [];
var facesDone = new haxe_ds_ObjectMap();
vFaceIsFromEdge.push(adjEdge);
if(adjEdge.get_leftFace() == throughFace) {
vFaceToCheck.push(adjEdge.get_rightFace());
facesDone.set(adjEdge.get_rightFace(),true);
} else {
vFaceToCheck.push(adjEdge.get_leftFace());
facesDone.set(adjEdge.get_leftFace(),true);
}
var currFace;
var faceFromEdge;
var currEdgeA;
var nextFaceA;
var currEdgeB;
var nextFaceB;
while(vFaceToCheck.length > 0) {
currFace = vFaceToCheck.shift();
faceFromEdge = vFaceIsFromEdge.shift();
if(currFace.get_edge() == faceFromEdge || currFace.get_edge() == faceFromEdge.get_oppositeEdge()) {
currEdgeA = currFace.get_edge().get_nextLeftEdge();
currEdgeB = currFace.get_edge().get_nextLeftEdge().get_nextLeftEdge();
} else if(currFace.get_edge().get_nextLeftEdge() == faceFromEdge || currFace.get_edge().get_nextLeftEdge() == faceFromEdge.get_oppositeEdge()) {
currEdgeA = currFace.get_edge();
currEdgeB = currFace.get_edge().get_nextLeftEdge().get_nextLeftEdge();
} else {
currEdgeA = currFace.get_edge();
currEdgeB = currFace.get_edge().get_nextLeftEdge();
}
if(currEdgeA.get_leftFace() == currFace) {
nextFaceA = currEdgeA.get_rightFace();
} else {
nextFaceA = currEdgeA.get_leftFace();
}
if(currEdgeB.get_leftFace() == currFace) {
nextFaceB = currEdgeB.get_rightFace();
} else {
nextFaceB = currEdgeB.get_leftFace();
}
if(!facesDone.h[nextFaceA.xid] && xDaedalus_data_math_Geom2D.distanceSquaredVertexToEdge(vC,currEdgeA) < this.diameterSquared) {
if(currEdgeA.get_isConstrained()) {
return false;
} else {
vFaceToCheck.push(nextFaceA);
vFaceIsFromEdge.push(currEdgeA);
facesDone.set(nextFaceA,true);
}
}
if(!facesDone.h[nextFaceB.xid] && xDaedalus_data_math_Geom2D.distanceSquaredVertexToEdge(vC,currEdgeB) < this.diameterSquared) {
if(currEdgeB.get_isConstrained()) {
return false;
} else {
vFaceToCheck.push(nextFaceB);
vFaceIsFromEdge.push(currEdgeB);
facesDone.set(nextFaceB,true);
}
}
}
return true;
}
}
}
,__class__: xDaedalus_ai_AStar
};
var xDaedalus_ai_EntityAI = xExport["xDaedalus"]["ai"]["EntityAI"] = function() {
this._radius = 10;
this.x = this.y = 0;
this.dirNormX = 1;
this.dirNormY = 0;
};
xClasses["xDaedalus.ai.EntityAI"] = xDaedalus_ai_EntityAI;
xDaedalus_ai_EntityAI.nom = true;
xDaedalus_ai_EntityAI.prototype = {
dirNormY: null
,dirNormX: null
,y: null
,x: null
,_radius: null
,_radiusSquared: null
,_x: null
,_y: null
,_dirNormX: null
,_dirNormY: null
,_approximateObject: null
,buildApproximation: function() {
this._approximateObject = new xDaedalus_data_Object();
this._approximateObject.get_matrix().translate(this.x,this.y);
var coordinates = [];
this._approximateObject.set_coordinates(coordinates);
if(this._radius == 0) {
return;
}
var _g = 0;
while(_g < 6) {
var i = _g++;
coordinates.push(this._radius * Math.cos(2 * Math.PI * i / 6));
coordinates.push(this._radius * Math.sin(2 * Math.PI * i / 6));
coordinates.push(this._radius * Math.cos(2 * Math.PI * (i + 1) / 6));
coordinates.push(this._radius * Math.sin(2 * Math.PI * (i + 1) / 6));
}
}
,get_approximateObject: function() {
this._approximateObject.get_matrix().identity();
this._approximateObject.get_matrix().translate(this.x,this.y);
return this._approximateObject;
}
,get_radius: function() {
return this._radius;
}
,get_radiusSquared: function() {
return this._radiusSquared;
}
,set_radius: function(value) {
this._radius = value;
this._radiusSquared = this._radius * this._radius;
return value;
}
,__class__: xDaedalus_ai_EntityAI
};
var xDaedalus_ai_Funnel = xExport["xDaedalus"]["ai"]["Funnel"] = function() {
this._currPoolPointsIndex = 0;
this._poolPointsSize = 3000;
this._numSamplesCircle = 16;
this._radiusSquared = 0;
this._radius = 0;
this._poolPoints = [];
var _g1 = 0;
var _g = this._poolPointsSize;
while(_g1 < _g) {
var i = _g1++;
this._poolPoints.push(new xDaedalus_data_math_Point2D());
}
};
xClasses["xDaedalus.ai.Funnel"] = xDaedalus_ai_Funnel;
xDaedalus_ai_Funnel.nom = true;
xDaedalus_ai_Funnel.prototype = {
_radius: null
,_radiusSquared: null
,_numSamplesCircle: null
,_sampleCircle: null
,_sampleCircleDistanceSquared: null
,dispose: function() {
this._sampleCircle = null;
}
,_poolPointsSize: null
,_poolPoints: null
,_currPoolPointsIndex: null
,__point: null
,getPoint: function(x,y) {
if(y == null) {
y = 0;
}
if(x == null) {
x = 0;
}
this.__point = this._poolPoints[this._currPoolPointsIndex];
this.__point.setXY(x,y);
this._currPoolPointsIndex++;
if(this._currPoolPointsIndex == this._poolPointsSize) {
this._poolPoints.push(new xDaedalus_data_math_Point2D());
this._poolPointsSize++;
}
return this.__point;
}
,getCopyPoint: function(pointToCopy) {
return this.getPoint(pointToCopy.x,pointToCopy.y);
}
,get_radius: function() {
return this._radius;
}
,set_radius: function(value) {
this._radius = Math.max(0,value);
this._radiusSquared = this._radius * this._radius;
this._sampleCircle = [];
if(this.get_radius() == 0) {
return 0;
}
var _g1 = 0;
var _g = this._numSamplesCircle;
while(_g1 < _g) {
var i = _g1++;
this._sampleCircle.push(new xDaedalus_data_math_Point2D(this._radius * Math.cos(-2 * Math.PI * i / this._numSamplesCircle),this._radius * Math.sin(-2 * Math.PI * i / this._numSamplesCircle)));
}
this._sampleCircleDistanceSquared = (this._sampleCircle[0].x - this._sampleCircle[1].x) * (this._sampleCircle[0].x - this._sampleCircle[1].x) + (this._sampleCircle[0].y - this._sampleCircle[1].y) * (this._sampleCircle[0].y - this._sampleCircle[1].y);
return this._radius;
}
,findPath: function(fromX,fromY,toX,toY,listFaces,listEdges,resultPath) {
this._currPoolPointsIndex = 0;
if(this._radius > 0) {
var checkFace = listFaces[0];
var distanceSquared;
var distance;
var p1;
var p2;
var p3;
p1 = checkFace.get_edge().get_originVertex().get_pos();
p2 = checkFace.get_edge().get_destinationVertex().get_pos();
p3 = checkFace.get_edge().get_nextLeftEdge().get_destinationVertex().get_pos();
distanceSquared = (p1.x - fromX) * (p1.x - fromX) + (p1.y - fromY) * (p1.y - fromY);
if(distanceSquared <= this._radiusSquared) {
distance = Math.sqrt(distanceSquared);
fromX = this._radius * 1.01 * ((fromX - p1.x) / distance) + p1.x;
fromY = this._radius * 1.01 * ((fromY - p1.y) / distance) + p1.y;
} else {
distanceSquared = (p2.x - fromX) * (p2.x - fromX) + (p2.y - fromY) * (p2.y - fromY);
if(distanceSquared <= this._radiusSquared) {
distance = Math.sqrt(distanceSquared);
fromX = this._radius * 1.01 * ((fromX - p2.x) / distance) + p2.x;
fromY = this._radius * 1.01 * ((fromY - p2.y) / distance) + p2.y;
} else {
distanceSquared = (p3.x - fromX) * (p3.x - fromX) + (p3.y - fromY) * (p3.y - fromY);
if(distanceSquared <= this._radiusSquared) {
distance = Math.sqrt(distanceSquared);
fromX = this._radius * 1.01 * ((fromX - p3.x) / distance) + p3.x;
fromY = this._radius * 1.01 * ((fromY - p3.y) / distance) + p3.y;
}
}
}
checkFace = listFaces[listFaces.length - 1];
p1 = checkFace.get_edge().get_originVertex().get_pos();
p2 = checkFace.get_edge().get_destinationVertex().get_pos();
p3 = checkFace.get_edge().get_nextLeftEdge().get_destinationVertex().get_pos();
distanceSquared = (p1.x - toX) * (p1.x - toX) + (p1.y - toY) * (p1.y - toY);
if(distanceSquared <= this._radiusSquared) {
distance = Math.sqrt(distanceSquared);
toX = this._radius * 1.01 * ((toX - p1.x) / distance) + p1.x;
toY = this._radius * 1.01 * ((toY - p1.y) / distance) + p1.y;
} else {
distanceSquared = (p2.x - toX) * (p2.x - toX) + (p2.y - toY) * (p2.y - toY);
if(distanceSquared <= this._radiusSquared) {
distance = Math.sqrt(distanceSquared);
toX = this._radius * 1.01 * ((toX - p2.x) / distance) + p2.x;
toY = this._radius * 1.01 * ((toY - p2.y) / distance) + p2.y;
} else {
distanceSquared = (p3.x - toX) * (p3.x - toX) + (p3.y - toY) * (p3.y - toY);
if(distanceSquared <= this._radiusSquared) {
distance = Math.sqrt(distanceSquared);
toX = this._radius * 1.01 * ((toX - p3.x) / distance) + p3.x;
toY = this._radius * 1.01 * ((toY - p3.y) / distance) + p3.y;
}
}
}
}
var startPoint;
var endPoint;
startPoint = new xDaedalus_data_math_Point2D(fromX,fromY);
endPoint = new xDaedalus_data_math_Point2D(toX,toY);
if(listFaces.length == 1) {
resultPath.push(startPoint.x);
resultPath.push(startPoint.y);
resultPath.push(endPoint.x);
resultPath.push(endPoint.y);
return;
}
var i;
var j;
var k;
var currEdge = null;
var currVertex = null;
var direction;
var _g = xDaedalus_data_math_Geom2D.isInFace(fromX,fromY,listFaces[0]);
if(_g[1] == 1) {
var edge = _g[2];
if(listEdges[0] == edge) {
listEdges.shift();
listFaces.shift();
}
}
var funnelLeft = [];
var funnelRight = [];
funnelLeft.push(startPoint);
funnelRight.push(startPoint);
var verticesDoneSide = new haxe_ds_ObjectMap();
var pointsList = [];
var pointSides = new haxe_ds_ObjectMap();
var pointSuccessor = new haxe_ds_ObjectMap();
pointSides.set(startPoint,0);
currEdge = listEdges[0];
var relativPos = xDaedalus_data_math_Geom2D.getRelativePosition2(fromX,fromY,currEdge);
var prevPoint;
var newPointA;
var newPointB;
newPointA = this.getCopyPoint(currEdge.get_destinationVertex().get_pos());
newPointB = this.getCopyPoint(currEdge.get_originVertex().get_pos());
pointsList.push(newPointA);
pointsList.push(newPointB);
pointSuccessor.set(startPoint,newPointA);
pointSuccessor.set(newPointA,newPointB);
prevPoint = newPointB;
if(relativPos == 1) {
pointSides.set(newPointA,1);
pointSides.set(newPointB,-1);
verticesDoneSide.set(currEdge.get_destinationVertex(),1);
verticesDoneSide.set(currEdge.get_originVertex(),-1);
} else if(relativPos == -1) {
pointSides.set(newPointA,-1);
pointSides.set(newPointB,1);
verticesDoneSide.set(currEdge.get_destinationVertex(),-1);
verticesDoneSide.set(currEdge.get_originVertex(),1);
}
var fromVertex = listEdges[0].get_originVertex();
var fromFromVertex = listEdges[0].get_destinationVertex();
var _g2 = 1;
var _g1 = listEdges.length;
while(_g2 < _g1) {
var i1 = _g2++;
currEdge = listEdges[i1];
if(currEdge.get_originVertex() == fromVertex) {
currVertex = currEdge.get_destinationVertex();
} else if(currEdge.get_destinationVertex() == fromVertex) {
currVertex = currEdge.get_originVertex();
} else if(currEdge.get_originVertex() == fromFromVertex) {
currVertex = currEdge.get_destinationVertex();
fromVertex = fromFromVertex;
} else if(currEdge.get_destinationVertex() == fromFromVertex) {
currVertex = currEdge.get_originVertex();
fromVertex = fromFromVertex;
}
newPointA = this.getCopyPoint(currVertex.get_pos());
pointsList.push(newPointA);
direction = -verticesDoneSide.h[fromVertex.xid];
pointSides.set(newPointA,direction);
pointSuccessor.set(prevPoint,newPointA);
verticesDoneSide.set(currVertex,direction);
prevPoint = newPointA;
fromFromVertex = fromVertex;
fromVertex = currVertex;
}
pointSuccessor.set(prevPoint,endPoint);
pointSides.set(endPoint,0);
var pathPoints = [];
var pathSides = new haxe_ds_ObjectMap();
pathPoints.push(startPoint);
pathSides.set(startPoint,0);
var currPos;
var _g21 = 0;
var _g11 = pointsList.length;
while(_g21 < _g11) {
var i2 = _g21++;
currPos = pointsList[i2];
if(pointSides.h[currPos.xid] == -1) {
j = funnelLeft.length - 2;
while(j >= 0) {
direction = xDaedalus_data_math_Geom2D.getDirection(funnelLeft[j].x,funnelLeft[j].y,funnelLeft[j + 1].x,funnelLeft[j + 1].y,currPos.x,currPos.y);
if(direction != -1) {
funnelLeft.shift();
var _g4 = 0;
var _g3 = j;
while(_g4 < _g3) {
var k1 = _g4++;
pathPoints.push(funnelLeft[0]);
pathSides.set(funnelLeft[0],1);
funnelLeft.shift();
}
pathPoints.push(funnelLeft[0]);
pathSides.set(funnelLeft[0],1);
funnelRight.splice(0,funnelRight.length);
funnelRight.push(funnelLeft[0]);
funnelRight.push(currPos);
break;
}
--j;
}
funnelRight.push(currPos);
j = funnelRight.length - 3;
while(j >= 0) {
direction = xDaedalus_data_math_Geom2D.getDirection(funnelRight[j].x,funnelRight[j].y,funnelRight[j + 1].x,funnelRight[j + 1].y,currPos.x,currPos.y);
if(direction == -1) {
break;
} else {
funnelRight.splice(j + 1,1);
}
--j;
}
} else {
j = funnelRight.length - 2;
while(j >= 0) {
direction = xDaedalus_data_math_Geom2D.getDirection(funnelRight[j].x,funnelRight[j].y,funnelRight[j + 1].x,funnelRight[j + 1].y,currPos.x,currPos.y);
if(direction != 1) {
funnelRight.shift();
var _g41 = 0;
var _g31 = j;
while(_g41 < _g31) {
var k2 = _g41++;
pathPoints.push(funnelRight[0]);
pathSides.set(funnelRight[0],-1);
funnelRight.shift();
}
pathPoints.push(funnelRight[0]);
pathSides.set(funnelRight[0],-1);
funnelLeft.splice(0,funnelLeft.length);
funnelLeft.push(funnelRight[0]);
funnelLeft.push(currPos);
break;
}
--j;
}
funnelLeft.push(currPos);
j = funnelLeft.length - 3;
while(j >= 0) {
direction = xDaedalus_data_math_Geom2D.getDirection(funnelLeft[j].x,funnelLeft[j].y,funnelLeft[j + 1].x,funnelLeft[j + 1].y,currPos.x,currPos.y);
if(direction == 1) {
break;
} else {
funnelLeft.splice(j + 1,1);
}
--j;
}
}
}
var blocked = false;
j = funnelRight.length - 2;
while(j >= 0) {
direction = xDaedalus_data_math_Geom2D.getDirection(funnelRight[j].x,funnelRight[j].y,funnelRight[j + 1].x,funnelRight[j + 1].y,toX,toY);
if(direction != 1) {
funnelRight.shift();
var _g22 = 0;
var _g12 = j + 1;
while(_g22 < _g12) {
var k3 = _g22++;
pathPoints.push(funnelRight[0]);
pathSides.set(funnelRight[0],-1);
funnelRight.shift();
}
pathPoints.push(endPoint);
pathSides.set(endPoint,0);
blocked = true;
break;
}
--j;
}
if(!blocked) {
j = funnelLeft.length - 2;
while(j >= 0) {
direction = xDaedalus_data_math_Geom2D.getDirection(funnelLeft[j].x,funnelLeft[j].y,funnelLeft[j + 1].x,funnelLeft[j + 1].y,toX,toY);
if(direction != -1) {
funnelLeft.shift();
var _g23 = 0;
var _g13 = j + 1;
while(_g23 < _g13) {
var k4 = _g23++;
pathPoints.push(funnelLeft[0]);
pathSides.set(funnelLeft[0],1);
funnelLeft.shift();
}
pathPoints.push(endPoint);
pathSides.set(endPoint,0);
blocked = true;
break;
}
--j;
}
}
if(!blocked) {
pathPoints.push(endPoint);
pathSides.set(endPoint,0);
blocked = true;
}
var adjustedPoints = [];
if(this.get_radius() > 0) {
var newPath = [];
if(pathPoints.length == 2) {
this.adjustWithTangents(pathPoints[0],false,pathPoints[1],false,pointSides,pointSuccessor,newPath,adjustedPoints);
} else if(pathPoints.length > 2) {
this.adjustWithTangents(pathPoints[0],false,pathPoints[1],true,pointSides,pointSuccessor,newPath,adjustedPoints);
if(pathPoints.length > 3) {
var _g24 = 1;
var _g14 = pathPoints.length - 3 + 1;
while(_g24 < _g14) {
var i3 = _g24++;
this.adjustWithTangents(pathPoints[i3],true,pathPoints[i3 + 1],true,pointSides,pointSuccessor,newPath,adjustedPoints);
}
}
var pathLength = pathPoints.length;
this.adjustWithTangents(pathPoints[pathLength - 2],true,pathPoints[pathLength - 1],false,pointSides,pointSuccessor,newPath,adjustedPoints);
}
newPath.push(endPoint);
this.checkAdjustedPath(newPath,adjustedPoints,pointSides);
var smoothPoints = [];
i = newPath.length - 2;
while(i >= 1) {
this.smoothAngle(adjustedPoints[i * 2 - 1],newPath[i],adjustedPoints[i * 2],pointSides.h[newPath[i].xid],smoothPoints);
while(smoothPoints.length != 0) {
var temp = i * 2;
adjustedPoints.splice(temp,0);
var x = smoothPoints.pop();
adjustedPoints.splice(temp,0,x);
}
--i;
}
} else {
adjustedPoints = pathPoints;
}
var _g25 = 0;
var _g15 = adjustedPoints.length;
while(_g25 < _g15) {
var i4 = _g25++;
resultPath.push(adjustedPoints[i4].x);
resultPath.push(adjustedPoints[i4].y);
}
}
,adjustWithTangents: function(p1,applyRadiusToP1,p2,applyRadiusToP2,pointSides,pointSuccessor,newPath,adjustedPoints) {
var tangentsResult = [];
var side1 = pointSides.h[p1.xid];
var side2 = pointSides.h[p2.xid];
var pTangent1 = null;
var pTangent2 = null;
if(!applyRadiusToP1 && !applyRadiusToP2) {
pTangent1 = p1;
pTangent2 = p2;
} else if(!applyRadiusToP1) {
if(xDaedalus_data_math_Geom2D.tangentsPointToCircle(p1.x,p1.y,p2.x,p2.y,this._radius,tangentsResult)) {
if(side2 == 1) {
pTangent1 = p1;
pTangent2 = this.getPoint(tangentsResult[2],tangentsResult[3]);
} else {
pTangent1 = p1;
pTangent2 = this.getPoint(tangentsResult[0],tangentsResult[1]);
}
} else {
return;
}
} else if(!applyRadiusToP2) {
if(xDaedalus_data_math_Geom2D.tangentsPointToCircle(p2.x,p2.y,p1.x,p1.y,this._radius,tangentsResult)) {
if(tangentsResult.length > 0) {
if(side1 == 1) {
pTangent1 = this.getPoint(tangentsResult[0],tangentsResult[1]);
pTangent2 = p2;
} else {
pTangent1 = this.getPoint(tangentsResult[2],tangentsResult[3]);
pTangent2 = p2;
}
}
} else {
return;
}
} else if(side1 == 1 && side2 == 1) {
xDaedalus_data_math_Geom2D.tangentsParalCircleToCircle(this._radius,p1.x,p1.y,p2.x,p2.y,tangentsResult);
pTangent1 = this.getPoint(tangentsResult[2],tangentsResult[3]);
pTangent2 = this.getPoint(tangentsResult[4],tangentsResult[5]);
} else if(side1 == -1 && side2 == -1) {
xDaedalus_data_math_Geom2D.tangentsParalCircleToCircle(this._radius,p1.x,p1.y,p2.x,p2.y,tangentsResult);
pTangent1 = this.getPoint(tangentsResult[0],tangentsResult[1]);
pTangent2 = this.getPoint(tangentsResult[6],tangentsResult[7]);
} else if(side1 == 1 && side2 == -1) {
if(xDaedalus_data_math_Geom2D.tangentsCrossCircleToCircle(this._radius,p1.x,p1.y,p2.x,p2.y,tangentsResult)) {
pTangent1 = this.getPoint(tangentsResult[2],tangentsResult[3]);
pTangent2 = this.getPoint(tangentsResult[6],tangentsResult[7]);
} else {
return;
}
} else if(xDaedalus_data_math_Geom2D.tangentsCrossCircleToCircle(this._radius,p1.x,p1.y,p2.x,p2.y,tangentsResult)) {
pTangent1 = this.getPoint(tangentsResult[0],tangentsResult[1]);
pTangent2 = this.getPoint(tangentsResult[4],tangentsResult[5]);
} else {
return;
}
var successor = pointSuccessor.h[p1.xid];
var distance;
while(successor != p2) {
distance = xDaedalus_data_math_Geom2D.distanceSquaredPointToSegment(successor.x,successor.y,pTangent1.x,pTangent1.y,pTangent2.x,pTangent2.y);
if(distance < this._radiusSquared) {
this.adjustWithTangents(p1,applyRadiusToP1,successor,true,pointSides,pointSuccessor,newPath,adjustedPoints);
this.adjustWithTangents(successor,true,p2,applyRadiusToP2,pointSides,pointSuccessor,newPath,adjustedPoints);
return;
} else {
successor = pointSuccessor.h[successor.xid];
}
}
adjustedPoints.push(pTangent1);
adjustedPoints.push(pTangent2);
newPath.push(p1);
}
,checkAdjustedPath: function(newPath,adjustedPoints,pointSides) {
var needCheck = true;
var point0;
var point0Side;
var point1;
var point1Side;
var point2;
var point2Side;
var pt1;
var pt2;
var pt3;
var dot;
var tangentsResult = [];
var pTangent1 = null;
var pTangent2 = null;
while(needCheck) {
needCheck = false;
var i = 2;
while(i < newPath.length) {
point2 = newPath[i];
point2Side = pointSides.h[point2.xid];
point1 = newPath[i - 1];
point1Side = pointSides.h[point1.xid];
point0 = newPath[i - 2];
point0Side = pointSides.h[point0.xid];
if(point1Side == point2Side) {
pt1 = adjustedPoints[(i - 2) * 2];
pt2 = adjustedPoints[(i - 1) * 2 - 1];
pt3 = adjustedPoints[(i - 1) * 2];
dot = (pt1.x - pt2.x) * (pt3.x - pt2.x) + (pt1.y - pt2.y) * (pt3.y - pt2.y);
if(dot > 0) {
if(i == 2) {
xDaedalus_data_math_Geom2D.tangentsPointToCircle(point0.x,point0.y,point2.x,point2.y,this._radius,tangentsResult);
if(point2Side == 1) {
pTangent1 = point0;
pTangent2 = this.getPoint(tangentsResult[2],tangentsResult[3]);
} else {
pTangent1 = point0;
pTangent2 = this.getPoint(tangentsResult[0],tangentsResult[1]);
}
} else if(i == newPath.length - 1) {
xDaedalus_data_math_Geom2D.tangentsPointToCircle(point2.x,point2.y,point0.x,point0.y,this._radius,tangentsResult);
if(point0Side == 1) {
pTangent1 = this.getPoint(tangentsResult[0],tangentsResult[1]);
pTangent2 = point2;
} else {
pTangent1 = this.getPoint(tangentsResult[2],tangentsResult[3]);
pTangent2 = point2;
}
} else if(point0Side == 1 && point2Side == -1) {
xDaedalus_data_math_Geom2D.tangentsCrossCircleToCircle(this._radius,point0.x,point0.y,point2.x,point2.y,tangentsResult);
pTangent1 = this.getPoint(tangentsResult[2],tangentsResult[3]);
pTangent2 = this.getPoint(tangentsResult[6],tangentsResult[7]);
} else if(point0Side == -1 && point2Side == 1) {
xDaedalus_data_math_Geom2D.tangentsCrossCircleToCircle(this._radius,point0.x,point0.y,point2.x,point2.y,tangentsResult);
pTangent1 = this.getPoint(tangentsResult[0],tangentsResult[1]);
pTangent2 = this.getPoint(tangentsResult[4],tangentsResult[5]);
} else if(point0Side == 1 && point2Side == 1) {
xDaedalus_data_math_Geom2D.tangentsParalCircleToCircle(this._radius,point0.x,point0.y,point2.x,point2.y,tangentsResult);
pTangent1 = this.getPoint(tangentsResult[2],tangentsResult[3]);
pTangent2 = this.getPoint(tangentsResult[4],tangentsResult[5]);
} else if(point0Side == -1 && point2Side == -1) {
xDaedalus_data_math_Geom2D.tangentsParalCircleToCircle(this._radius,point0.x,point0.y,point2.x,point2.y,tangentsResult);
pTangent1 = this.getPoint(tangentsResult[0],tangentsResult[1]);
pTangent2 = this.getPoint(tangentsResult[6],tangentsResult[7]);
}
var temp = (i - 2) * 2;
adjustedPoints.splice(temp,1);
adjustedPoints.splice(temp,0,pTangent1);
temp = i * 2 - 1;
adjustedPoints.splice(temp,1);
adjustedPoints.splice(temp,0,pTangent2);
newPath.splice(i - 1,1);
adjustedPoints.splice((i - 1) * 2 - 1,2);
tangentsResult.splice(0,tangentsResult.length);
--i;
}
}
++i;
}
}
}
,smoothAngle: function(prevPoint,pointToSmooth,nextPoint,side,encirclePoints) {
var angleType = xDaedalus_data_math_Geom2D.getDirection(prevPoint.x,prevPoint.y,pointToSmooth.x,pointToSmooth.y,nextPoint.x,nextPoint.y);
var distanceSquared = (prevPoint.x - nextPoint.x) * (prevPoint.x - nextPoint.x) + (prevPoint.y - nextPoint.y) * (prevPoint.y - nextPoint.y);
if(distanceSquared <= this._sampleCircleDistanceSquared) {
return;
}
var index = 0;
var side1;
var side2;
var pointInArea;
var xToCheck;
var yToCheck;
var _g1 = 0;
var _g = this._numSamplesCircle;
while(_g1 < _g) {
var i = _g1++;
pointInArea = false;
xToCheck = pointToSmooth.x + this._sampleCircle[i].x;
yToCheck = pointToSmooth.y + this._sampleCircle[i].y;
side1 = xDaedalus_data_math_Geom2D.getDirection(prevPoint.x,prevPoint.y,pointToSmooth.x,pointToSmooth.y,xToCheck,yToCheck);
side2 = xDaedalus_data_math_Geom2D.getDirection(pointToSmooth.x,pointToSmooth.y,nextPoint.x,nextPoint.y,xToCheck,yToCheck);
if(side == 1) {
if(angleType == -1) {
if(side1 == -1 && side2 == -1) {
pointInArea = true;
}
} else if(side1 == -1 || side2 == -1) {
pointInArea = true;
}
} else if(angleType == 1) {
if(side1 == 1 && side2 == 1) {
pointInArea = true;
}
} else if(side1 == 1 || side2 == 1) {
pointInArea = true;
}
if(pointInArea) {
encirclePoints.splice(index,0);
var x = new xDaedalus_data_math_Point2D(xToCheck,yToCheck);
encirclePoints.splice(index,0,x);
++index;
} else {
index = 0;
}
}
if(side == -1) {
encirclePoints.reverse();
}
}
,__class__: xDaedalus_ai_Funnel
};
var xDaedalus_ai_PathFinder = xExport["xDaedalus"]["ai"]["PathFinder"] = function() {
this.astar = new xDaedalus_ai_AStar();
this.funnel = new xDaedalus_ai_Funnel();
this.listFaces = [];
this.listEdges = [];
};
xClasses["xDaedalus.ai.PathFinder"] = xDaedalus_ai_PathFinder;
xDaedalus_ai_PathFinder.nom = true;
xDaedalus_ai_PathFinder.prototype = {
entity: null
,_mesh: null
,astar: null
,funnel: null
,radius: null
,listFaces: null
,listEdges: null
,dispose: function() {
this._mesh = null;
this.astar.dispose();
this.astar = null;
this.funnel.dispose();
this.funnel = null;
this.listEdges = null;
this.listFaces = null;
}
,get_mesh: function() {
return this._mesh;
}
,set_mesh: function(value) {
this._mesh = value;
this.astar.set_mesh(this._mesh);
return value;
}
,findPath: function(toX,toY,resultPath) {
resultPath.splice(0,resultPath.length);
var cond = this._mesh == null;
var cond1 = this.entity == null;
if(xDaedalus_data_math_Geom2D.isCircleIntersectingAnyConstraint(toX,toY,this.entity.get_radius(),this._mesh)) {
return;
}
this.astar.set_radius(this.entity.get_radius());
this.funnel.set_radius(this.entity.get_radius());
this.listFaces.splice(0,this.listFaces.length);
this.listEdges.splice(0,this.listEdges.length);
this.astar.findPath(this.entity.x,this.entity.y,toX,toY,this.listFaces,this.listEdges);
if(this.listFaces.length == 0) {
return;
}
this.funnel.findPath(this.entity.x,this.entity.y,toX,toY,this.listFaces,this.listEdges,resultPath);
}
,__class__: xDaedalus_ai_PathFinder
};
var xDaedalus_ai_trajectory_LinearPathSampler = xExport["xDaedalus"]["ai"]["trajectory"]["LinearPathSampler"] = function() {
this._samplingDistanceSquared = 1;
this._samplingDistance = 1;
this._preCompX = [];
this._preCompY = [];
};
xClasses["xDaedalus.ai.trajectory.LinearPathSampler"] = xDaedalus_ai_trajectory_LinearPathSampler;
xDaedalus_ai_trajectory_LinearPathSampler.nom = true;
xDaedalus_ai_trajectory_LinearPathSampler.pythag = function(a,b) {
return Math.sqrt(a * a + b * b);
};
xDaedalus_ai_trajectory_LinearPathSampler.prototype = {
entity: null
,_entity: null
,_currentX: null
,_currentY: null
,_hasPrev: null
,_hasNext: null
,_samplingDistance: null
,_samplingDistanceSquared: null
,_path: null
,_iPrev: null
,_iNext: null
,_preComputed: null
,_count: null
,_preCompX: null
,_preCompY: null
,dispose: function() {
this.entity = null;
this._path = null;
this._preCompX = null;
this._preCompY = null;
}
,get_x: function() {
return this._currentX;
}
,get_y: function() {
return this._currentY;
}
,get_hasPrev: function() {
return this._hasPrev;
}
,get_hasNext: function() {
return this._hasNext;
}
,get_count: function() {
return this._count;
}
,set_count: function(value) {
this._count = value;
if(this._count < 0) {
this._count = 0;
}
if(this._count > this.get_countMax() - 1) {
this._count = this.get_countMax() - 1;
}
this._hasPrev = this._count == 0 ? false : true;
this._hasNext = this._count == this.get_countMax() - 1 ? false : true;
this._currentX = this._preCompX[this._count];
this._currentY = this._preCompY[this._count];
this.updateEntity();
return this._count;
}
,get_countMax: function() {
return this._preCompX.length - 1;
}
,get_samplingDistance: function() {
return this._samplingDistance;
}
,set_samplingDistance: function(value) {
this._samplingDistance = value;
this._samplingDistanceSquared = this._samplingDistance * this._samplingDistance;
return value;
}
,set_path: function(value) {
this._path = value;
this._preComputed = false;
this.reset();
return value;
}
,reset: function() {
if(this._path.length > 0) {
var cond = (this._path.length & 1) == 0;
this._currentX = this._path[0];
this._currentY = this._path[1];
this._iPrev = 0;
this._iNext = 2;
this._hasPrev = false;
this._hasNext = true;
this._count = 0;
this.updateEntity();
} else {
this._hasPrev = false;
this._hasNext = false;
this._count = 0;
}
}
,preCompute: function() {
this._preCompX.splice(0,this._preCompX.length);
this._preCompY.splice(0,this._preCompY.length);
this._count = 0;
this._preCompX.push(this._currentX);
this._preCompY.push(this._currentY);
this._preComputed = false;
while(this.next()) {
this._preCompX.push(this._currentX);
this._preCompY.push(this._currentY);
}
this.reset();
this._preComputed = true;
}
,prev: function() {
if(!this._hasPrev) {
return false;
}
this._hasNext = true;
if(this._preComputed) {
this._count--;
if(this._count == 0) {
this._hasPrev = false;
}
this._currentX = this._preCompX[this._count];
this._currentY = this._preCompY[this._count];
this.updateEntity();
return true;
}
var remainingDist = this._samplingDistance;
var dist = 0;
while(true) {
var pathPrev = this._path[this._iPrev];
var pathPrev1 = this._path[this._iPrev + 1];
var a = this._currentX - pathPrev;
var b = this._currentY - pathPrev1;
dist = Math.sqrt(a * a + b * b);
if(dist < remainingDist) {
remainingDist -= dist;
this._iPrev -= 2;
this._iNext -= 2;
if(this._iNext == 0) {
break;
}
} else {
break;
}
}
if(this._iNext == 0) {
this._currentX = this._path[0];
this._currentY = this._path[1];
this._hasPrev = false;
this._iNext = 2;
this._iPrev = 0;
this.updateEntity();
return true;
} else {
this._currentX += (this._path[this._iPrev] - this._currentX) * remainingDist / dist;
this._currentY += (this._path[this._iPrev + 1] - this._currentY) * remainingDist / dist;
this.updateEntity();
return true;
}
}
,next: function() {
if(!this._hasNext) {
return false;
}
this._hasPrev = true;
if(this._preComputed) {
this._count++;
if(this._count == this._preCompX.length - 1) {
this._hasNext = false;
}
this._currentX = this._preCompX[this._count];
this._currentY = this._preCompY[this._count];
this.updateEntity();
return true;
}
var remainingDist = this._samplingDistance;
var dist = 0;
while(true) {
var pathNext = this._path[this._iNext];
var pathNext1 = this._path[this._iNext + 1];
var a = this._currentX - pathNext;
var b = this._currentY - pathNext1;
dist = Math.sqrt(a * a + b * b);
if(dist < remainingDist) {
remainingDist -= dist;
this._currentX = this._path[this._iNext];
this._currentY = this._path[this._iNext + 1];
this._iPrev += 2;
this._iNext += 2;
if(this._iNext == this._path.length) {
break;
}
} else {
break;
}
}
if(this._iNext == this._path.length) {
this._currentX = this._path[this._iPrev];
this._currentY = this._path[this._iPrev + 1];
this._hasNext = false;
this._iNext = this._path.length - 2;
this._iPrev = this._iNext - 2;
this.updateEntity();
return true;
} else {
this._currentX += (this._path[this._iNext] - this._currentX) * remainingDist / dist;
this._currentY += (this._path[this._iNext + 1] - this._currentY) * remainingDist / dist;
this.updateEntity();
return true;
}
}
,updateEntity: function() {
if(this.entity == null) {
return;
}
var cond = isNaN(this._currentX) && isNaN(this._currentY);
this.entity.x = this._currentX;
this.entity.y = this._currentY;
}
,__class__: xDaedalus_ai_trajectory_LinearPathSampler
};
var xDaedalus_data_Constants = xExport["xDaedalus"]["data"]["Constants"] = function() { };
xClasses["xDaedalus.data.Constants"] = xDaedalus_data_Constants;
xDaedalus_data_Constants.nom = true;
var xDaedalus_data_ConstraintSegment = xExport["xDaedalus"]["data"]["ConstraintSegment"] = function() {
this._id = xDaedalus_data_ConstraintSegment.INC;
xDaedalus_data_ConstraintSegment.INC++;
this._edges = [];
};
xClasses["xDaedalus.data.ConstraintSegment"] = xDaedalus_data_ConstraintSegment;
xDaedalus_data_ConstraintSegment.nom = true;
xDaedalus_data_ConstraintSegment.prototype = {
fromShape: null
,_id: null
,_edges: null
,get_id: function() {
return this._id;
}
,addEdge: function(edge) {
if(this._edges.indexOf(edge) == -1 && this._edges.indexOf(edge.get_oppositeEdge()) == -1) {
this._edges.push(edge);
}
}
,removeEdge: function(edge) {
var index = this._edges.indexOf(edge);
if(index == -1) {
index = this._edges.indexOf(edge.get_oppositeEdge());
}
if(index != -1) {
this._edges.splice(index,1);
}
}
,get_edges: function() {
return this._edges;
}
,dispose: function() {
this._edges = null;
this.fromShape = null;
}
,toString: function() {
return "seg_id " + this._id;
}
,__class__: xDaedalus_data_ConstraintSegment
};
var xDaedalus_data_ConstraintShape = xExport["xDaedalus"]["data"]["ConstraintShape"] = function() {
this._id = xDaedalus_data_ConstraintShape.INC;
xDaedalus_data_ConstraintShape.INC++;
this.segments = [];
};
xClasses["xDaedalus.data.ConstraintShape"] = xDaedalus_data_ConstraintShape;
xDaedalus_data_ConstraintShape.nom = true;
xDaedalus_data_ConstraintShape.prototype = {
segments: null
,_id: null
,get_id: function() {
return this._id;
}
,dispose: function() {
while(this.segments.length > 0) this.segments.pop().dispose();
this.segments = null;
}
,__class__: xDaedalus_data_ConstraintShape
};
var xDaedalus_data_Edge = xExport["xDaedalus"]["data"]["Edge"] = function() {
this.colorDebug = -1;
this._id = xDaedalus_data_Edge.INC;
xDaedalus_data_Edge.INC++;
this.fromConstraintSegments = [];
};
xClasses["xDaedalus.data.Edge"] = xDaedalus_data_Edge;
xDaedalus_data_Edge.nom = true;
xDaedalus_data_Edge.prototype = {
fromConstraintSegments: null
,_id: null
,_isReal: null
,_isConstrained: null
,_originVertex: null
,_oppositeEdge: null
,_nextLeftEdge: null
,_leftFace: null
,colorDebug: null
,get_id: function() {
return this._id;
}
,get_isReal: function() {
return this._isReal;
}
,get_isConstrained: function() {
return this._isConstrained;
}
,setDatas: function(originVertex,oppositeEdge,nextLeftEdge,leftFace,isReal,isConstrained) {
if(isConstrained == null) {
isConstrained = false;
}
if(isReal == null) {
isReal = true;
}
this._isConstrained = isConstrained;
this._isReal = isReal;
this._originVertex = originVertex;
this._oppositeEdge = oppositeEdge;
this._nextLeftEdge = nextLeftEdge;
this._leftFace = leftFace;
}
,addFromConstraintSegment: function(segment) {
if(this.fromConstraintSegments.indexOf(segment) == -1) {
this.fromConstraintSegments.push(segment);
}
}
,removeFromConstraintSegment: function(segment) {
var index = this.fromConstraintSegments.indexOf(segment);
if(index != -1) {
this.fromConstraintSegments.splice(index,1);
}
}
,set_originVertex: function(value) {
this._originVertex = value;
return value;
}
,set_nextLeftEdge: function(value) {
this._nextLeftEdge = value;
return value;
}
,set_leftFace: function(value) {
this._leftFace = value;
return value;
}
,set_isConstrained: function(value) {
this._isConstrained = value;
return value;
}
,dispose: function() {
this._originVertex = null;
this._oppositeEdge = null;
this._nextLeftEdge = null;
this._leftFace = null;
this.fromConstraintSegments = null;
}
,get_originVertex: function() {
return this._originVertex;
}
,get_destinationVertex: function() {
return this.get_oppositeEdge().get_originVertex();
}
,get_oppositeEdge: function() {
return this._oppositeEdge;
}
,get_nextLeftEdge: function() {
return this._nextLeftEdge;
}
,get_prevLeftEdge: function() {
return this._nextLeftEdge.get_nextLeftEdge();
}
,get_nextRightEdge: function() {
return this._oppositeEdge.get_nextLeftEdge().get_nextLeftEdge().get_oppositeEdge();
}
,get_prevRightEdge: function() {
return this._oppositeEdge.get_nextLeftEdge().get_oppositeEdge();
}
,get_rotLeftEdge: function() {
return this._nextLeftEdge.get_nextLeftEdge().get_oppositeEdge();
}
,get_rotRightEdge: function() {
return this._oppositeEdge.get_nextLeftEdge();
}
,get_leftFace: function() {
return this._leftFace;
}
,get_rightFace: function() {
return this._oppositeEdge.get_leftFace();
}
,toString: function() {
return "edge " + this.get_originVertex().get_id() + " - " + this.get_destinationVertex().get_id();
}
,__class__: xDaedalus_data_Edge
};
var xDaedalus_data_Face = xExport["xDaedalus"]["data"]["Face"] = function() {
this.colorDebug = -1;
this._id = xDaedalus_data_Face.INC;
xDaedalus_data_Face.INC++;
};
xClasses["xDaedalus.data.Face"] = xDaedalus_data_Face;
xDaedalus_data_Face.nom = true;
xDaedalus_data_Face.prototype = {
_id: null
,_isReal: null
,_edge: null
,colorDebug: null
,get_id: function() {
return this._id;
}
,get_isReal: function() {
return this._isReal;
}
,set_datas: function(edge) {
this._isReal = true;
this._edge = edge;
}
,setDatas: function(edge,isReal) {
if(isReal == null) {
isReal = true;
}
this._isReal = isReal;
this._edge = edge;
}
,dispose: function() {
this._edge = null;
}
,get_edge: function() {
return this._edge;
}
,__class__: xDaedalus_data_Face
};
var xDaedalus_data_Mesh = xExport["xDaedalus"]["data"]["Mesh"] = function(width,height) {
this.__objectsUpdateInProgress = false;
this.__edgesToCheck = null;
this.__centerVertex = null;
this._objects = null;
this._constraintShapes = null;
this._faces = null;
this._edges = null;
this._vertices = null;
this._clipping = false;
this._height = 0;
this._width = 0;
this._id = xDaedalus_data_Mesh.INC;
xDaedalus_data_Mesh.INC++;
this._width = width;
this._height = height;
this._clipping = true;
this._vertices = [];
this._edges = [];
this._faces = [];
this._constraintShapes = [];
this._objects = [];
this.__edgesToCheck = [];
};
xClasses["xDaedalus.data.Mesh"] = xDaedalus_data_Mesh;
xDaedalus_data_Mesh.nom = true;
xDaedalus_data_Mesh.prototype = {
_id: null
,_width: null
,_height: null
,_clipping: null
,_vertices: null
,_edges: null
,_faces: null
,_constraintShapes: null
,_objects: null
,__centerVertex: null
,__edgesToCheck: null
,get_height: function() {
return this._height;
}
,get_width: function() {
return this._width;
}
,get_clipping: function() {
return this._clipping;
}
,set_clipping: function(value) {
this._clipping = value;
return value;
}
,get_id: function() {
return this._id;
}
,dispose: function() {
while(this._vertices.length > 0) this._vertices.pop().dispose();
this._vertices = null;
while(this._edges.length > 0) this._edges.pop().dispose();
this._edges = null;
while(this._faces.length > 0) this._faces.pop().dispose();
this._faces = null;
while(this._constraintShapes.length > 0) this._constraintShapes.pop().dispose();
this._constraintShapes = null;
while(this._objects.length > 0) this._objects.pop().dispose();
this._objects = null;
this.__edgesToCheck = null;
this.__centerVertex = null;
}
,get___constraintShapes: function() {
return this._constraintShapes;
}
,buildFromRecord: function(rec) {
var positions = rec.split(";");
var i = 0;
while(i < positions.length) {
this.insertConstraintSegment(parseFloat(positions[i]),parseFloat(positions[i + 1]),parseFloat(positions[i + 2]),parseFloat(positions[i + 3]));
i += 4;
}
}
,insertObject: function(object) {
if(object.get_constraintShape() != null) {
this.deleteObject(object);
}
var shape = new xDaedalus_data_ConstraintShape();
var segment;
var coordinates = object.get_coordinates();
var m = object.get_matrix();
object.updateMatrixFromValues();
var x1;
var y1;
var x2;
var y2;
var transfx1;
var transfy1;
var transfx2;
var transfy2;
var i = 0;
while(i < coordinates.length) {
x1 = coordinates[i];
y1 = coordinates[i + 1];
x2 = coordinates[i + 2];
y2 = coordinates[i + 3];
transfx1 = m.transformX(x1,y1);
transfy1 = m.transformY(x1,y1);
transfx2 = m.transformX(x2,y2);
transfy2 = m.transformY(x2,y2);
segment = this.insertConstraintSegment(transfx1,transfy1,transfx2,transfy2);
if(segment != null) {
segment.fromShape = shape;
shape.segments.push(segment);
}
i += 4;
}
this._constraintShapes.push(shape);
object.set_constraintShape(shape);
if(!this.__objectsUpdateInProgress) {
this._objects.push(object);
}
}
,deleteObject: function(object) {
if(object.get_constraintShape() == null) {
return;
}
this.deleteConstraintShape(object.get_constraintShape());
object.set_constraintShape(null);
if(!this.__objectsUpdateInProgress) {
var index = this._objects.indexOf(object);
this._objects.splice(index,1);
}
}
,__objectsUpdateInProgress: null
,updateObjects: function() {
this.__objectsUpdateInProgress = true;
var _g1 = 0;
var _g = this._objects.length;
while(_g1 < _g) {
var i = _g1++;
if(this._objects[i].get_hasChanged()) {
this.deleteObject(this._objects[i]);
this.insertObject(this._objects[i]);
this._objects[i].set_hasChanged(false);
}
}
this.__objectsUpdateInProgress = false;
}
,insertConstraintShape: function(coordinates) {
var shape = new xDaedalus_data_ConstraintShape();
var segment = null;
var i = 0;
while(i < coordinates.length) {
segment = this.insertConstraintSegment(coordinates[i],coordinates[i + 1],coordinates[i + 2],coordinates[i + 3]);
if(segment != null) {
segment.fromShape = shape;
shape.segments.push(segment);
}
i += 4;
}
this._constraintShapes.push(shape);
return shape;
}
,deleteConstraintShape: function(shape) {
var _g1 = 0;
var _g = shape.segments.length;
while(_g1 < _g) {
var i = _g1++;
this.deleteConstraintSegment(shape.segments[i]);
}
shape.dispose();
this._constraintShapes.splice(this._constraintShapes.indexOf(shape),1);
}
,insertConstraintSegment: function(x1,y1,x2,y2) {
var p1pos = this.findPositionFromBounds(x1,y1);
var p2pos = this.findPositionFromBounds(x2,y2);
var newX1 = x1;
var newY1 = y1;
var newX2 = x2;
var newY2 = y2;
if(this._clipping && (p1pos != 0 || p2pos != 0)) {
var intersectPoint = new xDaedalus_data_math_Point2D();
if(p1pos != 0 && p2pos != 0) {
if(x1 <= 0 && x2 <= 0 || x1 >= this._width && x2 >= this._width || y1 <= 0 && y2 <= 0 || y1 >= this._height && y2 >= this._height) {
return null;
}
if(p1pos == 8 && p2pos == 4 || p1pos == 4 && p2pos == 8) {
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,0,this._height,intersectPoint);
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,this._width,0,this._width,this._height,intersectPoint);
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
} else if(p1pos == 2 && p2pos == 6 || p1pos == 6 && p2pos == 2) {
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,this._width,0,intersectPoint);
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,this._height,this._width,this._height,intersectPoint);
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
} else if(p1pos == 2 && p2pos == 8 || p1pos == 8 && p2pos == 2) {
if(xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,this._width,0,intersectPoint)) {
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,0,this._height,intersectPoint);
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
} else {
return null;
}
} else if(p1pos == 2 && p2pos == 4 || p1pos == 4 && p2pos == 2) {
if(xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,this._width,0,intersectPoint)) {
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,this._width,0,this._width,this._height,intersectPoint);
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
} else {
return null;
}
} else if(p1pos == 6 && p2pos == 4 || p1pos == 4 && p2pos == 6) {
if(xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,this._height,this._width,this._height,intersectPoint)) {
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,this._width,0,this._width,this._height,intersectPoint);
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
} else {
return null;
}
} else if(p1pos == 8 && p2pos == 6 || p1pos == 6 && p2pos == 8) {
if(xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,this._height,this._width,this._height,intersectPoint)) {
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,0,this._height,intersectPoint);
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
} else {
return null;
}
} else {
var firstDone = false;
var secondDone = false;
if(xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,this._width,0,intersectPoint)) {
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
firstDone = true;
}
if(xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,this._width,0,this._width,this._height,intersectPoint)) {
if(!firstDone) {
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
firstDone = true;
} else {
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
secondDone = true;
}
}
if(!secondDone && xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,this._height,this._width,this._height,intersectPoint)) {
if(!firstDone) {
newX1 = intersectPoint.x;
newY1 = intersectPoint.y;
firstDone = true;
} else {
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
secondDone = true;
}
}
if(!secondDone && xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,0,this._height,intersectPoint)) {
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
}
if(!firstDone) {
return null;
}
}
} else {
if(p1pos == 2 || p2pos == 2) {
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,this._width,0,intersectPoint);
} else if(p1pos == 4 || p2pos == 4) {
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,this._width,0,this._width,this._height,intersectPoint);
} else if(p1pos == 6 || p2pos == 6) {
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,this._height,this._width,this._height,intersectPoint);
} else if(p1pos == 8 || p2pos == 8) {
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,0,this._height,intersectPoint);
} else if(!xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,this._width,0,intersectPoint)) {
if(!xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,this._width,0,this._width,this._height,intersectPoint)) {
if(!xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,this._height,this._width,this._height,intersectPoint)) {
xDaedalus_data_math_Geom2D.intersections2segments(x1,y1,x2,y2,0,0,0,this._height,intersectPoint);
}
}
}
if(p1pos == 0) {
newX1 = x1;
newY1 = y1;
} else {
newX1 = x2;
newY1 = y2;
}
newX2 = intersectPoint.x;
newY2 = intersectPoint.y;
}
}
var vertexDown = this.insertVertex(newX1,newY1);
if(vertexDown == null) {
return null;
}
var vertexUp = this.insertVertex(newX2,newY2);
if(vertexUp == null) {
return null;
}
if(vertexDown == vertexUp) {
return null;
}
var iterVertexToOutEdges = new xDaedalus_iterators_FromVertexToOutgoingEdges();
var currVertex;
var currEdge;
var i;
var segment = new xDaedalus_data_ConstraintSegment();
var tempEdgeDownUp = new xDaedalus_data_Edge();
var tempSdgeUpDown = new xDaedalus_data_Edge();
tempEdgeDownUp.setDatas(vertexDown,tempSdgeUpDown,null,null,true,true);
tempSdgeUpDown.setDatas(vertexUp,tempEdgeDownUp,null,null,true,true);
var intersectedEdges = [];
var leftBoundingEdges = [];
var rightBoundingEdges = [];
var currObjet;
var pIntersect = new xDaedalus_data_math_Point2D();
var edgeLeft;
var newEdgeDownUp;
var newEdgeUpDown;
var done;
currVertex = vertexDown;
currObjet = xDaedalus_data_math_Intersection.EVertex(currVertex);
while(true) {
done = false;
switch(currObjet[1]) {
case 0:
var vertex = currObjet[2];
currVertex = vertex;
iterVertexToOutEdges.set_fromVertex(currVertex);
while(true) {
currEdge = iterVertexToOutEdges.next();
if(!(currEdge != null)) {
break;
}
if(currEdge.get_destinationVertex() == vertexUp) {
if(!currEdge.get_isConstrained()) {
currEdge.set_isConstrained(true);
currEdge.get_oppositeEdge().set_isConstrained(true);
}
currEdge.addFromConstraintSegment(segment);
currEdge.get_oppositeEdge().fromConstraintSegments = currEdge.fromConstraintSegments;
vertexDown.addFromConstraintSegment(segment);
vertexUp.addFromConstraintSegment(segment);
segment.addEdge(currEdge);
return segment;
}
if(xDaedalus_data_math_Geom2D.distanceSquaredVertexToEdge(currEdge.get_destinationVertex(),tempEdgeDownUp) <= 0.0001) {
if(!currEdge.get_isConstrained()) {
currEdge.set_isConstrained(true);
currEdge.get_oppositeEdge().set_isConstrained(true);
}
currEdge.addFromConstraintSegment(segment);
currEdge.get_oppositeEdge().fromConstraintSegments = currEdge.fromConstraintSegments;
vertexDown.addFromConstraintSegment(segment);
segment.addEdge(currEdge);
vertexDown = currEdge.get_destinationVertex();
tempEdgeDownUp.set_originVertex(vertexDown);
currObjet = xDaedalus_data_math_Intersection.EVertex(vertexDown);
done = true;
break;
}
}
if(done) {
continue;
}
iterVertexToOutEdges.set_fromVertex(currVertex);
while(true) {
currEdge = iterVertexToOutEdges.next();
if(!(currEdge != null)) {
break;
}
currEdge = currEdge.get_nextLeftEdge();
if(xDaedalus_data_math_Geom2D.intersections2edges(currEdge,tempEdgeDownUp,pIntersect)) {
if(currEdge.get_isConstrained()) {
vertexDown = this.splitEdge(currEdge,pIntersect.x,pIntersect.y);
iterVertexToOutEdges.set_fromVertex(currVertex);
while(true) {
currEdge = iterVertexToOutEdges.next();
if(!(currEdge != null)) {
break;
}
if(currEdge.get_destinationVertex() == vertexDown) {
currEdge.set_isConstrained(true);
currEdge.get_oppositeEdge().set_isConstrained(true);
currEdge.addFromConstraintSegment(segment);
currEdge.get_oppositeEdge().fromConstraintSegments = currEdge.fromConstraintSegments;
segment.addEdge(currEdge);
break;
}
}
currVertex.addFromConstraintSegment(segment);
tempEdgeDownUp.set_originVertex(vertexDown);
currObjet = xDaedalus_data_math_Intersection.EVertex(vertexDown);
} else {
intersectedEdges.push(currEdge);
leftBoundingEdges.unshift(currEdge.get_nextLeftEdge());
rightBoundingEdges.push(currEdge.get_prevLeftEdge());
currEdge = currEdge.get_oppositeEdge();
currObjet = xDaedalus_data_math_Intersection.EEdge(currEdge);
}
break;
}
}
break;
case 1:
var edge = currObjet[2];
currEdge = edge;
edgeLeft = currEdge.get_nextLeftEdge();
if(edgeLeft.get_destinationVertex() == vertexUp) {
leftBoundingEdges.unshift(edgeLeft.get_nextLeftEdge());
rightBoundingEdges.push(edgeLeft);
newEdgeDownUp = new xDaedalus_data_Edge();
newEdgeUpDown = new xDaedalus_data_Edge();
newEdgeDownUp.setDatas(vertexDown,newEdgeUpDown,null,null,true,true);
newEdgeUpDown.setDatas(vertexUp,newEdgeDownUp,null,null,true,true);
leftBoundingEdges.push(newEdgeDownUp);
rightBoundingEdges.push(newEdgeUpDown);
this.insertNewConstrainedEdge(segment,newEdgeDownUp,intersectedEdges,leftBoundingEdges,rightBoundingEdges);
return segment;
} else if(xDaedalus_data_math_Geom2D.distanceSquaredVertexToEdge(edgeLeft.get_destinationVertex(),tempEdgeDownUp) <= 0.0001) {
leftBoundingEdges.unshift(edgeLeft.get_nextLeftEdge());
rightBoundingEdges.push(edgeLeft);
newEdgeDownUp = new xDaedalus_data_Edge();
newEdgeUpDown = new xDaedalus_data_Edge();
newEdgeDownUp.setDatas(vertexDown,newEdgeUpDown,null,null,true,true);
newEdgeUpDown.setDatas(edgeLeft.get_destinationVertex(),newEdgeDownUp,null,null,true,true);
leftBoundingEdges.push(newEdgeDownUp);
rightBoundingEdges.push(newEdgeUpDown);
this.insertNewConstrainedEdge(segment,newEdgeDownUp,intersectedEdges,leftBoundingEdges,rightBoundingEdges);
intersectedEdges.splice(0,intersectedEdges.length);
leftBoundingEdges.splice(0,leftBoundingEdges.length);
rightBoundingEdges.splice(0,rightBoundingEdges.length);
vertexDown = edgeLeft.get_destinationVertex();
tempEdgeDownUp.set_originVertex(vertexDown);
currObjet = xDaedalus_data_math_Intersection.EVertex(vertexDown);
} else if(xDaedalus_data_math_Geom2D.intersections2edges(edgeLeft,tempEdgeDownUp,pIntersect)) {
if(edgeLeft.get_isConstrained()) {
currVertex = this.splitEdge(edgeLeft,pIntersect.x,pIntersect.y);
iterVertexToOutEdges.set_fromVertex(currVertex);
while(true) {
currEdge = iterVertexToOutEdges.next();
if(!(currEdge != null)) {
break;
}
if(currEdge.get_destinationVertex() == leftBoundingEdges[0].get_originVertex()) {
leftBoundingEdges.unshift(currEdge);
}
if(currEdge.get_destinationVertex() == rightBoundingEdges[rightBoundingEdges.length - 1].get_destinationVertex()) {
rightBoundingEdges.push(currEdge.get_oppositeEdge());
}
}
newEdgeDownUp = new xDaedalus_data_Edge();
newEdgeUpDown = new xDaedalus_data_Edge();
newEdgeDownUp.setDatas(vertexDown,newEdgeUpDown,null,null,true,true);
newEdgeUpDown.setDatas(currVertex,newEdgeDownUp,null,null,true,true);
leftBoundingEdges.push(newEdgeDownUp);
rightBoundingEdges.push(newEdgeUpDown);
this.insertNewConstrainedEdge(segment,newEdgeDownUp,intersectedEdges,leftBoundingEdges,rightBoundingEdges);
intersectedEdges.splice(0,intersectedEdges.length);
leftBoundingEdges.splice(0,leftBoundingEdges.length);
rightBoundingEdges.splice(0,rightBoundingEdges.length);
vertexDown = currVertex;
tempEdgeDownUp.set_originVertex(vertexDown);
currObjet = xDaedalus_data_math_Intersection.EVertex(vertexDown);
} else {
intersectedEdges.push(edgeLeft);
leftBoundingEdges.unshift(edgeLeft.get_nextLeftEdge());
currEdge = edgeLeft.get_oppositeEdge();
currObjet = xDaedalus_data_math_Intersection.EEdge(currEdge);
}
} else {
edgeLeft = edgeLeft.get_nextLeftEdge();
xDaedalus_data_math_Geom2D.intersections2edges(edgeLeft,tempEdgeDownUp,pIntersect);
if(edgeLeft.get_isConstrained()) {
currVertex = this.splitEdge(edgeLeft,pIntersect.x,pIntersect.y);
iterVertexToOutEdges.set_fromVertex(currVertex);
while(true) {
currEdge = iterVertexToOutEdges.next();
if(!(currEdge != null)) {
break;
}
if(currEdge.get_destinationVertex() == leftBoundingEdges[0].get_originVertex()) {
leftBoundingEdges.unshift(currEdge);
}
if(currEdge.get_destinationVertex() == rightBoundingEdges[rightBoundingEdges.length - 1].get_destinationVertex()) {
rightBoundingEdges.push(currEdge.get_oppositeEdge());
}
}
newEdgeDownUp = new xDaedalus_data_Edge();
newEdgeUpDown = new xDaedalus_data_Edge();
newEdgeDownUp.setDatas(vertexDown,newEdgeUpDown,null,null,true,true);
newEdgeUpDown.setDatas(currVertex,newEdgeDownUp,null,null,true,true);
leftBoundingEdges.push(newEdgeDownUp);
rightBoundingEdges.push(newEdgeUpDown);
this.insertNewConstrainedEdge(segment,newEdgeDownUp,intersectedEdges,leftBoundingEdges,rightBoundingEdges);
intersectedEdges.splice(0,intersectedEdges.length);
leftBoundingEdges.splice(0,leftBoundingEdges.length);
rightBoundingEdges.splice(0,rightBoundingEdges.length);
vertexDown = currVertex;
tempEdgeDownUp.set_originVertex(vertexDown);
currObjet = xDaedalus_data_math_Intersection.EVertex(vertexDown);
} else {
intersectedEdges.push(edgeLeft);
rightBoundingEdges.push(edgeLeft.get_prevLeftEdge());
currEdge = edgeLeft.get_oppositeEdge();
currObjet = xDaedalus_data_math_Intersection.EEdge(currEdge);
}
}
break;
case 2:
var face = currObjet[2];
break;
case 3:
break;
}
}
}
,insertNewConstrainedEdge: function(fromSegment,edgeDownUp,intersectedEdges,leftBoundingEdges,rightBoundingEdges) {
this._edges.push(edgeDownUp);
this._edges.push(edgeDownUp.get_oppositeEdge());
edgeDownUp.addFromConstraintSegment(fromSegment);
edgeDownUp.get_oppositeEdge().fromConstraintSegments = edgeDownUp.fromConstraintSegments;
fromSegment.addEdge(edgeDownUp);
edgeDownUp.get_originVertex().addFromConstraintSegment(fromSegment);
edgeDownUp.get_destinationVertex().addFromConstraintSegment(fromSegment);
this.untriangulate(intersectedEdges);
this.triangulate(leftBoundingEdges,true);
this.triangulate(rightBoundingEdges,true);
}
,deleteConstraintSegment: function(segment) {
var i;
var vertexToDelete = [];
var edge = null;
var vertex;
var fromConstraintSegment;
var _g1 = 0;
var _g = segment.get_edges().length;
while(_g1 < _g) {
var i1 = _g1++;
edge = segment.get_edges()[i1];
edge.removeFromConstraintSegment(segment);
if(edge.fromConstraintSegments.length == 0) {
edge.set_isConstrained(false);
edge.get_oppositeEdge().set_isConstrained(false);
}
vertex = edge.get_originVertex();
vertex.removeFromConstraintSegment(segment);
vertexToDelete.push(vertex);
}
vertex = edge.get_destinationVertex();
vertex.removeFromConstraintSegment(segment);
vertexToDelete.push(vertex);
var _g11 = 0;
var _g2 = vertexToDelete.length;
while(_g11 < _g2) {
var i2 = _g11++;
this.deleteVertex(vertexToDelete[i2]);
}
segment.dispose();
}
,check: function() {
var _g1 = 0;
var _g = this._edges.length;
while(_g1 < _g) {
var i = _g1++;
if(this._edges[i].get_nextLeftEdge() == null) {
return;
}
}
}
,insertVertex: function(x,y) {
if(x < 0 || y < 0 || x > this._width || y > this._height) {
return null;
}
this.__edgesToCheck.splice(0,this.__edgesToCheck.length);
var inObject = xDaedalus_data_math_Geom2D.locatePosition(x,y,this);
var newVertex = null;
switch(inObject[1]) {
case 0:
var vertex = inObject[2];
newVertex = vertex;
break;
case 1:
var edge = inObject[2];
newVertex = this.splitEdge(edge,x,y);
break;
case 2:
var face = inObject[2];
newVertex = this.splitFace(face,x,y);
break;
case 3:
break;
}
this.restoreAsDelaunay();
return newVertex;
}
,flipEdge: function(edge) {
var eBot_Top = edge;
var eTop_Bot = edge.get_oppositeEdge();
var eLeft_Right = new xDaedalus_data_Edge();
var eRight_Left = new xDaedalus_data_Edge();
var eTop_Left = eBot_Top.get_nextLeftEdge();
var eLeft_Bot = eTop_Left.get_nextLeftEdge();
var eBot_Right = eTop_Bot.get_nextLeftEdge();
var eRight_Top = eBot_Right.get_nextLeftEdge();
var vBot = eBot_Top.get_originVertex();
var vTop = eTop_Bot.get_originVertex();
var vLeft = eLeft_Bot.get_originVertex();
var vRight = eRight_Top.get_originVertex();
var fLeft = eBot_Top.get_leftFace();
var fRight = eTop_Bot.get_leftFace();
var fBot = new xDaedalus_data_Face();
var fTop = new xDaedalus_data_Face();
this._edges.push(eLeft_Right);
this._edges.push(eRight_Left);
this._faces.push(fTop);
this._faces.push(fBot);
eLeft_Right.setDatas(vLeft,eRight_Left,eRight_Top,fTop,edge.get_isReal(),edge.get_isConstrained());
eRight_Left.setDatas(vRight,eLeft_Right,eLeft_Bot,fBot,edge.get_isReal(),edge.get_isConstrained());
fTop.setDatas(eLeft_Right);
fBot.setDatas(eRight_Left);
if(vTop.get_edge() == eTop_Bot) {
vTop.setDatas(eTop_Left);
}
if(vBot.get_edge() == eBot_Top) {
vBot.setDatas(eBot_Right);
}
eTop_Left.set_nextLeftEdge(eLeft_Right);
eTop_Left.set_leftFace(fTop);
eLeft_Bot.set_nextLeftEdge(eBot_Right);
eLeft_Bot.set_leftFace(fBot);
eBot_Right.set_nextLeftEdge(eRight_Left);
eBot_Right.set_leftFace(fBot);
eRight_Top.set_nextLeftEdge(eTop_Left);
eRight_Top.set_leftFace(fTop);
eBot_Top.dispose();
eTop_Bot.dispose();
this._edges.splice(this._edges.indexOf(eBot_Top),1);
this._edges.splice(this._edges.indexOf(eTop_Bot),1);
fLeft.dispose();
fRight.dispose();
this._faces.splice(this._faces.indexOf(fLeft),1);
this._faces.splice(this._faces.indexOf(fRight),1);
return eRight_Left;
}
,splitEdge: function(edge,x,y) {
this.__edgesToCheck.splice(0,this.__edgesToCheck.length);
var eLeft_Right = edge;
var eRight_Left = eLeft_Right.get_oppositeEdge();
var eRight_Top = eLeft_Right.get_nextLeftEdge();
var eTop_Left = eRight_Top.get_nextLeftEdge();
var eLeft_Bot = eRight_Left.get_nextLeftEdge();
var eBot_Right = eLeft_Bot.get_nextLeftEdge();
var vTop = eTop_Left.get_originVertex();
var vLeft = eLeft_Right.get_originVertex();
var vBot = eBot_Right.get_originVertex();
var vRight = eRight_Left.get_originVertex();
var fTop = eLeft_Right.get_leftFace();
var fBot = eRight_Left.get_leftFace();
if((vLeft.get_pos().x - x) * (vLeft.get_pos().x - x) + (vLeft.get_pos().y - y) * (vLeft.get_pos().y - y) <= 0.0001) {
return vLeft;
}
if((vRight.get_pos().x - x) * (vRight.get_pos().x - x) + (vRight.get_pos().y - y) * (vRight.get_pos().y - y) <= 0.0001) {
return vRight;
}
var vCenter = new xDaedalus_data_Vertex();
var eTop_Center = new xDaedalus_data_Edge();
var eCenter_Top = new xDaedalus_data_Edge();
var eBot_Center = new xDaedalus_data_Edge();
var eCenter_Bot = new xDaedalus_data_Edge();
var eLeft_Center = new xDaedalus_data_Edge();
var eCenter_Left = new xDaedalus_data_Edge();
var eRight_Center = new xDaedalus_data_Edge();
var eCenter_Right = new xDaedalus_data_Edge();
var fTopLeft = new xDaedalus_data_Face();
var fBotLeft = new xDaedalus_data_Face();
var fBotRight = new xDaedalus_data_Face();
var fTopRight = new xDaedalus_data_Face();
this._vertices.push(vCenter);
this._edges.push(eCenter_Top);
this._edges.push(eTop_Center);
this._edges.push(eCenter_Left);
this._edges.push(eLeft_Center);
this._edges.push(eCenter_Bot);
this._edges.push(eBot_Center);
this._edges.push(eCenter_Right);
this._edges.push(eRight_Center);
this._faces.push(fTopRight);
this._faces.push(fBotRight);
this._faces.push(fBotLeft);
this._faces.push(fTopLeft);
vCenter.setDatas(fTop.get_isReal() ? eCenter_Top : eCenter_Bot);
vCenter.get_pos().x = x;
vCenter.get_pos().y = y;
xDaedalus_data_math_Geom2D.projectOrthogonaly(vCenter.get_pos(),eLeft_Right);
eCenter_Top.setDatas(vCenter,eTop_Center,eTop_Left,fTopLeft,fTop.get_isReal());
eTop_Center.setDatas(vTop,eCenter_Top,eCenter_Right,fTopRight,fTop.get_isReal());
eCenter_Left.setDatas(vCenter,eLeft_Center,eLeft_Bot,fBotLeft,edge.get_isReal(),edge.get_isConstrained());
eLeft_Center.setDatas(vLeft,eCenter_Left,eCenter_Top,fTopLeft,edge.get_isReal(),edge.get_isConstrained());
eCenter_Bot.setDatas(vCenter,eBot_Center,eBot_Right,fBotRight,fBot.get_isReal());
eBot_Center.setDatas(vBot,eCenter_Bot,eCenter_Left,fBotLeft,fBot.get_isReal());
eCenter_Right.setDatas(vCenter,eRight_Center,eRight_Top,fTopRight,edge.get_isReal(),edge.get_isConstrained());
eRight_Center.setDatas(vRight,eCenter_Right,eCenter_Bot,fBotRight,edge.get_isReal(),edge.get_isConstrained());
fTopLeft.setDatas(eCenter_Top,fTop.get_isReal());
fBotLeft.setDatas(eCenter_Left,fBot.get_isReal());
fBotRight.setDatas(eCenter_Bot,fBot.get_isReal());
fTopRight.setDatas(eCenter_Right,fTop.get_isReal());
if(vLeft.get_edge() == eLeft_Right) {
vLeft.setDatas(eLeft_Center);
}
if(vRight.get_edge() == eRight_Left) {
vRight.setDatas(eRight_Center);
}
eTop_Left.set_nextLeftEdge(eLeft_Center);
eTop_Left.set_leftFace(fTopLeft);
eLeft_Bot.set_nextLeftEdge(eBot_Center);
eLeft_Bot.set_leftFace(fBotLeft);
eBot_Right.set_nextLeftEdge(eRight_Center);
eBot_Right.set_leftFace(fBotRight);
eRight_Top.set_nextLeftEdge(eTop_Center);
eRight_Top.set_leftFace(fTopRight);
if(eLeft_Right.get_isConstrained()) {
var fromSegments = eLeft_Right.fromConstraintSegments;
eLeft_Center.fromConstraintSegments = fromSegments.slice(0);
eCenter_Left.fromConstraintSegments = eLeft_Center.fromConstraintSegments;
eCenter_Right.fromConstraintSegments = fromSegments.slice(0);
eRight_Center.fromConstraintSegments = eCenter_Right.fromConstraintSegments;
var edges;
var index;
var _g1 = 0;
var _g = eLeft_Right.fromConstraintSegments.length;
while(_g1 < _g) {
var i = _g1++;
edges = eLeft_Right.fromConstraintSegments[i].get_edges();
index = edges.indexOf(eLeft_Right);
if(index != -1) {
edges.splice(index,1);
edges.splice(index,0,eLeft_Center);
edges.splice(index + 1,0,eCenter_Right);
} else {
index = edges.indexOf(eRight_Left);
edges.splice(index,1);
edges.splice(index,0,eRight_Center);
edges.splice(index + 1,0,eCenter_Left);
}
}
vCenter.set_fromConstraintSegments(fromSegments.slice(0));
}
eLeft_Right.dispose();
eRight_Left.dispose();
this._edges.splice(this._edges.indexOf(eLeft_Right),1);
this._edges.splice(this._edges.indexOf(eRight_Left),1);
fTop.dispose();
fBot.dispose();
this._faces.splice(this._faces.indexOf(fTop),1);
this._faces.splice(this._faces.indexOf(fBot),1);
this.__centerVertex = vCenter;
this.__edgesToCheck.push(eTop_Left);
this.__edgesToCheck.push(eLeft_Bot);
this.__edgesToCheck.push(eBot_Right);
this.__edgesToCheck.push(eRight_Top);
return vCenter;
}
,splitFace: function(face,x,y) {
this.__edgesToCheck.splice(0,this.__edgesToCheck.length);
var eTop_Left = face.get_edge();
var eLeft_Right = eTop_Left.get_nextLeftEdge();
var eRight_Top = eLeft_Right.get_nextLeftEdge();
var vTop = eTop_Left.get_originVertex();
var vLeft = eLeft_Right.get_originVertex();
var vRight = eRight_Top.get_originVertex();
var vCenter = new xDaedalus_data_Vertex();
var eTop_Center = new xDaedalus_data_Edge();
var eCenter_Top = new xDaedalus_data_Edge();
var eLeft_Center = new xDaedalus_data_Edge();
var eCenter_Left = new xDaedalus_data_Edge();
var eRight_Center = new xDaedalus_data_Edge();
var eCenter_Right = new xDaedalus_data_Edge();
var fTopLeft = new xDaedalus_data_Face();
var fBot = new xDaedalus_data_Face();
var fTopRight = new xDaedalus_data_Face();
this._vertices.push(vCenter);
this._edges.push(eTop_Center);
this._edges.push(eCenter_Top);
this._edges.push(eLeft_Center);
this._edges.push(eCenter_Left);
this._edges.push(eRight_Center);
this._edges.push(eCenter_Right);
this._faces.push(fTopLeft);
this._faces.push(fBot);
this._faces.push(fTopRight);
vCenter.setDatas(eCenter_Top);
vCenter.get_pos().x = x;
vCenter.get_pos().y = y;
eTop_Center.setDatas(vTop,eCenter_Top,eCenter_Right,fTopRight);
eCenter_Top.setDatas(vCenter,eTop_Center,eTop_Left,fTopLeft);
eLeft_Center.setDatas(vLeft,eCenter_Left,eCenter_Top,fTopLeft);
eCenter_Left.setDatas(vCenter,eLeft_Center,eLeft_Right,fBot);
eRight_Center.setDatas(vRight,eCenter_Right,eCenter_Left,fBot);
eCenter_Right.setDatas(vCenter,eRight_Center,eRight_Top,fTopRight);
fTopLeft.setDatas(eCenter_Top);
fBot.setDatas(eCenter_Left);
fTopRight.setDatas(eCenter_Right);
eTop_Left.set_nextLeftEdge(eLeft_Center);
eTop_Left.set_leftFace(fTopLeft);
eLeft_Right.set_nextLeftEdge(eRight_Center);
eLeft_Right.set_leftFace(fBot);
eRight_Top.set_nextLeftEdge(eTop_Center);
eRight_Top.set_leftFace(fTopRight);
face.dispose();
this._faces.splice(this._faces.indexOf(face),1);
this.__centerVertex = vCenter;
this.__edgesToCheck.push(eTop_Left);
this.__edgesToCheck.push(eLeft_Right);
this.__edgesToCheck.push(eRight_Top);
return vCenter;
}
,restoreAsDelaunay: function() {
var edge;
while(this.__edgesToCheck.length > 0) {
edge = this.__edgesToCheck.shift();
if(edge.get_isReal() && !edge.get_isConstrained() && !xDaedalus_data_math_Geom2D.isDelaunay(edge)) {
if(edge.get_nextLeftEdge().get_destinationVertex() == this.__centerVertex) {
this.__edgesToCheck.push(edge.get_nextRightEdge());
this.__edgesToCheck.push(edge.get_prevRightEdge());
} else {
this.__edgesToCheck.push(edge.get_nextLeftEdge());
this.__edgesToCheck.push(edge.get_prevLeftEdge());
}
this.flipEdge(edge);
}
}
}
,deleteVertex: function(vertex) {
var i;
var freeOfConstraint;
var iterEdges = new xDaedalus_iterators_FromVertexToOutgoingEdges();
iterEdges.set_fromVertex(vertex);
iterEdges.realEdgesOnly = false;
var edge;
var outgoingEdges = [];
freeOfConstraint = vertex.get_fromConstraintSegments().length == 0;
var bound = [];
var realA = false;
var realB = false;
var boundA = [];
var boundB = [];
if(freeOfConstraint) {
while(true) {
edge = iterEdges.next();
if(!(edge != null)) {
break;
}
outgoingEdges.push(edge);
bound.push(edge.get_nextLeftEdge());
}
} else {
var edges;
var _g1 = 0;
var _g = vertex.get_fromConstraintSegments().length;
while(_g1 < _g) {
var i1 = _g1++;
edges = vertex.get_fromConstraintSegments()[i1].get_edges();
if(edges[0].get_originVertex() == vertex || edges[edges.length - 1].get_destinationVertex() == vertex) {
return false;
}
}
var count = 0;
while(true) {
edge = iterEdges.next();
if(!(edge != null)) {
break;
}
outgoingEdges.push(edge);
if(edge.get_isConstrained()) {
++count;
if(count > 2) {
return false;
}
}
}
boundA = [];
boundB = [];
var constrainedEdgeA = null;
var constrainedEdgeB = null;
var edgeA = new xDaedalus_data_Edge();
var edgeB = new xDaedalus_data_Edge();
this._edges.push(edgeA);
this._edges.push(edgeB);
var _g11 = 0;
var _g2 = outgoingEdges.length;
while(_g11 < _g2) {
var i2 = _g11++;
edge = outgoingEdges[i2];
if(edge.get_isConstrained()) {
if(constrainedEdgeA == null) {
edgeB.setDatas(edge.get_destinationVertex(),edgeA,null,null,true,true);
boundA.push(edgeA);
boundA.push(edge.get_nextLeftEdge());
boundB.push(edgeB);
constrainedEdgeA = edge;
} else if(constrainedEdgeB == null) {
edgeA.setDatas(edge.get_destinationVertex(),edgeB,null,null,true,true);
boundB.push(edge.get_nextLeftEdge());
constrainedEdgeB = edge;
}
} else if(constrainedEdgeA == null) {
boundB.push(edge.get_nextLeftEdge());
} else if(constrainedEdgeB == null) {
boundA.push(edge.get_nextLeftEdge());
} else {
boundB.push(edge.get_nextLeftEdge());
}
}
realA = constrainedEdgeA.get_leftFace().get_isReal();
realB = constrainedEdgeB.get_leftFace().get_isReal();
edgeA.fromConstraintSegments = constrainedEdgeA.fromConstraintSegments.slice(0);
edgeB.fromConstraintSegments = edgeA.fromConstraintSegments;
var index;
var _g12 = 0;
var _g3 = vertex.get_fromConstraintSegments().length;
while(_g12 < _g3) {
var i3 = _g12++;
edges = vertex.get_fromConstraintSegments()[i3].get_edges();
index = edges.indexOf(constrainedEdgeA);
if(index != -1) {
edges.splice(index - 1,2);
edges.splice(index - 1,0,edgeA);
} else {
var index2 = edges.indexOf(constrainedEdgeB) - 1;
edges.splice(index2,2);
edges.splice(index2,0,edgeB);
}
}
}
var faceToDelete;
var _g13 = 0;
var _g4 = outgoingEdges.length;
while(_g13 < _g4) {
var i4 = _g13++;
edge = outgoingEdges[i4];
faceToDelete = edge.get_leftFace();
this._faces.splice(this._faces.indexOf(faceToDelete),1);
faceToDelete.dispose();
edge.get_destinationVertex().set_edge(edge.get_nextLeftEdge());
this._edges.splice(this._edges.indexOf(edge.get_oppositeEdge()),1);
edge.get_oppositeEdge().dispose();
this._edges.splice(this._edges.indexOf(edge),1);
edge.dispose();
}
this._vertices.splice(this._vertices.indexOf(vertex),1);
vertex.dispose();
if(freeOfConstraint) {
this.triangulate(bound,true);
} else {
this.triangulate(boundA,realA);
this.triangulate(boundB,realB);
}
return true;
}
,untriangulate: function(edgesList) {
var i;
var verticesCleaned = new haxe_ds_ObjectMap();
var currEdge;
var outEdge;
var _g1 = 0;
var _g = edgesList.length;
while(_g1 < _g) {
var i1 = _g1++;
currEdge = edgesList[i1];
var key = currEdge.get_originVertex();
if(verticesCleaned.h[key.xid] == null) {
currEdge.get_originVertex().set_edge(currEdge.get_prevLeftEdge().get_oppositeEdge());
verticesCleaned.set(currEdge.get_originVertex(),true);
}
var key1 = currEdge.get_destinationVertex();
if(verticesCleaned.h[key1.xid] == null) {
currEdge.get_destinationVertex().set_edge(currEdge.get_nextLeftEdge());
verticesCleaned.set(currEdge.get_destinationVertex(),true);
}
this._faces.splice(this._faces.indexOf(currEdge.get_leftFace()),1);
currEdge.get_leftFace().dispose();
if(i1 == edgesList.length - 1) {
this._faces.splice(this._faces.indexOf(currEdge.get_rightFace()),1);
currEdge.get_rightFace().dispose();
}
}
var _g11 = 0;
var _g2 = edgesList.length;
while(_g11 < _g2) {
var i2 = _g11++;
currEdge = edgesList[i2];
this._edges.splice(this._edges.indexOf(currEdge.get_oppositeEdge()),1);
this._edges.splice(this._edges.indexOf(currEdge),1);
currEdge.get_oppositeEdge().dispose();
currEdge.dispose();
}
}
,triangulate: function(bound,isReal) {
if(bound.length < 2) {
return;
} else if(bound.length == 2) {
var value = " - edge0: " + bound[0].get_originVertex().get_id() + " -> " + bound[0].get_destinationVertex().get_id();
var value1 = " - edge1: " + bound[1].get_originVertex().get_id() + " -> " + bound[1].get_destinationVertex().get_id();
return;
} else if(bound.length == 3) {
var f = new xDaedalus_data_Face();
f.setDatas(bound[0],isReal);
this._faces.push(f);
bound[0].set_leftFace(f);
bound[1].set_leftFace(f);
bound[2].set_leftFace(f);
bound[0].set_nextLeftEdge(bound[1]);
bound[1].set_nextLeftEdge(bound[2]);
bound[2].set_nextLeftEdge(bound[0]);
} else {
var baseEdge = bound[0];
var vertexA = baseEdge.get_originVertex();
var vertexB = baseEdge.get_destinationVertex();
var vertexC;
var vertexCheck;
var circumcenter = new xDaedalus_data_math_Point2D();
var radiusSquared;
var distanceSquared;
var isDelaunay = false;
var index = 0;
var i;
var _g1 = 2;
var _g = bound.length;
while(_g1 < _g) {
var i1 = _g1++;
vertexC = bound[i1].get_originVertex();
if(xDaedalus_data_math_Geom2D.getRelativePosition2(vertexC.get_pos().x,vertexC.get_pos().y,baseEdge) == 1) {
index = i1;
isDelaunay = true;
xDaedalus_data_math_Geom2D.getCircumcenter(vertexA.get_pos().x,vertexA.get_pos().y,vertexB.get_pos().x,vertexB.get_pos().y,vertexC.get_pos().x,vertexC.get_pos().y,circumcenter);
radiusSquared = (vertexA.get_pos().x - circumcenter.x) * (vertexA.get_pos().x - circumcenter.x) + (vertexA.get_pos().y - circumcenter.y) * (vertexA.get_pos().y - circumcenter.y);
radiusSquared -= 0.0001;
var _g3 = 2;
var _g2 = bound.length;
while(_g3 < _g2) {
var j = _g3++;
if(j != i1) {
vertexCheck = bound[j].get_originVertex();
distanceSquared = (vertexCheck.get_pos().x - circumcenter.x) * (vertexCheck.get_pos().x - circumcenter.x) + (vertexCheck.get_pos().y - circumcenter.y) * (vertexCheck.get_pos().y - circumcenter.y);
if(distanceSquared < radiusSquared) {
isDelaunay = false;
break;
}
}
}
if(isDelaunay) {
break;
}
}
}
if(!isDelaunay) {
var s = "";
var _g11 = 0;
var _g4 = bound.length;
while(_g11 < _g4) {
var i2 = _g11++;
s += bound[i2].get_originVertex().get_pos().x + " , ";
s += bound[i2].get_originVertex().get_pos().y + " , ";
s += bound[i2].get_destinationVertex().get_pos().x + " , ";
s += bound[i2].get_destinationVertex().get_pos().y + " , ";
}
index = 2;
}
var edgeA = null;
var edgeAopp = null;
var edgeB = null;
var edgeBopp;
var boundA;
var boundM;
var boundB;
if(index < bound.length - 1) {
edgeA = new xDaedalus_data_Edge();
edgeAopp = new xDaedalus_data_Edge();
this._edges.push(edgeA);
this._edges.push(edgeAopp);
edgeA.setDatas(vertexA,edgeAopp,null,null,isReal,false);
edgeAopp.setDatas(bound[index].get_originVertex(),edgeA,null,null,isReal,false);
boundA = bound.slice(index);
boundA.push(edgeA);
this.triangulate(boundA,isReal);
}
if(index > 2) {
edgeB = new xDaedalus_data_Edge();
edgeBopp = new xDaedalus_data_Edge();
this._edges.push(edgeB);
this._edges.push(edgeBopp);
edgeB.setDatas(bound[1].get_originVertex(),edgeBopp,null,null,isReal,false);
edgeBopp.setDatas(bound[index].get_originVertex(),edgeB,null,null,isReal,false);
boundB = bound.slice(1,index);
boundB.push(edgeBopp);
this.triangulate(boundB,isReal);
}
if(index == 2) {
boundM = [baseEdge,bound[1],edgeAopp];
} else if(index == bound.length - 1) {
boundM = [baseEdge,edgeB,bound[index]];
} else {
boundM = [baseEdge,edgeB,edgeAopp];
}
this.triangulate(boundM,isReal);
}
}
,findPositionFromBounds: function(x,y) {
if(x <= 0) {
if(y <= 0) {
return 1;
} else if(y >= this._height) {
return 7;
} else {
return 8;
}
} else if(x >= this._width) {
if(y <= 0) {
return 3;
} else if(y >= this._height) {
return 5;
} else {
return 4;
}
} else if(y <= 0) {
return 2;
} else if(y >= this._height) {
return 6;
} else {
return 0;
}
}
,debug: function() {
var i;
var _g1 = 0;
var _g = this._vertices.length;
while(_g1 < _g) {
var i1 = _g1++;
var value = "-- vertex " + this._vertices[i1].get_id();
var value1 = " edge " + this._vertices[i1].get_edge().get_id() + " - " + Std.string(this._vertices[i1].get_edge());
var value2 = " edge isReal: " + Std.string(this._vertices[i1].get_edge().get_isReal());
}
var _g11 = 0;
var _g2 = this._edges.length;
while(_g11 < _g2) {
var i2 = _g11++;
var value3 = "-- edge " + Std.string(this._edges[i2]);
var value4 = " isReal " + this._edges[i2].get_id() + " - " + Std.string(this._edges[i2].get_isReal());
var value5 = " nextLeftEdge " + Std.string(this._edges[i2].get_nextLeftEdge());
var value6 = " oppositeEdge " + Std.string(this._edges[i2].get_oppositeEdge());
}
}
,getVerticesAndEdges: function() {
var res = { vertices : [], edges : []};
var vertex;
var incomingEdge;
var holdingFace;
var iterVertices = new xDaedalus_iterators_FromMeshToVertices();
iterVertices.set_fromMesh(this);
var iterEdges = new xDaedalus_iterators_FromVertexToIncomingEdges();
var dictVerticesDone = new haxe_ds_ObjectMap();
while(true) {
vertex = iterVertices.next();
if(!(vertex != null)) {
break;
}
dictVerticesDone.set(vertex,true);
if(!(!(vertex.get_pos().x < 0 || vertex.get_pos().x > this.get_width() || vertex.get_pos().y < 0 || vertex.get_pos().y > this.get_height()))) {
continue;
}
res.vertices.push(vertex);
iterEdges.set_fromVertex(vertex);
while(true) {
incomingEdge = iterEdges.next();
if(!(incomingEdge != null)) {
break;
}
var key = incomingEdge.get_originVertex();
if(!dictVerticesDone.h[key.xid]) {
res.edges.push(incomingEdge);
}
}
}
return res;
}
,vertexIsInsideAABB: function(vertex,mesh) {
return !(vertex.get_pos().x < 0 || vertex.get_pos().x > mesh.get_width() || vertex.get_pos().y < 0 || vertex.get_pos().y > mesh.get_height());
}
,__class__: xDaedalus_data_Mesh
};
var xDaedalus_data_Object = xExport["xDaedalus"]["data"]["Object"] = function() {
this._id = xDaedalus_data_Object.INC;
xDaedalus_data_Object.INC++;
this._pivotX = 0;
this._pivotY = 0;
this._matrix = new xDaedalus_data_math_Matrix2D();
this._scaleX = 1;
this._scaleY = 1;
this._rotation = 0;
this._x = 0;
this._y = 0;
this._coordinates = [];
this._hasChanged = false;
};
xClasses["xDaedalus.data.Object"] = xDaedalus_data_Object;
xDaedalus_data_Object.nom = true;
xDaedalus_data_Object.prototype = {
_id: null
,_matrix: null
,_coordinates: null
,_constraintShape: null
,_pivotX: null
,_pivotY: null
,_scaleX: null
,_scaleY: null
,_rotation: null
,_x: null
,_y: null
,_hasChanged: null
,get_id: function() {
return this._id;
}
,dispose: function() {
this._matrix = null;
this._coordinates = null;
this._constraintShape = null;
}
,updateValuesFromMatrix: function() {
}
,updateMatrixFromValues: function() {
this._matrix.identity();
this._matrix.translate(-this._pivotX,-this._pivotY);
this._matrix.scale(this._scaleX,this._scaleY);
this._matrix.rotate(this._rotation);
this._matrix.translate(this._x,this._y);
}
,get_pivotX: function() {
return this._pivotX;
}
,set_pivotX: function(value) {
this._pivotX = value;
this._hasChanged = true;
return value;
}
,get_pivotY: function() {
return this._pivotY;
}
,set_pivotY: function(value) {
this._pivotY = value;
this._hasChanged = true;
return value;
}
,get_scaleX: function() {
return this._scaleX;
}
,set_scaleX: function(value) {
if(this._scaleX != value) {
this._scaleX = value;
this._hasChanged = true;
}
return value;
}
,get_scaleY: function() {
return this._scaleY;
}
,set_scaleY: function(value) {
if(this._scaleY != value) {
this._scaleY = value;
this._hasChanged = true;
}
return value;
}
,get_rotation: function() {
return this._rotation;
}
,set_rotation: function(value) {
if(this._rotation != value) {
this._rotation = value;
this._hasChanged = true;
}
return value;
}
,get_x: function() {
return this._x;
}
,set_x: function(value) {
if(this._x != value) {
this._x = value;
this._hasChanged = true;
}
return value;
}
,get_y: function() {
return this._y;
}
,set_y: function(value) {
if(this._y != value) {
this._y = value;
this._hasChanged = true;
}
return value;
}
,get_matrix: function() {
return this._matrix;
}
,set_matrix: function(value) {
this._matrix = value;
this._hasChanged = true;
return value;
}
,get_coordinates: function() {
return this._coordinates;
}
,set_coordinates: function(value) {
this._coordinates = value;
this._hasChanged = true;
return value;
}
,get_constraintShape: function() {
return this._constraintShape;
}
,set_constraintShape: function(value) {
this._constraintShape = value;
this._hasChanged = true;
return value;
}
,get_hasChanged: function() {
return this._hasChanged;
}
,set_hasChanged: function(value) {
this._hasChanged = value;
return value;
}
,get_edges: function() {
var res = [];
var seg = this._constraintShape.segments;
var _g1 = 0;
var _g = seg.length;
while(_g1 < _g) {
var i = _g1++;
var _g3 = 0;
var _g2 = seg[i].get_edges().length;
while(_g3 < _g2) {
var j = _g3++;
res.push(seg[i].get_edges()[j]);
}
}
return res;
}
,__class__: xDaedalus_data_Object
};
var xDaedalus_data_Vertex = xExport["xDaedalus"]["data"]["Vertex"] = function() {
this.colorDebug = -1;
this._id = xDaedalus_data_Vertex.INC;
xDaedalus_data_Vertex.INC++;
this._pos = new xDaedalus_data_math_Point2D();
this._fromConstraintSegments = [];
};
xClasses["xDaedalus.data.Vertex"] = xDaedalus_data_Vertex;
xDaedalus_data_Vertex.nom = true;
xDaedalus_data_Vertex.prototype = {
_id: null
,_pos: null
,_isReal: null
,_edge: null
,_fromConstraintSegments: null
,colorDebug: null
,get_id: function() {
return this._id;
}
,get_isReal: function() {
return this._isReal;
}
,get_pos: function() {
return this._pos;
}
,get_fromConstraintSegments: function() {
return this._fromConstraintSegments;
}
,set_fromConstraintSegments: function(value) {
return this._fromConstraintSegments = value;
}
,setDatas: function(edge,isReal) {
if(isReal == null) {
isReal = true;
}
this._isReal = isReal;
this._edge = edge;
}
,addFromConstraintSegment: function(segment) {
if(this._fromConstraintSegments.indexOf(segment) == -1) {
this._fromConstraintSegments.push(segment);
}
}
,removeFromConstraintSegment: function(segment) {
var index = this._fromConstraintSegments.indexOf(segment);
if(index != -1) {
this._fromConstraintSegments.splice(index,1);
}
}
,dispose: function() {
this._pos = null;
this._edge = null;
this._fromConstraintSegments = null;
}
,get_edge: function() {
return this._edge;
}
,set_edge: function(value) {
return this._edge = value;
}
,toString: function() {
return "ver_id " + this._id;
}
,__class__: xDaedalus_data_Vertex
};
var xDaedalus_data_graph_Graph = xExport["xDaedalus"]["data"]["graph"]["Graph"] = function() {
this._id = xDaedalus_data_graph_Graph.INC;
xDaedalus_data_graph_Graph.INC++;
};
xClasses["xDaedalus.data.graph.Graph"] = xDaedalus_data_graph_Graph;
xDaedalus_data_graph_Graph.nom = true;
xDaedalus_data_graph_Graph.prototype = {
get_id: function() {
return this._id;
}
,get_edge: function() {
return this._edge;
}
,get_node: function() {
return this._node;
}
,_id: null
,_node: null
,_edge: null
,dispose: function() {
while(this._node != null) this.deleteNode(this._node);
}
,insertNode: function() {
var node = new xDaedalus_data_graph_GraphNode();
if(this._node != null) {
node.set_next(this._node);
this._node.set_prev(node);
}
this._node = node;
return node;
}
,deleteNode: function(node) {
while(node.get_outgoingEdge() != null) {
if(node.get_outgoingEdge().get_oppositeEdge() != null) {
this.deleteEdge(node.get_outgoingEdge().get_oppositeEdge());
}
this.deleteEdge(node.get_outgoingEdge());
}
var otherNode = this._node;
var incomingEdge;
while(otherNode != null) {
incomingEdge = otherNode.get_successorNodes().h[node.xid];
if(incomingEdge != null) {
this.deleteEdge(incomingEdge);
}
otherNode = otherNode.get_next();
}
if(this._node == node) {
if(node.get_next() != null) {
node.get_next().set_prev(null);
this._node = node.get_next();
} else {
this._node = null;
}
} else if(node.get_next() != null) {
node.get_prev().set_next(node.get_next());
node.get_next().set_prev(node.get_prev());
} else {
node.get_prev().set_next(null);
}
node.dispose();
}
,insertEdge: function(fromNode,toNode) {
if(fromNode.get_successorNodes().h[toNode.xid] != null) {
return null;
}
var edge = new xDaedalus_data_graph_GraphEdge();
if(this._edge != null) {
this._edge.set_prev(edge);
edge.set_next(this._edge);
}
this._edge = edge;
edge.set_sourceNode(fromNode);
edge.set_destinationNode(toNode);
fromNode.get_successorNodes().set(toNode,edge);
if(fromNode.get_outgoingEdge() != null) {
fromNode.get_outgoingEdge().set_rotPrevEdge(edge);
edge.set_rotNextEdge(fromNode.get_outgoingEdge());
fromNode.set_outgoingEdge(edge);
} else {
fromNode.set_outgoingEdge(edge);
}
var oppositeEdge = toNode.get_successorNodes().h[fromNode.xid];
if(oppositeEdge != null) {
edge.set_oppositeEdge(oppositeEdge);
oppositeEdge.set_oppositeEdge(edge);
}
return edge;
}
,deleteEdge: function(edge) {
if(this._edge == edge) {
if(edge.get_next() != null) {
edge.get_next().set_prev(null);
this._edge = edge.get_next();
} else {
this._edge = null;
}
} else if(edge.get_next() != null) {
edge.get_prev().set_next(edge.get_next());
edge.get_next().set_prev(edge.get_prev());
} else {
edge.get_prev().set_next(null);
}
if(edge.get_sourceNode().get_outgoingEdge() == edge) {
if(edge.get_rotNextEdge() != null) {
edge.get_rotNextEdge().set_rotPrevEdge(null);
edge.get_sourceNode().set_outgoingEdge(edge.get_rotNextEdge());
} else {
edge.get_sourceNode().set_outgoingEdge(null);
}
} else if(edge.get_rotNextEdge() != null) {
edge.get_rotPrevEdge().set_rotNextEdge(edge.get_rotNextEdge());
edge.get_rotNextEdge().set_rotPrevEdge(edge.get_rotPrevEdge());
} else {
edge.get_rotPrevEdge().set_rotNextEdge(null);
}
edge.dispose();
}
,__class__: xDaedalus_data_graph_Graph
};
var xDaedalus_data_graph_GraphEdge = xExport["xDaedalus"]["data"]["graph"]["GraphEdge"] = function() {
this._id = xDaedalus_data_graph_GraphEdge.INC;
xDaedalus_data_graph_GraphEdge.INC++;
};
xClasses["xDaedalus.data.graph.GraphEdge"] = xDaedalus_data_graph_GraphEdge;
xDaedalus_data_graph_GraphEdge.nom = true;
xDaedalus_data_graph_GraphEdge.prototype = {
get_id: function() {
return this._id;
}
,_id: null
,_prev: null
,_next: null
,_rotPrevEdge: null
,_rotNextEdge: null
,_oppositeEdge: null
,_sourceNode: null
,_destinationNode: null
,_data: null
,dispose: function() {
}
,get_prev: function() {
return this._prev;
}
,set_prev: function(value) {
this._prev = value;
return value;
}
,get_next: function() {
return this._next;
}
,set_next: function(value) {
this._next = value;
return value;
}
,get_rotPrevEdge: function() {
return this._rotPrevEdge;
}
,set_rotPrevEdge: function(value) {
this._rotPrevEdge = value;
return value;
}
,get_rotNextEdge: function() {
return this._rotNextEdge;
}
,set_rotNextEdge: function(value) {
this._rotNextEdge = value;
return value;
}
,get_oppositeEdge: function() {
return this._oppositeEdge;
}
,set_oppositeEdge: function(value) {
this._oppositeEdge = value;
return value;
}
,get_sourceNode: function() {
return this._sourceNode;
}
,set_sourceNode: function(value) {
this._sourceNode = value;
return value;
}
,get_destinationNode: function() {
return this._destinationNode;
}
,set_destinationNode: function(value) {
this._destinationNode = value;
return value;
}
,get_data: function() {
return this._data;
}
,set_data: function(value) {
this._data = value;
return value;
}
,__class__: xDaedalus_data_graph_GraphEdge
};
var xDaedalus_data_graph_GraphNode = xExport["xDaedalus"]["data"]["graph"]["GraphNode"] = function() {
this._id = xDaedalus_data_graph_GraphNode.INC;
xDaedalus_data_graph_GraphNode.INC++;
this._successorNodes = new haxe_ds_ObjectMap();
};
xClasses["xDaedalus.data.graph.GraphNode"] = xDaedalus_data_graph_GraphNode;
xDaedalus_data_graph_GraphNode.nom = true;
xDaedalus_data_graph_GraphNode.prototype = {
_id: null
,_prev: null
,_next: null
,_outgoingEdge: null
,_successorNodes: null
,_data: null
,get_id: function() {
return this._id;
}
,dispose: function() {
this._prev = null;
this._next = null;
this._outgoingEdge = null;
this._successorNodes = null;
this._data = null;
}
,get_prev: function() {
return this._prev;
}
,set_prev: function(value) {
this._prev = value;
return value;
}
,get_next: function() {
return this._next;
}
,set_next: function(value) {
this._next = value;
return value;
}
,get_outgoingEdge: function() {
return this._outgoingEdge;
}
,set_outgoingEdge: function(value) {
this._outgoingEdge = value;
return value;
}
,get_successorNodes: function() {
return this._successorNodes;
}
,set_successorNodes: function(value) {
this._successorNodes = value;
return value;
}
,get_data: function() {
return this._data;
}
,set_data: function(value) {
this._data = value;
return value;
}
,__class__: xDaedalus_data_graph_GraphNode
};
var xDaedalus_data_math_EdgeData = xExport["xDaedalus"]["data"]["math"]["EdgeData"] = function() {
};
xClasses["xDaedalus.data.math.EdgeData"] = xDaedalus_data_math_EdgeData;
xDaedalus_data_math_EdgeData.nom = true;
xDaedalus_data_math_EdgeData.prototype = {
sumDistancesSquared: null
,length: null
,nodesCount: null
,__class__: xDaedalus_data_math_EdgeData
};
var xDaedalus_data_math_Intersection = xClasses["xDaedalus.data.math.Intersection"] = { __ename__ : true, __constructs__ : ["EVertex","EEdge","EFace","ENull"] };
xDaedalus_data_math_Intersection.EVertex = function(vertex) { var $x = ["EVertex",0,vertex]; $x.__enum__ = xDaedalus_data_math_Intersection; $x.toString = $estr; return $x; };
xDaedalus_data_math_Intersection.EEdge = function(edge) { var $x = ["EEdge",1,edge]; $x.__enum__ = xDaedalus_data_math_Intersection; $x.toString = $estr; return $x; };
xDaedalus_data_math_Intersection.EFace = function(face) { var $x = ["EFace",2,face]; $x.__enum__ = xDaedalus_data_math_Intersection; $x.toString = $estr; return $x; };
xDaedalus_data_math_Intersection.ENull = ["ENull",3];
xDaedalus_data_math_Intersection.ENull.toString = $estr;
xDaedalus_data_math_Intersection.ENull.__enum__ = xDaedalus_data_math_Intersection;
var xDaedalus_data_math_Point2D = xExport["xDaedalus"]["data"]["math"]["Point2D"] = function(x_,y_) {
if(y_ == null) {
y_ = 0;
}
if(x_ == null) {
x_ = 0;
}
this.x = x_;
this.y = y_;
};
xClasses["xDaedalus.data.math.Point2D"] = xDaedalus_data_math_Point2D;
xDaedalus_data_math_Point2D.nom = true;
xDaedalus_data_math_Point2D.prototype = {
x: null
,y: null
,transform: function(matrix) {
matrix.tranform(this);
}
,setXY: function(x_,y_) {
this.x = x_;
this.y = y_;
}
,clone: function() {
return new xDaedalus_data_math_Point2D(this.x,this.y);
}
,substract: function(p) {
this.x -= p.x;
this.y -= p.y;
}
,get_length: function() {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
,normalize: function() {
var norm = this.get_length();
this.x /= norm;
this.y /= norm;
}
,scale: function(s) {
this.x *= s;
this.y *= s;
}
,distanceTo: function(p) {
var diffX = this.x - p.x;
var diffY = this.y - p.y;
return Math.sqrt(diffX * diffX + diffY * diffY);
}
,__class__: xDaedalus_data_math_Point2D
};
var xDaedalus_data_math_Geom2D = xExport["xDaedalus"]["data"]["math"]["Geom2D"] = function() {
};
xClasses["xDaedalus.data.math.Geom2D"] = xDaedalus_data_math_Geom2D;
xDaedalus_data_math_Geom2D.nom = true;
xDaedalus_data_math_Geom2D.locatePosition = function(x,y,mesh) {
if(xDaedalus_data_math_Geom2D._randGen == null) {
xDaedalus_data_math_Geom2D._randGen = new xDaedalus_data_math_RandGenerator();
}
xDaedalus_data_math_Geom2D._randGen.set_seed(x * 10 + 4 * y | 0);
var i;
xDaedalus_data_math_Geom2D.__samples.splice(0,xDaedalus_data_math_Geom2D.__samples.length);
var numSamples = Math.pow(mesh._vertices.length,0.333333333333333315) | 0;
xDaedalus_data_math_Geom2D._randGen.rangeMin = 0;
xDaedalus_data_math_Geom2D._randGen.rangeMax = mesh._vertices.length - 1;
var _g1 = 0;
var _g = numSamples;
while(_g1 < _g) {
var i1 = _g1++;
var _rnd = xDaedalus_data_math_Geom2D._randGen.next();
var cond = _rnd < 0 || _rnd > mesh._vertices.length - 1;
var cond1 = mesh._vertices == null;
var message = "vertices: " + mesh._vertices.length;
xDaedalus_data_math_Geom2D.__samples.push(mesh._vertices[_rnd]);
}
var currVertex;
var currVertexPos;
var distSquared;
var minDistSquared = Infinity;
var closedVertex = null;
var _g11 = 0;
var _g2 = numSamples;
while(_g11 < _g2) {
var i2 = _g11++;
currVertex = xDaedalus_data_math_Geom2D.__samples[i2];
currVertexPos = currVertex.get_pos();
distSquared = (currVertexPos.x - x) * (currVertexPos.x - x) + (currVertexPos.y - y) * (currVertexPos.y - y);
if(distSquared < minDistSquared) {
minDistSquared = distSquared;
closedVertex = currVertex;
}
}
var currFace;
var iterFace = new xDaedalus_iterators_FromVertexToHoldingFaces();
iterFace.set_fromVertex(closedVertex);
currFace = iterFace.next();
var faceVisited = new haxe_ds_ObjectMap();
var currEdge;
var iterEdge = new xDaedalus_iterators_FromFaceToInnerEdges();
var objectContainer = xDaedalus_data_math_Intersection.ENull;
var relativPos;
var numIter = 0;
while(true) {
var tmp;
if(!faceVisited.h[currFace.xid]) {
objectContainer = xDaedalus_data_math_Geom2D.isInFace(x,y,currFace);
var _g3 = objectContainer;
if(_g3[1] == 3) {
tmp = true;
} else {
tmp = false;
}
} else {
tmp = true;
}
if(!tmp) {
break;
}
++numIter;
var tmp1 = numIter == 50;
iterEdge.set_fromFace(currFace);
while(true) {
currEdge = iterEdge.next();
if(currEdge == null) {
return xDaedalus_data_math_Intersection.ENull;
}
relativPos = xDaedalus_data_math_Geom2D.getRelativePosition(x,y,currEdge);
if(!(relativPos == 1 || relativPos == 0)) {
break;
}
}
currFace = currEdge.get_rightFace();
}
return objectContainer;
};
xDaedalus_data_math_Geom2D.isCircleIntersectingAnyConstraint = function(x,y,radius,mesh) {
if(x <= 0 || x >= mesh.get_width() || y <= 0 || y >= mesh.get_height()) {
return true;
}
var loc = xDaedalus_data_math_Geom2D.locatePosition(x,y,mesh);
var face;
switch(loc[1]) {
case 0:
var vertex = loc[2];
face = vertex.get_edge().get_leftFace();
break;
case 1:
var edge = loc[2];
face = edge.get_leftFace();
break;
case 2:
var face_ = loc[2];
face = face_;
break;
case 3:
face = null;
break;
}
var radiusSquared = radius * radius;
var pos;
var distSquared;
pos = face.get_edge().get_originVertex().get_pos();
distSquared = (pos.x - x) * (pos.x - x) + (pos.y - y) * (pos.y - y);
if(distSquared <= radiusSquared) {
return true;
}
pos = face.get_edge().get_nextLeftEdge().get_originVertex().get_pos();
distSquared = (pos.x - x) * (pos.x - x) + (pos.y - y) * (pos.y - y);
if(distSquared <= radiusSquared) {
return true;
}
pos = face.get_edge().get_nextLeftEdge().get_nextLeftEdge().get_originVertex().get_pos();
distSquared = (pos.x - x) * (pos.x - x) + (pos.y - y) * (pos.y - y);
if(distSquared <= radiusSquared) {
return true;
}
var edgesToCheck = [];
edgesToCheck.push(face.get_edge());
edgesToCheck.push(face.get_edge().get_nextLeftEdge());
edgesToCheck.push(face.get_edge().get_nextLeftEdge().get_nextLeftEdge());
var edge1;
var pos1;
var pos2;
var checkedEdges = new haxe_ds_ObjectMap();
var intersecting;
while(edgesToCheck.length > 0) {
edge1 = edgesToCheck.pop();
checkedEdges.set(edge1,true);
pos1 = edge1.get_originVertex().get_pos();
pos2 = edge1.get_destinationVertex().get_pos();
intersecting = xDaedalus_data_math_Geom2D.intersectionsSegmentCircle(pos1.x,pos1.y,pos2.x,pos2.y,x,y,radius);
if(intersecting) {
if(edge1.get_isConstrained()) {
return true;
} else {
edge1 = edge1.get_oppositeEdge().get_nextLeftEdge();
var tmp;
var tmp1;
var tmp2;
if(!checkedEdges.h[edge1.xid]) {
var key = edge1.get_oppositeEdge();
tmp2 = !checkedEdges.h[key.xid];
} else {
tmp2 = false;
}
if(tmp2) {
tmp1 = edgesToCheck.indexOf(edge1) == -1;
} else {
tmp1 = false;
}
if(tmp1) {
tmp = edgesToCheck.indexOf(edge1.get_oppositeEdge()) == -1;
} else {
tmp = false;
}
if(tmp) {
edgesToCheck.push(edge1);
}
edge1 = edge1.get_nextLeftEdge();
var tmp3;
var tmp4;
var tmp5;
if(!checkedEdges.h[edge1.xid]) {
var key1 = edge1.get_oppositeEdge();
tmp5 = !checkedEdges.h[key1.xid];
} else {
tmp5 = false;
}
if(tmp5) {
tmp4 = edgesToCheck.indexOf(edge1) == -1;
} else {
tmp4 = false;
}
if(tmp4) {
tmp3 = edgesToCheck.indexOf(edge1.get_oppositeEdge()) == -1;
} else {
tmp3 = false;
}
if(tmp3) {
edgesToCheck.push(edge1);
}
}
}
}
return false;
};
xDaedalus_data_math_Geom2D.getDirection = function(x1,y1,x2,y2,x3,y3) {
var dot = (x3 - x1) * (y2 - y1) + (y3 - y1) * (-x2 + x1);
if(dot == 0) {
return 0;
} else if(dot > 0) {
return 1;
} else {
return -1;
}
};
xDaedalus_data_math_Geom2D.getDirection2 = function(x1,y1,x2,y2,x3,y3) {
var dot = (x3 - x1) * (y2 - y1) + (y3 - y1) * (-x2 + x1);
if(dot == 0) {
return 0;
} else if(dot > 0) {
if(xDaedalus_data_math_Geom2D.distanceSquaredPointToLine(x3,y3,x1,y1,x2,y2) <= 0.0001) {
return 0;
} else {
return 1;
}
} else if(xDaedalus_data_math_Geom2D.distanceSquaredPointToLine(x3,y3,x1,y1,x2,y2) <= 0.0001) {
return 0;
} else {
return -1;
}
};
xDaedalus_data_math_Geom2D.getRelativePosition = function(x,y,eUp) {
return xDaedalus_data_math_Geom2D.getDirection(eUp.get_originVertex().get_pos().x,eUp.get_originVertex().get_pos().y,eUp.get_destinationVertex().get_pos().x,eUp.get_destinationVertex().get_pos().y,x,y);
};
xDaedalus_data_math_Geom2D.getRelativePosition2 = function(x,y,eUp) {
return xDaedalus_data_math_Geom2D.getDirection2(eUp.get_originVertex().get_pos().x,eUp.get_originVertex().get_pos().y,eUp.get_destinationVertex().get_pos().x,eUp.get_destinationVertex().get_pos().y,x,y);
};
xDaedalus_data_math_Geom2D.isInFace = function(x,y,polygon) {
var result = xDaedalus_data_math_Intersection.ENull;
var e1_2 = polygon.get_edge();
var e2_3 = e1_2.get_nextLeftEdge();
var e3_1 = e2_3.get_nextLeftEdge();
if(xDaedalus_data_math_Geom2D.getRelativePosition(x,y,e1_2) >= 0 && xDaedalus_data_math_Geom2D.getRelativePosition(x,y,e2_3) >= 0 && xDaedalus_data_math_Geom2D.getRelativePosition(x,y,e3_1) >= 0) {
var v1 = e1_2.get_originVertex();
var v2 = e2_3.get_originVertex();
var v3 = e3_1.get_originVertex();
var x1 = v1.get_pos().x;
var y1 = v1.get_pos().y;
var x2 = v2.get_pos().x;
var y2 = v2.get_pos().y;
var x3 = v3.get_pos().x;
var y3 = v3.get_pos().y;
var v_v1squaredLength = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y);
var v_v2squaredLength = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y);
var v_v3squaredLength = (x3 - x) * (x3 - x) + (y3 - y) * (y3 - y);
var v1_v2squaredLength = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
var v2_v3squaredLength = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);
var v3_v1squaredLength = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3);
var dot_v_v1v2 = (x - x1) * (x2 - x1) + (y - y1) * (y2 - y1);
var dot_v_v2v3 = (x - x2) * (x3 - x2) + (y - y2) * (y3 - y2);
var dot_v_v3v1 = (x - x3) * (x1 - x3) + (y - y3) * (y1 - y3);
var v_e1_2squaredLength = v_v1squaredLength - dot_v_v1v2 * dot_v_v1v2 / v1_v2squaredLength;
var v_e2_3squaredLength = v_v2squaredLength - dot_v_v2v3 * dot_v_v2v3 / v2_v3squaredLength;
var v_e3_1squaredLength = v_v3squaredLength - dot_v_v3v1 * dot_v_v3v1 / v3_v1squaredLength;
var closeTo_e1_2 = v_e1_2squaredLength <= 0.0001;
var closeTo_e2_3 = v_e2_3squaredLength <= 0.0001;
var closeTo_e3_1 = v_e3_1squaredLength <= 0.0001;
if(closeTo_e1_2) {
if(closeTo_e3_1) {
result = xDaedalus_data_math_Intersection.EVertex(v1);
} else if(closeTo_e2_3) {
result = xDaedalus_data_math_Intersection.EVertex(v2);
} else {
result = xDaedalus_data_math_Intersection.EEdge(e1_2);
}
} else if(closeTo_e2_3) {
if(closeTo_e3_1) {
result = xDaedalus_data_math_Intersection.EVertex(v3);
} else {
result = xDaedalus_data_math_Intersection.EEdge(e2_3);
}
} else if(closeTo_e3_1) {
result = xDaedalus_data_math_Intersection.EEdge(e3_1);
} else {
result = xDaedalus_data_math_Intersection.EFace(polygon);
}
}
return result;
};
xDaedalus_data_math_Geom2D.clipSegmentByTriangle = function(s1x,s1y,s2x,s2y,t1x,t1y,t2x,t2y,t3x,t3y,pResult1,pResult2) {
var side1_1;
var side1_2;
side1_1 = xDaedalus_data_math_Geom2D.getDirection(t1x,t1y,t2x,t2y,s1x,s1y);
side1_2 = xDaedalus_data_math_Geom2D.getDirection(t1x,t1y,t2x,t2y,s2x,s2y);
if(side1_1 <= 0 && side1_2 <= 0) {
return false;
}
var side2_1;
var side2_2;
side2_1 = xDaedalus_data_math_Geom2D.getDirection(t2x,t2y,t3x,t3y,s1x,s1y);
side2_2 = xDaedalus_data_math_Geom2D.getDirection(t2x,t2y,t3x,t3y,s2x,s2y);
if(side2_1 <= 0 && side2_2 <= 0) {
return false;
}
var side3_1;
var side3_2;
side3_1 = xDaedalus_data_math_Geom2D.getDirection(t3x,t3y,t1x,t1y,s1x,s1y);
side3_2 = xDaedalus_data_math_Geom2D.getDirection(t3x,t3y,t1x,t1y,s2x,s2y);
if(side3_1 <= 0 && side3_2 <= 0) {
return false;
}
if(side1_1 >= 0 && side2_1 >= 0 && side3_1 >= 0 && (side1_2 >= 0 && side2_2 >= 0 && side3_2 >= 0)) {
pResult1.x = s1x;
pResult1.y = s1y;
pResult2.x = s2x;
pResult2.y = s2y;
return true;
}
var n = 0;
if(xDaedalus_data_math_Geom2D.intersections2segments(s1x,s1y,s2x,s2y,t1x,t1y,t2x,t2y,pResult1,null)) {
++n;
}
if(n == 0) {
if(xDaedalus_data_math_Geom2D.intersections2segments(s1x,s1y,s2x,s2y,t2x,t2y,t3x,t3y,pResult1,null)) {
++n;
}
} else if(xDaedalus_data_math_Geom2D.intersections2segments(s1x,s1y,s2x,s2y,t2x,t2y,t3x,t3y,pResult2,null)) {
if(-0.01 > pResult1.x - pResult2.x || pResult1.x - pResult2.x > 0.01 || -0.01 > pResult1.y - pResult2.y || pResult1.y - pResult2.y > 0.01) {
++n;
}
}
if(n == 0) {
if(xDaedalus_data_math_Geom2D.intersections2segments(s1x,s1y,s2x,s2y,t3x,t3y,t1x,t1y,pResult1,null)) {
++n;
}
} else if(n == 1) {
if(xDaedalus_data_math_Geom2D.intersections2segments(s1x,s1y,s2x,s2y,t3x,t3y,t1x,t1y,pResult2,null)) {
if(-0.01 > pResult1.x - pResult2.x || pResult1.x - pResult2.x > 0.01 || -0.01 > pResult1.y - pResult2.y || pResult1.y - pResult2.y > 0.01) {
++n;
}
}
}
if(n == 1) {
if(side1_1 >= 0 && side2_1 >= 0 && side3_1 >= 0) {
pResult2.x = s1x;
pResult2.y = s1y;
} else if(side1_2 >= 0 && side2_2 >= 0 && side3_2 >= 0) {
pResult2.x = s2x;
pResult2.y = s2y;
} else {
n = 0;
}
}
if(n > 0) {
return true;
} else {
return false;
}
};
xDaedalus_data_math_Geom2D.isSegmentIntersectingTriangle = function(s1x,s1y,s2x,s2y,t1x,t1y,t2x,t2y,t3x,t3y) {
var side1_1;
var side1_2;
side1_1 = xDaedalus_data_math_Geom2D.getDirection(t1x,t1y,t2x,t2y,s1x,s1y);
side1_2 = xDaedalus_data_math_Geom2D.getDirection(t1x,t1y,t2x,t2y,s2x,s2y);
if(side1_1 <= 0 && side1_2 <= 0) {
return false;
}
var side2_1;
var side2_2;
side2_1 = xDaedalus_data_math_Geom2D.getDirection(t2x,t2y,t3x,t3y,s1x,s1y);
side2_2 = xDaedalus_data_math_Geom2D.getDirection(t2x,t2y,t3x,t3y,s2x,s2y);
if(side2_1 <= 0 && side2_2 <= 0) {
return false;
}
var side3_1;
var side3_2;
side3_1 = xDaedalus_data_math_Geom2D.getDirection(t3x,t3y,t1x,t1y,s1x,s1y);
side3_2 = xDaedalus_data_math_Geom2D.getDirection(t3x,t3y,t1x,t1y,s2x,s2y);
if(side3_1 <= 0 && side3_2 <= 0) {
return false;
}
if(side1_1 == 1 && side2_1 == 1 && side3_1 == 1) {
return true;
}
if(side1_1 == 1 && side2_1 == 1 && side3_1 == 1) {
return true;
}
var side1;
var side2;
if(side1_1 == 1 && side1_2 <= 0 || side1_1 <= 0 && side1_2 == 1) {
side1 = xDaedalus_data_math_Geom2D.getDirection(s1x,s1y,s2x,s2y,t1x,t1y);
side2 = xDaedalus_data_math_Geom2D.getDirection(s1x,s1y,s2x,s2y,t2x,t2y);
if(side1 == 1 && side2 <= 0 || side1 <= 0 && side2 == 1) {
return true;
}
}
if(side2_1 == 1 && side2_2 <= 0 || side2_1 <= 0 && side2_2 == 1) {
side1 = xDaedalus_data_math_Geom2D.getDirection(s1x,s1y,s2x,s2y,t2x,t2y);
side2 = xDaedalus_data_math_Geom2D.getDirection(s1x,s1y,s2x,s2y,t3x,t3y);
if(side1 == 1 && side2 <= 0 || side1 <= 0 && side2 == 1) {
return true;
}
}
if(side3_1 == 1 && side3_2 <= 0 || side3_1 <= 0 && side3_2 == 1) {
side1 = xDaedalus_data_math_Geom2D.getDirection(s1x,s1y,s2x,s2y,t3x,t3y);
side2 = xDaedalus_data_math_Geom2D.getDirection(s1x,s1y,s2x,s2y,t1x,t1y);
if(side1 == 1 && side2 <= 0 || side1 <= 0 && side2 == 1) {
return true;
}
}
return false;
};
xDaedalus_data_math_Geom2D.isDelaunay = function(edge) {
var vLeft = edge.get_originVertex();
var vRight = edge.get_destinationVertex();
var vCorner = edge.get_nextLeftEdge().get_destinationVertex();
var vOpposite = edge.get_nextRightEdge().get_destinationVertex();
xDaedalus_data_math_Geom2D.getCircumcenter(vCorner.get_pos().x,vCorner.get_pos().y,vLeft.get_pos().x,vLeft.get_pos().y,vRight.get_pos().x,vRight.get_pos().y,xDaedalus_data_math_Geom2D.__circumcenter);
var squaredRadius = (vCorner.get_pos().x - xDaedalus_data_math_Geom2D.__circumcenter.x) * (vCorner.get_pos().x - xDaedalus_data_math_Geom2D.__circumcenter.x) + (vCorner.get_pos().y - xDaedalus_data_math_Geom2D.__circumcenter.y) * (vCorner.get_pos().y - xDaedalus_data_math_Geom2D.__circumcenter.y);
var squaredDistance = (vOpposite.get_pos().x - xDaedalus_data_math_Geom2D.__circumcenter.x) * (vOpposite.get_pos().x - xDaedalus_data_math_Geom2D.__circumcenter.x) + (vOpposite.get_pos().y - xDaedalus_data_math_Geom2D.__circumcenter.y) * (vOpposite.get_pos().y - xDaedalus_data_math_Geom2D.__circumcenter.y);
return squaredDistance >= squaredRadius;
};
xDaedalus_data_math_Geom2D.getCircumcenter = function(x1,y1,x2,y2,x3,y3,result) {
if(result == null) {
result = new xDaedalus_data_math_Point2D();
}
var m1 = (x1 + x2) / 2;
var m2 = (y1 + y2) / 2;
var m3 = (x1 + x3) / 2;
var m4 = (y1 + y3) / 2;
var t1 = (m1 * (x1 - x3) + (m2 - m4) * (y1 - y3) + m3 * (x3 - x1)) / (x1 * (y3 - y2) + x2 * (y1 - y3) + x3 * (y2 - y1));
result.x = m1 + t1 * (y2 - y1);
result.y = m2 - t1 * (x2 - x1);
return result;
};
xDaedalus_data_math_Geom2D.intersections2segments = function(s1p1x,s1p1y,s1p2x,s1p2y,s2p1x,s2p1y,s2p2x,s2p2y,posIntersection,paramIntersection,infiniteLineMode) {
if(infiniteLineMode == null) {
infiniteLineMode = false;
}
var t1 = 0;
var t2 = 0;
var result;
var divisor = (s1p1x - s1p2x) * (s2p1y - s2p2y) + (s1p2y - s1p1y) * (s2p1x - s2p2x);
if(divisor == 0) {
result = false;
} else {
result = true;
if(!infiniteLineMode || posIntersection != null || paramIntersection != null) {
t1 = (s1p1x * (s2p1y - s2p2y) + s1p1y * (s2p2x - s2p1x) + s2p1x * s2p2y - s2p1y * s2p2x) / divisor;
t2 = (s1p1x * (s2p1y - s1p2y) + s1p1y * (s1p2x - s2p1x) - s1p2x * s2p1y + s1p2y * s2p1x) / divisor;
if(!infiniteLineMode && !(0 <= t1 && t1 <= 1 && 0 <= t2 && t2 <= 1)) {
result = false;
}
}
}
if(result) {
if(posIntersection != null) {
posIntersection.x = s1p1x + t1 * (s1p2x - s1p1x);
posIntersection.y = s1p1y + t1 * (s1p2y - s1p1y);
}
if(paramIntersection != null) {
paramIntersection.push(t1);
paramIntersection.push(t2);
}
}
return result;
};
xDaedalus_data_math_Geom2D.intersections2edges = function(edge1,edge2,posIntersection,paramIntersection,infiniteLineMode) {
if(infiniteLineMode == null) {
infiniteLineMode = false;
}
return xDaedalus_data_math_Geom2D.intersections2segments(edge1.get_originVertex().get_pos().x,edge1.get_originVertex().get_pos().y,edge1.get_destinationVertex().get_pos().x,edge1.get_destinationVertex().get_pos().y,edge2.get_originVertex().get_pos().x,edge2.get_originVertex().get_pos().y,edge2.get_destinationVertex().get_pos().x,edge2.get_destinationVertex().get_pos().y,posIntersection,paramIntersection,infiniteLineMode);
};
xDaedalus_data_math_Geom2D.isConvex = function(edge) {
var result = true;
var eLeft;
var vRight;
eLeft = edge.get_nextLeftEdge().get_oppositeEdge();
vRight = edge.get_nextRightEdge().get_destinationVertex();
if(xDaedalus_data_math_Geom2D.getRelativePosition(vRight.get_pos().x,vRight.get_pos().y,eLeft) != -1) {
result = false;
} else {
eLeft = edge.get_prevRightEdge();
vRight = edge.get_prevLeftEdge().get_originVertex();
if(xDaedalus_data_math_Geom2D.getRelativePosition(vRight.get_pos().x,vRight.get_pos().y,eLeft) != -1) {
result = false;
}
}
return result;
};
xDaedalus_data_math_Geom2D.projectOrthogonaly = function(vertexPos,edge) {
var a = edge.get_originVertex().get_pos().x;
var b = edge.get_originVertex().get_pos().y;
var c = edge.get_destinationVertex().get_pos().x;
var d = edge.get_destinationVertex().get_pos().y;
var e = vertexPos.x;
var f = vertexPos.y;
var t1 = (a * a - a * c - a * e + b * b - b * d - b * f + c * e + d * f) / (a * a - 2 * a * c + b * b - 2 * b * d + c * c + d * d);
vertexPos.x = a + t1 * (c - a);
vertexPos.y = b + t1 * (d - b);
};
xDaedalus_data_math_Geom2D.intersections2Circles = function(cx1,cy1,r1,cx2,cy2,r2,result) {
var distRadiusSQRD = (cx2 - cx1) * (cx2 - cx1) + (cy2 - cy1) * (cy2 - cy1);
if((cx1 != cx2 || cy1 != cy2) && distRadiusSQRD <= (r1 + r2) * (r1 + r2) && distRadiusSQRD >= (r1 - r2) * (r1 - r2)) {
var transcendPart = Math.sqrt(((r1 + r2) * (r1 + r2) - distRadiusSQRD) * (distRadiusSQRD - (r2 - r1) * (r2 - r1)));
var xFirstPart = (cx1 + cx2) / 2 + (cx2 - cx1) * (r1 * r1 - r2 * r2) / (2 * distRadiusSQRD);
var yFirstPart = (cy1 + cy2) / 2 + (cy2 - cy1) * (r1 * r1 - r2 * r2) / (2 * distRadiusSQRD);
var xFactor = (cy2 - cy1) / (2 * distRadiusSQRD);
var yFactor = (cx2 - cx1) / (2 * distRadiusSQRD);
if(result != null) {
var _g = 0;
var _g1 = [xFirstPart + xFactor * transcendPart,yFirstPart - yFactor * transcendPart,xFirstPart - xFactor * transcendPart,yFirstPart + yFactor * transcendPart];
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
result.push(f);
}
}
return true;
} else {
return false;
}
};
xDaedalus_data_math_Geom2D.intersectionsSegmentCircle = function(p0x,p0y,p1x,p1y,cx,cy,r,result) {
var p0xSQD = p0x * p0x;
var p0ySQD = p0y * p0y;
var a = p1y * p1y - 2 * p1y * p0y + p0ySQD + p1x * p1x - 2 * p1x * p0x + p0xSQD;
var b = 2 * p0y * cy - 2 * p0xSQD + 2 * p1y * p0y - 2 * p0ySQD + 2 * p1x * p0x - 2 * p1x * cx + 2 * p0x * cx - 2 * p1y * cy;
var c = p0ySQD + cy * cy + cx * cx - 2 * p0y * cy - 2 * p0x * cx + p0xSQD - r * r;
var delta = b * b - 4 * a * c;
var deltaSQRT;
var t0;
var t1;
if(delta < 0) {
return false;
} else if(delta == 0) {
t0 = -b / (2 * a);
if(t0 < 0 || t0 > 1) {
return false;
}
if(result != null) {
var _g = 0;
var _g1 = [p0x + t0 * (p1x - p0x),p0y + t0 * (p1y - p0y),t0];
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
result.push(f);
}
}
return true;
} else {
deltaSQRT = Math.sqrt(delta);
t0 = (-b + deltaSQRT) / (2 * a);
t1 = (-b - deltaSQRT) / (2 * a);
var intersecting = false;
if(0 <= t0 && t0 <= 1) {
if(result != null) {
var _g2 = 0;
var _g11 = [p0x + t0 * (p1x - p0x),p0y + t0 * (p1y - p0y),t0];
while(_g2 < _g11.length) {
var f1 = _g11[_g2];
++_g2;
result.push(f1);
}
}
intersecting = true;
}
if(0 <= t1 && t1 <= 1) {
if(result != null) {
var _g3 = 0;
var _g12 = [p0x + t1 * (p1x - p0x),p0y + t1 * (p1y - p0y),t1];
while(_g3 < _g12.length) {
var f2 = _g12[_g3];
++_g3;
result.push(f2);
}
}
intersecting = true;
}
return intersecting;
}
};
xDaedalus_data_math_Geom2D.intersectionsLineCircle = function(p0x,p0y,p1x,p1y,cx,cy,r,result) {
var p0xSQD = p0x * p0x;
var p0ySQD = p0y * p0y;
var a = p1y * p1y - 2 * p1y * p0y + p0ySQD + p1x * p1x - 2 * p1x * p0x + p0xSQD;
var b = 2 * p0y * cy - 2 * p0xSQD + 2 * p1y * p0y - 2 * p0ySQD + 2 * p1x * p0x - 2 * p1x * cx + 2 * p0x * cx - 2 * p1y * cy;
var c = p0ySQD + cy * cy + cx * cx - 2 * p0y * cy - 2 * p0x * cx + p0xSQD - r * r;
var delta = b * b - 4 * a * c;
var deltaSQRT;
var t0;
var t1;
if(delta < 0) {
return false;
} else if(delta == 0) {
t0 = -b / (2 * a);
var _g = 0;
var _g1 = [p0x + t0 * (p1x - p0x),p0y + t0 * (p1y - p0y),t0];
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
result.push(f);
}
} else if(delta > 0) {
deltaSQRT = Math.sqrt(delta);
t0 = (-b + deltaSQRT) / (2 * a);
t1 = (-b - deltaSQRT) / (2 * a);
var _g2 = 0;
var _g11 = [p0x + t0 * (p1x - p0x),p0y + t0 * (p1y - p0y),t0,p0x + t1 * (p1x - p0x),p0y + t1 * (p1y - p0y),t1];
while(_g2 < _g11.length) {
var f1 = _g11[_g2];
++_g2;
result.push(f1);
}
}
return true;
};
xDaedalus_data_math_Geom2D.tangentsPointToCircle = function(px,py,cx,cy,r,result) {
var c2x = (px + cx) / 2;
var c2y = (py + cy) / 2;
var r2 = 0.5 * Math.sqrt((px - cx) * (px - cx) + (py - cy) * (py - cy));
return xDaedalus_data_math_Geom2D.intersections2Circles(c2x,c2y,r2,cx,cy,r,result);
};
xDaedalus_data_math_Geom2D.tangentsCrossCircleToCircle = function(r,c1x,c1y,c2x,c2y,result) {
var distance = Math.sqrt((c1x - c2x) * (c1x - c2x) + (c1y - c2y) * (c1y - c2y));
var radius = distance / 4;
var centerX = c1x + (c2x - c1x) / 4;
var centerY = c1y + (c2y - c1y) / 4;
if(xDaedalus_data_math_Geom2D.intersections2Circles(c1x,c1y,r,centerX,centerY,radius,result)) {
var t1x = result[0];
var t1y = result[1];
var t2x = result[2];
var t2y = result[3];
var midX = (c1x + c2x) / 2;
var midY = (c1y + c2y) / 2;
var dotProd = (t1x - midX) * (c2y - c1y) + (t1y - midY) * (-c2x + c1x);
var tproj = dotProd / (distance * distance);
var projx = midX + tproj * (c2y - c1y);
var projy = midY - tproj * (c2x - c1x);
var t4x = 2 * projx - t1x;
var t4y = 2 * projy - t1y;
var t3x = t4x + t2x - t1x;
var t3y = t2y + t4y - t1y;
var _g = 0;
var _g1 = [t3x,t3y,t4x,t4y];
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
result.push(f);
}
return true;
} else {
return false;
}
};
xDaedalus_data_math_Geom2D.tangentsParalCircleToCircle = function(r,c1x,c1y,c2x,c2y,result) {
var distance = Math.sqrt((c1x - c2x) * (c1x - c2x) + (c1y - c2y) * (c1y - c2y));
var t1x = c1x + r * (c2y - c1y) / distance;
var t1y = c1y + r * (-c2x + c1x) / distance;
var t2x = 2 * c1x - t1x;
var t2y = 2 * c1y - t1y;
var t3x = t2x + c2x - c1x;
var t3y = t2y + c2y - c1y;
var t4x = t1x + c2x - c1x;
var t4y = t1y + c2y - c1y;
var _g = 0;
var _g1 = [t1x,t1y,t2x,t2y,t3x,t3y,t4x,t4y];
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
result.push(f);
}
};
xDaedalus_data_math_Geom2D.distanceSquaredPointToLine = function(px,py,ax,ay,bx,by) {
var a_b_squaredLength = (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
var dotProduct = (px - ax) * (bx - ax) + (py - ay) * (by - ay);
var p_a_squaredLength = (ax - px) * (ax - px) + (ay - py) * (ay - py);
return p_a_squaredLength - dotProduct * dotProduct / a_b_squaredLength;
};
xDaedalus_data_math_Geom2D.distanceSquaredPointToSegment = function(px,py,ax,ay,bx,by) {
var a_b_squaredLength = (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
var dotProduct = ((px - ax) * (bx - ax) + (py - ay) * (by - ay)) / a_b_squaredLength;
if(dotProduct < 0) {
return (px - ax) * (px - ax) + (py - ay) * (py - ay);
} else if(dotProduct <= 1) {
var p_a_squaredLength = (ax - px) * (ax - px) + (ay - py) * (ay - py);
return p_a_squaredLength - dotProduct * dotProduct * a_b_squaredLength;
} else {
return (px - bx) * (px - bx) + (py - by) * (py - by);
}
};
xDaedalus_data_math_Geom2D.distanceSquaredVertexToEdge = function(vertex,edge) {
return xDaedalus_data_math_Geom2D.distanceSquaredPointToSegment(vertex.get_pos().x,vertex.get_pos().y,edge.get_originVertex().get_pos().x,edge.get_originVertex().get_pos().y,edge.get_destinationVertex().get_pos().x,edge.get_destinationVertex().get_pos().y);
};
xDaedalus_data_math_Geom2D.pathLength = function(path) {
var sumDistance = 0.;
var fromX = path[0];
var fromY = path[1];
var nextX;
var nextY;
var x;
var y;
var distance;
var i = 2;
while(i < path.length) {
nextX = path[i];
nextY = path[i + 1];
x = nextX - fromX;
y = nextY - fromY;
distance = Math.sqrt(x * x + y * y);
sumDistance += distance;
fromX = nextX;
fromY = nextY;
i += 2;
}
return sumDistance;
};
xDaedalus_data_math_Geom2D.prototype = {
__class__: xDaedalus_data_math_Geom2D
};
var xDaedalus_data_math_Matrix2D = xExport["xDaedalus"]["data"]["math"]["Matrix2D"] = function(a_,b_,c_,d_,e_,f_) {
if(f_ == null) {
f_ = 0;
}
if(e_ == null) {
e_ = 0;
}
if(d_ == null) {
d_ = 1;
}
if(c_ == null) {
c_ = 0;
}
if(b_ == null) {
b_ = 0;
}
if(a_ == null) {
a_ = 1;
}
this.a = a_;
this.b = b_;
this.c = c_;
this.d = d_;
this.e = e_;
this.f = f_;
};
xClasses["xDaedalus.data.math.Matrix2D"] = xDaedalus_data_math_Matrix2D;
xDaedalus_data_math_Matrix2D.nom = true;
xDaedalus_data_math_Matrix2D.prototype = {
a: null
,b: null
,c: null
,d: null
,e: null
,f: null
,identity: function() {
this.a = 1;
this.b = 0;
this.c = 0;
this.d = 1;
this.e = 0;
this.f = 0;
}
,translate: function(tx,ty) {
this.e += tx;
this.f += ty;
}
,scale: function(sx,sy) {
this.a *= sx;
this.b *= sy;
this.c *= sx;
this.d *= sy;
this.e *= sx;
this.f *= sy;
}
,rotate: function(rad) {
var cos = Math.cos(rad);
var sin = Math.sin(rad);
var a_ = this.a * cos + this.b * -sin;
var b_ = this.a * sin + this.b * cos;
var c_ = this.c * cos + this.d * -sin;
var d_ = this.c * sin + this.d * cos;
var e_ = this.e * cos + this.f * -sin;
var f_ = this.e * sin + this.f * cos;
this.a = a_;
this.b = b_;
this.c = c_;
this.d = d_;
this.e = e_;
this.f = f_;
}
,clone: function() {
return new xDaedalus_data_math_Matrix2D(this.a,this.b,this.c,this.d,this.e,this.f);
}
,tranform: function(point) {
var x = this.a * point.x + this.c * point.y + this.e;
var y = this.b * point.x + this.d * point.y + this.f;
point.x = x;
point.y = y;
}
,transformX: function(x,y) {
return this.a * x + this.c * y + this.e;
}
,transformY: function(x,y) {
return this.b * x + this.d * y + this.f;
}
,concat: function(matrix) {
var a_ = this.a * matrix.a + this.b * matrix.c;
var b_ = this.a * matrix.b + this.b * matrix.d;
var c_ = this.c * matrix.a + this.d * matrix.c;
var d_ = this.c * matrix.b + this.d * matrix.d;
var e_ = this.e * matrix.a + this.f * matrix.c + matrix.e;
var f_ = this.e * matrix.b + this.f * matrix.d + matrix.f;
this.a = a_;
this.b = b_;
this.c = c_;
this.d = d_;
this.e = e_;
this.f = f_;
}
,__class__: xDaedalus_data_math_Matrix2D
};
var xDaedalus_data_math_NodeData = xExport["xDaedalus"]["data"]["math"]["NodeData"] = function() {
};
xClasses["xDaedalus.data.math.NodeData"] = xDaedalus_data_math_NodeData;
xDaedalus_data_math_NodeData.nom = true;
xDaedalus_data_math_NodeData.prototype = {
index: null
,point: null
,__class__: xDaedalus_data_math_NodeData
};
var xDaedalus_data_math_Potrace = xExport["xDaedalus"]["data"]["math"]["Potrace"] = function() {
};
xClasses["xDaedalus.data.math.Potrace"] = xDaedalus_data_math_Potrace;
xDaedalus_data_math_Potrace.nom = true;
xDaedalus_data_math_Potrace.buildShapes = function(bmpData,debugBmp,debugShape) {
var shapes = [];
var dictPixelsDone = new haxe_ds_StringMap();
var _g1 = 1;
var _g = bmpData.height - 1;
while(_g1 < _g) {
var row = _g1++;
var _g3 = 0;
var _g2 = bmpData.width - 1;
while(_g3 < _g2) {
var col = _g3++;
if(xPixels_xPixels_PixelsxImplx.getPixel(bmpData,col,row) == 16777215 && xPixels_xPixels_PixelsxImplx.getPixel(bmpData,col + 1,row) < 16777215) {
var key = col + 1 + "_" + row;
if(!(__map_reserved[key] != null ? dictPixelsDone.getReserved(key) : dictPixelsDone.h[key])) {
shapes.push(xDaedalus_data_math_Potrace.buildShape(bmpData,row,col + 1,dictPixelsDone,debugBmp,debugShape));
}
}
}
}
return shapes;
};
xDaedalus_data_math_Potrace.buildShape = function(bmpData,fromPixelRow,fromPixelCol,dictPixelsDone,debugBmp,debugShape) {
var newX = fromPixelCol;
var newY = fromPixelRow;
var path = [newX,newY];
var key = newX + "_" + newY;
if(__map_reserved[key] != null) {
dictPixelsDone.setReserved(key,true);
} else {
dictPixelsDone.h[key] = true;
}
var curDir = new xDaedalus_data_math_Point2D(0,1);
var newDir = new xDaedalus_data_math_Point2D();
var newPixelRow;
var newPixelCol;
var count = -1;
while(true) {
if(debugBmp != null) {
xPixels_xPixels_PixelsxImplx.setPixel32(debugBmp,fromPixelCol,fromPixelRow,-65536);
}
newPixelRow = fromPixelRow + curDir.x + curDir.y | 0;
newPixelCol = fromPixelCol + curDir.x - curDir.y | 0;
if(xPixels_xPixels_PixelsxImplx.getPixel(bmpData,newPixelCol,newPixelRow) < 16777215) {
newDir.x = -curDir.y;
newDir.y = curDir.x;
} else {
newPixelRow = fromPixelRow + curDir.y | 0;
newPixelCol = fromPixelCol + curDir.x | 0;
if(xPixels_xPixels_PixelsxImplx.getPixel(bmpData,newPixelCol,newPixelRow) < 16777215) {
newDir.x = curDir.x;
newDir.y = curDir.y;
} else {
newPixelRow = fromPixelRow;
newPixelCol = fromPixelCol;
newDir.x = curDir.y;
newDir.y = -curDir.x;
}
}
newX += curDir.x;
newY += curDir.y;
if(newX == path[0] && newY == path[1]) {
break;
} else {
path.push(newX);
path.push(newY);
var key1 = newX + "_" + newY;
if(__map_reserved[key1] != null) {
dictPixelsDone.setReserved(key1,true);
} else {
dictPixelsDone.h[key1] = true;
}
fromPixelRow = newPixelRow;
fromPixelCol = newPixelCol;
curDir.x = newDir.x;
curDir.y = newDir.y;
}
--count;
if(count == 0) {
break;
}
}
if(debugShape != null) {
debugShape.graphics.lineStyle(0.5,65280,1);
debugShape.graphics.moveTo(path[0],path[1]);
var i = 2;
while(i < path.length) {
debugShape.graphics.lineTo(path[i],path[i + 1]);
i += 2;
}
debugShape.graphics.lineTo(path[0],path[1]);
}
return path;
};
xDaedalus_data_math_Potrace.buildGraph = function(shape) {
var i;
var graph = new xDaedalus_data_graph_Graph();
var node;
i = 0;
while(i < shape.length) {
node = graph.insertNode();
node.set_data(new xDaedalus_data_math_NodeData());
node.get_data().index = i;
var shape1 = shape[i];
var shape2 = shape[i + 1];
node.get_data().point = new xDaedalus_data_math_Point2D(shape1,shape2);
i += 2;
}
var node1;
var node2;
var subNode;
var distSqrd;
var sumDistSqrd;
var count;
var isValid;
var edge;
var edgeData;
node1 = graph.get_node();
while(node1 != null) {
if(node1.get_next() != null) {
node2 = node1.get_next();
} else {
node2 = graph.get_node();
}
while(node2 != node1) {
isValid = true;
if(node1.get_next() != null) {
subNode = node1.get_next();
} else {
subNode = graph.get_node();
}
count = 2;
sumDistSqrd = 0;
while(subNode != node2) {
distSqrd = xDaedalus_data_math_Geom2D.distanceSquaredPointToSegment(subNode.get_data().point.x,subNode.get_data().point.y,node1.get_data().point.x,node1.get_data().point.y,node2.get_data().point.x,node2.get_data().point.y);
if(distSqrd < 0) {
distSqrd = 0;
}
if(distSqrd >= xDaedalus_data_math_Potrace.maxDistance) {
isValid = false;
break;
}
++count;
sumDistSqrd += distSqrd;
if(subNode.get_next() != null) {
subNode = subNode.get_next();
} else {
subNode = graph.get_node();
}
}
if(!isValid) {
break;
}
edge = graph.insertEdge(node1,node2);
edgeData = new xDaedalus_data_math_EdgeData();
edgeData.sumDistancesSquared = sumDistSqrd;
edgeData.length = node1.get_data().point.distanceTo(node2.get_data().point);
edgeData.nodesCount = count;
edge.set_data(edgeData);
if(node2.get_next() != null) {
node2 = node2.get_next();
} else {
node2 = graph.get_node();
}
}
node1 = node1.get_next();
}
return graph;
};
xDaedalus_data_math_Potrace.buildPolygon = function(graph,debugShape) {
var polygon = [];
var currNode;
var minNodeIndex = 2147483647;
var edge;
var score;
var higherScore;
var lowerScoreEdge = null;
currNode = graph.get_node();
while(currNode.get_data().index < minNodeIndex) {
minNodeIndex = currNode.get_data().index;
polygon.push(currNode.get_data().point.x);
polygon.push(currNode.get_data().point.y);
higherScore = 0;
edge = currNode.get_outgoingEdge();
while(edge != null) {
score = edge.get_data().nodesCount - edge.get_data().length * Math.sqrt(edge.get_data().sumDistancesSquared / edge.get_data().nodesCount);
if(score > higherScore) {
higherScore = score;
lowerScoreEdge = edge;
}
edge = edge.get_rotNextEdge();
}
currNode = lowerScoreEdge.get_destinationNode();
}
if(xDaedalus_data_math_Geom2D.getDirection(polygon[polygon.length - 2],polygon[polygon.length - 1],polygon[0],polygon[1],polygon[2],polygon[3]) == 0) {
polygon.shift();
polygon.shift();
}
if(debugShape != null) {
debugShape.graphics.lineStyle(0.5,255);
debugShape.graphics.moveTo(polygon[0],polygon[1]);
var i = 2;
while(i < polygon.length) {
debugShape.graphics.lineTo(polygon[i],polygon[i + 1]);
i += 2;
}
debugShape.graphics.lineTo(polygon[0],polygon[1]);
}
return polygon;
};
xDaedalus_data_math_Potrace.prototype = {
__class__: xDaedalus_data_math_Potrace
};
var xDaedalus_data_math_RandGenerator = xExport["xDaedalus"]["data"]["math"]["RandGenerator"] = function(seed,rangeMin_,rangeMax_) {
if(rangeMax_ == null) {
rangeMax_ = 1;
}
if(rangeMin_ == null) {
rangeMin_ = 0;
}
if(seed == null) {
seed = 1234;
}
this._originalSeed = this._currSeed = seed;
this.rangeMin = rangeMin_;
this.rangeMax = rangeMax_;
this._numIter = 0;
};
xClasses["xDaedalus.data.math.RandGenerator"] = xDaedalus_data_math_RandGenerator;
xDaedalus_data_math_RandGenerator.nom = true;
xDaedalus_data_math_RandGenerator.prototype = {
rangeMin: null
,rangeMax: null
,_originalSeed: null
,_currSeed: null
,_rangeMin: null
,_rangeMax: null
,_numIter: null
,_tempString: null
,set_seed: function(value) {
this._originalSeed = this._currSeed = value;
return value;
}
,get_seed: function() {
return this._originalSeed;
}
,reset: function() {
this._currSeed = this._originalSeed;
this._numIter = 0;
}
,next: function() {
var _floatSeed = this._currSeed * 1.0;
this._tempString = Std.string(_floatSeed * _floatSeed);
while(this._tempString.length < 8) this._tempString = "0" + this._tempString;
this._currSeed = Std.parseInt(xOverrides.substr(this._tempString,1,5));
var res = Math.round(this.rangeMin + this._currSeed / 99999 * (this.rangeMax - this.rangeMin));
if(this._currSeed == 0) {
this._currSeed = this._originalSeed + this._numIter;
}
this._numIter++;
if(this._numIter == 200) {
this.reset();
}
return res;
}
,nextInRange: function(rangeMin,rangeMax) {
this.rangeMin = rangeMin;
this.rangeMax = rangeMax;
return this.next();
}
,shuffle: function(array) {
var currIdx = array.length;
while(currIdx > 0) {
var rndIdx = this.nextInRange(0,currIdx - 1);
--currIdx;
var tmp = array[currIdx];
array[currIdx] = array[rndIdx];
array[rndIdx] = tmp;
}
}
,__class__: xDaedalus_data_math_RandGenerator
};
var xDaedalus_data_math_ShapeSimplifier = xExport["xDaedalus"]["data"]["math"]["ShapeSimplifier"] = function() { };
xClasses["xDaedalus.data.math.ShapeSimplifier"] = xDaedalus_data_math_ShapeSimplifier;
xDaedalus_data_math_ShapeSimplifier.nom = true;
xDaedalus_data_math_ShapeSimplifier.simplify = function(coords,epsilon) {
if(epsilon == null) {
epsilon = 1;
}
var len = coords.length;
if(len <= 4 || epsilon < 1) {
return [].concat(coords);
}
var firstPointX = coords[0];
var firstPointY = coords[1];
var lastPointX = coords[len - 2];
var lastPointY = coords[len - 1];
var index = -1;
var dist = 0.;
var _g1 = 1;
var _g = len >> 1;
while(_g1 < _g) {
var i = _g1++;
var currDist = xDaedalus_data_math_Geom2D.distanceSquaredPointToSegment(coords[i << 1],coords[(i << 1) + 1],firstPointX,firstPointY,lastPointX,lastPointY);
if(currDist > dist) {
dist = currDist;
index = i;
}
}
if(dist > epsilon * epsilon) {
var l1 = coords.slice(0,(index << 1) + 2);
var l2 = coords.slice(index << 1);
var r1 = xDaedalus_data_math_ShapeSimplifier.simplify(l1,epsilon);
var r2 = xDaedalus_data_math_ShapeSimplifier.simplify(l2,epsilon);
var rs = r1.slice(0,r1.length - 2).concat(r2);
return rs;
} else {
return [firstPointX,firstPointY,lastPointX,lastPointY];
}
};
var xDaedalus_debug_Debug = function() { };
xClasses["xDaedalus.debug.Debug"] = xDaedalus_debug_Debug;
xDaedalus_debug_Debug.nom = true;
xDaedalus_debug_Debug.assertTrue = function(cond,message,pos) {
return;
};
xDaedalus_debug_Debug.assertFalse = function(cond,message,pos) {
return;
};
xDaedalus_debug_Debug.assertEquals = function(expected,actual,message,pos) {
return;
};
xDaedalus_debug_Debug.trace = function(value,pos) {
return;
};
var xDaedalus_factories_BitmapObject = xExport["xDaedalus"]["factories"]["BitmapObject"] = function() {
};
xClasses["xDaedalus.factories.BitmapObject"] = xDaedalus_factories_BitmapObject;
xDaedalus_factories_BitmapObject.nom = true;
xDaedalus_factories_BitmapObject.buildFromBmpData = function(bmpData,simplificationEpsilon,debugBmp,debugShape) {
if(simplificationEpsilon == null) {
simplificationEpsilon = 1;
}
var i;
var j;
var cond = bmpData.width > 0 && bmpData.height > 0;
var message = "Invalid `bmpData` size (" + bmpData.width + ", " + bmpData.height + ")";
var shapes = xDaedalus_data_math_Potrace.buildShapes(bmpData,debugBmp,debugShape);
if(simplificationEpsilon >= 1) {
var _g1 = 0;
var _g = shapes.length;
while(_g1 < _g) {
var i1 = _g1++;
shapes[i1] = xDaedalus_data_math_ShapeSimplifier.simplify(shapes[i1],simplificationEpsilon);
}
}
var graphs = [];
var _g11 = 0;
var _g2 = shapes.length;
while(_g11 < _g2) {
var i2 = _g11++;
graphs.push(xDaedalus_data_math_Potrace.buildGraph(shapes[i2]));
}
var polygons = [];
var _g12 = 0;
var _g3 = graphs.length;
while(_g12 < _g3) {
var i3 = _g12++;
polygons.push(xDaedalus_data_math_Potrace.buildPolygon(graphs[i3],debugShape));
}
var obj = new xDaedalus_data_Object();
var _g13 = 0;
var _g4 = polygons.length;
while(_g13 < _g4) {
var i4 = _g13++;
j = 0;
while(j < polygons[i4].length - 2) {
obj.get_coordinates().push(polygons[i4][j]);
obj.get_coordinates().push(polygons[i4][j + 1]);
obj.get_coordinates().push(polygons[i4][j + 2]);
obj.get_coordinates().push(polygons[i4][j + 3]);
j += 2;
}
obj.get_coordinates().push(polygons[i4][0]);
obj.get_coordinates().push(polygons[i4][1]);
obj.get_coordinates().push(polygons[i4][j]);
obj.get_coordinates().push(polygons[i4][j + 1]);
}
return obj;
};
xDaedalus_factories_BitmapObject.prototype = {
__class__: xDaedalus_factories_BitmapObject
};
var xDaedalus_factories_RectMesh = xExport["xDaedalus"]["factories"]["RectMesh"] = function() {
};
xClasses["xDaedalus.factories.RectMesh"] = xDaedalus_factories_RectMesh;
xDaedalus_factories_RectMesh.nom = true;
xDaedalus_factories_RectMesh.buildRectangle = function(width,height) {
var vTL = new xDaedalus_data_Vertex();
var vTR = new xDaedalus_data_Vertex();
var vBR = new xDaedalus_data_Vertex();
var vBL = new xDaedalus_data_Vertex();
var eTL_TR = new xDaedalus_data_Edge();
var eTR_TL = new xDaedalus_data_Edge();
var eTR_BR = new xDaedalus_data_Edge();
var eBR_TR = new xDaedalus_data_Edge();
var eBR_BL = new xDaedalus_data_Edge();
var eBL_BR = new xDaedalus_data_Edge();
var eBL_TL = new xDaedalus_data_Edge();
var eTL_BL = new xDaedalus_data_Edge();
var eTR_BL = new xDaedalus_data_Edge();
var eBL_TR = new xDaedalus_data_Edge();
var eTL_BR = new xDaedalus_data_Edge();
var eBR_TL = new xDaedalus_data_Edge();
var fTL_BL_TR = new xDaedalus_data_Face();
var fTR_BL_BR = new xDaedalus_data_Face();
var fTL_BR_BL = new xDaedalus_data_Face();
var fTL_TR_BR = new xDaedalus_data_Face();
var boundShape = new xDaedalus_data_ConstraintShape();
var segTop = new xDaedalus_data_ConstraintSegment();
var segRight = new xDaedalus_data_ConstraintSegment();
var segBot = new xDaedalus_data_ConstraintSegment();
var segLeft = new xDaedalus_data_ConstraintSegment();
var mesh = new xDaedalus_data_Mesh(width,height);
var offset = 10.;
vTL.get_pos().setXY(0 - offset,0 - offset);
vTR.get_pos().setXY(width + offset,0 - offset);
vBR.get_pos().setXY(width + offset,height + offset);
vBL.get_pos().setXY(0 - offset,height + offset);
vTL.setDatas(eTL_TR);
vTR.setDatas(eTR_BR);
vBR.setDatas(eBR_BL);
vBL.setDatas(eBL_TL);
eTL_TR.setDatas(vTL,eTR_TL,eTR_BR,fTL_TR_BR,true,true);
eTR_TL.setDatas(vTR,eTL_TR,eTL_BL,fTL_BL_TR,true,true);
eTR_BR.setDatas(vTR,eBR_TR,eBR_TL,fTL_TR_BR,true,true);
eBR_TR.setDatas(vBR,eTR_BR,eTR_BL,fTR_BL_BR,true,true);
eBR_BL.setDatas(vBR,eBL_BR,eBL_TL,fTL_BR_BL,true,true);
eBL_BR.setDatas(vBL,eBR_BL,eBR_TR,fTR_BL_BR,true,true);
eBL_TL.setDatas(vBL,eTL_BL,eTL_BR,fTL_BR_BL,true,true);
eTL_BL.setDatas(vTL,eBL_TL,eBL_TR,fTL_BL_TR,true,true);
eTR_BL.setDatas(vTR,eBL_TR,eBL_BR,fTR_BL_BR,true,false);
eBL_TR.setDatas(vBL,eTR_BL,eTR_TL,fTL_BL_TR,true,false);
eTL_BR.setDatas(vTL,eBR_TL,eBR_BL,fTL_BR_BL,false,false);
eBR_TL.setDatas(vBR,eTL_BR,eTL_TR,fTL_TR_BR,false,false);
fTL_BL_TR.setDatas(eBL_TR);
fTR_BL_BR.setDatas(eTR_BL);
fTL_BR_BL.setDatas(eBR_BL,false);
fTL_TR_BR.setDatas(eTR_BR,false);
vTL.set_fromConstraintSegments([segTop,segLeft]);
vTR.set_fromConstraintSegments([segTop,segRight]);
vBR.set_fromConstraintSegments([segRight,segBot]);
vBL.set_fromConstraintSegments([segBot,segLeft]);
eTL_TR.fromConstraintSegments.push(segTop);
eTR_TL.fromConstraintSegments.push(segTop);
eTR_BR.fromConstraintSegments.push(segRight);
eBR_TR.fromConstraintSegments.push(segRight);
eBR_BL.fromConstraintSegments.push(segBot);
eBL_BR.fromConstraintSegments.push(segBot);
eBL_TL.fromConstraintSegments.push(segLeft);
eTL_BL.fromConstraintSegments.push(segLeft);
segTop.get_edges().push(eTL_TR);
segRight.get_edges().push(eTR_BR);
segBot.get_edges().push(eBR_BL);
segLeft.get_edges().push(eBL_TL);
segTop.fromShape = boundShape;
segRight.fromShape = boundShape;
segBot.fromShape = boundShape;
segLeft.fromShape = boundShape;
var _g = 0;
var _g1 = [segTop,segRight,segBot,segLeft];
while(_g < _g1.length) {
var f = _g1[_g];
++_g;
boundShape.segments.push(f);
}
var _g2 = 0;
var _g11 = [vTL,vTR,vBR,vBL];
while(_g2 < _g11.length) {
var f1 = _g11[_g2];
++_g2;
mesh._vertices.push(f1);
}
var _g3 = 0;
var _g12 = [eTL_TR,eTR_TL,eTR_BR,eBR_TR,eBR_BL,eBL_BR,eBL_TL,eTL_BL,eTR_BL,eBL_TR,eTL_BR,eBR_TL];
while(_g3 < _g12.length) {
var f2 = _g12[_g3];
++_g3;
mesh._edges.push(f2);
}
var _g4 = 0;
var _g13 = [fTL_BL_TR,fTR_BL_BR,fTL_BR_BL,fTL_TR_BR];
while(_g4 < _g13.length) {
var f3 = _g13[_g4];
++_g4;
mesh._faces.push(f3);
}
mesh.get___constraintShapes().push(boundShape);
var securityRect = [];
var _g5 = 0;
var _g14 = [0,0,width,0];
while(_g5 < _g14.length) {
var f4 = _g14[_g5];
++_g5;
securityRect.push(f4);
}
var _g6 = 0;
var _g15 = [width,0,width,height];
while(_g6 < _g15.length) {
var f5 = _g15[_g6];
++_g6;
securityRect.push(f5);
}
var _g7 = 0;
var _g16 = [width,height,0,height];
while(_g7 < _g16.length) {
var f6 = _g16[_g7];
++_g7;
securityRect.push(f6);
}
var _g8 = 0;
var _g17 = [0,height,0,0];
while(_g8 < _g17.length) {
var f7 = _g17[_g8];
++_g8;
securityRect.push(f7);
}
mesh.set_clipping(false);
mesh.insertConstraintShape(securityRect);
mesh.set_clipping(true);
return mesh;
};
xDaedalus_factories_RectMesh.prototype = {
__class__: xDaedalus_factories_RectMesh
};
var xDaedalus_iterators_FromFaceToInnerEdges = xExport["xDaedalus"]["iterators"]["FromFaceToInnerEdges"] = function() {
};
xClasses["xDaedalus.iterators.FromFaceToInnerEdges"] = xDaedalus_iterators_FromFaceToInnerEdges;
xDaedalus_iterators_FromFaceToInnerEdges.nom = true;
xDaedalus_iterators_FromFaceToInnerEdges.prototype = {
_fromFace: null
,_nextEdge: null
,_resultEdge: null
,set_fromFace: function(value) {
this._fromFace = value;
this._nextEdge = this._fromFace.get_edge();
return value;
}
,next: function() {
if(this._nextEdge != null) {
this._resultEdge = this._nextEdge;
this._nextEdge = this._nextEdge.get_nextLeftEdge();
if(this._nextEdge == this._fromFace.get_edge()) {
this._nextEdge = null;
}
} else {
this._resultEdge = null;
}
return this._resultEdge;
}
,__class__: xDaedalus_iterators_FromFaceToInnerEdges
};
var xDaedalus_iterators_FromMeshToVertices = xExport["xDaedalus"]["iterators"]["FromMeshToVertices"] = function() {
};
xClasses["xDaedalus.iterators.FromMeshToVertices"] = xDaedalus_iterators_FromMeshToVertices;
xDaedalus_iterators_FromMeshToVertices.nom = true;
xDaedalus_iterators_FromMeshToVertices.prototype = {
_fromMesh: null
,_currIndex: null
,_resultVertex: null
,set_fromMesh: function(value) {
this._fromMesh = value;
this._currIndex = 0;
return value;
}
,next: function() {
while(true) {
if(this._currIndex < this._fromMesh._vertices.length) {
this._resultVertex = this._fromMesh._vertices[this._currIndex];
this._currIndex++;
} else {
this._resultVertex = null;
break;
}
if(!(!this._resultVertex.get_isReal())) {
break;
}
}
return this._resultVertex;
}
,__class__: xDaedalus_iterators_FromMeshToVertices
};
var xDaedalus_iterators_FromVertexToHoldingFaces = xExport["xDaedalus"]["iterators"]["FromVertexToHoldingFaces"] = function() {
};
xClasses["xDaedalus.iterators.FromVertexToHoldingFaces"] = xDaedalus_iterators_FromVertexToHoldingFaces;
xDaedalus_iterators_FromVertexToHoldingFaces.nom = true;
xDaedalus_iterators_FromVertexToHoldingFaces.prototype = {
_fromVertex: null
,_nextEdge: null
,_resultFace: null
,set_fromVertex: function(value) {
this._fromVertex = value;
this._nextEdge = this._fromVertex.get_edge();
return value;
}
,next: function() {
if(this._nextEdge != null) {
while(true) {
this._resultFace = this._nextEdge.get_leftFace();
this._nextEdge = this._nextEdge.get_rotLeftEdge();
if(this._nextEdge == this._fromVertex.get_edge()) {
this._nextEdge = null;
if(!this._resultFace.get_isReal()) {
this._resultFace = null;
}
break;
}
if(!(!this._resultFace.get_isReal())) {
break;
}
}
} else {
this._resultFace = null;
}
return this._resultFace;
}
,__class__: xDaedalus_iterators_FromVertexToHoldingFaces
};
var xDaedalus_iterators_FromVertexToIncomingEdges = xExport["xDaedalus"]["iterators"]["FromVertexToIncomingEdges"] = function() {
};
xClasses["xDaedalus.iterators.FromVertexToIncomingEdges"] = xDaedalus_iterators_FromVertexToIncomingEdges;
xDaedalus_iterators_FromVertexToIncomingEdges.nom = true;
xDaedalus_iterators_FromVertexToIncomingEdges.prototype = {
_fromVertex: null
,_nextEdge: null
,_resultEdge: null
,set_fromVertex: function(value) {
this._fromVertex = value;
this._nextEdge = this._fromVertex.get_edge();
while(!this._nextEdge.get_isReal()) this._nextEdge = this._nextEdge.get_rotLeftEdge();
return value;
}
,next: function() {
if(this._nextEdge != null) {
this._resultEdge = this._nextEdge.get_oppositeEdge();
while(true) {
this._nextEdge = this._nextEdge.get_rotLeftEdge();
if(this._nextEdge == this._fromVertex.get_edge()) {
this._nextEdge = null;
break;
}
if(!(!this._nextEdge.get_isReal())) {
break;
}
}
} else {
this._resultEdge = null;
}
return this._resultEdge;
}
,__class__: xDaedalus_iterators_FromVertexToIncomingEdges
};
var xDaedalus_iterators_FromVertexToOutgoingEdges = xExport["xDaedalus"]["iterators"]["FromVertexToOutgoingEdges"] = function() {
this.realEdgesOnly = true;
};
xClasses["xDaedalus.iterators.FromVertexToOutgoingEdges"] = xDaedalus_iterators_FromVertexToOutgoingEdges;
xDaedalus_iterators_FromVertexToOutgoingEdges.nom = true;
xDaedalus_iterators_FromVertexToOutgoingEdges.prototype = {
_fromVertex: null
,_nextEdge: null
,realEdgesOnly: null
,set_fromVertex: function(value) {
this._fromVertex = value;
this._nextEdge = this._fromVertex.get_edge();
while(this.realEdgesOnly && !this._nextEdge.get_isReal()) this._nextEdge = this._nextEdge.get_rotLeftEdge();
return value;
}
,_resultEdge: null
,next: function() {
if(this._nextEdge != null) {
this._resultEdge = this._nextEdge;
while(true) {
this._nextEdge = this._nextEdge.get_rotLeftEdge();
if(this._nextEdge == this._fromVertex.get_edge()) {
this._nextEdge = null;
break;
}
if(!(this.realEdgesOnly && !this._nextEdge.get_isReal())) {
break;
}
}
} else {
this._resultEdge = null;
}
return this._resultEdge;
}
,__class__: xDaedalus_iterators_FromVertexToOutgoingEdges
};
var xDaedalus_view_KSimpleView = xExport["xDaedalus"]["view"]["KSimpleView"] = function() {
this.faceToEdgeIter = new xDaedalus_iterators_FromFaceToInnerEdges();
this.faceAlpha = .5;
this.faceWidth = 1;
this.faceColor = -65281;
this.entitiesAlpha = .75;
this.entitiesWidth = 1;
this.entitiesColor = -16711936;
this.pathsAlpha = .75;
this.pathsWidth = 1.5;
this.pathsColor = -65281;
this.verticesAlpha = .25;
this.verticesRadius = .5;
this.verticesColor = -16776961;
this.constraintsAlpha = 1.0;
this.constraintsWidth = 2;
this.constraintsColor = -65536;
this.edgesAlpha = .25;
this.edgesWidth = 1;
this.edgesColor = -6710887;
};
xClasses["xDaedalus.view.KSimpleView"] = xDaedalus_view_KSimpleView;
xDaedalus_view_KSimpleView.nom = true;
xDaedalus_view_KSimpleView.prototype = {
edgesColor: null
,edgesWidth: null
,edgesAlpha: null
,constraintsColor: null
,constraintsWidth: null
,constraintsAlpha: null
,verticesColor: null
,verticesRadius: null
,verticesAlpha: null
,pathsColor: null
,pathsWidth: null
,pathsAlpha: null
,entitiesColor: null
,entitiesWidth: null
,entitiesAlpha: null
,faceColor: null
,faceWidth: null
,faceAlpha: null
,faceToEdgeIter: null
,circle: function(g2,p,radius,color,alpha) {
g2.set_opacity(alpha);
g2.set_color(color);
kgraphics2_GraphicsExtension.fillCircle(g2,p.x,p.y,radius);
}
,label: function(g2,p,t,font,fontSize,color,alpha) {
g2.set_opacity(alpha);
g2.set_color(color);
g2.set_font(font);
g2.set_fontSize(fontSize);
g2.drawString(t,p.x,p.y);
}
,lineP: function(g2,p0,p1,color,alpha,strength) {
g2.set_opacity(alpha);
g2.set_color(color);
g2.drawLine(p0.x,p0.y,p1.x,p1.y);
}
,line: function(g2,x0,y0,x1,y1,color,alpha,strength) {
g2.set_opacity(alpha);
g2.set_color(color);
g2.drawLine(x0,y0,x1,y1);
}
,drawVertex: function(g2,vertex) {
var p = vertex.get_pos();
var radius = this.verticesRadius;
var color = this.verticesColor;
g2.set_opacity(this.verticesAlpha);
g2.set_color(color);
kgraphics2_GraphicsExtension.fillCircle(g2,p.x,p.y,radius);
}
,drawFace: function(g2,face) {
this.faceToEdgeIter.set_fromFace(face);
var count = 0;
var edge;
while(true) {
edge = this.faceToEdgeIter.next();
if(edge == null) {
break;
}
var p0 = edge.get_originVertex();
var p1 = edge.get_destinationVertex();
var color = this.faceColor;
var strength = this.faceWidth;
g2.set_opacity(this.faceAlpha);
g2.set_color(color);
g2.drawLine(p0.x,p0.y,p1.x,p1.y);
++count;
}
}
,drawEdge: function(g2,edge) {
var p0 = edge.get_originVertex().get_pos();
var p1 = edge.get_destinationVertex().get_pos();
if(edge.get_isConstrained()) {
var color = this.constraintsColor;
var strength = this.constraintsWidth;
g2.set_opacity(this.constraintsAlpha);
g2.set_color(color);
g2.drawLine(p0.x,p0.y,p1.x,p1.y);
} else {
var color1 = this.edgesColor;
var strength1 = this.edgesWidth;
g2.set_opacity(this.edgesAlpha);
g2.set_color(color1);
g2.drawLine(p0.x,p0.y,p1.x,p1.y);
}
}
,drawMesh: function(g2,mesh) {
var all = mesh.getVerticesAndEdges();
var _g = 0;
var _g1 = all.vertices;
while(_g < _g1.length) {
var v = _g1[_g];
++_g;
this.drawVertex(g2,v);
}
var _g2 = 0;
var _g11 = all.edges;
while(_g2 < _g11.length) {
var e = _g11[_g2];
++_g2;
this.drawEdge(g2,e);
}
}
,drawEntity: function(g2,entity) {
var radius = entity.get_radius();
var color = this.entitiesColor;
g2.set_opacity(this.entitiesAlpha);
g2.set_color(color);
kgraphics2_GraphicsExtension.fillCircle(g2,entity.x,entity.y,radius);
}
,drawEntities: function(g2,vEntities) {
var _g1 = 0;
var _g = vEntities.length;
while(_g1 < _g) {
var i = _g1++;
this.drawEntity(g2,vEntities[i]);
}
}
,drawPath: function(g2,path,cleanBefore) {
if(cleanBefore == null) {
cleanBefore = false;
}
if(path.length == 0) {
return;
}
var i = 0;
while(i < path.length) {
var color = this.pathsColor;
var strength = this.pathsWidth;
g2.set_opacity(this.pathsAlpha);
g2.set_color(color);
g2.drawLine(path[i],path[i + 1],path[i + 2],path[i + 3]);
i += 2;
}
}
,__class__: xDaedalus_view_KSimpleView
};
var xPixels_xPixels_PixelsxImplx = xExport["xPixels"]["_Pixels"]["Pixels_Impl_"] = {};
xClasses["xPixels._Pixels.Pixels_Impl_"] = xPixels_xPixels_PixelsxImplx;
xPixels_xPixels_PixelsxImplx.nom = true;
xPixels_xPixels_PixelsxImplx._new = function(width,height,alloc) {
if(alloc == null) {
alloc = true;
}
var this1 = new xPixels_xPixels_PixelsData(width,height,alloc);
return this1;
};
xPixels_xPixels_PixelsxImplx.getByte = function(this1,i) {
return this1.bytes.b[(i & -4) + this1.format.channelMap[i & 3]];
};
xPixels_xPixels_PixelsxImplx.getPixel = function(this1,x,y) {
var pos = y * this1.width + x << 2;
var r = this1.bytes.b[pos + this1.format.ch1] << 16;
var g = this1.bytes.b[pos + this1.format.ch2] << 8;
var b = this1.bytes.b[pos + this1.format.ch3];
return r | g | b;
};
xPixels_xPixels_PixelsxImplx.getPixel32 = function(this1,x,y) {
var pos = y * this1.width + x << 2;
var a = this1.bytes.b[pos + this1.format.ch0] << 24;
var r = this1.bytes.b[pos + this1.format.ch1] << 16;
var g = this1.bytes.b[pos + this1.format.ch2] << 8;
var b = this1.bytes.b[pos + this1.format.ch3];
return a | r | g | b;
};
xPixels_xPixels_PixelsxImplx.setByte = function(this1,i,value) {
this1.bytes.b[(i & -4) + this1.format.channelMap[i & 3]] = value & 255;
};
xPixels_xPixels_PixelsxImplx.setPixel = function(this1,x,y,value) {
var pos = y * this1.width + x << 2;
var r = value >> 16 & 255;
var g = value >> 8 & 255;
var b = value & 255;
this1.bytes.b[pos + this1.format.ch1] = r & 255;
this1.bytes.b[pos + this1.format.ch2] = g & 255;
this1.bytes.b[pos + this1.format.ch3] = b & 255;
};
xPixels_xPixels_PixelsxImplx.setPixel32 = function(this1,x,y,value) {
var pos = y * this1.width + x << 2;
var a = value >> 24 & 255;
var r = value >> 16 & 255;
var g = value >> 8 & 255;
var b = value & 255;
this1.bytes.b[pos + this1.format.ch0] = a & 255;
this1.bytes.b[pos + this1.format.ch1] = r & 255;
this1.bytes.b[pos + this1.format.ch2] = g & 255;
this1.bytes.b[pos + this1.format.ch3] = b & 255;
};
xPixels_xPixels_PixelsxImplx.fillRect = function(this1,x,y,width,height,value) {
var pos = y * this1.width + x << 2;
var this2 = new xPixels_xPixels_PixelsData(width,1,true);
var stridePixels = this2;
stridePixels.format = this1.format;
var stride = width << 2;
var _g1 = 0;
var _g = width;
while(_g1 < _g) {
var x1 = _g1++;
xPixels_xPixels_PixelsxImplx.setPixel32(stridePixels,x1,0,value);
}
var _g11 = 0;
var _g2 = height;
while(_g11 < _g2) {
var y1 = _g11++;
this1.bytes.blit(pos,stridePixels.bytes,0,stride);
pos += this1.width << 2;
}
};
xPixels_xPixels_PixelsxImplx.clone = function(this1) {
var this2 = new xPixels_xPixels_PixelsData(this1.width,this1.height,true);
var clone = this2;
clone.bytes.blit(0,this1.bytes,0,this1.bytes.length);
clone.format = this1.format;
return clone;
};
xPixels_xPixels_PixelsxImplx.fromBytes = function(bytes,width,height,format) {
var this1 = new xPixels_xPixels_PixelsData(width,height,false);
var pixels = this1;
if(format == null) {
format = xPixels_PixelFormat.ARGB;
}
pixels.bytes = bytes;
return pixels;
};
xPixels_xPixels_PixelsxImplx.convertTo = function(this1,format) {
return xPixels_xPixels_PixelsxImplx.convert(this1,format,true);
};
xPixels_xPixels_PixelsxImplx.convert = function(pixels,toFormat,inPlace) {
if(inPlace == null) {
inPlace = false;
}
var res = inPlace ? pixels : xPixels_xPixels_PixelsxImplx.clone(pixels);
if(toFormat == pixels.format) {
return res;
}
var i = 0;
var pos = 0;
if(pixels.format == xPixels_PixelFormat.BGRA && toFormat == xPixels_PixelFormat.RGBA || pixels.format == xPixels_PixelFormat.RGBA && toFormat == xPixels_PixelFormat.BGRA) {
while(i < pixels.count) {
var i1 = pos + 1;
var r = pixels.bytes.b[(i1 & -4) + pixels.format.channelMap[i1 & 3]];
var i2 = pos + 3;
var b = pixels.bytes.b[(i2 & -4) + pixels.format.channelMap[i2 & 3]];
res.bytes.b[pos + toFormat.ch1] = r & 255;
res.bytes.b[pos + toFormat.ch3] = b & 255;
++i;
pos += 4;
}
} else {
while(i < pixels.count) {
var a = pixels.bytes.b[(pos & -4) + pixels.format.channelMap[pos & 3]];
var i3 = pos + 1;
var r1 = pixels.bytes.b[(i3 & -4) + pixels.format.channelMap[i3 & 3]];
var i4 = pos + 2;
var g = pixels.bytes.b[(i4 & -4) + pixels.format.channelMap[i4 & 3]];
var i5 = pos + 3;
var b1 = pixels.bytes.b[(i5 & -4) + pixels.format.channelMap[i5 & 3]];
res.bytes.b[pos + toFormat.ch0] = a & 255;
res.bytes.b[pos + toFormat.ch1] = r1 & 255;
res.bytes.b[pos + toFormat.ch2] = g & 255;
res.bytes.b[pos + toFormat.ch3] = b1 & 255;
++i;
pos += 4;
}
}
res.format = toFormat;
return res;
};
xPixels_xPixels_PixelsxImplx.fromImageData = function(image) {
var this1 = new xPixels_xPixels_PixelsData(image.width,image.height,true);
var pixels = this1;
pixels.format = xPixels_PixelFormat.ARGB;
var data = image.data;
var _g1 = 0;
var _g = data.byteLength;
while(_g1 < _g) {
var i = _g1++;
pixels.bytes.b[i] = data[i] & 255;
}
return pixels;
};
var xPixels_xPixels_PixelsData = function(width,height,alloc,format) {
if(alloc == null) {
alloc = true;
}
this.count = width * height;
if(alloc) {
this.bytes = new haxe_io_Bytes(new ArrayBuffer(this.count << 2));
}
this.width = width;
this.height = height;
this.format = format != null ? format : xPixels_PixelFormat.ARGB;
};
xClasses["xPixels._Pixels.PixelsData"] = xPixels_xPixels_PixelsData;
xPixels_xPixels_PixelsData.nom = true;
xPixels_xPixels_PixelsData.prototype = {
count: null
,bytes: null
,width: null
,height: null
,format: null
,__class__: xPixels_xPixels_PixelsData
};
var xPixels_PixelFormat = xExport["xPixels"]["PixelFormat"] = function(a,r,g,b,name) {
if(name == null) {
name = "PixelFormat";
}
this.channelMap = [a,r,g,b];
this.ch0 = a;
this.ch1 = r;
this.ch2 = g;
this.ch3 = b;
this.name = name;
};
xClasses["xPixels.PixelFormat"] = xPixels_PixelFormat;
xPixels_PixelFormat.nom = true;
xPixels_PixelFormat.prototype = {
channelMap: null
,ch0: null
,ch1: null
,ch2: null
,ch3: null
,name: null
,A: null
,get_A: function() {
return this.ch0;
}
,R: null
,get_R: function() {
return this.ch1;
}
,G: null
,get_G: function() {
return this.ch2;
}
,B: null
,get_B: function() {
return this.ch3;
}
,toString: function() {
return this.name;
}
,__class__: xPixels_PixelFormat
};
var xPixels_xPixels_PixelxImplx = xExport["xPixels"]["_Pixels"]["Pixel_Impl_"] = {};
xClasses["xPixels._Pixels.Pixel_Impl_"] = xPixels_xPixels_PixelxImplx;
xPixels_xPixels_PixelxImplx.nom = true;
xPixels_xPixels_PixelxImplx.get_A = function(this1) {
return this1 >> 24 & 255;
};
xPixels_xPixels_PixelxImplx.set_A = function(this1,a) {
a &= 255;
this1 = this1 & 16777215 | a << 24;
return a;
};
xPixels_xPixels_PixelxImplx.get_R = function(this1) {
return this1 >> 16 & 255;
};
xPixels_xPixels_PixelxImplx.set_R = function(this1,r) {
r &= 255;
this1 = this1 & -16711681 | r << 16;
return r;
};
xPixels_xPixels_PixelxImplx.get_G = function(this1) {
return this1 >> 8 & 255;
};
xPixels_xPixels_PixelxImplx.set_G = function(this1,g) {
g &= 255;
this1 = this1 & -65281 | g << 8;
return g;
};
xPixels_xPixels_PixelxImplx.get_B = function(this1) {
return this1 & 255;
};
xPixels_xPixels_PixelxImplx.set_B = function(this1,b) {
b &= 255;
this1 = this1 & -256 | b;
return b;
};
var jsxBoot_HaxeError = function(val) {
Error.call(this);
this.val = val;
this.message = String(val);
if(Error.captureStackTrace) {
Error.captureStackTrace(this,jsxBoot_HaxeError);
}
};
xClasses["js._Boot.HaxeError"] = jsxBoot_HaxeError;
jsxBoot_HaxeError.nom = true;
jsxBoot_HaxeError.wrap = function(val) {
if((val instanceof Error)) {
return val;
} else {
return new jsxBoot_HaxeError(val);
}
};
jsxBoot_HaxeError.__super__ = Error;
jsxBoot_HaxeError.prototype = $extend(Error.prototype,{
val: null
,__class__: jsxBoot_HaxeError
});
var jsBoot = function() { };
xClasses["js.Boot"] = jsBoot;
jsBoot.nom = true;
jsBoot.__unhtml = function(s) {
return s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
};
jsBoot.__trace = function(v,i) {
var msg = i != null ? i.fileName + ":" + i.lineNumber + ": " : "";
msg += jsBoot.__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 += "," + jsBoot.__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 += jsBoot.__unhtml(msg) + "<br/>";
} else if(typeof console != "undefined" && console.log != null) {
console.log(msg);
}
};
jsBoot.getClass = function(o) {
if((o instanceof Array) && o.__enum__ == null) {
return Array;
} else {
var cl = o.__class__;
if(cl != null) {
return cl;
}
var name = jsBoot.__nativeClassName(o);
if(name != null) {
return jsBoot.__resolveNativeClass(name);
}
return null;
}
};
jsBoot.__string_rec = function(o,s) {
if(o == null) {
return "null";
}
if(s.length >= 5) {
return "<...>";
}
var t = typeof(o);
if(t == "function" && (o.nom || o.__ename__)) {
t = "object";
}
switch(t) {
case "function":
return "<function>";
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 += "," + jsBoot.__string_rec(o[i],s);
} else {
str += jsBoot.__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 ? "," : "") + jsBoot.__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 + " : " + jsBoot.__string_rec(o[k],s);
}
s = s.substring(1);
str2 += "\n" + s + "}";
return str2;
case "string":
return o;
default:
return String(o);
}
};
jsBoot.__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 || jsBoot.__interfLoop(i1,cl)) {
return true;
}
}
}
return jsBoot.__interfLoop(cc.__super__,cl);
};
jsBoot.__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(jsBoot.__interfLoop(jsBoot.getClass(o),cl)) {
return true;
}
} else if(typeof(cl) == "object" && jsBoot.__isNativeObj(cl)) {
if(o instanceof cl) {
return true;
}
}
} else {
return false;
}
if(cl == Class ? o.nom != null : false) {
return true;
}
if(cl == Enum ? o.__ename__ != null : false) {
return true;
}
return o.__enum__ == cl;
}
};
jsBoot.__cast = function(o,t) {
if(jsBoot.__instanceof(o,t)) {
return o;
} else {
throw new jsxBoot_HaxeError("Cannot cast " + Std.string(o) + " to " + Std.string(t));
}
};
jsBoot.__nativeClassName = function(o) {
var name = jsBoot.__toStr.call(o).slice(8,-1);
if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") {
return null;
}
return name;
};
jsBoot.__isNativeObj = function(o) {
return jsBoot.__nativeClassName(o) != null;
};
jsBoot.__resolveNativeClass = function(name) {
return $global[name];
};
var jshtml_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;
}
};
xClasses["js.html.compat.ArrayBuffer"] = jshtml_compat_ArrayBuffer;
jshtml_compat_ArrayBuffer.nom = true;
jshtml_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;
};
jshtml_compat_ArrayBuffer.prototype = {
byteLength: null
,a: null
,slice: function(begin,end) {
return new jshtml_compat_ArrayBuffer(this.a.slice(begin,end));
}
,__class__: jshtml_compat_ArrayBuffer
};
var jshtml_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 jsxBoot_HaxeError(haxe_io_Error.OutsideBounds);
}
this.byteLength = this.length;
this.byteOffset = this.offset;
this.buffer = this.buf;
};
xClasses["js.html.compat.DataView"] = jshtml_compat_DataView;
jshtml_compat_DataView.nom = true;
jshtml_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__: jshtml_compat_DataView
};
var jshtml_compat_Float32Array = function() { };
xClasses["js.html.compat.Float32Array"] = jshtml_compat_Float32Array;
jshtml_compat_Float32Array.nom = true;
jshtml_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 jshtml_compat_ArrayBuffer(_g2);
} else if(jsBoot.__instanceof(arg1,jshtml_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 jshtml_compat_ArrayBuffer(buffer1);
} else {
throw new jsxBoot_HaxeError("TODO " + Std.string(arg1));
}
arr.subarray = jshtml_compat_Float32Array._subarray;
arr.set = jshtml_compat_Float32Array._set;
return arr;
};
jshtml_compat_Float32Array._set = function(arg,offset) {
if(jsBoot.__instanceof(arg.buffer,jshtml_compat_ArrayBuffer)) {
var a = arg;
if(arg.byteLength + offset > this.byteLength) {
throw new jsxBoot_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 jsxBoot_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 jsxBoot_HaxeError("TODO");
}
};
jshtml_compat_Float32Array._subarray = function(start,end) {
var a = jshtml_compat_Float32Array._new(this.slice(start,end));
a.byteOffset = start * 4;
return a;
};
var jshtml_compat_Uint8Array = function() { };
xClasses["js.html.compat.Uint8Array"] = jshtml_compat_Uint8Array;
jshtml_compat_Uint8Array.nom = true;
jshtml_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 jshtml_compat_ArrayBuffer(arr);
} else if(jsBoot.__instanceof(arg1,jshtml_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 jshtml_compat_ArrayBuffer(arr);
} else {
throw new jsxBoot_HaxeError("TODO " + Std.string(arg1));
}
arr.subarray = jshtml_compat_Uint8Array._subarray;
arr.set = jshtml_compat_Uint8Array._set;
return arr;
};
jshtml_compat_Uint8Array._set = function(arg,offset) {
if(jsBoot.__instanceof(arg.buffer,jshtml_compat_ArrayBuffer)) {
var a = arg;
if(arg.byteLength + offset > this.byteLength) {
throw new jsxBoot_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 jsxBoot_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 jsxBoot_HaxeError("TODO");
}
};
jshtml_compat_Uint8Array._subarray = function(start,end) {
var a = jshtml_compat_Uint8Array._new(this.slice(start,end));
a.byteOffset = start;
return a;
};
var kxAssets_ImageList = function() {
this.names = ["galapagosBW","galapagosColor"];
this.galapagosColorDescription = { files : ["galapagosColor.png"], original_height : 780, type : "image", original_width : 1024, name : "galapagosColor"};
this.galapagosColorName = "galapagosColor";
this.galapagosColor = null;
this.galapagosBWDescription = { files : ["galapagosBW.png"], original_height : 780, type : "image", original_width : 1024, name : "galapagosBW"};
this.galapagosBWName = "galapagosBW";
this.galapagosBW = null;
};
xClasses["kha._Assets.ImageList"] = kxAssets_ImageList;
kxAssets_ImageList.nom = true;
kxAssets_ImageList.prototype = {
galapagosBW: null
,galapagosBWName: null
,galapagosBWDescription: null
,galapagosBWLoad: function(done) {
kAssets.loadImage("galapagosBW",function(image) {
done();
});
}
,galapagosBWUnload: function() {
this.galapagosBW.unload();
this.galapagosBW = null;
}
,galapagosColor: null
,galapagosColorName: null
,galapagosColorDescription: null
,galapagosColorLoad: function(done) {
kAssets.loadImage("galapagosColor",function(image) {
done();
});
}
,galapagosColorUnload: function() {
this.galapagosColor.unload();
this.galapagosColor = null;
}
,names: null
,__class__: kxAssets_ImageList
};
var kxAssets_SoundList = function() {
this.names = [];
};
xClasses["kha._Assets.SoundList"] = kxAssets_SoundList;
kxAssets_SoundList.nom = true;
kxAssets_SoundList.prototype = {
names: null
,__class__: kxAssets_SoundList
};
var kxAssets_BlobList = function() {
this.names = [];
};
xClasses["kha._Assets.BlobList"] = kxAssets_BlobList;
kxAssets_BlobList.nom = true;
kxAssets_BlobList.prototype = {
names: null
,__class__: kxAssets_BlobList
};
var kxAssets_FontList = function() {
this.names = [];
};
xClasses["kha._Assets.FontList"] = kxAssets_FontList;
kxAssets_FontList.nom = true;
kxAssets_FontList.prototype = {
names: null
,__class__: kxAssets_FontList
};
var kxAssets_VideoList = function() {
this.names = [];
};
xClasses["kha._Assets.VideoList"] = kxAssets_VideoList;
kxAssets_VideoList.nom = true;
kxAssets_VideoList.prototype = {
names: null
,__class__: kxAssets_VideoList
};
var kAssets = function() { };
xClasses["kha.Assets"] = kAssets;
kAssets.nom = true;
kAssets.loadEverything = function(callback) {
var fileCount = 0;
var _g = 0;
var _g1 = Type.getInstanceFields(kxAssets_BlobList);
while(_g < _g1.length) {
var blob = _g1[_g];
++_g;
if(StringTools.endsWith(blob,"Load")) {
fileCount += 1;
}
}
var _g2 = 0;
var _g11 = Type.getInstanceFields(kxAssets_ImageList);
while(_g2 < _g11.length) {
var image = _g11[_g2];
++_g2;
if(StringTools.endsWith(image,"Load")) {
fileCount += 1;
}
}
var _g3 = 0;
var _g12 = Type.getInstanceFields(kxAssets_SoundList);
while(_g3 < _g12.length) {
var sound = _g12[_g3];
++_g3;
if(StringTools.endsWith(sound,"Load")) {
fileCount += 1;
}
}
var _g4 = 0;
var _g13 = Type.getInstanceFields(kxAssets_FontList);
while(_g4 < _g13.length) {
var font = _g13[_g4];
++_g4;
if(StringTools.endsWith(font,"Load")) {
fileCount += 1;
}
}
var _g5 = 0;
var _g14 = Type.getInstanceFields(kxAssets_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(kxAssets_BlobList);
while(_g6 < _g15.length) {
var blob1 = _g15[_g6];
++_g6;
if(StringTools.endsWith(blob1,"Load")) {
(Reflect.field(kAssets.blobs,blob1))(function() {
filesLeft -= 1;
kAssets.progress = 1 - filesLeft / fileCount;
if(filesLeft == 0) {
callback();
}
});
}
}
var _g7 = 0;
var _g16 = Type.getInstanceFields(kxAssets_ImageList);
while(_g7 < _g16.length) {
var image1 = _g16[_g7];
++_g7;
if(StringTools.endsWith(image1,"Load")) {
(Reflect.field(kAssets.images,image1))(function() {
filesLeft -= 1;
kAssets.progress = 1 - filesLeft / fileCount;
if(filesLeft == 0) {
callback();
}
});
}
}
var _g8 = 0;
var _g17 = Type.getInstanceFields(kxAssets_SoundList);
while(_g8 < _g17.length) {
var sound1 = [_g17[_g8]];
++_g8;
if(StringTools.endsWith(sound1[0],"Load")) {
(Reflect.field(kAssets.sounds,sound1[0]))((function(sound2) {
return function() {
var sound3 = Reflect.field(kAssets.sounds,sound2[0].substring(0,sound2[0].length - 4));
sound3.uncompress((function() {
return function() {
filesLeft -= 1;
kAssets.progress = 1 - filesLeft / fileCount;
if(filesLeft == 0) {
callback();
}
};
})());
};
})(sound1));
}
}
var _g9 = 0;
var _g18 = Type.getInstanceFields(kxAssets_FontList);
while(_g9 < _g18.length) {
var font1 = _g18[_g9];
++_g9;
if(StringTools.endsWith(font1,"Load")) {
(Reflect.field(kAssets.fonts,font1))(function() {
filesLeft -= 1;
kAssets.progress = 1 - filesLeft / fileCount;
if(filesLeft == 0) {
callback();
}
});
}
}
var _g10 = 0;
var _g19 = Type.getInstanceFields(kxAssets_VideoList);
while(_g10 < _g19.length) {
var video1 = _g19[_g10];
++_g10;
if(StringTools.endsWith(video1,"Load")) {
(Reflect.field(kAssets.videos,video1))(function() {
filesLeft -= 1;
kAssets.progress = 1 - filesLeft / fileCount;
if(filesLeft == 0) {
callback();
}
});
}
}
};
kAssets.loadImage = function(name,done) {
var description = Reflect.field(kAssets.images,name + "Description");
kLoaderImpl.loadImageFromDescription(description,function(image) {
kAssets.images[name] = image;
done(image);
});
};
kAssets.loadImageFromPath = function(path,readable,done) {
var description = { files : [path], readable : readable};
kLoaderImpl.loadImageFromDescription(description,done);
};
kAssets.get_imageFormats = function() {
return kLoaderImpl.getImageFormats();
};
kAssets.loadBlob = function(name,done) {
var description = Reflect.field(kAssets.blobs,name + "Description");
kLoaderImpl.loadBlobFromDescription(description,function(blob) {
kAssets.blobs[name] = blob;
done(blob);
});
};
kAssets.loadBlobFromPath = function(path,done) {
var description = { files : [path]};
kLoaderImpl.loadBlobFromDescription(description,done);
};
kAssets.loadSound = function(name,done) {
var description = Reflect.field(kAssets.sounds,name + "Description");
kLoaderImpl.loadSoundFromDescription(description,function(sound) {
kAssets.sounds[name] = sound;
done(sound);
});
return;
};
kAssets.loadSoundFromPath = function(path,done) {
var description = { files : [path]};
kLoaderImpl.loadSoundFromDescription(description,done);
return;
};
kAssets.get_soundFormats = function() {
return kLoaderImpl.getSoundFormats();
};
kAssets.loadFont = function(name,done) {
var description = Reflect.field(kAssets.fonts,name + "Description");
kLoaderImpl.loadFontFromDescription(description,function(font) {
kAssets.fonts[name] = font;
done(font);
});
return;
};
kAssets.loadFontFromPath = function(path,done) {
var description = { files : [path]};
kLoaderImpl.loadFontFromDescription(description,done);
return;
};
kAssets.get_fontFormats = function() {
return ["ttf"];
};
kAssets.loadVideo = function(name,done) {
var description = Reflect.field(kAssets.videos,name + "Description");
kLoaderImpl.loadVideoFromDescription(description,function(video) {
kAssets.videos[name] = video;
done(video);
});
return;
};
kAssets.loadVideoFromPath = function(path,done) {
var description = { files : [path]};
kLoaderImpl.loadVideoFromDescription(description,done);
return;
};
kAssets.get_videoFormats = function() {
return kLoaderImpl.getVideoFormats();
};
var kCanvas = function() { };
xClasses["kha.Canvas"] = kCanvas;
kCanvas.nom = true;
kCanvas.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__: kCanvas
};
var kResource = function() { };
xClasses["kha.Resource"] = kResource;
kResource.nom = true;
kResource.prototype = {
unload: null
,__class__: kResource
};
var kImage = function() { };
xClasses["kha.Image"] = kImage;
kImage.nom = true;
kImage.__interfaces__ = [kResource,kCanvas];
kImage.create = function(width,height,format,usage) {
if(format == null) {
format = kgraphics4_TextureFormat.RGBA32;
}
if(usage == null) {
usage = kgraphics4_Usage.StaticUsage;
}
if(kSystemImpl.gl == null) {
return new kCanvasImage(width,height,format,false);
} else {
return new kWebGLImage(width,height,format,false,0);
}
};
kImage.create3D = function(width,height,depth,format,usage) {
return null;
};
kImage.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 = kgraphics4_TextureFormat.RGBA32;
}
if(kSystemImpl.gl == null) {
return new kCanvasImage(width,height,format,true);
} else {
return new kWebGLImage(width,height,format,true,depthStencil);
}
};
kImage.fromImage = function(image,readable) {
if(kSystemImpl.gl == null) {
var img = new kCanvasImage(image.width,image.height,kgraphics4_TextureFormat.RGBA32,false);
img.image = image;
img.createTexture();
return img;
} else {
var img1 = new kWebGLImage(image.width,image.height,kgraphics4_TextureFormat.RGBA32,false,0);
img1.image = image;
img1.createTexture();
return img1;
}
};
kImage.fromBytes = function(bytes,width,height,format,usage) {
if(format == null) {
format = kgraphics4_TextureFormat.RGBA32;
}
if(usage == null) {
usage = kgraphics4_Usage.StaticUsage;
}
if(kSystemImpl.gl != null) {
var img = new kWebGLImage(width,height,format,false,0);
img.image = img.bytesToArray(bytes);
img.createTexture();
return img;
}
return null;
};
kImage.fromEncodedBytes = function(bytes,fileExtention,doneCallback,errorCallback,readable) {
if(readable == null) {
readable = false;
}
var dataUrl = "data:image;base64," + haxe_crypto_Base64.encode(bytes);
var imageElement = jsBoot.__cast(window.document.createElement("img") , HTMLImageElement);
imageElement.onload = function() {
var tmp = kImage.fromImage(imageElement,readable);
doneCallback(tmp);
};
imageElement.onerror = function() {
errorCallback("Image was not created");
};
imageElement.src = dataUrl;
};
kImage.fromVideo = function(video) {
if(kSystemImpl.gl == null) {
var img = new kCanvasImage(video.element.videoWidth,video.element.videoHeight,kgraphics4_TextureFormat.RGBA32,false);
img.video = video.element;
img.createTexture();
return img;
} else {
var img1 = new kWebGLImage(video.element.videoWidth,video.element.videoHeight,kgraphics4_TextureFormat.RGBA32,false,0);
img1.video = video.element;
img1.createTexture();
return img1;
}
};
kImage.get_maxSize = function() {
if(kSystemImpl.gl == null) {
return 8192;
} else {
return kSystemImpl.gl.getParameter(3379);
}
};
kImage.get_nonPow2Supported = function() {
return kSystemImpl.gl != null;
};
kImage.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__: kImage
};
var kCanvasImage = 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();
}
};
xClasses["kha.CanvasImage"] = kCanvasImage;
kCanvasImage.nom = true;
kCanvasImage.init = function() {
var canvas = window.document.createElement("canvas");
if(canvas != null) {
kCanvasImage.context = canvas.getContext("2d");
canvas.width = 2048;
canvas.height = 2048;
kCanvasImage.context.globalCompositeOperation = "copy";
}
};
kCanvasImage.upperPowerOfTwo = function(v) {
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return ++v;
};
kCanvasImage.__super__ = kImage;
kCanvasImage.prototype = $extend(kImage.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 kgraphics2_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 kjsCanvasGraphics(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(kCanvasImage.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(kCanvasImage.context == null) {
return -16777216;
} else {
this.createImageData();
}
}
return kxColor_ColorxImplx._new(this.data.data[y * (this.image.width | 0) * 4 + x * 4]);
}
,createImageData: function() {
kCanvasImage.context.strokeStyle = "rgba(0,0,0,0)";
kCanvasImage.context.fillStyle = "rgba(0,0,0,0)";
kCanvasImage.context.fillRect(0,0,this.image.width,this.image.height);
kCanvasImage.context.drawImage(this.image,0,0,this.image.width,this.image.height,0,0,this.image.width,this.image.height);
this.data = kCanvasImage.context.getImageData(0,0,this.image.width,this.image.height);
}
,texture: null
,createTexture: function() {
if(kSystemImpl.gl == null) {
return;
}
this.texture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(3553,this.texture);
kSystemImpl.gl.texParameteri(3553,10240,9729);
kSystemImpl.gl.texParameteri(3553,10241,9729);
kSystemImpl.gl.texParameteri(3553,10242,33071);
kSystemImpl.gl.texParameteri(3553,10243,33071);
if(this.renderTarget) {
this.frameBuffer = kSystemImpl.gl.createFramebuffer();
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null);
kSystemImpl.gl.framebufferTexture2D(36160,36064,3553,this.texture,0);
kSystemImpl.gl.bindFramebuffer(36160,null);
} else if(this.video != null) {
kSystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.video);
} else {
kSystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.image);
}
kSystemImpl.gl.bindTexture(3553,null);
}
,set: function(stage) {
kSystemImpl.gl.activeTexture(33984 + stage);
kSystemImpl.gl.bindTexture(3553,this.texture);
if(this.video != null) {
kSystemImpl.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 == kgraphics4_TextureFormat.RGBA32 ? 4 * this.get_width() * this.get_height() : this.get_width() * this.get_height()));
return this.bytes;
}
,unlock: function() {
if(kSystemImpl.gl != null) {
this.texture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(3553,this.texture);
kSystemImpl.gl.texParameteri(3553,10240,9729);
kSystemImpl.gl.texParameteri(3553,10241,9729);
kSystemImpl.gl.texParameteri(3553,10242,33071);
kSystemImpl.gl.texParameteri(3553,10243,33071);
kSystemImpl.gl.texImage2D(3553,0,6409,this.get_width(),this.get_height(),0,6409,5121,new Uint8Array(this.bytes.b.bufferValue));
if(kSystemImpl.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;
}
}
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,new Uint8Array(rgbaBytes.b.bufferValue));
}
kSystemImpl.gl.bindTexture(3553,null);
this.bytes = null;
}
}
,unload: function() {
this.image = null;
this.video = null;
this.data = null;
}
,__class__: kCanvasImage
});
var kxColor_ColorxImplx = xExport["kha"]["_Color"]["Color_Impl_"] = {};
xClasses["kha._Color.Color_Impl_"] = kxColor_ColorxImplx;
kxColor_ColorxImplx.nom = true;
kxColor_ColorxImplx.fromValue = function(value) {
return kxColor_ColorxImplx._new(value);
};
kxColor_ColorxImplx.fromBytes = function(r,g,b,a) {
if(a == null) {
a = 255;
}
return kxColor_ColorxImplx._new(a << 24 | r << 16 | g << 8 | b);
};
kxColor_ColorxImplx.fromFloats = function(r,g,b,a) {
if(a == null) {
a = 1;
}
return kxColor_ColorxImplx._new((a * 255 | 0) << 24 | (r * 255 | 0) << 16 | (g * 255 | 0) << 8 | (b * 255 | 0));
};
kxColor_ColorxImplx.fromString = function(value) {
if((value.length == 7 || value.length == 9) && value.charCodeAt(0) == 35) {
var colorValue = Std.parseInt("0x" + xOverrides.substr(value,1,null));
if(value.length == 7) {
colorValue += -16777216;
}
return kxColor_ColorxImplx._new(colorValue);
} else {
throw new jsxBoot_HaxeError("Invalid Color string: '" + value + "'");
}
};
kxColor_ColorxImplx._new = function(value) {
var this1 = value;
return this1;
};
kxColor_ColorxImplx.get_value = function(this1) {
return this1;
};
kxColor_ColorxImplx.set_value = function(this1,value) {
this1 = value;
return this1;
};
kxColor_ColorxImplx.get_Rb = function(this1) {
return (this1 & 16711680) >>> 16;
};
kxColor_ColorxImplx.get_Gb = function(this1) {
return (this1 & 65280) >>> 8;
};
kxColor_ColorxImplx.get_Bb = function(this1) {
return this1 & 255;
};
kxColor_ColorxImplx.get_Ab = function(this1) {
return this1 >>> 24;
};
kxColor_ColorxImplx.set_Rb = function(this1,i) {
this1 = this1 >>> 24 << 24 | i << 16 | (this1 & 65280) >>> 8 << 8 | this1 & 255;
return i;
};
kxColor_ColorxImplx.set_Gb = function(this1,i) {
this1 = this1 >>> 24 << 24 | (this1 & 16711680) >>> 16 << 16 | i << 8 | this1 & 255;
return i;
};
kxColor_ColorxImplx.set_Bb = function(this1,i) {
this1 = this1 >>> 24 << 24 | (this1 & 16711680) >>> 16 << 16 | (this1 & 65280) >>> 8 << 8 | i;
return i;
};
kxColor_ColorxImplx.set_Ab = function(this1,i) {
this1 = i << 24 | (this1 & 16711680) >>> 16 << 16 | (this1 & 65280) >>> 8 << 8 | this1 & 255;
return i;
};
kxColor_ColorxImplx.get_R = function(this1) {
return ((this1 & 16711680) >>> 16) * 0.00392156862745098;
};
kxColor_ColorxImplx.get_G = function(this1) {
return ((this1 & 65280) >>> 8) * 0.00392156862745098;
};
kxColor_ColorxImplx.get_B = function(this1) {
return (this1 & 255) * 0.00392156862745098;
};
kxColor_ColorxImplx.get_A = function(this1) {
return (this1 >>> 24) * 0.00392156862745098;
};
kxColor_ColorxImplx.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;
};
kxColor_ColorxImplx.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;
};
kxColor_ColorxImplx.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;
};
kxColor_ColorxImplx.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 kCompilerDefines = function() { };
xClasses["kha.CompilerDefines"] = kCompilerDefines;
kCompilerDefines.nom = true;
var kEnvironmentVariables = function() {
};
xClasses["kha.EnvironmentVariables"] = kEnvironmentVariables;
kEnvironmentVariables.nom = true;
kEnvironmentVariables.prototype = {
getVariable: function(name) {
return "";
}
,__class__: kEnvironmentVariables
};
var kFont = function() { };
xClasses["kha.Font"] = kFont;
kFont.nom = true;
kFont.__interfaces__ = [kResource];
kFont.prototype = {
height: null
,width: null
,baseline: null
,__class__: kFont
};
var kFontStyle = function(bold,italic,underlined) {
this.bold = bold;
this.italic = italic;
this.underlined = underlined;
};
xClasses["kha.FontStyle"] = kFontStyle;
kFontStyle.nom = true;
kFontStyle.prototype = {
bold: null
,italic: null
,underlined: null
,getBold: function() {
return this.bold;
}
,getItalic: function() {
return this.italic;
}
,getUnderlined: function() {
return this.underlined;
}
,__class__: kFontStyle
};
var kFramebuffer = function(windowId,g1,g2,g4) {
this.windowId = windowId;
this.graphics1 = g1;
this.graphics2 = g2;
this.graphics4 = g4;
};
xClasses["kha.Framebuffer"] = kFramebuffer;
kFramebuffer.nom = true;
kFramebuffer.__interfaces__ = [kCanvas];
kFramebuffer.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 kSystem.windowWidth(this.windowId);
}
,height: null
,get_height: function() {
return kSystem.windowHeight(this.windowId);
}
,__class__: kFramebuffer
};
var kAlignedQuad = function() {
};
xClasses["kha.AlignedQuad"] = kAlignedQuad;
kAlignedQuad.nom = true;
kAlignedQuad.prototype = {
x0: null
,y0: null
,s0: null
,t0: null
,x1: null
,y1: null
,s1: null
,t1: null
,xadvance: null
,__class__: kAlignedQuad
};
var kKravurImage = 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 = kImage.create(width,height,kgraphics4_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();
};
xClasses["kha.KravurImage"] = kKravurImage;
kKravurImage.nom = true;
kKravurImage.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 kAlignedQuad();
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(xOverrides.cca(str,c));
}
return width;
}
,getBaselinePosition: function() {
return this.baseline;
}
,__class__: kKravurImage
};
var kKravur = function(blob) {
this.images = new haxe_ds_IntMap();
this.blob = blob;
};
xClasses["kha.Kravur"] = kKravur;
kKravur.nom = true;
kKravur.__interfaces__ = [kFont];
kKravur.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 kgraphics2_truetype_Stbttxbakedchar();
}
var pixels = null;
var status = -1;
while(status < 0) {
if(height < width) {
height *= 2;
} else {
width *= 2;
}
pixels = kinternal_BytesBlob.alloc(width * height);
status = kgraphics2_truetype_StbTruetype.stbtt_BakeFontBitmap(this.blob,0,fontSize,pixels,width,height,glyphs,baked);
}
var info = new kgraphics2_truetype_Stbttxfontinfo();
kgraphics2_truetype_StbTruetype.stbtt_InitFont(info,this.blob,0);
var metrics = kgraphics2_truetype_StbTruetype.stbtt_GetFontVMetrics(info);
var scale = kgraphics2_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 kKravurImage(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__: kKravur
};
var kLoaderImpl = function() { };
xClasses["kha.LoaderImpl"] = kLoaderImpl;
kLoaderImpl.nom = true;
kLoaderImpl.getImageFormats = function() {
return ["png","jpg","hdr"];
};
kLoaderImpl.loadImageFromDescription = function(desc,done) {
var readable = Object.prototype.hasOwnProperty.call(desc,"readable") && desc.readable;
if(StringTools.endsWith(desc.files[0],".hdr")) {
kLoaderImpl.loadBlobFromDescription(desc,function(blob) {
var hdrImage = kinternal_HdrFormat.parse(blob.toBytes());
var tmp = kImage.fromBytes(haxe_io_Bytes.ofData(hdrImage.data.buffer),hdrImage.width,hdrImage.height,kgraphics4_TextureFormat.RGBA128,readable ? kgraphics4_Usage.DynamicUsage : kgraphics4_Usage.StaticUsage);
done(tmp);
});
} else {
var img = window.document.createElement("img");
img.onload = function(event) {
var tmp1 = kImage.fromImage(img,readable);
done(tmp1);
};
img.src = desc.files[0];
img.crossOrigin = "";
}
};
kLoaderImpl.getSoundFormats = function() {
var element = window.document.createElement("audio");
var formats = [];
if(element.canPlayType("audio/mp4") != "") {
formats.push("mp4");
}
if(kSystemImpl._hasWebAudio || element.canPlayType("audio/ogg") != "") {
formats.push("ogg");
}
return formats;
};
kLoaderImpl.loadSoundFromDescription = function(desc,done) {
if(kSystemImpl._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 kjsWebAudioSound(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 kjsWebAudioSound(file1,done);
return;
}
}
} else if(kSystemImpl.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 kjsMobileWebAudioSound(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 kjsMobileWebAudioSound(file3,done);
return;
}
}
} else {
new kjsSound(desc.files,done);
}
};
kLoaderImpl.getVideoFormats = function() {
return ["mp4","webm"];
};
kLoaderImpl.loadVideoFromDescription = function(desc,done) {
kjsVideo.fromFile(desc.files,done);
};
kLoaderImpl.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.x", lineNumber : 144, className : "kha.LoaderImpl", methodName : "loadBlobFromDescription"});
window.console.log("loadBlob failed");
}
done(new kinternal_BytesBlob(bytes));
} else {
haxe_Log.trace("Error loading " + desc.files[0],{ fileName : "LoaderImpl.x", lineNumber : 150, className : "kha.LoaderImpl", methodName : "loadBlobFromDescription"});
window.console.log("loadBlob failed");
}
};
request.send(null);
};
kLoaderImpl.loadFontFromDescription = function(desc,done) {
kLoaderImpl.loadBlobFromDescription(desc,function(blob) {
if(kSystemImpl.gl == null) {
done(new kjsFont(new kKravur(blob)));
} else {
done(new kKravur(blob));
}
});
};
var kRotation = function(center,angle) {
this.center = center;
this.angle = angle;
};
xClasses["kha.Rotation"] = kRotation;
kRotation.nom = true;
kRotation.prototype = {
center: null
,angle: null
,__class__: kRotation
};
var kTimeTask = function() {
};
xClasses["kha.TimeTask"] = kTimeTask;
kTimeTask.nom = true;
kTimeTask.prototype = {
task: null
,start: null
,period: null
,duration: null
,next: null
,id: null
,groupId: null
,active: null
,paused: null
,__class__: kTimeTask
};
var kFrameTask = function(task,priority,id) {
this.task = task;
this.priority = priority;
this.id = id;
this.active = true;
this.paused = false;
};
xClasses["kha.FrameTask"] = kFrameTask;
kFrameTask.nom = true;
kFrameTask.prototype = {
task: null
,priority: null
,id: null
,active: null
,paused: null
,__class__: kFrameTask
};
var kScheduler = function() { };
xClasses["kha.Scheduler"] = kScheduler;
kScheduler.nom = true;
kScheduler.init = function() {
kScheduler.deltas = [];
var _g1 = 0;
var _g = kScheduler.DIF_COUNT;
while(_g1 < _g) {
var i = _g1++;
kScheduler.deltas[i] = 0;
}
kScheduler.stopped = true;
kScheduler.frame_tasks_sorted = true;
kScheduler.current = kScheduler.realTime();
kScheduler.lastTime = kScheduler.realTime();
kScheduler.currentFrameTaskId = 0;
kScheduler.currentTimeTaskId = 0;
kScheduler.currentGroupId = 0;
kScheduler.timeTasks = [];
kScheduler.pausedTimeTasks = [];
kScheduler.outdatedTimeTasks = [];
kScheduler.timeTasksScratchpad = [];
kScheduler.frameTasks = [];
kScheduler.toDeleteFrame = [];
};
kScheduler.start = function(restartTimers) {
if(restartTimers == null) {
restartTimers = false;
}
kScheduler.vsync = kSystem.get_vsync();
var hz = kSystem.get_refreshRate();
if(hz >= 57 && hz <= 63) {
hz = 60;
}
kScheduler.onedifhz = 1.0 / hz;
kScheduler.stopped = false;
kScheduler.resetTime();
kScheduler.lastTime = kScheduler.realTime() - kScheduler.startTime;
var _g1 = 0;
var _g = kScheduler.DIF_COUNT;
while(_g1 < _g) {
var i = _g1++;
kScheduler.deltas[i] = 0;
}
if(restartTimers) {
var _g2 = 0;
var _g11 = kScheduler.timeTasks;
while(_g2 < _g11.length) {
var timeTask = _g11[_g2];
++_g2;
timeTask.paused = false;
}
var _g3 = 0;
var _g12 = kScheduler.frameTasks;
while(_g3 < _g12.length) {
var frameTask = _g12[_g3];
++_g3;
frameTask.paused = false;
}
}
};
kScheduler.stop = function() {
kScheduler.stopped = true;
};
kScheduler.isStopped = function() {
return kScheduler.stopped;
};
kScheduler.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;
}
}
};
kScheduler.back = function(time) {
if(time >= kScheduler.lastTime) {
return;
}
kScheduler.current = time;
kScheduler.lastTime = time;
kScheduler.warpTimeTasks(time,kScheduler.outdatedTimeTasks);
kScheduler.warpTimeTasks(time,kScheduler.timeTasks);
var _g = 0;
var _g1 = kScheduler.outdatedTimeTasks;
while(_g < _g1.length) {
var task = _g1[_g];
++_g;
if(task.next >= time) {
kScheduler.timeTasksScratchpad.push(task);
}
}
var _g2 = 0;
var _g11 = kScheduler.timeTasksScratchpad;
while(_g2 < _g11.length) {
var task1 = _g11[_g2];
++_g2;
xOverrides.remove(kScheduler.outdatedTimeTasks,task1);
}
var _g3 = 0;
var _g12 = kScheduler.timeTasksScratchpad;
while(_g3 < _g12.length) {
var task2 = _g12[_g3];
++_g3;
kScheduler.insertSorted(kScheduler.timeTasks,task2);
}
while(kScheduler.timeTasksScratchpad.length > 0) xOverrides.remove(kScheduler.timeTasksScratchpad,kScheduler.timeTasksScratchpad[0]);
var _g4 = 0;
var _g13 = kScheduler.outdatedTimeTasks;
while(_g4 < _g13.length) {
var task3 = _g13[_g4];
++_g4;
if(task3.next < time - 1.0) {
kScheduler.timeTasksScratchpad.push(task3);
}
}
var _g5 = 0;
var _g14 = kScheduler.timeTasksScratchpad;
while(_g5 < _g14.length) {
var task4 = _g14[_g5];
++_g5;
xOverrides.remove(kScheduler.outdatedTimeTasks,task4);
}
while(kScheduler.timeTasksScratchpad.length > 0) xOverrides.remove(kScheduler.timeTasksScratchpad,kScheduler.timeTasksScratchpad[0]);
};
kScheduler.executeFrame = function() {
var now = kScheduler.realTime() - kScheduler.startTime;
var delta = now - kScheduler.lastTime;
var frameEnd = kScheduler.current;
if(delta < 0) {
return;
}
if(delta > kScheduler.maxframetime) {
kScheduler.startTime += delta - kScheduler.maxframetime;
delta = kScheduler.maxframetime;
frameEnd += delta;
} else if(kScheduler.vsync) {
var realdif = kScheduler.onedifhz;
while(realdif < delta - kScheduler.onedifhz) realdif += kScheduler.onedifhz;
delta = realdif;
var _g1 = 0;
var _g = kScheduler.DIF_COUNT - 2;
while(_g1 < _g) {
var i = _g1++;
delta += kScheduler.deltas[i];
kScheduler.deltas[i] = kScheduler.deltas[i + 1];
}
delta += kScheduler.deltas[kScheduler.DIF_COUNT - 2];
delta /= kScheduler.DIF_COUNT;
kScheduler.deltas[kScheduler.DIF_COUNT - 2] = realdif;
frameEnd += delta;
} else {
var _g11 = 0;
var _g2 = kScheduler.DIF_COUNT - 1;
while(_g11 < _g2) {
var i1 = _g11++;
kScheduler.deltas[i1] = kScheduler.deltas[i1 + 1];
}
kScheduler.deltas[kScheduler.DIF_COUNT - 1] = delta;
var next = 0;
var _g12 = 0;
var _g3 = kScheduler.DIF_COUNT;
while(_g12 < _g3) {
var i2 = _g12++;
next += kScheduler.deltas[i2];
}
next /= kScheduler.DIF_COUNT;
frameEnd += next;
}
kScheduler.lastTime = frameEnd;
if(!kScheduler.stopped) {
kScheduler.current = frameEnd;
}
var _g4 = 0;
var _g13 = kScheduler.pausedTimeTasks;
while(_g4 < _g13.length) {
var pausedTask = _g13[_g4];
++_g4;
pausedTask.next += delta;
}
if(kScheduler.stopped) {
var _g5 = 0;
var _g14 = kScheduler.timeTasks;
while(_g5 < _g14.length) {
var timeTask = _g14[_g5];
++_g5;
timeTask.next += delta;
}
}
while(kScheduler.timeTasks.length > 0) {
kScheduler.activeTimeTask = kScheduler.timeTasks[0];
if(kScheduler.activeTimeTask.next <= frameEnd) {
kScheduler.activeTimeTask.next += kScheduler.activeTimeTask.period;
xOverrides.remove(kScheduler.timeTasks,kScheduler.activeTimeTask);
if(kScheduler.activeTimeTask.active && kScheduler.activeTimeTask.task()) {
if(kScheduler.activeTimeTask.period > 0 && (kScheduler.activeTimeTask.duration == 0 || kScheduler.activeTimeTask.duration >= kScheduler.activeTimeTask.start + kScheduler.activeTimeTask.next)) {
kScheduler.insertSorted(kScheduler.timeTasks,kScheduler.activeTimeTask);
} else {
kScheduler.archiveTimeTask(kScheduler.activeTimeTask,frameEnd);
}
} else {
kScheduler.activeTimeTask.active = false;
kScheduler.archiveTimeTask(kScheduler.activeTimeTask,frameEnd);
}
} else {
break;
}
}
kScheduler.activeTimeTask = null;
kScheduler.sortFrameTasks();
var _g6 = 0;
var _g15 = kScheduler.frameTasks;
while(_g6 < _g15.length) {
var frameTask = _g15[_g6];
++_g6;
if(!kScheduler.stopped && !frameTask.paused && frameTask.active) {
if(!frameTask.task()) {
frameTask.active = false;
}
}
}
var _g7 = 0;
var _g16 = kScheduler.frameTasks;
while(_g7 < _g16.length) {
var frameTask1 = _g16[_g7];
++_g7;
if(!frameTask1.active) {
kScheduler.toDeleteFrame.push(frameTask1);
}
}
while(kScheduler.toDeleteFrame.length > 0) xOverrides.remove(kScheduler.frameTasks,kScheduler.toDeleteFrame.pop());
};
kScheduler.archiveTimeTask = function(timeTask,frameEnd) {
};
kScheduler.time = function() {
return kScheduler.current;
};
kScheduler.realTime = function() {
return kSystem.get_time();
};
kScheduler.resetTime = function() {
var now = kSystem.get_time();
var dif = now - kScheduler.startTime;
kScheduler.startTime = now;
var _g = 0;
var _g1 = kScheduler.timeTasks;
while(_g < _g1.length) {
var timeTask = _g1[_g];
++_g;
timeTask.start -= dif;
timeTask.next -= dif;
}
var _g11 = 0;
var _g2 = kScheduler.DIF_COUNT;
while(_g11 < _g2) {
var i = _g11++;
kScheduler.deltas[i] = 0;
}
kScheduler.current = 0;
kScheduler.lastTime = 0;
};
kScheduler.addBreakableFrameTask = function(task,priority) {
kScheduler.frameTasks.push(new kFrameTask(task,priority,++kScheduler.currentFrameTaskId));
kScheduler.frame_tasks_sorted = false;
return kScheduler.currentFrameTaskId;
};
kScheduler.addFrameTask = function(task,priority) {
return kScheduler.addBreakableFrameTask(function() {
task();
return true;
},priority);
};
kScheduler.pauseFrameTask = function(id,paused) {
var _g = 0;
var _g1 = kScheduler.frameTasks;
while(_g < _g1.length) {
var frameTask = _g1[_g];
++_g;
if(frameTask.id == id) {
frameTask.paused = paused;
break;
}
}
};
kScheduler.removeFrameTask = function(id) {
var _g = 0;
var _g1 = kScheduler.frameTasks;
while(_g < _g1.length) {
var frameTask = _g1[_g];
++_g;
if(frameTask.id == id) {
frameTask.active = false;
break;
}
}
};
kScheduler.generateGroupId = function() {
return ++kScheduler.currentGroupId;
};
kScheduler.addBreakableTimeTaskToGroup = function(groupId,task,start,period,duration) {
if(duration == null) {
duration = 0;
}
if(period == null) {
period = 0;
}
var t = new kTimeTask();
t.active = true;
t.task = task;
t.id = ++kScheduler.currentTimeTaskId;
t.groupId = groupId;
t.start = kScheduler.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;
kScheduler.insertSorted(kScheduler.timeTasks,t);
return t.id;
};
kScheduler.addTimeTaskToGroup = function(groupId,task,start,period,duration) {
if(duration == null) {
duration = 0;
}
if(period == null) {
period = 0;
}
return kScheduler.addBreakableTimeTaskToGroup(groupId,function() {
task();
return true;
},start,period,duration);
};
kScheduler.addBreakableTimeTask = function(task,start,period,duration) {
if(duration == null) {
duration = 0;
}
if(period == null) {
period = 0;
}
return kScheduler.addBreakableTimeTaskToGroup(0,task,start,period,duration);
};
kScheduler.addTimeTask = function(task,start,period,duration) {
if(duration == null) {
duration = 0;
}
if(period == null) {
period = 0;
}
return kScheduler.addTimeTaskToGroup(0,task,start,period,duration);
};
kScheduler.getTimeTask = function(id) {
if(kScheduler.activeTimeTask != null && kScheduler.activeTimeTask.id == id) {
return kScheduler.activeTimeTask;
}
var _g = 0;
var _g1 = kScheduler.timeTasks;
while(_g < _g1.length) {
var timeTask = _g1[_g];
++_g;
if(timeTask.id == id) {
return timeTask;
}
}
var _g2 = 0;
var _g11 = kScheduler.pausedTimeTasks;
while(_g2 < _g11.length) {
var timeTask1 = _g11[_g2];
++_g2;
if(timeTask1.id == id) {
return timeTask1;
}
}
return null;
};
kScheduler.pauseTimeTask = function(id,paused) {
var timeTask = kScheduler.getTimeTask(id);
if(timeTask != null) {
kScheduler.pauseRunningTimeTask(timeTask,paused);
}
if(kScheduler.activeTimeTask != null && kScheduler.activeTimeTask.id == id) {
kScheduler.activeTimeTask.paused = paused;
}
};
kScheduler.pauseRunningTimeTask = function(timeTask,paused) {
timeTask.paused = paused;
if(paused) {
xOverrides.remove(kScheduler.timeTasks,timeTask);
kScheduler.pausedTimeTasks.push(timeTask);
} else {
kScheduler.insertSorted(kScheduler.timeTasks,timeTask);
xOverrides.remove(kScheduler.pausedTimeTasks,timeTask);
}
};
kScheduler.pauseTimeTasks = function(groupId,paused) {
var _g = 0;
var _g1 = kScheduler.timeTasks;
while(_g < _g1.length) {
var timeTask = _g1[_g];
++_g;
if(timeTask.groupId == groupId) {
kScheduler.pauseRunningTimeTask(timeTask,paused);
}
}
if(kScheduler.activeTimeTask != null && kScheduler.activeTimeTask.groupId == groupId) {
kScheduler.activeTimeTask.paused = paused;
}
};
kScheduler.removeTimeTask = function(id) {
var timeTask = kScheduler.getTimeTask(id);
if(timeTask != null) {
timeTask.active = false;
xOverrides.remove(kScheduler.timeTasks,timeTask);
}
};
kScheduler.removeTimeTasks = function(groupId) {
var _g = 0;
var _g1 = kScheduler.timeTasks;
while(_g < _g1.length) {
var timeTask = _g1[_g];
++_g;
if(timeTask.groupId == groupId) {
timeTask.active = false;
kScheduler.timeTasksScratchpad.push(timeTask);
}
}
var _g2 = 0;
var _g11 = kScheduler.timeTasksScratchpad;
while(_g2 < _g11.length) {
var timeTask1 = _g11[_g2];
++_g2;
xOverrides.remove(kScheduler.timeTasks,timeTask1);
}
while(kScheduler.timeTasksScratchpad.length > 0) xOverrides.remove(kScheduler.timeTasksScratchpad,kScheduler.timeTasksScratchpad[0]);
if(kScheduler.activeTimeTask != null && kScheduler.activeTimeTask.groupId == groupId) {
kScheduler.activeTimeTask.active = false;
}
};
kScheduler.numTasksInSchedule = function() {
return kScheduler.timeTasks.length + kScheduler.frameTasks.length;
};
kScheduler.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);
};
kScheduler.sortFrameTasks = function() {
if(kScheduler.frame_tasks_sorted) {
return;
}
kScheduler.frameTasks.sort(function(a,b) {
if(a.priority > b.priority) {
return 1;
} else if(a.priority < b.priority) {
return -1;
} else {
return 0;
}
});
kScheduler.frame_tasks_sorted = true;
};
var kScreenRotation = xClasses["kha.ScreenRotation"] = { __ename__ : true, __constructs__ : ["RotationNone","Rotation90","Rotation180","Rotation270"] };
kScreenRotation.RotationNone = ["RotationNone",0];
kScreenRotation.RotationNone.toString = $estr;
kScreenRotation.RotationNone.__enum__ = kScreenRotation;
kScreenRotation.Rotation90 = ["Rotation90",1];
kScreenRotation.Rotation90.toString = $estr;
kScreenRotation.Rotation90.__enum__ = kScreenRotation;
kScreenRotation.Rotation180 = ["Rotation180",2];
kScreenRotation.Rotation180.toString = $estr;
kScreenRotation.Rotation180.__enum__ = kScreenRotation;
kScreenRotation.Rotation270 = ["Rotation270",3];
kScreenRotation.Rotation270.toString = $estr;
kScreenRotation.Rotation270.__enum__ = kScreenRotation;
var kShaders = function() { };
xClasses["kha.Shaders"] = kShaders;
kShaders.nom = true;
kShaders.init = function() {
var blobs = [];
var _g = 0;
while(_g < 3) {
var i = _g++;
var data = Reflect.field(kShaders,"painter_colored_fragData" + i);
var bytes = haxe_Unserializer.run(data);
blobs.push(kinternal_BytesBlob.fromBytes(bytes));
}
kShaders.painter_colored_frag = new kgraphics4_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(kShaders,"painter_colored_vertData" + i1);
var bytes1 = haxe_Unserializer.run(data1);
blobs1.push(kinternal_BytesBlob.fromBytes(bytes1));
}
kShaders.painter_colored_vert = new kgraphics4_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(kShaders,"painter_image_fragData" + i2);
var bytes2 = haxe_Unserializer.run(data2);
blobs2.push(kinternal_BytesBlob.fromBytes(bytes2));
}
kShaders.painter_image_frag = new kgraphics4_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(kShaders,"painter_image_vertData" + i3);
var bytes3 = haxe_Unserializer.run(data3);
blobs3.push(kinternal_BytesBlob.fromBytes(bytes3));
}
kShaders.painter_image_vert = new kgraphics4_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(kShaders,"painter_text_fragData" + i4);
var bytes4 = haxe_Unserializer.run(data4);
blobs4.push(kinternal_BytesBlob.fromBytes(bytes4));
}
kShaders.painter_text_frag = new kgraphics4_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(kShaders,"painter_text_vertData" + i5);
var bytes5 = haxe_Unserializer.run(data5);
blobs5.push(kinternal_BytesBlob.fromBytes(bytes5));
}
kShaders.painter_text_vert = new kgraphics4_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(kShaders,"painter_video_fragData" + i6);
var bytes6 = haxe_Unserializer.run(data6);
blobs6.push(kinternal_BytesBlob.fromBytes(bytes6));
}
kShaders.painter_video_frag = new kgraphics4_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(kShaders,"painter_video_vertData" + i7);
var bytes7 = haxe_Unserializer.run(data7);
blobs7.push(kinternal_BytesBlob.fromBytes(bytes7));
}
kShaders.painter_video_vert = new kgraphics4_VertexShader(blobs7,["painter-video.vert.essl","painter-video-relaxed.vert.essl","painter-video-webgl2.vert.essl"]);
};
var kSound = function() {
};
xClasses["kha.Sound"] = kSound;
kSound.nom = true;
kSound.__interfaces__ = [kResource];
kSound.prototype = {
compressedData: null
,uncompressedData: null
,uncompress: function(done) {
var output = new haxe_io_BytesOutput();
var header = kaudio2_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__: kSound
};
var kSystem = function() { };
xClasses["kha.System"] = kSystem;
kSystem.nom = true;
kSystem.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 = kWindowMode.Window;
}
kSystem.theTitle = options.title;
kSystemImpl.init(options,callback);
};
kSystem.initEx = function(title,options,windowCallback,callback) {
kSystem.theTitle = title;
kSystemImpl.initEx(title,options,windowCallback,callback);
};
kSystem.get_title = function() {
return kSystem.theTitle;
};
kSystem.notifyOnRender = function(listener,id) {
if(id == null) {
id = 0;
}
while(id >= kSystem.renderListeners.length) kSystem.renderListeners.push([]);
kSystem.renderListeners[id].push(listener);
};
kSystem.removeRenderListener = function(listener,id) {
if(id == null) {
id = 0;
}
xOverrides.remove(kSystem.renderListeners[id],listener);
};
kSystem.notifyOnApplicationState = function(foregroundListener,resumeListener,pauseListener,backgroundListener,shutdownListener) {
if(foregroundListener != null) {
kSystem.foregroundListeners.push(foregroundListener);
}
if(resumeListener != null) {
kSystem.resumeListeners.push(resumeListener);
}
if(pauseListener != null) {
kSystem.pauseListeners.push(pauseListener);
}
if(backgroundListener != null) {
kSystem.backgroundListeners.push(backgroundListener);
}
if(shutdownListener != null) {
kSystem.shutdownListeners.push(shutdownListener);
}
};
kSystem.notifyOnDropFiles = function(dropFilesListener) {
kSystem.dropFilesListeners.push(dropFilesListener);
};
kSystem.render = function(id,framebuffer) {
if(kSystem.renderListeners.length == 0) {
return;
}
var _g = 0;
var _g1 = kSystem.renderListeners[id];
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener(framebuffer);
}
};
kSystem.foreground = function() {
var _g = 0;
var _g1 = kSystem.foregroundListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener();
}
};
kSystem.resume = function() {
var _g = 0;
var _g1 = kSystem.resumeListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener();
}
};
kSystem.pause = function() {
var _g = 0;
var _g1 = kSystem.pauseListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener();
}
};
kSystem.background = function() {
var _g = 0;
var _g1 = kSystem.backgroundListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener();
}
};
kSystem.shutdown = function() {
var _g = 0;
var _g1 = kSystem.shutdownListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener();
}
};
kSystem.dropFiles = function(filePath) {
var _g = 0;
var _g1 = kSystem.dropFilesListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener(filePath);
}
};
kSystem.get_time = function() {
return kSystemImpl.getTime();
};
kSystem.windowWidth = function(windowId) {
if(windowId == null) {
windowId = 0;
}
return kSystemImpl.windowWidth(windowId);
};
kSystem.windowHeight = function(windowId) {
if(windowId == null) {
windowId = 0;
}
return kSystemImpl.windowHeight(windowId);
};
kSystem.screenDpi = function() {
return kSystemImpl.screenDpi();
};
kSystem.get_screenRotation = function() {
return kSystemImpl.getScreenRotation();
};
kSystem.get_vsync = function() {
return kSystemImpl.getVsync();
};
kSystem.get_refreshRate = function() {
return kSystemImpl.getRefreshRate();
};
kSystem.get_systemId = function() {
return kSystemImpl.getSystemId();
};
kSystem.requestShutdown = function() {
kSystemImpl.requestShutdown();
};
kSystem.changeResolution = function(width,height) {
kSystemImpl.changeResolution(width,height);
};
kSystem.loadUrl = function(url) {
kSystemImpl.loadUrl(url);
};
var kGamepadStates = function() {
this.axes = [];
this.buttons = [];
};
xClasses["kha.GamepadStates"] = kGamepadStates;
kGamepadStates.nom = true;
kGamepadStates.prototype = {
axes: null
,buttons: null
,__class__: kGamepadStates
};
var kSystemImpl = function() { };
xClasses["kha.SystemImpl"] = kSystemImpl;
kSystemImpl.nom = true;
kSystemImpl.initPerformanceTimer = function() {
if(window.performance != null && ($_=window.performance,$bind($_,$_.now)) != null) {
kSystemImpl.performance = window.performance;
} else {
kSystemImpl.performance = window.Date;
}
};
kSystemImpl.errorHandler = function(message,source,lineno,colno,error) {
window.console.error(error.stack);
return true;
};
kSystemImpl.init = function(options,callback) {
kSystemImpl.options = options;
kSystemImpl.mobile = kSystemImpl.isMobile();
kSystemImpl.chrome = kSystemImpl.isChrome();
kSystemImpl.init2();
callback();
};
kSystemImpl.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.x", lineNumber : 86, className : "kha.SystemImpl", methodName : "initEx"});
kSystemImpl.init({ title : title, width : options[0].width, height : options[0].height},callback);
if(windowCallback != null) {
windowCallback(0);
}
};
kSystemImpl.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;
}
};
kSystemImpl.isChrome = function() {
var agent = window.navigator.userAgent;
if(agent.indexOf("Chrome") >= 0) {
return true;
} else {
return false;
}
};
kSystemImpl.windowWidth = function(windowId) {
if(windowId == null) {
windowId = 0;
}
if(kSystemImpl.khanvas.width == 0 && kSystemImpl.options.width != null) {
return kSystemImpl.options.width;
} else {
return kSystemImpl.khanvas.width;
}
};
kSystemImpl.windowHeight = function(windowId) {
if(windowId == null) {
windowId = 0;
}
if(kSystemImpl.khanvas.height == 0 && kSystemImpl.options.height != null) {
return kSystemImpl.options.height;
} else {
return kSystemImpl.khanvas.height;
}
};
kSystemImpl.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;
};
kSystemImpl.setCanvas = function(canvas) {
kSystemImpl.khanvas = canvas;
};
kSystemImpl.getScreenRotation = function() {
return kScreenRotation.RotationNone;
};
kSystemImpl.getTime = function() {
return kSystemImpl.performance.now() / 1000;
};
kSystemImpl.getVsync = function() {
return true;
};
kSystemImpl.getRefreshRate = function() {
return 60;
};
kSystemImpl.getSystemId = function() {
return "HTML5";
};
kSystemImpl.requestShutdown = function() {
window.close();
};
kSystemImpl.init2 = function(backbufferFormat) {
haxe_Log.trace = jsBoot.__trace;
kSystemImpl.keyboard = new kinput_Keyboard();
kSystemImpl.mouse = new kinput_MouseImpl();
kSystemImpl.surface = new kinput_Surface();
kSystemImpl.gamepads = [];
kSystemImpl.gamepadStates = [];
var _g = 0;
while(_g < 4) {
var i = _g++;
kSystemImpl.gamepads[i] = new kinput_Gamepad(i);
kSystemImpl.gamepadStates[i] = new kGamepadStates();
}
kSystemImpl.pressedKeys = [];
var _g1 = 0;
while(_g1 < 256) {
var i1 = _g1++;
kSystemImpl.pressedKeys.push(false);
}
var _g2 = 0;
while(_g2 < 256) {
var i2 = _g2++;
kSystemImpl.pressedKeys.push(null);
}
kCanvasImage.init();
kSystemImpl.initPerformanceTimer();
kScheduler.init();
kSystemImpl.loadFinished();
kEnvironmentVariables.instance = new kjsEnvironmentVariables();
};
kSystemImpl.getMouse = function(num) {
if(num != 0) {
return null;
}
return kSystemImpl.mouse;
};
kSystemImpl.getKeyboard = function(num) {
if(num != 0) {
return null;
}
return kSystemImpl.keyboard;
};
kSystemImpl.checkGamepad = function(pad) {
var _g1 = 0;
var _g = pad.axes.length;
while(_g1 < _g) {
var i = _g1++;
if(pad.axes[i] != null) {
if(kSystemImpl.gamepadStates[pad.index].axes[i] != pad.axes[i]) {
var axis = pad.axes[i];
if(i % 2 == 1) {
axis = -axis;
}
kSystemImpl.gamepadStates[pad.index].axes[i] = axis;
kSystemImpl.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(kSystemImpl.gamepadStates[pad.index].buttons[i1] != pad.buttons[i1].value) {
kSystemImpl.gamepadStates[pad.index].buttons[i1] = pad.buttons[i1].value;
kSystemImpl.gamepads[pad.index].sendButtonEvent(i1,pad.buttons[i1].value);
}
}
}
if(pad.axes.length <= 4 && pad.buttons.length > 7) {
kSystemImpl.gamepadStates[pad.index].axes[4] = pad.buttons[6].value;
kSystemImpl.gamepads[pad.index].sendAxisEvent(4,pad.buttons[6].value);
kSystemImpl.gamepadStates[pad.index].axes[5] = pad.buttons[7].value;
kSystemImpl.gamepads[pad.index].sendAxisEvent(5,pad.buttons[7].value);
}
};
kSystemImpl.loadFinished = function() {
var canvas = kSystemImpl.khanvas;
if(canvas == null) {
canvas = window.document.getElementById(kCompilerDefines.canvas_id);
}
canvas.style.cursor = "default";
var gl = false;
try {
kSystemImpl.gl = canvas.getContext("webgl2",{ alpha : false, antialias : kSystemImpl.options.samplesPerPixel > 1, stencil : true, preserveDrawingBuffer : true});
kSystemImpl.gl.pixelStorei(37441,1);
kSystemImpl.halfFloat = { HALF_FLOAT_OES : 5131};
kSystemImpl.depthTexture = { UNSIGNED_INT_24_8_WEBGL : 34042};
kSystemImpl.drawBuffers = { COLOR_ATTACHMENT0_WEBGL : 36064};
kSystemImpl.elementIndexUint = true;
kSystemImpl.gl.getExtension("EXT_color_buffer_float");
kSystemImpl.gl.getExtension("OES_texture_float_linear");
kSystemImpl.gl.getExtension("OES_texture_half_float_linear");
kSystemImpl.anisotropicFilter = kSystemImpl.gl.getExtension("EXT_texture_filter_anisotropic");
if(kSystemImpl.anisotropicFilter == null) {
kSystemImpl.anisotropicFilter = kSystemImpl.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
}
gl = true;
kSystemImpl.gl2 = true;
kShaders.init();
} catch( e ) {
haxe_Log.trace("Could not initialize WebGL 2, falling back to WebGL.",{ fileName : "SystemImpl.x", lineNumber : 302, className : "kha.SystemImpl", methodName : "loadFinished"});
}
if(!kSystemImpl.gl2) {
try {
kSystemImpl.gl = canvas.getContext("experimental-webgl",{ alpha : false, antialias : kSystemImpl.options.samplesPerPixel > 1, stencil : true, preserveDrawingBuffer : true});
if(kSystemImpl.gl != null) {
kSystemImpl.gl.pixelStorei(37441,1);
kSystemImpl.gl.getExtension("OES_texture_float");
kSystemImpl.gl.getExtension("OES_texture_float_linear");
kSystemImpl.halfFloat = kSystemImpl.gl.getExtension("OES_texture_half_float");
kSystemImpl.gl.getExtension("OES_texture_half_float_linear");
kSystemImpl.depthTexture = kSystemImpl.gl.getExtension("WEBGL_depth_texture");
kSystemImpl.gl.getExtension("EXT_shader_texture_lod");
kSystemImpl.gl.getExtension("OES_standard_derivatives");
kSystemImpl.anisotropicFilter = kSystemImpl.gl.getExtension("EXT_texture_filter_anisotropic");
if(kSystemImpl.anisotropicFilter == null) {
kSystemImpl.anisotropicFilter = kSystemImpl.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
}
kSystemImpl.drawBuffers = kSystemImpl.gl.getExtension("WEBGL_draw_buffers");
kSystemImpl.elementIndexUint = kSystemImpl.gl.getExtension("OES_element_index_uint");
gl = true;
kShaders.init();
}
} catch( e1 ) {
haxe_Log.trace("Could not initialize WebGL, falling back to Canvas.",{ fileName : "SystemImpl.x", lineNumber : 326, className : "kha.SystemImpl", methodName : "loadFinished"});
}
}
kSystemImpl.setCanvas(canvas);
if(gl) {
var g4 = gl ? new kjsgraphics4_Graphics() : null;
kSystemImpl.frame = new kFramebuffer(0,null,null,g4);
kSystemImpl.frame.init(new kgraphics2_Graphics1(kSystemImpl.frame),new kjsgraphics4_Graphics2(kSystemImpl.frame),g4);
} else {
var g2 = new kjsCanvasGraphics(canvas.getContext("2d"));
kSystemImpl.frame = new kFramebuffer(0,null,g2,null);
kSystemImpl.frame.init(new kgraphics2_Graphics1(kSystemImpl.frame),g2,null);
}
if(!kSystemImpl.mobile && kaudio2_Audio._init()) {
kSystemImpl._hasWebAudio = true;
kaudio2_Audio1._init();
} else if(kSystemImpl.mobile) {
kSystemImpl._hasWebAudio = false;
kjsMobileWebAudio._init();
kaudio2_Audio1 = kjsMobileWebAudio;
} else {
kSystemImpl._hasWebAudio = false;
kjsAudioElementAudio._compile();
kaudio2_Audio1 = kjsAudioElementAudio;
}
kvr_VrInterface.instance = new kjsvr_VrInterface();
kScheduler.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 = kSystemImpl.getGamepads();
if(sysGamepads != null) {
var _g1 = 0;
var _g = sysGamepads.length;
while(_g1 < _g) {
var i = _g1++;
var pad = sysGamepads[i];
if(pad != null) {
kSystemImpl.checkGamepad(pad);
}
}
}
kScheduler.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;
}
kSystem.render(0,kSystemImpl.frame);
if(kSystemImpl.gl != null) {
kSystemImpl.gl.clearColor(1,1,1,1);
kSystemImpl.gl.colorMask(false,false,false,true);
kSystemImpl.gl.clear(16384);
kSystemImpl.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 = kSystemImpl.mouseDown;
canvas.onmousemove = kSystemImpl.mouseMove;
if(kSystemImpl.keyboard != null) {
canvas.onkeydown = kSystemImpl.keyDown;
canvas.onkeyup = kSystemImpl.keyUp;
canvas.onkeypress = kSystemImpl.keyPress;
}
canvas.onblur = kSystemImpl.onBlur;
canvas.onfocus = kSystemImpl.onFocus;
canvas.onmousewheel = canvas.onwheel = kSystemImpl.mouseWheel;
canvas.onmouseleave = kSystemImpl.mouseLeave;
canvas.addEventListener("wheel mousewheel",kSystemImpl.mouseWheel,false);
canvas.addEventListener("touchstart",kSystemImpl.touchDown,false);
canvas.addEventListener("touchend",kSystemImpl.touchUp,false);
canvas.addEventListener("touchmove",kSystemImpl.touchMove,false);
window.addEventListener("unload",kSystemImpl.unload);
};
kSystemImpl.lockMouse = function() {
if(($_=kSystemImpl.khanvas,$bind($_,$_.requestPointerLock))) {
kSystemImpl.khanvas.requestPointerLock();
} else if(kSystemImpl.khanvas.mozRequestPointerLock) {
kSystemImpl.khanvas.mozRequestPointerLock();
} else if(kSystemImpl.khanvas.webkitRequestPointerLock) {
kSystemImpl.khanvas.webkitRequestPointerLock();
}
};
kSystemImpl.unlockMouse = function() {
if(document.exitPointerLock) {
document.exitPointerLock();
} else if(document.mozExitPointerLock) {
document.mozExitPointerLock();
} else if(document.webkitExitPointerLock) {
document.webkitExitPointerLock();
}
};
kSystemImpl.canLockMouse = function() {
return 'pointerLockElement' in document ||
'mozPointerLockElement' in document ||
'webkitPointerLockElement' in document;
};
kSystemImpl.isMouseLocked = function() {
return document.pointerLockElement === kSys.khanvas ||
document.mozPointerLockElement === kSys.khanvas ||
document.webkitPointerLockElement === kSys.khanvas;
};
kSystemImpl.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);
};
kSystemImpl.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);
};
kSystemImpl.unload = function(_) {
};
kSystemImpl.setMouseXY = function(event) {
var rect = kSystemImpl.khanvas.getBoundingClientRect();
var borderWidth = kSystemImpl.khanvas.clientLeft;
var borderHeight = kSystemImpl.khanvas.clientTop;
kSystemImpl.mouseX = (event.clientX - rect.left - borderWidth) * kSystemImpl.khanvas.width / (rect.width - 2 * borderWidth) | 0;
kSystemImpl.mouseY = (event.clientY - rect.top - borderHeight) * kSystemImpl.khanvas.height / (rect.height - 2 * borderHeight) | 0;
};
kSystemImpl.unlockSoundOnIOS = function() {
if(!kSystemImpl.mobile || kSystemImpl.iosSoundEnabled) {
return;
}
var buffer = kjsMobileWebAudio._context.createBuffer(1,1,22050);
var source = kjsMobileWebAudio._context.createBufferSource();
source.buffer = buffer;
source.connect(kjsMobileWebAudio._context.destination);
if(source.noteOn) {
source.noteOn(0);
}
kSystemImpl.iosSoundEnabled = true;
};
kSystemImpl.mouseLeave = function() {
kSystemImpl.mouse.sendLeaveEvent(0);
};
kSystemImpl.mouseWheel = function(event) {
kSystemImpl.insideInputEvent = true;
kSystemImpl.unlockSoundOnIOS();
event.preventDefault();
if(event.deltaMode == 0) {
if(event.deltaY < 0) {
kSystemImpl.mouse.sendWheelEvent(0,-1);
} else if(event.deltaY > 0) {
kSystemImpl.mouse.sendWheelEvent(0,1);
}
kSystemImpl.insideInputEvent = false;
return false;
}
if(event.deltaMode == 1) {
kSystemImpl.minimumScroll = Math.min(kSystemImpl.minimumScroll,Math.abs(event.deltaY)) | 0;
kSystemImpl.mouse.sendWheelEvent(0,event.deltaY / kSystemImpl.minimumScroll | 0);
kSystemImpl.insideInputEvent = false;
return false;
}
kSystemImpl.insideInputEvent = false;
return false;
};
kSystemImpl.mouseDown = function(event) {
kSystemImpl.insideInputEvent = true;
kSystemImpl.unlockSoundOnIOS();
kSystemImpl.setMouseXY(event);
if(event.which == 1) {
if(event.ctrlKey) {
kSystemImpl.leftMouseCtrlDown = true;
kSystemImpl.mouse.sendDownEvent(0,1,kSystemImpl.mouseX,kSystemImpl.mouseY);
} else {
kSystemImpl.leftMouseCtrlDown = false;
kSystemImpl.mouse.sendDownEvent(0,0,kSystemImpl.mouseX,kSystemImpl.mouseY);
}
if(($_=kSystemImpl.khanvas,$bind($_,$_.setCapture)) != null) {
kSystemImpl.khanvas.setCapture();
}
kSystemImpl.khanvas.ownerDocument.addEventListener("mouseup",kSystemImpl.mouseLeftUp);
} else if(event.which == 2) {
kSystemImpl.mouse.sendDownEvent(0,2,kSystemImpl.mouseX,kSystemImpl.mouseY);
kSystemImpl.khanvas.ownerDocument.addEventListener("mouseup",kSystemImpl.mouseMiddleUp);
} else if(event.which == 3) {
kSystemImpl.mouse.sendDownEvent(0,1,kSystemImpl.mouseX,kSystemImpl.mouseY);
kSystemImpl.khanvas.ownerDocument.addEventListener("mouseup",kSystemImpl.mouseRightUp);
}
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.mouseLeftUp = function(event) {
kSystemImpl.unlockSoundOnIOS();
if(event.which != 1) {
return;
}
kSystemImpl.insideInputEvent = true;
kSystemImpl.khanvas.ownerDocument.removeEventListener("mouseup",kSystemImpl.mouseLeftUp);
if(($_=kSystemImpl.khanvas,$bind($_,$_.releaseCapture)) != null) {
kSystemImpl.khanvas.ownerDocument.releaseCapture();
}
if(kSystemImpl.leftMouseCtrlDown) {
kSystemImpl.mouse.sendUpEvent(0,1,kSystemImpl.mouseX,kSystemImpl.mouseY);
} else {
kSystemImpl.mouse.sendUpEvent(0,0,kSystemImpl.mouseX,kSystemImpl.mouseY);
}
kSystemImpl.leftMouseCtrlDown = false;
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.mouseMiddleUp = function(event) {
kSystemImpl.unlockSoundOnIOS();
if(event.which != 2) {
return;
}
kSystemImpl.insideInputEvent = true;
kSystemImpl.khanvas.ownerDocument.removeEventListener("mouseup",kSystemImpl.mouseMiddleUp);
kSystemImpl.mouse.sendUpEvent(0,2,kSystemImpl.mouseX,kSystemImpl.mouseY);
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.mouseRightUp = function(event) {
kSystemImpl.unlockSoundOnIOS();
if(event.which != 3) {
return;
}
kSystemImpl.insideInputEvent = true;
kSystemImpl.khanvas.ownerDocument.removeEventListener("mouseup",kSystemImpl.mouseRightUp);
kSystemImpl.mouse.sendUpEvent(0,1,kSystemImpl.mouseX,kSystemImpl.mouseY);
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.mouseMove = function(event) {
kSystemImpl.insideInputEvent = true;
kSystemImpl.unlockSoundOnIOS();
var lastMouseX = kSystemImpl.mouseX;
var lastMouseY = kSystemImpl.mouseY;
kSystemImpl.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 = kSystemImpl.mouseX - lastMouseX;
}
if(event.mozMovementY != null) {
movementY = event.mozMovementY;
} else if(event.webkitMovementY != null) {
movementY = event.webkitMovementY;
} else {
movementY = kSystemImpl.mouseY - lastMouseY;
}
}
kSystemImpl.mouse.sendMoveEvent(0,kSystemImpl.mouseX,kSystemImpl.mouseY,movementX,movementY);
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.setTouchXY = function(touch) {
var rect = kSystemImpl.khanvas.getBoundingClientRect();
var borderWidth = kSystemImpl.khanvas.clientLeft;
var borderHeight = kSystemImpl.khanvas.clientTop;
kSystemImpl.touchX = (touch.clientX - rect.left - borderWidth) * kSystemImpl.khanvas.width / (rect.width - 2 * borderWidth) | 0;
kSystemImpl.touchY = (touch.clientY - rect.top - borderHeight) * kSystemImpl.khanvas.height / (rect.height - 2 * borderHeight) | 0;
};
kSystemImpl.touchDown = function(event) {
kSystemImpl.insideInputEvent = true;
kSystemImpl.unlockSoundOnIOS();
event.stopPropagation();
event.preventDefault();
var _g = 0;
var _g1 = event.changedTouches;
while(_g < _g1.length) {
var touch = _g1[_g];
++_g;
kSystemImpl.setTouchXY(touch);
kSystemImpl.mouse.sendDownEvent(0,0,kSystemImpl.touchX,kSystemImpl.touchY);
kSystemImpl.surface.sendTouchStartEvent(touch.identifier,kSystemImpl.touchX,kSystemImpl.touchY);
}
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.touchUp = function(event) {
kSystemImpl.insideInputEvent = true;
kSystemImpl.unlockSoundOnIOS();
var _g = 0;
var _g1 = event.changedTouches;
while(_g < _g1.length) {
var touch = _g1[_g];
++_g;
kSystemImpl.setTouchXY(touch);
kSystemImpl.mouse.sendUpEvent(0,0,kSystemImpl.touchX,kSystemImpl.touchY);
kSystemImpl.surface.sendTouchEndEvent(touch.identifier,kSystemImpl.touchX,kSystemImpl.touchY);
}
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.touchMove = function(event) {
kSystemImpl.insideInputEvent = true;
kSystemImpl.unlockSoundOnIOS();
var index = 0;
var _g = 0;
var _g1 = event.changedTouches;
while(_g < _g1.length) {
var touch = _g1[_g];
++_g;
kSystemImpl.setTouchXY(touch);
if(index == 0) {
var movementX = kSystemImpl.touchX - kSystemImpl.lastFirstTouchX;
var movementY = kSystemImpl.touchY - kSystemImpl.lastFirstTouchY;
kSystemImpl.lastFirstTouchX = kSystemImpl.touchX;
kSystemImpl.lastFirstTouchY = kSystemImpl.touchY;
kSystemImpl.mouse.sendMoveEvent(0,kSystemImpl.touchX,kSystemImpl.touchY,movementX,movementY);
}
kSystemImpl.surface.sendMoveEvent(touch.identifier,kSystemImpl.touchX,kSystemImpl.touchY);
++index;
}
kSystemImpl.insideInputEvent = false;
};
kSystemImpl.onBlur = function() {
kSystem.background();
};
kSystemImpl.onFocus = function() {
kSystem.foreground();
};
kSystemImpl.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);
};
kSystemImpl.keyDown = function(event) {
event.stopPropagation();
if(kSystemImpl.pressedKeys[event.keyCode]) {
event.preventDefault();
return;
}
kSystemImpl.pressedKeys[event.keyCode] = true;
kSystemImpl.keyboard.sendDownEvent(event.keyCode);
};
kSystemImpl.keyUp = function(event) {
event.preventDefault();
event.stopPropagation();
kSystemImpl.pressedKeys[event.keyCode] = false;
kSystemImpl.keyboard.sendUpEvent(event.keyCode);
};
kSystemImpl.keyPress = function(event) {
event.stopPropagation();
kSystemImpl.keyboard.sendPressEvent(String.fromCharCode(event.which));
};
kSystemImpl.canSwitchFullscreen = function() {
return 'fullscreenElement ' in document ||
'mozFullScreenElement' in document ||
'webkitFullscreenElement' in document ||
'msFullscreenElement' in document
;
};
kSystemImpl.isFullscreen = function() {
return document.fullscreenElement === this.khanvas ||
document.mozFullScreenElement === this.khanvas ||
document.webkitFullscreenElement === this.khanvas ||
document.msFullscreenElement === this.khanvas ;
};
kSystemImpl.requestFullscreen = function() {
if(($_=kSystemImpl.khanvas,$bind($_,$_.requestFullscreen))) {
kSystemImpl.khanvas.requestFullscreen();
} else if(kSystemImpl.khanvas.msRequestFullscreen) {
kSystemImpl.khanvas.msRequestFullscreen();
} else if(kSystemImpl.khanvas.mozRequestFullScreen) {
kSystemImpl.khanvas.mozRequestFullScreen();
} else if(kSystemImpl.khanvas.webkitRequestFullscreen) {
kSystemImpl.khanvas.webkitRequestFullscreen();
}
};
kSystemImpl.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();
}
};
kSystemImpl.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);
};
kSystemImpl.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);
};
kSystemImpl.changeResolution = function(width,height) {
};
kSystemImpl.setKeepScreenOn = function(on) {
};
kSystemImpl.loadUrl = function(url) {
window.open(url,"_blank");
};
kSystemImpl.getGamepadId = function(index) {
var sysGamepads = kSystemImpl.getGamepads();
if(sysGamepads != null && sysGamepads[index]) {
return sysGamepads[index].id;
}
return "unkown";
};
kSystemImpl.getGamepads = function() {
if(kSystemImpl.chrome && kvr_VrInterface.instance.IsVrEnabled()) {
return null;
}
if(navigator.getGamepads) {
return window.navigator.getGamepads();
} else {
return null;
}
};
var kVideo = function() {
};
xClasses["kha.Video"] = kVideo;
kVideo.nom = true;
kVideo.__interfaces__ = [kResource];
kVideo.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__: kVideo
};
var kWebGLImage = 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;
kWebGLImage.init();
if(renderTarget) {
this.createTexture();
}
};
xClasses["kha.WebGLImage"] = kWebGLImage;
kWebGLImage.nom = true;
kWebGLImage.init = function() {
if(kWebGLImage.context == null) {
var canvas = window.document.createElement("canvas");
if(canvas != null) {
kWebGLImage.context = canvas.getContext("2d");
canvas.width = 2048;
canvas.height = 2048;
kWebGLImage.context.globalCompositeOperation = "copy";
}
}
};
kWebGLImage.upperPowerOfTwo = function(v) {
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return ++v;
};
kWebGLImage.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;
}
};
kWebGLImage.__super__ = kImage;
kWebGLImage.prototype = $extend(kImage.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 kgraphics2_Graphics1(this);
}
return this.graphics1;
}
,get_g2: function() {
if(this.graphics2 == null) {
this.graphics2 = new kjsgraphics4_Graphics2(this);
}
return this.graphics2;
}
,get_g4: function() {
if(this.graphics4 == null) {
this.graphics4 = new kjsgraphics4_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(kWebGLImage.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(kWebGLImage.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 kxColor_ColorxImplx._new(a << 24 | r << 16 | g << 8 | b);
}
,createImageData: function() {
if(jsBoot.__instanceof(this.image,Uint8Array)) {
this.data = new ImageData(new Uint8ClampedArray(this.image.buffer),this.get_width(),this.get_height());
} else {
kWebGLImage.context.strokeStyle = "rgba(0,0,0,0)";
kWebGLImage.context.fillStyle = "rgba(0,0,0,0)";
kWebGLImage.context.fillRect(0,0,this.image.width,this.image.height);
kWebGLImage.context.drawImage(this.image,0,0,this.image.width,this.image.height,0,0,this.image.width,this.image.height);
this.data = kWebGLImage.context.getImageData(0,0,this.image.width,this.image.height);
}
}
,createTexture: function() {
if(kSystemImpl.gl == null) {
return;
}
this.texture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(3553,this.texture);
kSystemImpl.gl.texParameteri(3553,10240,9729);
kSystemImpl.gl.texParameteri(3553,10241,9729);
kSystemImpl.gl.texParameteri(3553,10242,33071);
kSystemImpl.gl.texParameteri(3553,10243,33071);
if(this.renderTarget) {
this.frameBuffer = kSystemImpl.gl.createFramebuffer();
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
var _g = this.format;
switch(_g[1]) {
case 0:
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null);
break;
case 2:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 34836 : 6408,this.get_realWidth(),this.get_realHeight(),0,6408,5126,null);
break;
case 3:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33189 : 6402,this.get_realWidth(),this.get_realHeight(),0,6402,5123,null);
break;
case 4:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 34842 : 6408,this.get_realWidth(),this.get_realHeight(),0,6408,kSystemImpl.halfFloat.HALF_FLOAT_OES,null);
break;
case 5:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33326 : 6406,this.get_realWidth(),this.get_realHeight(),0,kSystemImpl.gl2 ? 6403 : 6406,5126,null);
break;
case 6:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33325 : 6406,this.get_realWidth(),this.get_realHeight(),0,kSystemImpl.gl2 ? 6403 : 6406,kSystemImpl.halfFloat.HALF_FLOAT_OES,null);
break;
default:
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null);
}
if(this.format == kgraphics4_TextureFormat.DEPTH16) {
kSystemImpl.gl.texParameteri(3553,10240,9728);
kSystemImpl.gl.texParameteri(3553,10241,9728);
kSystemImpl.gl.framebufferTexture2D(36160,36096,3553,this.texture,0);
if(navigator.appVersion.indexOf("Win") == -1) {
var colortex = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(3553,colortex);
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_realWidth(),this.get_realHeight(),0,6408,5121,null);
kSystemImpl.gl.framebufferTexture2D(36160,36064,3553,colortex,0);
kSystemImpl.gl.bindTexture(3553,this.texture);
}
} else {
kSystemImpl.gl.framebufferTexture2D(36160,36064,3553,this.texture,0);
}
this.initDepthStencilBuffer(this.depthStencilFormat);
if(kSystemImpl.gl.checkFramebufferStatus(36160) != 36053) {
haxe_Log.trace("WebGL error: Framebuffer incomplete",{ fileName : "WebGLImage.x", lineNumber : 206, className : "kha.WebGLImage", methodName : "createTexture"});
}
kSystemImpl.gl.bindRenderbuffer(36161,null);
kSystemImpl.gl.bindFramebuffer(36160,null);
} else if(this.video != null) {
kSystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.video);
} else {
var _g1 = this.format;
switch(_g1[1]) {
case 0:
if(jsBoot.__instanceof(this.image,Uint8Array)) {
kSystemImpl.gl.texImage2D(3553,0,6408,this.myWidth,this.myHeight,0,6408,5121,this.image);
} else {
kSystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.image);
}
break;
case 2:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 34836 : 6408,this.myWidth,this.myHeight,0,6408,5126,this.image);
break;
case 4:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 34842 : 6408,this.myWidth,this.myHeight,0,6408,kSystemImpl.halfFloat.HALF_FLOAT_OES,this.image);
break;
case 5:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33326 : 6406,this.myWidth,this.myHeight,0,kSystemImpl.gl2 ? 6403 : 6406,5126,this.image);
break;
case 6:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33325 : 6406,this.myWidth,this.myHeight,0,kSystemImpl.gl2 ? 6403 : 6406,kSystemImpl.halfFloat.HALF_FLOAT_OES,this.image);
break;
default:
kSystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.image);
}
}
kSystemImpl.gl.bindTexture(3553,null);
}
,initDepthStencilBuffer: function(depthStencilFormat) {
switch(depthStencilFormat) {
case 0:
break;
case 1:case 5:
if(kSystemImpl.depthTexture == null) {
this.renderBuffer = kSystemImpl.gl.createRenderbuffer();
kSystemImpl.gl.bindRenderbuffer(36161,this.renderBuffer);
kSystemImpl.gl.renderbufferStorage(36161,33189,this.get_realWidth(),this.get_realHeight());
kSystemImpl.gl.framebufferRenderbuffer(36160,36096,36161,this.renderBuffer);
} else {
this.depthTexture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(3553,this.depthTexture);
if(depthStencilFormat == 1) {
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33190 : 6402,this.get_realWidth(),this.get_realHeight(),0,6402,5125,null);
} else {
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33189 : 6402,this.get_realWidth(),this.get_realHeight(),0,6402,5123,null);
}
kSystemImpl.gl.texParameteri(3553,10240,9728);
kSystemImpl.gl.texParameteri(3553,10241,9728);
kSystemImpl.gl.texParameteri(3553,10242,33071);
kSystemImpl.gl.texParameteri(3553,10243,33071);
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
kSystemImpl.gl.framebufferTexture2D(36160,36096,3553,this.depthTexture,0);
}
break;
case 2:case 3:case 4:
if(kSystemImpl.depthTexture == null) {
this.renderBuffer = kSystemImpl.gl.createRenderbuffer();
kSystemImpl.gl.bindRenderbuffer(36161,this.renderBuffer);
kSystemImpl.gl.renderbufferStorage(36161,34041,this.get_realWidth(),this.get_realHeight());
kSystemImpl.gl.framebufferRenderbuffer(36160,33306,36161,this.renderBuffer);
} else {
this.depthTexture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(3553,this.depthTexture);
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 35056 : 34041,this.get_realWidth(),this.get_realHeight(),0,34041,kSystemImpl.depthTexture.UNSIGNED_INT_24_8_WEBGL,null);
kSystemImpl.gl.texParameteri(3553,10240,9728);
kSystemImpl.gl.texParameteri(3553,10241,9728);
kSystemImpl.gl.texParameteri(3553,10242,33071);
kSystemImpl.gl.texParameteri(3553,10243,33071);
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
kSystemImpl.gl.framebufferTexture2D(36160,33306,3553,this.depthTexture,0);
}
break;
}
}
,set: function(stage) {
kSystemImpl.gl.activeTexture(33984 + stage);
kSystemImpl.gl.bindTexture(3553,this.texture);
if(this.video != null) {
kSystemImpl.gl.texImage2D(3553,0,6408,6408,5121,this.video);
}
}
,setDepth: function(stage) {
kSystemImpl.gl.activeTexture(33984 + stage);
kSystemImpl.gl.bindTexture(3553,this.depthTexture);
}
,setDepthStencilFrom: function(image) {
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
kSystemImpl.gl.framebufferTexture2D(36160,36096,3553,(jsBoot.__cast(image , kWebGLImage)).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(kWebGLImage.formatByteSize(this.format) * this.get_width() * this.get_height()));
return this.bytes;
}
,unlock: function() {
if(kSystemImpl.gl != null) {
this.texture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(3553,this.texture);
kSystemImpl.gl.texParameteri(3553,10240,9729);
kSystemImpl.gl.texParameteri(3553,10241,9729);
kSystemImpl.gl.texParameteri(3553,10242,33071);
kSystemImpl.gl.texParameteri(3553,10243,33071);
var _g = this.format;
switch(_g[1]) {
case 0:
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,this.bytesToArray(this.bytes));
break;
case 1:
kSystemImpl.gl.texImage2D(3553,0,6409,this.get_width(),this.get_height(),0,6409,5121,this.bytesToArray(this.bytes));
if(kSystemImpl.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;
}
}
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,this.bytesToArray(rgbaBytes));
}
break;
case 2:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 34836 : 6408,this.get_width(),this.get_height(),0,6408,5126,this.bytesToArray(this.bytes));
break;
case 4:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 34842 : 6408,this.get_width(),this.get_height(),0,6408,kSystemImpl.halfFloat.HALF_FLOAT_OES,this.bytesToArray(this.bytes));
break;
case 5:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33326 : 6406,this.get_width(),this.get_height(),0,kSystemImpl.gl2 ? 6403 : 6406,5126,this.bytesToArray(this.bytes));
break;
case 6:
kSystemImpl.gl.texImage2D(3553,0,kSystemImpl.gl2 ? 33325 : 6406,this.get_width(),this.get_height(),0,kSystemImpl.gl2 ? 6403 : 6406,kSystemImpl.halfFloat.HALF_FLOAT_OES,this.bytesToArray(this.bytes));
break;
default:
kSystemImpl.gl.texImage2D(3553,0,6408,this.get_width(),this.get_height(),0,6408,5121,this.bytesToArray(this.bytes));
}
kSystemImpl.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(kWebGLImage.formatByteSize(this.format) * this.get_width() * this.get_height());
}
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
kSystemImpl.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) {
kSystemImpl.gl.deleteTexture(this.texture);
}
if(this.depthTexture != null) {
kSystemImpl.gl.deleteTexture(this.depthTexture);
}
if(this.frameBuffer != null) {
kSystemImpl.gl.deleteFramebuffer(this.frameBuffer);
}
if(this.renderBuffer != null) {
kSystemImpl.gl.deleteRenderbuffer(this.renderBuffer);
}
}
,generateMipmaps: function(levels) {
kSystemImpl.gl.bindTexture(3553,this.texture);
kSystemImpl.gl.generateMipmap(3553);
}
,setMipmaps: function(mipmaps) {
kSystemImpl.gl.bindTexture(3553,this.texture);
if(this.format == kgraphics4_TextureFormat.RGBA128) {
var _g1 = 0;
var _g = mipmaps.length;
while(_g1 < _g) {
var i = _g1++;
kSystemImpl.gl.texImage2D(3553,i + 1,kSystemImpl.gl2 ? 34836 : 6408,mipmaps[i].get_width(),mipmaps[i].get_height(),0,6408,5126,(jsBoot.__cast(mipmaps[i] , kWebGLImage)).image);
}
} else if(this.format == kgraphics4_TextureFormat.RGBA64) {
var _g11 = 0;
var _g2 = mipmaps.length;
while(_g11 < _g2) {
var i1 = _g11++;
kSystemImpl.gl.texImage2D(3553,i1 + 1,kSystemImpl.gl2 ? 34842 : 6408,mipmaps[i1].get_width(),mipmaps[i1].get_height(),0,6408,kSystemImpl.halfFloat.HALF_FLOAT_OES,(jsBoot.__cast(mipmaps[i1] , kWebGLImage)).image);
}
} else {
var _g12 = 0;
var _g3 = mipmaps.length;
while(_g12 < _g3) {
var i2 = _g12++;
kSystemImpl.gl.texImage2D(3553,i2 + 1,6408,6408,5121,(jsBoot.__cast(mipmaps[i2] , kWebGLImage)).image);
}
}
}
,__class__: kWebGLImage
});
var kWindowMode = xClasses["kha.WindowMode"] = { __ename__ : true, __constructs__ : ["Window","BorderlessWindow","Fullscreen"] };
kWindowMode.Window = ["Window",0];
kWindowMode.Window.toString = $estr;
kWindowMode.Window.__enum__ = kWindowMode;
kWindowMode.BorderlessWindow = ["BorderlessWindow",1];
kWindowMode.BorderlessWindow.toString = $estr;
kWindowMode.BorderlessWindow.__enum__ = kWindowMode;
kWindowMode.Fullscreen = ["Fullscreen",2];
kWindowMode.Fullscreen.toString = $estr;
kWindowMode.Fullscreen.__enum__ = kWindowMode;
var kPosition = xClasses["kha.Position"] = { __ename__ : true, __constructs__ : ["Center","Fixed"] };
kPosition.Center = ["Center",0];
kPosition.Center.toString = $estr;
kPosition.Center.__enum__ = kPosition;
kPosition.Fixed = function(v) { var $x = ["Fixed",1,v]; $x.__enum__ = kPosition; $x.toString = $estr; return $x; };
var kTargetDisplay = xClasses["kha.TargetDisplay"] = { __ename__ : true, __constructs__ : ["Primary","ById"] };
kTargetDisplay.Primary = ["Primary",0];
kTargetDisplay.Primary.toString = $estr;
kTargetDisplay.Primary.__enum__ = kTargetDisplay;
kTargetDisplay.ById = function(id) { var $x = ["ById",1,id]; $x.__enum__ = kTargetDisplay; $x.toString = $estr; return $x; };
var kRendererOptions = function(textureFormat,depthStencilFormat,samplesPerPixel) {
this.textureFormat = textureFormat;
this.depthStencilFormat = depthStencilFormat;
this.samplesPerPixel = samplesPerPixel;
};
xClasses["kha.RendererOptions"] = kRendererOptions;
kRendererOptions.nom = true;
kRendererOptions.prototype = {
textureFormat: null
,depthStencilFormat: null
,samplesPerPixel: null
,__class__: kRendererOptions
};
var kWindowedModeOptions = function(minimizable,maximizable,resizable) {
this.minimizable = minimizable;
this.maximizable = maximizable;
this.resizable = resizable;
};
xClasses["kha.WindowedModeOptions"] = kWindowedModeOptions;
kWindowedModeOptions.nom = true;
kWindowedModeOptions.prototype = {
minimizable: null
,maximizable: null
,resizable: null
,__class__: kWindowedModeOptions
};
var kWindowOptions = 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;
};
xClasses["kha.WindowOptions"] = kWindowOptions;
kWindowOptions.nom = true;
kWindowOptions.prototype = {
width: null
,height: null
,mode: null
,title: null
,x: null
,y: null
,targetDisplay: null
,rendererOptions: null
,windowedModeOptions: null
,__class__: kWindowOptions
};
var karrays_xFloat32Array_Float32ArrayxImplx = {};
xClasses["kha.arrays._Float32Array.Float32Array_Impl_"] = karrays_xFloat32Array_Float32ArrayxImplx;
karrays_xFloat32Array_Float32ArrayxImplx.nom = true;
karrays_xFloat32Array_Float32ArrayxImplx._new = function(elements) {
var this1 = new Float32Array(elements);
return this1;
};
karrays_xFloat32Array_Float32ArrayxImplx.get_length = function(this1) {
return this1.length;
};
karrays_xFloat32Array_Float32ArrayxImplx.set = function(this1,index,value) {
return this1[index] = value;
};
karrays_xFloat32Array_Float32ArrayxImplx.get = function(this1,index) {
return this1[index];
};
karrays_xFloat32Array_Float32ArrayxImplx.data = function(this1) {
return this1;
};
karrays_xFloat32Array_Float32ArrayxImplx.arrayRead = function(this1,index) {
return this1[index];
};
karrays_xFloat32Array_Float32ArrayxImplx.arrayWrite = function(this1,index,value) {
return this1[index] = value;
};
karrays_xFloat32Array_Float32ArrayxImplx.subarray = function(this1,start,end) {
return this1.subarray(start,end);
};
var karrays_xUint32Array_Uint32ArrayxImplx = {};
xClasses["kha.arrays._Uint32Array.Uint32Array_Impl_"] = karrays_xUint32Array_Uint32ArrayxImplx;
karrays_xUint32Array_Uint32ArrayxImplx.nom = true;
karrays_xUint32Array_Uint32ArrayxImplx._new = function(elements) {
var this1 = new Uint32Array(elements);
return this1;
};
karrays_xUint32Array_Uint32ArrayxImplx.get_length = function(this1) {
return this1.length;
};
karrays_xUint32Array_Uint32ArrayxImplx.set = function(this1,index,value) {
return this1[index] = value;
};
karrays_xUint32Array_Uint32ArrayxImplx.get = function(this1,index) {
return this1[index];
};
karrays_xUint32Array_Uint32ArrayxImplx.data = function(this1) {
return this1;
};
karrays_xUint32Array_Uint32ArrayxImplx.arrayRead = function(this1,index) {
return this1[index];
};
karrays_xUint32Array_Uint32ArrayxImplx.arrayWrite = function(this1,index,value) {
return this1[index] = value;
};
karrays_xUint32Array_Uint32ArrayxImplx.subarray = function(this1,start,end) {
return this1.subarray(start,end);
};
var kaudio1_AudioChannel = function() { };
xClasses["kha.audio1.AudioChannel"] = kaudio1_AudioChannel;
kaudio1_AudioChannel.nom = true;
kaudio1_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__: kaudio1_AudioChannel
};
var kaudio2_Audio = function() { };
xClasses["kha.audio2.Audio"] = kaudio2_Audio;
kaudio2_Audio.nom = true;
kaudio2_Audio.initContext = function() {
try {
kaudio2_Audio._context = new AudioContext();
return;
} catch( e ) {
}
try {
this._context = new webkitAudioContext();
return;
} catch( e1 ) {
}
};
kaudio2_Audio._init = function() {
kaudio2_Audio.initContext();
if(kaudio2_Audio._context == null) {
return false;
}
var bufferSize = 2048;
kaudio2_Audio.buffer = new kaudio2_Buffer(bufferSize * 4,2,kaudio2_Audio._context.sampleRate | 0);
kaudio2_Audio.processingNode = kaudio2_Audio._context.createScriptProcessor(bufferSize,0,2);
kaudio2_Audio.processingNode.onaudioprocess = function(e) {
var output1 = e.outputBuffer.getChannelData(0);
var output2 = e.outputBuffer.getChannelData(1);
if(kaudio2_Audio.audioCallback != null) {
kaudio2_Audio.audioCallback(e.outputBuffer.length * 2,kaudio2_Audio.buffer);
var _g1 = 0;
var _g = e.outputBuffer.length;
while(_g1 < _g) {
var i = _g1++;
output1[i] = kaudio2_Audio.buffer.data[kaudio2_Audio.buffer.readLocation];
kaudio2_Audio.buffer.readLocation += 1;
output2[i] = kaudio2_Audio.buffer.data[kaudio2_Audio.buffer.readLocation];
kaudio2_Audio.buffer.readLocation += 1;
if(kaudio2_Audio.buffer.readLocation >= kaudio2_Audio.buffer.size) {
kaudio2_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;
}
}
};
kaudio2_Audio.processingNode.connect(kaudio2_Audio._context.destination);
return true;
};
kaudio2_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 kjsAEAudioChannel(element);
channel.play();
return channel;
};
var kaudio2_Audio1 = function() { };
xClasses["kha.audio2.Audio1"] = kaudio2_Audio1;
kaudio2_Audio1.nom = true;
kaudio2_Audio1._init = function() {
var this1 = new Array(16);
kaudio2_Audio1.soundChannels = this1;
var this2 = new Array(16);
kaudio2_Audio1.streamChannels = this2;
var this3 = new Array(16);
kaudio2_Audio1.internalSoundChannels = this3;
var this4 = new Array(16);
kaudio2_Audio1.internalStreamChannels = this4;
var this5 = new Array(512);
kaudio2_Audio1.sampleCache1 = this5;
var this6 = new Array(512);
kaudio2_Audio1.sampleCache2 = this6;
kaudio2_Audio.audioCallback = kaudio2_Audio1.mix;
};
kaudio2_Audio1.max = function(a,b) {
if(a > b) {
return a;
} else {
return b;
}
};
kaudio2_Audio1.min = function(a,b) {
if(a < b) {
return a;
} else {
return b;
}
};
kaudio2_Audio1.mix = function(samples,buffer) {
if(kaudio2_Audio1.sampleCache1.length < samples) {
var this1 = new Array(samples);
kaudio2_Audio1.sampleCache1 = this1;
var this2 = new Array(samples);
kaudio2_Audio1.sampleCache2 = this2;
}
var _g1 = 0;
var _g = samples;
while(_g1 < _g) {
var i = _g1++;
kaudio2_Audio1.sampleCache2[i] = 0;
}
var _g2 = 0;
while(_g2 < 16) {
var i1 = _g2++;
kaudio2_Audio1.internalSoundChannels[i1] = kaudio2_Audio1.soundChannels[i1];
}
var _g3 = 0;
while(_g3 < 16) {
var i2 = _g3++;
kaudio2_Audio1.internalStreamChannels[i2] = kaudio2_Audio1.streamChannels[i2];
}
var _g4 = 0;
var _g11 = kaudio2_Audio1.internalSoundChannels;
while(_g4 < _g11.length) {
var channel = _g11[_g4];
++_g4;
if(channel == null || channel.get_finished()) {
continue;
}
channel.nextSamples(kaudio2_Audio1.sampleCache1,samples,buffer.samplesPerSecond);
var _g31 = 0;
var _g21 = samples;
while(_g31 < _g21) {
var i3 = _g31++;
var _g41 = i3;
var _g5 = kaudio2_Audio1.sampleCache2;
var val = kaudio2_Audio1.sampleCache1[i3] * channel.get_volume();
_g5[_g41] = _g5[_g41] + val;
}
}
var _g6 = 0;
var _g12 = kaudio2_Audio1.internalStreamChannels;
while(_g6 < _g12.length) {
var channel1 = _g12[_g6];
++_g6;
if(channel1 == null || channel1.get_finished()) {
continue;
}
channel1.nextSamples(kaudio2_Audio1.sampleCache1,samples,buffer.samplesPerSecond);
var _g32 = 0;
var _g22 = samples;
while(_g32 < _g22) {
var i4 = _g32++;
var _g42 = i4;
var _g51 = kaudio2_Audio1.sampleCache2;
var val1 = kaudio2_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 = kaudio2_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;
}
}
};
kaudio2_Audio1.play = function(sound,loop) {
if(loop == null) {
loop = false;
}
var channel = null;
var _g = 0;
while(_g < 16) {
var i = _g++;
if(kaudio2_Audio1.soundChannels[i] == null || kaudio2_Audio1.soundChannels[i].get_finished()) {
channel = new kaudio2_AudioChannel(loop);
channel.data = sound.uncompressedData;
kaudio2_Audio1.soundChannels[i] = channel;
break;
}
}
return channel;
};
kaudio2_Audio1._playAgain = function(channel) {
var _g = 0;
while(_g < 16) {
var i = _g++;
if(kaudio2_Audio1.soundChannels[i] == null || kaudio2_Audio1.soundChannels[i].get_finished() || kaudio2_Audio1.soundChannels[i] == channel) {
kaudio2_Audio1.soundChannels[i] = channel;
break;
}
}
};
kaudio2_Audio1.stream = function(sound,loop) {
if(loop == null) {
loop = false;
}
var hardwareChannel = kaudio2_Audio.stream(sound,loop);
if(hardwareChannel != null) {
return hardwareChannel;
}
var channel = null;
var _g = 0;
while(_g < 16) {
var i = _g++;
if(kaudio2_Audio1.streamChannels[i] == null || kaudio2_Audio1.streamChannels[i].get_finished()) {
channel = new kaudio2_StreamChannel(sound.compressedData,loop);
kaudio2_Audio1.streamChannels[i] = channel;
break;
}
}
return channel;
};
var kaudio2_AudioChannel = function(looping) {
this.paused = false;
this.looping = looping;
this.myVolume = 1;
this.myPosition = 0;
};
xClasses["kha.audio2.AudioChannel"] = kaudio2_AudioChannel;
kaudio2_AudioChannel.nom = true;
kaudio2_AudioChannel.__interfaces__ = [kaudio1_AudioChannel];
kaudio2_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 w_ptr = 0;
var chk_ptr = 0;
while(w_ptr < length) {
var addressable_data = this.data.length - this.myPosition;
var next_chunk = addressable_data < length ? addressable_data : length;
while(chk_ptr < next_chunk) {
samples[w_ptr] = this.data[this.myPosition];
++this.myPosition;
++chk_ptr;
++w_ptr;
}
if(!this.looping) {
break;
} else {
chk_ptr = 0;
if(this.myPosition >= this.data.length) {
this.myPosition = 0;
}
}
}
while(w_ptr < length) {
samples[w_ptr] = 0;
++w_ptr;
}
}
,play: function() {
this.paused = false;
if(this.get_finished()) {
this.myPosition = 0;
kaudio2_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__: kaudio2_AudioChannel
};
var kaudio2_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;
};
xClasses["kha.audio2.Buffer"] = kaudio2_Buffer;
kaudio2_Buffer.nom = true;
kaudio2_Buffer.prototype = {
channels: null
,samplesPerSecond: null
,data: null
,size: null
,readLocation: null
,writeLocation: null
,__class__: kaudio2_Buffer
};
var kaudio2_StreamChannel = function(data,loop) {
this.paused = false;
this.atend = false;
this.myVolume = 1;
this.loop = loop;
this.reader = kaudio2_ogg_vorbis_Reader.openFromBytes(data);
};
xClasses["kha.audio2.StreamChannel"] = kaudio2_StreamChannel;
kaudio2_StreamChannel.nom = true;
kaudio2_StreamChannel.__interfaces__ = [kaudio1_AudioChannel];
kaudio2_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__: kaudio2_StreamChannel
};
var kaudio2_ogg_tools_Crc32 = function() { };
xClasses["kha.audio2.ogg.tools.Crc32"] = kaudio2_ogg_tools_Crc32;
kaudio2_ogg_tools_Crc32.nom = true;
kaudio2_ogg_tools_Crc32.init = function() {
if(kaudio2_ogg_tools_Crc32.table != null) {
return;
}
var this1 = new Array(256);
kaudio2_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 ^ (xUInt_UIntxImplx.gte(s,1 << 31) ? 79764919 : 0);
}
kaudio2_ogg_tools_Crc32.table[i] = s;
}
};
kaudio2_ogg_tools_Crc32.update = function(crc,$byte) {
return crc << 8 ^ kaudio2_ogg_tools_Crc32.table[$byte ^ crc >>> 24];
};
var kaudio2_ogg_tools_MathTools = function() { };
xClasses["kha.audio2.ogg.tools.MathTools"] = kaudio2_ogg_tools_MathTools;
kaudio2_ogg_tools_MathTools.nom = true;
kaudio2_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 kaudio2_ogg_tools_Mdct = function() { };
xClasses["kha.audio2.ogg.tools.Mdct"] = kaudio2_ogg_tools_Mdct;
kaudio2_ogg_tools_Mdct.nom = true;
kaudio2_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;
}
};
kaudio2_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;
}
};
kaudio2_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;
}
};
kaudio2_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;
}
};
kaudio2_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;
};
kaudio2_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 kaudio2_ogg_vorbis_Reader = function(input,seekFunc,inputLength) {
this.seekFunc = seekFunc;
this.inputLength = inputLength;
this.decoder = kaudio2_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();
};
xClasses["kha.audio2.ogg.vorbis.Reader"] = kaudio2_ogg_vorbis_Reader;
kaudio2_ogg_vorbis_Reader.nom = true;
kaudio2_ogg_vorbis_Reader.openFromBytes = function(bytes) {
var input = new haxe_io_BytesInput(bytes);
var a1 = input;
return new kaudio2_ogg_vorbis_Reader(input,function(a2) {
kaudio2_ogg_vorbis_Reader.seekBytes(a1,a2);
},bytes.length);
};
kaudio2_ogg_vorbis_Reader.seekBytes = function(bytes,pos) {
bytes.set_position(pos);
};
kaudio2_ogg_vorbis_Reader.readAll = function(bytes,output,useFloat) {
if(useFloat == null) {
useFloat = false;
}
var input = new haxe_io_BytesInput(bytes);
var decoder = kaudio2_ogg_vorbis_VorbisDecoder.start(input);
var a1 = input;
decoder.setupSampleNumber(function(a2) {
kaudio2_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;
};
kaudio2_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 xUInt_UIntxImplx.toFloat(samples) / xUInt_UIntxImplx.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 xUInt_UIntxImplx.toFloat(samples) / xUInt_UIntxImplx.toFloat(b) * 1000;
}
,set_currentMillisecond: function(value) {
var _g = value / 1000;
var _g1 = this.get_header().sampleRate;
this.set_currentSample(Math.floor(xUInt_UIntxImplx.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(kaudio2_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 xUInt_UIntxImplx.toFloat(samples) / xUInt_UIntxImplx.toFloat(b) * 1000;
}
,millisecondToSample: function(millseconds) {
var _g = millseconds / 1000;
var _g1 = this.get_header().sampleRate;
return Math.floor(xUInt_UIntxImplx.toFloat(_g1) * _g);
}
,__class__: kaudio2_ogg_vorbis_Reader
};
var kaudio2_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 kaudio2_ogg_vorbis_data_Page();
kaudio2_ogg_tools_Crc32.init();
};
xClasses["kha.audio2.ogg.vorbis.VorbisDecodeState"] = kaudio2_ogg_vorbis_VorbisDecodeState;
kaudio2_ogg_vorbis_VorbisDecodeState.nom = true;
kaudio2_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 kaudio2_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(kaudio2_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 jsxBoot_HaxeError) e = e.val;
if( jsBoot.__instanceof(e,kaudio2_ogg_vorbis_data_ReaderError) ) {
this.lastSeg = true;
this.error = e;
return 0;
} else throw(e);
}
if((this.page.flag & 1) == 0) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID,null,{ fileName : "VorbisDecodeState.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.x", 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 jsxBoot_HaxeError) e = e.val;
if( jsBoot.__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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"vorbis header",{ fileName : "VorbisDecodeState.x", lineNumber : 300, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "vorbisValidate"}));
}
}
,firstPageValidate: function() {
if(this.segments.length != 1) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"segmentCount",{ fileName : "VorbisDecodeState.x", lineNumber : 307, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "firstPageValidate"}));
}
if(this.segments[0] != 30) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"decodeState head",{ fileName : "VorbisDecodeState.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.x", 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 = xUInt_UIntxImplx.gte(inputLength,65536) && xUInt_UIntxImplx.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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE,null,{ fileName : "VorbisDecodeState.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE,null,{ fileName : "VorbisDecodeState.x", lineNumber : 552, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "getSampleNumber"}));
}
this.pLast = new kaudio2_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 kaudio2_ogg_vorbis_xVorbisDecodeState_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 ^ kaudio2_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 ^ kaudio2_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 ^ kaudio2_ogg_tools_Crc32.table[$byte ^ crc >>> 24];
}
} catch( e ) {
if (e instanceof jsxBoot_HaxeError) e = e.val;
if( jsBoot.__instanceof(e,haxe_io_Eof) ) {
return kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult.NotFound;
} else throw(e);
}
if(crc == goal) {
var end = this.inputPosition;
seekFunc(this.inputPosition = retryLoc - 1);
return kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult.Found(end,(header[5] & 4) != 0);
}
}
}
} catch( e1 ) {
if (e1 instanceof jsxBoot_HaxeError) e1 = e1.val;
if( jsBoot.__instanceof(e1,haxe_io_Eof) ) {
return kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult.NotFound;
} else throw(e1);
}
}
,analyzePage: function(seekFunc,h) {
var z = new kaudio2_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(xUInt_UIntxImplx.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 kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "VorbisDecodeState.x", lineNumber : 846, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "decodeScalarRaw"});
this.validBits = 0;
return -1;
}
,__class__: kaudio2_ogg_vorbis_VorbisDecodeState
};
var kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult = xClasses["kha.audio2.ogg.vorbis._VorbisDecodeState.FindPageResult"] = { __ename__ : true, __constructs__ : ["Found","NotFound"] };
kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult.Found = function(end,last) { var $x = ["Found",0,end,last]; $x.__enum__ = kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult; $x.toString = $estr; return $x; };
kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult.NotFound = ["NotFound",1];
kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult.NotFound.toString = $estr;
kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult.NotFound.__enum__ = kaudio2_ogg_vorbis_xVorbisDecodeState_FindPageResult;
var kaudio2_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);
};
xClasses["kha.audio2.ogg.vorbis.VorbisDecoder"] = kaudio2_ogg_vorbis_VorbisDecoder;
kaudio2_ogg_vorbis_VorbisDecoder.nom = true;
kaudio2_ogg_vorbis_VorbisDecoder.start = function(input) {
var decodeState = new kaudio2_ogg_vorbis_VorbisDecodeState(input);
var header = kaudio2_ogg_vorbis_data_Header.read(decodeState);
var decoder = new kaudio2_ogg_vorbis_VorbisDecoder(header,decodeState);
decodeState.startFirstDecode();
decoder.pumpFirstFrame();
return decoder;
};
kaudio2_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((xUInt_UIntxImplx.toFloat(sampleRate) % xUInt_UIntxImplx.toFloat(b) | 0) != 0) {
throw new jsxBoot_HaxeError("Unsupported sampleRate : can't convert " + Std.string(xUInt_UIntxImplx.toFloat(this.header.sampleRate)) + " to " + sampleRate);
}
if(channels % this.header.channel != 0) {
throw new jsxBoot_HaxeError("Unsupported channels : can't convert " + this.header.channel + " to " + channels);
}
var b1 = this.header.sampleRate;
var sampleRepeat = xUInt_UIntxImplx.toFloat(sampleRate) / xUInt_UIntxImplx.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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE,null,{ fileName : "VorbisDecoder.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.x", lineNumber : 219, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "seek"}));
}
if(xUInt_UIntxImplx.gt(endOffset,startOffset + 4000)) {
endOffset = endOffset - 4000;
}
var probe = startOffset + Math.floor(xUInt_UIntxImplx.toFloat(endOffset - startOffset) / xUInt_UIntxImplx.toFloat(endSample - startSample) * (sampleNumber - startSample));
if(attempts >= 4) {
var probe2 = startOffset + (endOffset - startOffset >>> 1);
if(attempts >= 8) {
probe = probe2;
} else if(xUInt_UIntxImplx.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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.x", lineNumber : 249, className : "kha.audio2.ogg.vorbis.VorbisDecoder", methodName : "seek"}));
break;
}
var q = this.decodeState.analyzePage(seekFunc,this.header);
if(q == null) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.x", 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(kaudio2_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] = kaudio2_ogg_vorbis_VorbisTools.copyVector(this.channelBuffers[i]);
decoder.previousWindow[i] = kaudio2_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;
kaudio2_ogg_vorbis_VorbisTools.computeTwiddleFactors(n,this.a[bs],this.b[bs],this.c[bs]);
kaudio2_ogg_vorbis_VorbisTools.computeWindow(n,this.window[bs]);
kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED,null,{ fileName : "VorbisDecoder.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "VorbisDecoder.x", 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__: kaudio2_ogg_vorbis_VorbisDecoder
};
var kaudio2_ogg_vorbis_VorbisTools = function() { };
xClasses["kha.audio2.ogg.vorbis.VorbisTools"] = kaudio2_ogg_vorbis_VorbisTools;
kaudio2_ogg_vorbis_VorbisTools.nom = true;
kaudio2_ogg_vorbis_VorbisTools.assert = function(b,p) {
};
kaudio2_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};
};
kaudio2_ogg_vorbis_VorbisTools.floatUnpack = function(x) {
var mantissa = xUInt_UIntxImplx.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);
};
kaudio2_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;
};
kaudio2_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;
}
};
kaudio2_ogg_vorbis_VorbisTools.uintAsc = function(a,b) {
if(xUInt_UIntxImplx.gt(b,a)) {
return -1;
} else if(a == b) {
return 0;
} else {
return 1;
}
};
kaudio2_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;
};
kaudio2_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 * kaudio2_ogg_vorbis_VorbisTools.square(Math.sin((i + 0.5) / n2 * 0.5 * 3.14159265358979323846264)));
}
};
kaudio2_ogg_vorbis_VorbisTools.square = function(f) {
return f * f;
};
kaudio2_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;
}
};
kaudio2_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;
}
};
kaudio2_ogg_vorbis_VorbisTools.drawLine = function(output,x0,y0,x1,y1,n) {
if(kaudio2_ogg_vorbis_VorbisTools.integerDivideTable == null) {
var this1 = new Array(32);
kaudio2_ogg_vorbis_VorbisTools.integerDivideTable = this1;
var _g = 0;
while(_g < 32) {
var i = _g++;
var this2 = kaudio2_ogg_vorbis_VorbisTools.integerDivideTable;
var this3 = new Array(64);
this2[i] = this3;
var _g1 = 1;
while(_g1 < 64) {
var j = _g1++;
kaudio2_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 = -kaudio2_ogg_vorbis_VorbisTools.integerDivideTable[ady][adx];
sy = base - 1;
} else {
base = kaudio2_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] * kaudio2_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] * kaudio2_ogg_vorbis_VorbisTools.INVERSE_DB_TABLE[y];
}
};
kaudio2_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;
}
};
kaudio2_ogg_vorbis_VorbisTools.emptyFloatVector = function(len) {
var this1 = new Array(len);
var vec = this1;
return vec;
};
kaudio2_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 kaudio2_ogg_vorbis_data_Codebook = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Codebook"] = kaudio2_ogg_vorbis_data_Codebook;
kaudio2_ogg_vorbis_data_Codebook.nom = true;
kaudio2_ogg_vorbis_data_Codebook.read = function(decodeState) {
var c = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Codebook.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"codebook entrys",{ fileName : "Codebook.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"compute codewords",{ fileName : "Codebook.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"codebook lookup type",{ fileName : "Codebook.x", 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 = xUInt_UIntxImplx.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 = xUInt_UIntxImplx.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 = kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"fail lookup",{ fileName : "Codebook.x", 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;
};
kaudio2_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(kaudio2_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(xUInt_UIntxImplx.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 = xUInt_UIntxImplx.toFloat(z / div | 0) % xUInt_UIntxImplx.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 = xUInt_UIntxImplx.toFloat(z / div | 0) % xUInt_UIntxImplx.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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "Codebook.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "Codebook.x", 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 = xUInt_UIntxImplx.toFloat(z / div | 0) % xUInt_UIntxImplx.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 = xUInt_UIntxImplx.toFloat(z / div | 0) % xUInt_UIntxImplx.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__: kaudio2_ogg_vorbis_data_Codebook
};
var kaudio2_ogg_vorbis_data_Comment = function() {
this.data = new haxe_ds_StringMap();
};
xClasses["kha.audio2.ogg.vorbis.data.Comment"] = kaudio2_ogg_vorbis_data_Comment;
kaudio2_ogg_vorbis_data_Comment.nom = true;
kaudio2_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__: kaudio2_ogg_vorbis_data_Comment
};
var kaudio2_ogg_vorbis_data_Floor = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Floor"] = kaudio2_ogg_vorbis_data_Floor;
kaudio2_ogg_vorbis_data_Floor.nom = true;
kaudio2_ogg_vorbis_data_Floor.read = function(decodeState,codebooks) {
var floor = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Floor.x", lineNumber : 28, className : "kha.audio2.ogg.vorbis.data.Floor", methodName : "read"}));
}
if(floor.type == 0) {
var g = floor.floor0 = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED,null,{ fileName : "Floor.x", lineNumber : 41, className : "kha.audio2.ogg.vorbis.data.Floor", methodName : "read"}));
} else {
var p = [];
var g1 = floor.floor1 = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Floor.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Floor.x", 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 kaudio2_ogg_vorbis_data_IntPoint());
p[j4].x = g1.xlist[j4];
p[j4].y = j4;
}
p.sort(kaudio2_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;
};
kaudio2_ogg_vorbis_data_Floor.prototype = {
floor0: null
,floor1: null
,type: null
,__class__: kaudio2_ogg_vorbis_data_Floor
};
var kaudio2_ogg_vorbis_data_Floor0 = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Floor0"] = kaudio2_ogg_vorbis_data_Floor0;
kaudio2_ogg_vorbis_data_Floor0.nom = true;
kaudio2_ogg_vorbis_data_Floor0.prototype = {
order: null
,rate: null
,barkMapSize: null
,amplitudeBits: null
,amplitudeOffset: null
,numberOfBooks: null
,bookList: null
,__class__: kaudio2_ogg_vorbis_data_Floor0
};
var kaudio2_ogg_vorbis_data_Floor1 = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Floor1"] = kaudio2_ogg_vorbis_data_Floor1;
kaudio2_ogg_vorbis_data_Floor1.nom = true;
kaudio2_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__: kaudio2_ogg_vorbis_data_Floor1
};
var kaudio2_ogg_vorbis_data_Header = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Header"] = kaudio2_ogg_vorbis_data_Header;
kaudio2_ogg_vorbis_data_Header.nom = true;
kaudio2_ogg_vorbis_data_Header.read = function(decodeState) {
var page = decodeState.page;
page.start(decodeState);
if((page.flag & 2) == 0) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"not firstPage",{ fileName : "Header.x", lineNumber : 46, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
}
if((page.flag & 4) != 0) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"lastPage",{ fileName : "Header.x", lineNumber : 49, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
}
if((page.flag & 1) != 0) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"continuedPacket",{ fileName : "Header.x", lineNumber : 52, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
}
decodeState.firstPageValidate();
decodeState.inputPosition += 1;
if(decodeState.input.readByte() != 1) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"decodeState head",{ fileName : "Header.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"vorbis header",{ fileName : "VorbisDecodeState.x", lineNumber : 300, className : "kha.audio2.ogg.vorbis.VorbisDecodeState", methodName : "vorbisValidate"}));
}
decodeState.inputPosition += 4;
var version = decodeState.input.readInt32();
if(version != 0) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"vorbis version : " + version,{ fileName : "Header.x", lineNumber : 66, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
}
var header1 = new kaudio2_ogg_vorbis_data_Header();
decodeState.inputPosition += 1;
header1.channel = decodeState.input.readByte();
if(header1.channel == 0) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"no channel",{ fileName : "Header.x", lineNumber : 73, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
} else if(header1.channel > 16) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS,"too many channels",{ fileName : "Header.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,"no sampling rate",{ fileName : "Header.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", lineNumber : 93, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
}
if(log1 < 6 || log1 > 13) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", lineNumber : 96, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
}
if(log0 > log1) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE,null,{ fileName : "Header.x", 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 kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"setup packet",{ fileName : "Header.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"vorbis header",{ fileName : "VorbisDecodeState.x", 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] = kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", 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] = kaudio2_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] = kaudio2_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 = kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", lineNumber : 191, className : "kha.audio2.ogg.vorbis.data.Header", methodName : "read"}));
}
if(map.submapResidue[j] >= header1.residueConfig.length) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", 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 = kaudio2_ogg_vorbis_data_Mode.read(decodeState);
header1.modes[i8] = mode;
if(mode.mapping >= header1.mapping.length) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Header.x", 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;
};
kaudio2_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__: kaudio2_ogg_vorbis_data_Header
};
var kaudio2_ogg_vorbis_data_IntPoint = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.IntPoint"] = kaudio2_ogg_vorbis_data_IntPoint;
kaudio2_ogg_vorbis_data_IntPoint.nom = true;
kaudio2_ogg_vorbis_data_IntPoint.prototype = {
x: null
,y: null
,__class__: kaudio2_ogg_vorbis_data_IntPoint
};
var kaudio2_ogg_vorbis_data_Mapping = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Mapping"] = kaudio2_ogg_vorbis_data_Mapping;
kaudio2_ogg_vorbis_data_Mapping.nom = true;
kaudio2_ogg_vorbis_data_Mapping.read = function(decodeState,channels) {
var m = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,"mapping type " + mappingType,{ fileName : "Mapping.x", 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 kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.x", lineNumber : 46, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"}));
}
if(m.chan[k].angle >= channels) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.x", lineNumber : 49, className : "kha.audio2.ogg.vorbis.data.Mapping", methodName : "read"}));
}
if(m.chan[k].magnitude == m.chan[k].angle) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mapping.x", 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;
};
kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM,null,{ fileName : "Mapping.x", 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 x = g.xlist[j];
kaudio2_ogg_vorbis_VorbisTools.drawLine(target,lx,ly,x,hy,n2);
lx = x;
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] * kaudio2_ogg_vorbis_VorbisTools.INVERSE_DB_TABLE[ly];
}
}
}
}
,__class__: kaudio2_ogg_vorbis_data_Mapping
};
var kaudio2_ogg_vorbis_data_MappingChannel = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.MappingChannel"] = kaudio2_ogg_vorbis_data_MappingChannel;
kaudio2_ogg_vorbis_data_MappingChannel.nom = true;
kaudio2_ogg_vorbis_data_MappingChannel.prototype = {
magnitude: null
,angle: null
,mux: null
,__class__: kaudio2_ogg_vorbis_data_MappingChannel
};
var kaudio2_ogg_vorbis_data_Mode = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Mode"] = kaudio2_ogg_vorbis_data_Mode;
kaudio2_ogg_vorbis_data_Mode.nom = true;
kaudio2_ogg_vorbis_data_Mode.read = function(decodeState) {
var m = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mode.x", lineNumber : 22, className : "kha.audio2.ogg.vorbis.data.Mode", methodName : "read"}));
}
if(m.transformtype != 0) {
throw new jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Mode.x", lineNumber : 25, className : "kha.audio2.ogg.vorbis.data.Mode", methodName : "read"}));
}
return m;
};
kaudio2_ogg_vorbis_data_Mode.prototype = {
blockflag: null
,mapping: null
,windowtype: null
,transformtype: null
,__class__: kaudio2_ogg_vorbis_data_Mode
};
var kaudio2_ogg_vorbis_data_Page = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Page"] = kaudio2_ogg_vorbis_data_Page;
kaudio2_ogg_vorbis_data_Page.nom = true;
kaudio2_ogg_vorbis_data_Page.prototype = {
flag: null
,clone: function() {
var page = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN,null,{ fileName : "VorbisDecodeState.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION,"" + version,{ fileName : "Page.x", 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__: kaudio2_ogg_vorbis_data_Page
};
var kaudio2_ogg_vorbis_data_PageFlag = function() { };
xClasses["kha.audio2.ogg.vorbis.data.PageFlag"] = kaudio2_ogg_vorbis_data_PageFlag;
kaudio2_ogg_vorbis_data_PageFlag.nom = true;
var kaudio2_ogg_vorbis_data_ProbedPage = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.ProbedPage"] = kaudio2_ogg_vorbis_data_ProbedPage;
kaudio2_ogg_vorbis_data_ProbedPage.nom = true;
kaudio2_ogg_vorbis_data_ProbedPage.prototype = {
pageStart: null
,pageEnd: null
,afterPreviousPageStart: null
,firstDecodedSample: null
,lastDecodedSample: null
,__class__: kaudio2_ogg_vorbis_data_ProbedPage
};
var kaudio2_ogg_vorbis_data_ReaderError = function(type,message,posInfos) {
if(message == null) {
message = "";
}
this.type = type;
this.message = message;
this.posInfos = posInfos;
};
xClasses["kha.audio2.ogg.vorbis.data.ReaderError"] = kaudio2_ogg_vorbis_data_ReaderError;
kaudio2_ogg_vorbis_data_ReaderError.nom = true;
kaudio2_ogg_vorbis_data_ReaderError.prototype = {
type: null
,message: null
,posInfos: null
,__class__: kaudio2_ogg_vorbis_data_ReaderError
};
var kaudio2_ogg_vorbis_data_ReaderErrorType = xClasses["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"] };
kaudio2_ogg_vorbis_data_ReaderErrorType.NEED_MORE_DATA = ["NEED_MORE_DATA",0];
kaudio2_ogg_vorbis_data_ReaderErrorType.NEED_MORE_DATA.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.NEED_MORE_DATA.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_API_MIXING = ["INVALID_API_MIXING",1];
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_API_MIXING.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_API_MIXING.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.OUTOFMEM = ["OUTOFMEM",2];
kaudio2_ogg_vorbis_data_ReaderErrorType.OUTOFMEM.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.OUTOFMEM.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED = ["FEATURE_NOT_SUPPORTED",3];
kaudio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.FEATURE_NOT_SUPPORTED.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS = ["TOO_MANY_CHANNELS",4];
kaudio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.TOO_MANY_CHANNELS.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.FILE_OPEN_FAILURE = ["FILE_OPEN_FAILURE",5];
kaudio2_ogg_vorbis_data_ReaderErrorType.FILE_OPEN_FAILURE.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.FILE_OPEN_FAILURE.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_WITHOUT_LENGTH = ["SEEK_WITHOUT_LENGTH",6];
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_WITHOUT_LENGTH.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_WITHOUT_LENGTH.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.UNEXPECTED_EOF = ["UNEXPECTED_EOF",7];
kaudio2_ogg_vorbis_data_ReaderErrorType.UNEXPECTED_EOF.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.UNEXPECTED_EOF.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_INVALID = ["SEEK_INVALID",8];
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_INVALID.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_INVALID.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP = ["INVALID_SETUP",9];
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM = ["INVALID_STREAM",10];
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN = ["MISSING_CAPTURE_PATTERN",11];
kaudio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.MISSING_CAPTURE_PATTERN.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION = ["INVALID_STREAM_STRUCTURE_VERSION",12];
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_STREAM_STRUCTURE_VERSION.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID = ["CONTINUED_PACKET_FLAG_INVALID",13];
kaudio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.CONTINUED_PACKET_FLAG_INVALID.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.INCORRECT_STREAM_SERIAL_NUMBER = ["INCORRECT_STREAM_SERIAL_NUMBER",14];
kaudio2_ogg_vorbis_data_ReaderErrorType.INCORRECT_STREAM_SERIAL_NUMBER.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.INCORRECT_STREAM_SERIAL_NUMBER.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE = ["INVALID_FIRST_PAGE",15];
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_FIRST_PAGE.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.BAD_PACKET_TYPE = ["BAD_PACKET_TYPE",16];
kaudio2_ogg_vorbis_data_ReaderErrorType.BAD_PACKET_TYPE.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.BAD_PACKET_TYPE.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE = ["CANT_FIND_LAST_PAGE",17];
kaudio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.CANT_FIND_LAST_PAGE.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED = ["SEEK_FAILED",18];
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.SEEK_FAILED.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
kaudio2_ogg_vorbis_data_ReaderErrorType.OTHER = ["OTHER",19];
kaudio2_ogg_vorbis_data_ReaderErrorType.OTHER.toString = $estr;
kaudio2_ogg_vorbis_data_ReaderErrorType.OTHER.__enum__ = kaudio2_ogg_vorbis_data_ReaderErrorType;
var kaudio2_ogg_vorbis_data_Residue = function() {
};
xClasses["kha.audio2.ogg.vorbis.data.Residue"] = kaudio2_ogg_vorbis_data_Residue;
kaudio2_ogg_vorbis_data_Residue.nom = true;
kaudio2_ogg_vorbis_data_Residue.read = function(decodeState,codebooks) {
var r = new kaudio2_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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Residue.x", 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 jsxBoot_HaxeError(new kaudio2_ogg_vorbis_data_ReaderError(kaudio2_ogg_vorbis_data_ReaderErrorType.INVALID_SETUP,null,{ fileName : "Residue.x", 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;
};
kaudio2_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 = xUInt_UIntxImplx.toFloat(nRead) / xUInt_UIntxImplx.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 = xUInt_UIntxImplx.toFloat(z4) % xUInt_UIntxImplx.toFloat(ch) | 0;
var pInter2 = xUInt_UIntxImplx.toFloat(z4) / xUInt_UIntxImplx.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 = xUInt_UIntxImplx.toFloat(z5) % xUInt_UIntxImplx.toFloat(ch) | 0;
pInter2 = xUInt_UIntxImplx.toFloat(z5) / xUInt_UIntxImplx.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__: kaudio2_ogg_vorbis_data_Residue
};
var kaudio2_ogg_vorbis_data_Setting = function() { };
xClasses["kha.audio2.ogg.vorbis.data.Setting"] = kaudio2_ogg_vorbis_data_Setting;
kaudio2_ogg_vorbis_data_Setting.nom = true;
var kgraphics1_Graphics = function() { };
xClasses["kha.graphics1.Graphics"] = kgraphics1_Graphics;
kgraphics1_Graphics.nom = true;
kgraphics1_Graphics.prototype = {
begin: null
,end: null
,setPixel: null
,__class__: kgraphics1_Graphics
};
var kgraphics2_Graphics = function() {
this.transformations = [];
this.transformations.push(new kmath_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;
};
xClasses["kha.graphics2.Graphics"] = kgraphics2_Graphics;
kgraphics2_Graphics.nom = true;
kgraphics2_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 kgraphics2_ImageScaleQuality.Low;
}
,set_imageScaleQuality: function(value) {
return kgraphics2_ImageScaleQuality.High;
}
,get_mipmapScaleQuality: function() {
return kgraphics2_ImageScaleQuality.Low;
}
,set_mipmapScaleQuality: function(value) {
return kgraphics2_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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__: kgraphics2_Graphics
};
var kgraphics2_Graphics1 = function(canvas) {
this.canvas = canvas;
};
xClasses["kha.graphics2.Graphics1"] = kgraphics2_Graphics1;
kgraphics2_Graphics1.nom = true;
kgraphics2_Graphics1.__interfaces__ = [kgraphics1_Graphics];
kgraphics2_Graphics1.prototype = {
canvas: null
,texture: null
,pixels: null
,begin: function() {
if(this.texture == null) {
this.texture = kImage.create(this.canvas.get_width(),this.canvas.get_height(),kgraphics4_TextureFormat.RGBA32,kgraphics4_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,kxColor_ColorxImplx.fromBytes(color & 255,(color & 65280) >>> 8,(color & 16711680) >>> 16,color >>> 24));
}
,__class__: kgraphics2_Graphics1
};
var kgraphics2_GraphicsExtension = function() { };
xClasses["kha.graphics2.GraphicsExtension"] = kgraphics2_GraphicsExtension;
kgraphics2_GraphicsExtension.nom = true;
kgraphics2_GraphicsExtension.drawCircle = function(g2,cx,cy,radius,strength,segments) {
if(segments == null) {
segments = 0;
}
if(strength == null) {
strength = 1;
}
if(kSystemImpl.gl == null) {
var g = g2;
radius -= strength / 2;
g.drawCircle(cx,cy,radius,strength);
return;
}
if(segments <= 0) {
segments = Math.floor(10 * Math.sqrt(radius));
}
var theta = 2 * Math.PI / segments;
var c = Math.cos(theta);
var s = Math.sin(theta);
var x = radius;
var y = 0.0;
var _g1 = 0;
var _g = segments;
while(_g1 < _g) {
var n = _g1++;
var px = x + cx;
var py = y + cy;
var t = x;
x = c * x - s * y;
y = c * y + s * t;
g2.drawLine(px,py,x + cx,y + cy,strength);
}
};
kgraphics2_GraphicsExtension.fillCircle = function(g2,cx,cy,radius,segments) {
if(segments == null) {
segments = 0;
}
if(kSystemImpl.gl == null) {
var g = g2;
g.fillCircle(cx,cy,radius);
return;
}
if(segments <= 0) {
segments = Math.floor(10 * Math.sqrt(radius));
}
var theta = 2 * Math.PI / segments;
var c = Math.cos(theta);
var s = Math.sin(theta);
var x = radius;
var y = 0.0;
var _g1 = 0;
var _g = segments;
while(_g1 < _g) {
var n = _g1++;
var px = x + cx;
var py = y + cy;
var t = x;
x = c * x - s * y;
y = c * y + s * t;
g2.fillTriangle(px,py,x + cx,y + cy,cx,cy);
}
};
kgraphics2_GraphicsExtension.drawPolygon = function(g2,x,y,vertices,strength) {
if(strength == null) {
strength = 1;
}
var iterator = xOverrides.iter(vertices);
var v0 = iterator.next();
var v1 = v0;
while(iterator.hasNext()) {
var v2 = iterator.next();
g2.drawLine(v1.x + x,v1.y + y,v2.x + x,v2.y + y,strength);
v1 = v2;
}
g2.drawLine(v1.x + x,v1.y + y,v0.x + x,v0.y + y,strength);
};
kgraphics2_GraphicsExtension.fillPolygon = function(g2,x,y,vertices) {
var iterator = xOverrides.iter(vertices);
var v0 = iterator.next();
var v1 = v0;
while(iterator.hasNext()) {
var v2 = iterator.next();
g2.fillTriangle(v1.x + x,v1.y + y,v2.x + x,v2.y + y,x,y);
v1 = v2;
}
g2.fillTriangle(v1.x + x,v1.y + y,v0.x + x,v0.y + y,x,y);
};
kgraphics2_GraphicsExtension.drawCubicBezier = function(g2,x,y,segments,strength) {
if(strength == null) {
strength = 1.0;
}
if(segments == null) {
segments = 20;
}
var t;
var q0 = kgraphics2_GraphicsExtension.calculateCubicBezierPoint(0,x,y);
var q1;
var _g1 = 1;
var _g = segments + 1;
while(_g1 < _g) {
var i = _g1++;
t = i / segments;
q1 = kgraphics2_GraphicsExtension.calculateCubicBezierPoint(t,x,y);
g2.drawLine(q0[0],q0[1],q1[0],q1[1],strength);
q0 = q1;
}
};
kgraphics2_GraphicsExtension.drawCubicBezierPath = function(g2,x,y,segments,strength) {
if(strength == null) {
strength = 1.0;
}
if(segments == null) {
segments = 20;
}
var i = 0;
var t;
var q0 = null;
var q1 = null;
while(i < x.length - 3) {
if(i == 0) {
q0 = kgraphics2_GraphicsExtension.calculateCubicBezierPoint(0,[x[i],x[i + 1],x[i + 2],x[i + 3]],[y[i],y[i + 1],y[i + 2],y[i + 3]]);
}
var _g1 = 1;
var _g = segments + 1;
while(_g1 < _g) {
var j = _g1++;
t = j / segments;
q1 = kgraphics2_GraphicsExtension.calculateCubicBezierPoint(t,[x[i],x[i + 1],x[i + 2],x[i + 3]],[y[i],y[i + 1],y[i + 2],y[i + 3]]);
g2.drawLine(q0[0],q0[1],q1[0],q1[1],strength);
q0 = q1;
}
i += 3;
}
};
kgraphics2_GraphicsExtension.calculateCubicBezierPoint = function(t,x,y) {
var u = 1 - t;
var tt = t * t;
var uu = u * u;
var uuu = uu * u;
var ttt = tt * t;
var p = [uuu * x[0],uuu * y[0]];
p[0] += 3 * uu * t * x[1];
p[1] += 3 * uu * t * y[1];
p[0] += 3 * u * tt * x[2];
p[1] += 3 * u * tt * y[2];
p[0] += ttt * x[3];
p[1] += ttt * y[3];
return p;
};
var kgraphics2_ImageScaleQuality = xClasses["kha.graphics2.ImageScaleQuality"] = { __ename__ : true, __constructs__ : ["Low","High"] };
kgraphics2_ImageScaleQuality.Low = ["Low",0];
kgraphics2_ImageScaleQuality.Low.toString = $estr;
kgraphics2_ImageScaleQuality.Low.__enum__ = kgraphics2_ImageScaleQuality;
kgraphics2_ImageScaleQuality.High = ["High",1];
kgraphics2_ImageScaleQuality.High.toString = $estr;
kgraphics2_ImageScaleQuality.High.__enum__ = kgraphics2_ImageScaleQuality;
var kgraphics2_truetype_VectorOfIntPointer = function() {
};
xClasses["kha.graphics2.truetype.VectorOfIntPointer"] = kgraphics2_truetype_VectorOfIntPointer;
kgraphics2_truetype_VectorOfIntPointer.nom = true;
kgraphics2_truetype_VectorOfIntPointer.prototype = {
value: null
,__class__: kgraphics2_truetype_VectorOfIntPointer
};
var kgraphics2_truetype_Stbttxtempxrect = function() {
};
xClasses["kha.graphics2.truetype.Stbtt_temp_rect"] = kgraphics2_truetype_Stbttxtempxrect;
kgraphics2_truetype_Stbttxtempxrect.nom = true;
kgraphics2_truetype_Stbttxtempxrect.prototype = {
x0: null
,y0: null
,x1: null
,y1: null
,__class__: kgraphics2_truetype_Stbttxtempxrect
};
var kgraphics2_truetype_Stbttxtempxglypxxmetrics = function() {
};
xClasses["kha.graphics2.truetype.Stbtt_temp_glyph_h_metrics"] = kgraphics2_truetype_Stbttxtempxglypxxmetrics;
kgraphics2_truetype_Stbttxtempxglypxxmetrics.nom = true;
kgraphics2_truetype_Stbttxtempxglypxxmetrics.prototype = {
advanceWidth: null
,leftSideBearing: null
,__class__: kgraphics2_truetype_Stbttxtempxglypxxmetrics
};
var kgraphics2_truetype_Stbttxtempxfontxvxmetrics = function() {
};
xClasses["kha.graphics2.truetype.Stbtt_temp_font_v_metrics"] = kgraphics2_truetype_Stbttxtempxfontxvxmetrics;
kgraphics2_truetype_Stbttxtempxfontxvxmetrics.nom = true;
kgraphics2_truetype_Stbttxtempxfontxvxmetrics.prototype = {
ascent: null
,descent: null
,lineGap: null
,__class__: kgraphics2_truetype_Stbttxtempxfontxvxmetrics
};
var kgraphics2_truetype_Stbttxtempxregion = function() {
};
xClasses["kha.graphics2.truetype.Stbtt_temp_region"] = kgraphics2_truetype_Stbttxtempxregion;
kgraphics2_truetype_Stbttxtempxregion.nom = true;
kgraphics2_truetype_Stbttxtempxregion.prototype = {
width: null
,height: null
,xoff: null
,yoff: null
,__class__: kgraphics2_truetype_Stbttxtempxregion
};
var kgraphics2_truetype_Stbttxbakedchar = function() {
};
xClasses["kha.graphics2.truetype.Stbtt_bakedchar"] = kgraphics2_truetype_Stbttxbakedchar;
kgraphics2_truetype_Stbttxbakedchar.nom = true;
kgraphics2_truetype_Stbttxbakedchar.prototype = {
x0: null
,y0: null
,x1: null
,y1: null
,xoff: null
,yoff: null
,xadvance: null
,__class__: kgraphics2_truetype_Stbttxbakedchar
};
var kgraphics2_truetype_Stbttxalignedxquad = function() { };
xClasses["kha.graphics2.truetype.Stbtt_aligned_quad"] = kgraphics2_truetype_Stbttxalignedxquad;
kgraphics2_truetype_Stbttxalignedxquad.nom = true;
kgraphics2_truetype_Stbttxalignedxquad.prototype = {
x0: null
,y0: null
,s0: null
,t0: null
,x1: null
,y1: null
,s1: null
,t1: null
,__class__: kgraphics2_truetype_Stbttxalignedxquad
};
var kgraphics2_truetype_Stbttxpackedchar = function() { };
xClasses["kha.graphics2.truetype.Stbtt_packedchar"] = kgraphics2_truetype_Stbttxpackedchar;
kgraphics2_truetype_Stbttxpackedchar.nom = true;
kgraphics2_truetype_Stbttxpackedchar.prototype = {
x0: null
,y0: null
,x1: null
,y1: null
,xoff: null
,yoff: null
,xadvance: null
,xoff2: null
,yoff2: null
,__class__: kgraphics2_truetype_Stbttxpackedchar
};
var kgraphics2_truetype_Stbttxpackxrange = function() { };
xClasses["kha.graphics2.truetype.Stbtt_pack_range"] = kgraphics2_truetype_Stbttxpackxrange;
kgraphics2_truetype_Stbttxpackxrange.nom = true;
kgraphics2_truetype_Stbttxpackxrange.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__: kgraphics2_truetype_Stbttxpackxrange
};
var kgraphics2_truetype_Stbttxpackxcontext = function() { };
xClasses["kha.graphics2.truetype.Stbtt_pack_context"] = kgraphics2_truetype_Stbttxpackxcontext;
kgraphics2_truetype_Stbttxpackxcontext.nom = true;
kgraphics2_truetype_Stbttxpackxcontext.prototype = {
width: null
,height: null
,stride_in_bytes: null
,padding: null
,h_oversample: null
,v_oversample: null
,pixels: null
,__class__: kgraphics2_truetype_Stbttxpackxcontext
};
var kgraphics2_truetype_Stbttxfontinfo = function() {
};
xClasses["kha.graphics2.truetype.Stbtt_fontinfo"] = kgraphics2_truetype_Stbttxfontinfo;
kgraphics2_truetype_Stbttxfontinfo.nom = true;
kgraphics2_truetype_Stbttxfontinfo.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__: kgraphics2_truetype_Stbttxfontinfo
};
var kgraphics2_truetype_Stbttxvertex = function() {
};
xClasses["kha.graphics2.truetype.Stbtt_vertex"] = kgraphics2_truetype_Stbttxvertex;
kgraphics2_truetype_Stbttxvertex.nom = true;
kgraphics2_truetype_Stbttxvertex.prototype = {
x: null
,y: null
,cx: null
,cy: null
,type: null
,padding: null
,__class__: kgraphics2_truetype_Stbttxvertex
};
var kgraphics2_truetype_Stbttxxbitmap = function() {
};
xClasses["kha.graphics2.truetype.Stbtt__bitmap"] = kgraphics2_truetype_Stbttxxbitmap;
kgraphics2_truetype_Stbttxxbitmap.nom = true;
kgraphics2_truetype_Stbttxxbitmap.prototype = {
w: null
,h: null
,stride: null
,pixels: null
,pixels_offset: null
,__class__: kgraphics2_truetype_Stbttxxbitmap
};
var kgraphics2_truetype_Stbttxxedge = function() {
};
xClasses["kha.graphics2.truetype.Stbtt__edge"] = kgraphics2_truetype_Stbttxxedge;
kgraphics2_truetype_Stbttxxedge.nom = true;
kgraphics2_truetype_Stbttxxedge.prototype = {
x0: null
,y0: null
,x1: null
,y1: null
,invert: null
,__class__: kgraphics2_truetype_Stbttxxedge
};
var kgraphics2_truetype_Stbttxxactivexedge = function() {
};
xClasses["kha.graphics2.truetype.Stbtt__active_edge"] = kgraphics2_truetype_Stbttxxactivexedge;
kgraphics2_truetype_Stbttxxactivexedge.nom = true;
kgraphics2_truetype_Stbttxxactivexedge.prototype = {
next: null
,fx: null
,fdx: null
,fdy: null
,direction: null
,sy: null
,ey: null
,__class__: kgraphics2_truetype_Stbttxxactivexedge
};
var kgraphics2_truetype_Stbttxxpoint = function() {
};
xClasses["kha.graphics2.truetype.Stbtt__point"] = kgraphics2_truetype_Stbttxxpoint;
kgraphics2_truetype_Stbttxxpoint.nom = true;
kgraphics2_truetype_Stbttxxpoint.prototype = {
x: null
,y: null
,__class__: kgraphics2_truetype_Stbttxxpoint
};
var kgraphics2_truetype_StbTruetype = function() { };
xClasses["kha.graphics2.truetype.StbTruetype"] = kgraphics2_truetype_StbTruetype;
kgraphics2_truetype_StbTruetype.nom = true;
kgraphics2_truetype_StbTruetype.STBTT_assert = function(value) {
if(!value) {
throw new jsxBoot_HaxeError("Error");
}
};
kgraphics2_truetype_StbTruetype.STBTT_POINT_SIZE = function(x) {
return -x;
};
kgraphics2_truetype_StbTruetype.ttBYTE = function(p,pos) {
if(pos == null) {
pos = 0;
}
return p.readU8(pos);
};
kgraphics2_truetype_StbTruetype.ttCHAR = function(p,pos) {
if(pos == null) {
pos = 0;
}
var n = p.readU8(pos);
if(n >= 128) {
return n - 256;
}
return n;
};
kgraphics2_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;
};
kgraphics2_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;
};
kgraphics2_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;
};
kgraphics2_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;
};
kgraphics2_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;
};
kgraphics2_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;
}
};
kgraphics2_truetype_StbTruetype.stbtt_tag = function(p,pos,str) {
var c0 = xOverrides.cca(str,0);
var c1 = xOverrides.cca(str,1);
var c2 = xOverrides.cca(str,2);
var c3 = xOverrides.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;
}
};
kgraphics2_truetype_StbTruetype.stbtt__isfont = function(font) {
var c0 = xOverrides.cca("1",0);
if(font.readU8(0) == c0 && font.readU8(1) == 0 && font.readU8(2) == 0 && font.readU8(3) == 0) {
return true;
}
var c01 = xOverrides.cca("typ1",0);
var c1 = xOverrides.cca("typ1",1);
var c2 = xOverrides.cca("typ1",2);
var c3 = xOverrides.cca("typ1",3);
if(font.readU8(0) == c01 && font.readU8(1) == c1 && font.readU8(2) == c2 && font.readU8(3) == c3) {
return true;
}
var c02 = xOverrides.cca("OTTO",0);
var c11 = xOverrides.cca("OTTO",1);
var c21 = xOverrides.cca("OTTO",2);
var c31 = xOverrides.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;
};
kgraphics2_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 = xOverrides.cca(tag,0);
var c1 = xOverrides.cca(tag,1);
var c2 = xOverrides.cca(tag,2);
var c3 = xOverrides.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;
};
kgraphics2_truetype_StbTruetype.stbtt_GetFontOffsetForIndex = function(font_collection,index) {
if(kgraphics2_truetype_StbTruetype.stbtt__isfont(font_collection)) {
if(index == 0) {
return 0;
} else {
return -1;
}
}
var c0 = xOverrides.cca("ttcf",0);
var c1 = xOverrides.cca("ttcf",1);
var c2 = xOverrides.cca("ttcf",2);
var c3 = xOverrides.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;
};
kgraphics2_truetype_StbTruetype.stbtt_InitFont = function(info,data,fontstart) {
var cmap;
var t;
var numTables;
info.data = data;
info.fontstart = fontstart;
cmap = kgraphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"cmap");
info.loca = kgraphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"loca");
info.head = kgraphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"head");
info.glyf = kgraphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"glyf");
info.hhea = kgraphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"hhea");
info.hmtx = kgraphics2_truetype_StbTruetype.stbtt__find_table(data,fontstart,"hmtx");
info.kern = kgraphics2_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 = kgraphics2_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;
};
kgraphics2_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 jsxBoot_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 jsxBoot_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 jsxBoot_HaxeError("Error");
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointShape = function(info,unicode_codepoint) {
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,unicode_codepoint));
};
kgraphics2_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;
};
kgraphics2_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;
}
};
kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBox = function(info,glyph_index,rect) {
var g = kgraphics2_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;
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointBox = function(info,codepoint,rect) {
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBox(info,kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint),rect);
};
kgraphics2_truetype_StbTruetype.stbtt_IsGlyphEmpty = function(info,glyph_index) {
var numberOfContours;
var g = kgraphics2_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;
};
kgraphics2_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) {
kgraphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,cx + scx >> 1,cy + scy >> 1,cx,cy);
}
kgraphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,sx,sy,scx,scy);
} else if(was_off) {
kgraphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,sx,sy,cx,cy);
} else {
kgraphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],2,sx,sy,0,0);
}
return num_vertices;
};
kgraphics2_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];
}
};
kgraphics2_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 = kgraphics2_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 kgraphics2_truetype_Stbttxvertex();
}
}
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 = kgraphics2_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;
}
kgraphics2_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) {
kgraphics2_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) {
kgraphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],3,x,y,cx,cy);
} else {
kgraphics2_truetype_StbTruetype.stbtt_setvertex(vertices[num_vertices++],2,x,y,0,0);
}
was_off = false;
}
++i4;
}
num_vertices = kgraphics2_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 jsxBoot_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 = kgraphics2_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) {
kgraphics2_truetype_StbTruetype.copyVertices(vertices,tmp,0,num_vertices);
}
kgraphics2_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 jsxBoot_HaxeError("Error");
}
if(vertices == null) {
return null;
}
if(vertices.length < num_vertices) {
throw new jsxBoot_HaxeError("Error");
}
if(num_vertices < vertices.length) {
var this3 = new Array(num_vertices);
var tmp1 = this3;
kgraphics2_truetype_StbTruetype.copyVertices(vertices,tmp1,0,num_vertices);
return tmp1;
} else {
return vertices;
}
};
kgraphics2_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 kgraphics2_truetype_Stbttxtempxglypxxmetrics();
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;
};
kgraphics2_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;
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointKernAdvance = function(info,ch1,ch2) {
if(info.kern == 0) {
return 0;
}
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphKernAdvance(info,kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,ch1),kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,ch2));
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointHMetrics = function(info,codepoint) {
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphHMetrics(info,kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint));
};
kgraphics2_truetype_StbTruetype.stbtt_GetFontVMetrics = function(info) {
var metrics = new kgraphics2_truetype_Stbttxtempxfontxvxmetrics();
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;
};
kgraphics2_truetype_StbTruetype.stbtt_GetFontBoundingBox = function(info) {
var rect = new kgraphics2_truetype_Stbttxtempxrect();
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;
};
kgraphics2_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;
};
kgraphics2_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;
};
kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel = function(font,glyph,scale_x,scale_y,shift_x,shift_y) {
var rect = new kgraphics2_truetype_Stbttxtempxrect();
if(!kgraphics2_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;
};
kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBox = function(font,glyph,scale_x,scale_y) {
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(font,glyph,scale_x,scale_y,0.0,0.0);
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapBoxSubpixel = function(font,codepoint,scale_x,scale_y,shift_x,shift_y) {
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapBoxSubpixel(font,kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(font,codepoint),scale_x,scale_y,shift_x,shift_y);
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapBox = function(font,codepoint,scale_x,scale_y) {
return kgraphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapBoxSubpixel(font,codepoint,scale_x,scale_y,0.0,0.0);
};
kgraphics2_truetype_StbTruetype.stbtt__new_active = function(e,eIndex,off_x,start_point) {
var z = new kgraphics2_truetype_Stbttxxactivexedge();
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;
};
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge = function(scanline,scanlineIndex,x,e,x0,y0,x1,y1) {
if(y0 == y1) {
return;
}
if(!(y0 < y1)) {
throw new jsxBoot_HaxeError("Error");
}
if(!(e.sy <= e.ey)) {
throw new jsxBoot_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 jsxBoot_HaxeError("Error");
}
} else if(x0 == x + 1) {
if(!(x1 >= x)) {
throw new jsxBoot_HaxeError("Error");
}
} else if(x0 <= x) {
if(!(x1 <= x)) {
throw new jsxBoot_HaxeError("Error");
}
} else if(x0 >= x + 1) {
if(!(x1 >= x + 1)) {
throw new jsxBoot_HaxeError("Error");
}
} else if(!(x1 >= x && x1 <= x + 1)) {
throw new jsxBoot_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 jsxBoot_HaxeError("Error");
}
var _g2 = scanlineIndex + x;
var _g11 = scanline;
_g11[_g2] = _g11[_g2] + e.direction * (y1 - y0) * (1 - (x0 - x + (x1 - x)) / 2);
}
};
kgraphics2_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 jsxBoot_HaxeError("Error");
}
if(e.fdx == 0) {
var x0 = e.fx;
if(x0 < len) {
if(x0 >= 0) {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x0 | 0,e,x0,y_top,x0,y_bottom);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline_fill,scanline_fillIndex - 1,x0 + 1 | 0,e,x0,y_top,x0,y_bottom);
} else {
kgraphics2_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 jsxBoot_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 jsxBoot_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 jsxBoot_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) {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x12,y1);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x21,y2);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x31,y3);
} else if(x31 < x12 && x01 > x21) {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x21,y2);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x12,y1);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x31,y3);
} else if(x01 < x12 && x31 > x12) {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x12,y1);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x31,y3);
} else if(x31 < x12 && x01 > x12) {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x12,y1);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x12,y1,x31,y3);
} else if(x01 < x21 && x31 > x21) {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x21,y2);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x31,y3);
} else if(x31 < x21 && x01 > x21) {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x21,y2);
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x21,y2,x31,y3);
} else {
kgraphics2_truetype_StbTruetype.stbtt__handle_clipped_edge(scanline,0,x4,e,x01,y0,x31,y3);
}
}
}
}
e = e.next;
}
};
kgraphics2_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 jsxBoot_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 = kgraphics2_truetype_StbTruetype.stbtt__new_active(e,eIndex,off_x,scan_y_top);
if(!(z1.ey >= scan_y_top)) {
throw new jsxBoot_HaxeError("Error");
}
z1.next = active;
active = z1;
}
++eIndex;
}
if(active != null) {
kgraphics2_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;
}
};
kgraphics2_truetype_StbTruetype.STBTT__COMPARE = function(a,b) {
return a.y0 < b.y0;
};
kgraphics2_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 = kgraphics2_truetype_StbTruetype.STBTT__COMPARE(a,b);
if(!c) {
break;
}
p[j] = p[j - 1];
--j;
}
if(i1 != j) {
p[j] = t;
}
}
};
kgraphics2_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 = kgraphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex],p[pIndex + m]);
c12 = kgraphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex + m],p[pIndex + n - 1]);
if(c01 != c12) {
var z;
c = kgraphics2_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(kgraphics2_truetype_StbTruetype.STBTT__COMPARE(p[pIndex + i],p[pIndex])) ++i;
while(kgraphics2_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) {
kgraphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,pIndex,j);
pIndex += i;
n -= i;
} else {
kgraphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,pIndex + i,n - i);
n = j;
}
}
};
kgraphics2_truetype_StbTruetype.stbtt__sort_edges = function(p,n) {
kgraphics2_truetype_StbTruetype.stbtt__sort_edges_quicksort(p,0,n);
kgraphics2_truetype_StbTruetype.stbtt__sort_edges_ins_sort(p,n);
};
kgraphics2_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 kgraphics2_truetype_Stbttxxedge();
}
}
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;
}
}
kgraphics2_truetype_StbTruetype.stbtt__sort_edges(e,n);
kgraphics2_truetype_StbTruetype.stbtt__rasterize_sorted_edges(result,e,n,vsubsample,off_x,off_y);
};
kgraphics2_truetype_StbTruetype.stbtt__add_point = function(points,n,x,y) {
if(points == null) {
return;
}
points[n].x = x;
points[n].y = y;
};
kgraphics2_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) {
kgraphics2_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);
kgraphics2_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 {
kgraphics2_truetype_StbTruetype.stbtt__add_point(points,num_points.value,x2,y2);
num_points.value += 1;
}
return 1;
};
kgraphics2_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 kgraphics2_truetype_Stbttxxpoint();
}
}
}
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;
kgraphics2_truetype_StbTruetype.stbtt__add_point(points,num_points++,x,y);
break;
case 2:
x = vertices[i3].x;
y = vertices[i3].y;
kgraphics2_truetype_StbTruetype.stbtt__add_point(points,num_points++,x,y);
break;
case 3:
var num_points_reference = { value : num_points};
kgraphics2_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;
};
kgraphics2_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 kgraphics2_truetype_VectorOfIntPointer();
var windings = kgraphics2_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) {
kgraphics2_truetype_StbTruetype.stbtt__rasterize(result,windings,winding_lengths,winding_count,scale_x,scale_y,shift_x,shift_y,x_off,y_off,invert);
}
};
kgraphics2_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 kgraphics2_truetype_Stbttxxbitmap();
var vertices = kgraphics2_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 = kgraphics2_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 = kinternal_BytesBlob.alloc(gbm.w * gbm.h);
if(gbm.pixels != null) {
gbm.stride = gbm.w;
kgraphics2_truetype_StbTruetype.stbtt_Rasterize(gbm,0.35,vertices,num_verts,scale_x,scale_y,shift_x,shift_y,ix0,iy0,true);
}
}
return gbm.pixels;
};
kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBitmap = function(info,scale_x,scale_y,glyph,region) {
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapSubpixel(info,scale_x,scale_y,0.0,0.0,glyph,region);
};
kgraphics2_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 = kgraphics2_truetype_StbTruetype.stbtt_GetGlyphShape(info,glyph);
var num_verts = vertices == null ? 0 : vertices.length;
var gbm = new kgraphics2_truetype_Stbttxxbitmap();
var rect = kgraphics2_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) {
kgraphics2_truetype_StbTruetype.stbtt_Rasterize(gbm,0.35,vertices,num_verts,scale_x,scale_y,shift_x,shift_y,ix0,iy0,true);
}
};
kgraphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmap = function(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,glyph) {
kgraphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,0.0,0.0,glyph);
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapSubpixel = function(info,scale_x,scale_y,shift_x,shift_y,codepoint,region) {
return kgraphics2_truetype_StbTruetype.stbtt_GetGlyphBitmapSubpixel(info,scale_x,scale_y,shift_x,shift_y,kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint),region);
};
kgraphics2_truetype_StbTruetype.stbtt_MakeCodepointBitmapSubpixel = function(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,shift_x,shift_y,codepoint) {
kgraphics2_truetype_StbTruetype.stbtt_MakeGlyphBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,shift_x,shift_y,kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(info,codepoint));
};
kgraphics2_truetype_StbTruetype.stbtt_GetCodepointBitmap = function(info,scale_x,scale_y,codepoint,region) {
return kgraphics2_truetype_StbTruetype.stbtt_GetCodepointBitmapSubpixel(info,scale_x,scale_y,0.0,0.0,codepoint,region);
};
kgraphics2_truetype_StbTruetype.stbtt_MakeCodepointBitmap = function(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,codepoint) {
kgraphics2_truetype_StbTruetype.stbtt_MakeCodepointBitmapSubpixel(info,output,output_offset,out_w,out_h,out_stride,scale_x,scale_y,0.0,0.0,codepoint);
};
kgraphics2_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 kgraphics2_truetype_Stbttxfontinfo();
if(!kgraphics2_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 = kgraphics2_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 = kgraphics2_truetype_StbTruetype.stbtt_FindGlyphIndex(f,index);
var metrics = kgraphics2_truetype_StbTruetype.stbtt_GetGlyphHMetrics(f,g);
advance = metrics.advanceWidth;
lsb = metrics.leftSideBearing;
var rect = kgraphics2_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 jsxBoot_HaxeError("Error");
}
if(y + gh >= ph) {
throw new jsxBoot_HaxeError("Error");
}
kgraphics2_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;
};
kgraphics2_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 kgraphics4_BlendingFactor = xClasses["kha.graphics4.BlendingFactor"] = { __ename__ : true, __constructs__ : ["Undefined","BlendOne","BlendZero","SourceAlpha","DestinationAlpha","InverseSourceAlpha","InverseDestinationAlpha","SourceColor","DestinationColor","InverseSourceColor","InverseDestinationColor"] };
kgraphics4_BlendingFactor.Undefined = ["Undefined",0];
kgraphics4_BlendingFactor.Undefined.toString = $estr;
kgraphics4_BlendingFactor.Undefined.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.BlendOne = ["BlendOne",1];
kgraphics4_BlendingFactor.BlendOne.toString = $estr;
kgraphics4_BlendingFactor.BlendOne.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.BlendZero = ["BlendZero",2];
kgraphics4_BlendingFactor.BlendZero.toString = $estr;
kgraphics4_BlendingFactor.BlendZero.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.SourceAlpha = ["SourceAlpha",3];
kgraphics4_BlendingFactor.SourceAlpha.toString = $estr;
kgraphics4_BlendingFactor.SourceAlpha.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.DestinationAlpha = ["DestinationAlpha",4];
kgraphics4_BlendingFactor.DestinationAlpha.toString = $estr;
kgraphics4_BlendingFactor.DestinationAlpha.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.InverseSourceAlpha = ["InverseSourceAlpha",5];
kgraphics4_BlendingFactor.InverseSourceAlpha.toString = $estr;
kgraphics4_BlendingFactor.InverseSourceAlpha.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.InverseDestinationAlpha = ["InverseDestinationAlpha",6];
kgraphics4_BlendingFactor.InverseDestinationAlpha.toString = $estr;
kgraphics4_BlendingFactor.InverseDestinationAlpha.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.SourceColor = ["SourceColor",7];
kgraphics4_BlendingFactor.SourceColor.toString = $estr;
kgraphics4_BlendingFactor.SourceColor.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.DestinationColor = ["DestinationColor",8];
kgraphics4_BlendingFactor.DestinationColor.toString = $estr;
kgraphics4_BlendingFactor.DestinationColor.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.InverseSourceColor = ["InverseSourceColor",9];
kgraphics4_BlendingFactor.InverseSourceColor.toString = $estr;
kgraphics4_BlendingFactor.InverseSourceColor.__enum__ = kgraphics4_BlendingFactor;
kgraphics4_BlendingFactor.InverseDestinationColor = ["InverseDestinationColor",10];
kgraphics4_BlendingFactor.InverseDestinationColor.toString = $estr;
kgraphics4_BlendingFactor.InverseDestinationColor.__enum__ = kgraphics4_BlendingFactor;
var kgraphics4_BlendingOperation = xClasses["kha.graphics4.BlendingOperation"] = { __ename__ : true, __constructs__ : ["Add","Subtract","ReverseSubtract","Min","Max"] };
kgraphics4_BlendingOperation.Add = ["Add",0];
kgraphics4_BlendingOperation.Add.toString = $estr;
kgraphics4_BlendingOperation.Add.__enum__ = kgraphics4_BlendingOperation;
kgraphics4_BlendingOperation.Subtract = ["Subtract",1];
kgraphics4_BlendingOperation.Subtract.toString = $estr;
kgraphics4_BlendingOperation.Subtract.__enum__ = kgraphics4_BlendingOperation;
kgraphics4_BlendingOperation.ReverseSubtract = ["ReverseSubtract",2];
kgraphics4_BlendingOperation.ReverseSubtract.toString = $estr;
kgraphics4_BlendingOperation.ReverseSubtract.__enum__ = kgraphics4_BlendingOperation;
kgraphics4_BlendingOperation.Min = ["Min",3];
kgraphics4_BlendingOperation.Min.toString = $estr;
kgraphics4_BlendingOperation.Min.__enum__ = kgraphics4_BlendingOperation;
kgraphics4_BlendingOperation.Max = ["Max",4];
kgraphics4_BlendingOperation.Max.toString = $estr;
kgraphics4_BlendingOperation.Max.__enum__ = kgraphics4_BlendingOperation;
var kgraphics4_CompareMode = xClasses["kha.graphics4.CompareMode"] = { __ename__ : true, __constructs__ : ["Always","Never","Equal","NotEqual","Less","LessEqual","Greater","GreaterEqual"] };
kgraphics4_CompareMode.Always = ["Always",0];
kgraphics4_CompareMode.Always.toString = $estr;
kgraphics4_CompareMode.Always.__enum__ = kgraphics4_CompareMode;
kgraphics4_CompareMode.Never = ["Never",1];
kgraphics4_CompareMode.Never.toString = $estr;
kgraphics4_CompareMode.Never.__enum__ = kgraphics4_CompareMode;
kgraphics4_CompareMode.Equal = ["Equal",2];
kgraphics4_CompareMode.Equal.toString = $estr;
kgraphics4_CompareMode.Equal.__enum__ = kgraphics4_CompareMode;
kgraphics4_CompareMode.NotEqual = ["NotEqual",3];
kgraphics4_CompareMode.NotEqual.toString = $estr;
kgraphics4_CompareMode.NotEqual.__enum__ = kgraphics4_CompareMode;
kgraphics4_CompareMode.Less = ["Less",4];
kgraphics4_CompareMode.Less.toString = $estr;
kgraphics4_CompareMode.Less.__enum__ = kgraphics4_CompareMode;
kgraphics4_CompareMode.LessEqual = ["LessEqual",5];
kgraphics4_CompareMode.LessEqual.toString = $estr;
kgraphics4_CompareMode.LessEqual.__enum__ = kgraphics4_CompareMode;
kgraphics4_CompareMode.Greater = ["Greater",6];
kgraphics4_CompareMode.Greater.toString = $estr;
kgraphics4_CompareMode.Greater.__enum__ = kgraphics4_CompareMode;
kgraphics4_CompareMode.GreaterEqual = ["GreaterEqual",7];
kgraphics4_CompareMode.GreaterEqual.toString = $estr;
kgraphics4_CompareMode.GreaterEqual.__enum__ = kgraphics4_CompareMode;
var kgraphics4_ConstantLocation = function() { };
xClasses["kha.graphics4.ConstantLocation"] = kgraphics4_ConstantLocation;
kgraphics4_ConstantLocation.nom = true;
var kgraphics4_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();
}
};
xClasses["kha.graphics4.CubeMap"] = kgraphics4_CubeMap;
kgraphics4_CubeMap.nom = true;
kgraphics4_CubeMap.__interfaces__ = [kResource,kCanvas];
kgraphics4_CubeMap.createRenderTarget = function(size,format,depthStencil,contextId) {
if(contextId == null) {
contextId = 0;
}
if(format == null) {
format = kgraphics4_TextureFormat.RGBA32;
}
if(depthStencil == null) {
depthStencil = 0;
}
return new kgraphics4_CubeMap(size,format,true,depthStencil);
};
kgraphics4_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(kSystemImpl.gl == null) {
return;
}
this.texture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(34067,this.texture);
kSystemImpl.gl.texParameteri(34067,10240,9729);
kSystemImpl.gl.texParameteri(34067,10241,9729);
kSystemImpl.gl.texParameteri(34067,10242,33071);
kSystemImpl.gl.texParameteri(34067,10243,33071);
if(this.renderTarget) {
this.frameBuffer = kSystemImpl.gl.createFramebuffer();
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
var _g = this.format;
switch(_g[1]) {
case 0:
var _g1 = 0;
while(_g1 < 6) {
var i = _g1++;
kSystemImpl.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++;
kSystemImpl.gl.texImage2D(34069 + i1,0,kSystemImpl.gl2 ? 34836 : 6408,this.myWidth,this.myHeight,0,6408,5126,null);
}
break;
case 3:
var _g3 = 0;
while(_g3 < 6) {
var i2 = _g3++;
kSystemImpl.gl.texImage2D(34069 + i2,0,kSystemImpl.gl2 ? 33189 : 6402,this.myWidth,this.myHeight,0,6402,5123,null);
}
break;
case 4:
var _g4 = 0;
while(_g4 < 6) {
var i3 = _g4++;
kSystemImpl.gl.texImage2D(34069 + i3,0,kSystemImpl.gl2 ? 34842 : 6408,this.myWidth,this.myHeight,0,6408,kSystemImpl.halfFloat.HALF_FLOAT_OES,null);
}
break;
case 5:
var _g5 = 0;
while(_g5 < 6) {
var i4 = _g5++;
kSystemImpl.gl.texImage2D(34069 + i4,0,kSystemImpl.gl2 ? 33326 : 6406,this.myWidth,this.myHeight,0,6406,5126,null);
}
break;
case 6:
var _g6 = 0;
while(_g6 < 6) {
var i5 = _g6++;
kSystemImpl.gl.texImage2D(34069 + i5,0,kSystemImpl.gl2 ? 33325 : 6406,this.myWidth,this.myHeight,0,6406,kSystemImpl.halfFloat.HALF_FLOAT_OES,null);
}
break;
default:
var _g7 = 0;
while(_g7 < 6) {
var i6 = _g7++;
kSystemImpl.gl.texImage2D(34069 + i6,0,6408,this.myWidth,this.myHeight,0,6408,5121,null);
}
}
if(this.format == kgraphics4_TextureFormat.DEPTH16) {
kSystemImpl.gl.texParameteri(34067,10240,9728);
kSystemImpl.gl.texParameteri(34067,10241,9728);
this.isDepthAttachment = true;
if(navigator.appVersion.indexOf("Win") == -1) {
var colortex = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(34067,colortex);
var _g11 = 0;
while(_g11 < 6) {
var i7 = _g11++;
kSystemImpl.gl.texImage2D(34069 + i7,0,6408,this.myWidth,this.myHeight,0,6408,5121,null);
kSystemImpl.gl.framebufferTexture2D(36160,36064,34069 + i7,colortex,0);
}
kSystemImpl.gl.bindTexture(34067,this.texture);
}
}
this.initDepthStencilBuffer(this.depthStencilFormat);
kSystemImpl.gl.bindFramebuffer(36160,null);
}
kSystemImpl.gl.bindTexture(34067,null);
}
,initDepthStencilBuffer: function(depthStencilFormat) {
switch(depthStencilFormat) {
case 0:
break;
case 1:case 5:
this.depthTexture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(34067,this.depthTexture);
if(depthStencilFormat == 1) {
kSystemImpl.gl.texImage2D(34067,0,kSystemImpl.gl2 ? 33190 : 6402,this.myWidth,this.myHeight,0,6402,5125,null);
} else {
kSystemImpl.gl.texImage2D(34067,0,kSystemImpl.gl2 ? 33189 : 6402,this.myWidth,this.myHeight,0,6402,5123,null);
}
kSystemImpl.gl.texParameteri(34067,10240,9728);
kSystemImpl.gl.texParameteri(34067,10241,9728);
kSystemImpl.gl.texParameteri(34067,10242,33071);
kSystemImpl.gl.texParameteri(34067,10243,33071);
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
kSystemImpl.gl.framebufferTexture2D(36160,36096,34067,this.depthTexture,0);
break;
case 2:case 3:case 4:
this.depthTexture = kSystemImpl.gl.createTexture();
kSystemImpl.gl.bindTexture(34067,this.depthTexture);
kSystemImpl.gl.texImage2D(34067,0,kSystemImpl.gl2 ? 35056 : 34041,this.myWidth,this.myHeight,0,34041,kSystemImpl.depthTexture.UNSIGNED_INT_24_8_WEBGL,null);
kSystemImpl.gl.texParameteri(34067,10240,9728);
kSystemImpl.gl.texParameteri(34067,10241,9728);
kSystemImpl.gl.texParameteri(34067,10242,33071);
kSystemImpl.gl.texParameteri(34067,10243,33071);
kSystemImpl.gl.bindFramebuffer(36160,this.frameBuffer);
kSystemImpl.gl.framebufferTexture2D(36160,33306,34067,this.depthTexture,0);
break;
}
}
,set: function(stage) {
kSystemImpl.gl.activeTexture(33984 + stage);
kSystemImpl.gl.bindTexture(34067,this.texture);
}
,setDepth: function(stage) {
kSystemImpl.gl.activeTexture(33984 + stage);
kSystemImpl.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 kjsgraphics4_Graphics(this);
}
return this.graphics4;
}
,__class__: kgraphics4_CubeMap
};
var kgraphics4_CullMode = xClasses["kha.graphics4.CullMode"] = { __ename__ : true, __constructs__ : ["Clockwise","CounterClockwise","None"] };
kgraphics4_CullMode.Clockwise = ["Clockwise",0];
kgraphics4_CullMode.Clockwise.toString = $estr;
kgraphics4_CullMode.Clockwise.__enum__ = kgraphics4_CullMode;
kgraphics4_CullMode.CounterClockwise = ["CounterClockwise",1];
kgraphics4_CullMode.CounterClockwise.toString = $estr;
kgraphics4_CullMode.CounterClockwise.__enum__ = kgraphics4_CullMode;
kgraphics4_CullMode.None = ["None",2];
kgraphics4_CullMode.None.toString = $estr;
kgraphics4_CullMode.None.__enum__ = kgraphics4_CullMode;
var kgraphics4_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;
};
xClasses["kha.graphics4.FragmentShader"] = kgraphics4_FragmentShader;
kgraphics4_FragmentShader.nom = true;
kgraphics4_FragmentShader.fromSource = function(source) {
var shader = new kgraphics4_FragmentShader([],["runtime-string"]);
shader.sources.push(source);
return shader;
};
kgraphics4_FragmentShader.prototype = {
sources: null
,type: null
,shader: null
,files: null
,'delete': function() {
kSystemImpl.gl.deleteShader(this.shader);
this.shader = null;
this.sources = null;
}
,__class__: kgraphics4_FragmentShader
};
var kgraphics4_GeometryShader = function(source) {
};
xClasses["kha.graphics4.GeometryShader"] = kgraphics4_GeometryShader;
kgraphics4_GeometryShader.nom = true;
kgraphics4_GeometryShader.prototype = {
'delete': function() {
}
,__class__: kgraphics4_GeometryShader
};
var kgraphics4_Graphics = function() { };
xClasses["kha.graphics4.Graphics"] = kgraphics4_Graphics;
kgraphics4_Graphics.nom = true;
kgraphics4_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__: kgraphics4_Graphics
};
var kgraphics4_ImageShaderPainter = function(g4) {
this.destinationBlend = kgraphics4_BlendingFactor.Undefined;
this.sourceBlend = kgraphics4_BlendingFactor.Undefined;
this.myPipeline = null;
this.bilinearMipmaps = false;
this.bilinear = false;
this.g = g4;
this.bufferIndex = 0;
kgraphics4_ImageShaderPainter.initShaders();
this.initBuffers();
this.projectionLocation = kgraphics4_ImageShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix");
this.textureLocation = kgraphics4_ImageShaderPainter.shaderPipeline.getTextureUnit("tex");
};
xClasses["kha.graphics4.ImageShaderPainter"] = kgraphics4_ImageShaderPainter;
kgraphics4_ImageShaderPainter.nom = true;
kgraphics4_ImageShaderPainter.initShaders = function() {
if(kgraphics4_ImageShaderPainter.shaderPipeline != null) {
return;
}
kgraphics4_ImageShaderPainter.shaderPipeline = new kgraphics4_PipelineState();
kgraphics4_ImageShaderPainter.shaderPipeline.fragmentShader = kShaders.painter_image_frag;
kgraphics4_ImageShaderPainter.shaderPipeline.vertexShader = kShaders.painter_image_vert;
kgraphics4_ImageShaderPainter.structure = new kgraphics4_VertexStructure();
kgraphics4_ImageShaderPainter.structure.add("vertexPosition",kgraphics4_VertexData.Float3);
kgraphics4_ImageShaderPainter.structure.add("texPosition",kgraphics4_VertexData.Float2);
kgraphics4_ImageShaderPainter.structure.add("vertexColor",kgraphics4_VertexData.Float4);
kgraphics4_ImageShaderPainter.shaderPipeline.inputLayout = [kgraphics4_ImageShaderPainter.structure];
kgraphics4_ImageShaderPainter.shaderPipeline.blendSource = kgraphics4_BlendingFactor.BlendOne;
kgraphics4_ImageShaderPainter.shaderPipeline.blendDestination = kgraphics4_BlendingFactor.InverseSourceAlpha;
kgraphics4_ImageShaderPainter.shaderPipeline.alphaBlendSource = kgraphics4_BlendingFactor.SourceAlpha;
kgraphics4_ImageShaderPainter.shaderPipeline.alphaBlendDestination = kgraphics4_BlendingFactor.InverseSourceAlpha;
kgraphics4_ImageShaderPainter.shaderPipeline.compile();
};
kgraphics4_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 = kgraphics4_ImageShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix");
this.textureLocation = kgraphics4_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 kgraphics4_VertexBuffer(kgraphics4_ImageShaderPainter.bufferSize * 4,kgraphics4_ImageShaderPainter.structure,kgraphics4_Usage.DynamicUsage);
this.rectVertices = this.rectVertexBuffer.lock();
this.indexBuffer = new kgraphics4_IndexBuffer(kgraphics4_ImageShaderPainter.bufferSize * 3 * 2,kgraphics4_Usage.StaticUsage);
var indices = this.indexBuffer.lock();
var _g1 = 0;
var _g = kgraphics4_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 * kgraphics4_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 * kgraphics4_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 * kgraphics4_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 ? kgraphics4_ImageShaderPainter.shaderPipeline : this.get_pipeline());
this.g.setTexture(this.textureLocation,this.lastTexture);
this.g.setTextureParameters(this.textureLocation,kgraphics4_TextureAddressing.Clamp,kgraphics4_TextureAddressing.Clamp,this.bilinear ? kgraphics4_TextureFilter.LinearFilter : kgraphics4_TextureFilter.PointFilter,this.bilinear ? kgraphics4_TextureFilter.LinearFilter : kgraphics4_TextureFilter.PointFilter,this.bilinearMipmaps ? kgraphics4_MipMapFilter.LinearMipFilter : kgraphics4_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 >= kgraphics4_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 * kgraphics4_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 * kgraphics4_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 * kgraphics4_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 >= kgraphics4_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 * kgraphics4_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 * kgraphics4_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 * kgraphics4_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 >= kgraphics4_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 * kgraphics4_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 * kgraphics4_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 * kgraphics4_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__: kgraphics4_ImageShaderPainter
};
var kgraphics4_ColoredShaderPainter = function(g4) {
this.destinationBlend = kgraphics4_BlendingFactor.Undefined;
this.sourceBlend = kgraphics4_BlendingFactor.Undefined;
this.myPipeline = null;
this.g = g4;
this.bufferIndex = 0;
this.triangleBufferIndex = 0;
kgraphics4_ColoredShaderPainter.initShaders();
this.initBuffers();
this.projectionLocation = kgraphics4_ColoredShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix");
};
xClasses["kha.graphics4.ColoredShaderPainter"] = kgraphics4_ColoredShaderPainter;
kgraphics4_ColoredShaderPainter.nom = true;
kgraphics4_ColoredShaderPainter.initShaders = function() {
if(kgraphics4_ColoredShaderPainter.shaderPipeline != null) {
return;
}
kgraphics4_ColoredShaderPainter.shaderPipeline = new kgraphics4_PipelineState();
kgraphics4_ColoredShaderPainter.shaderPipeline.fragmentShader = kShaders.painter_colored_frag;
kgraphics4_ColoredShaderPainter.shaderPipeline.vertexShader = kShaders.painter_colored_vert;
kgraphics4_ColoredShaderPainter.structure = new kgraphics4_VertexStructure();
kgraphics4_ColoredShaderPainter.structure.add("vertexPosition",kgraphics4_VertexData.Float3);
kgraphics4_ColoredShaderPainter.structure.add("vertexColor",kgraphics4_VertexData.Float4);
kgraphics4_ColoredShaderPainter.shaderPipeline.inputLayout = [kgraphics4_ColoredShaderPainter.structure];
kgraphics4_ColoredShaderPainter.shaderPipeline.blendSource = kgraphics4_BlendingFactor.SourceAlpha;
kgraphics4_ColoredShaderPainter.shaderPipeline.blendDestination = kgraphics4_BlendingFactor.InverseSourceAlpha;
kgraphics4_ColoredShaderPainter.shaderPipeline.alphaBlendSource = kgraphics4_BlendingFactor.SourceAlpha;
kgraphics4_ColoredShaderPainter.shaderPipeline.alphaBlendDestination = kgraphics4_BlendingFactor.InverseSourceAlpha;
kgraphics4_ColoredShaderPainter.shaderPipeline.compile();
};
kgraphics4_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 = kgraphics4_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 kgraphics4_VertexBuffer(kgraphics4_ColoredShaderPainter.bufferSize * 4,kgraphics4_ColoredShaderPainter.structure,kgraphics4_Usage.DynamicUsage);
this.rectVertices = this.rectVertexBuffer.lock();
this.indexBuffer = new kgraphics4_IndexBuffer(kgraphics4_ColoredShaderPainter.bufferSize * 3 * 2,kgraphics4_Usage.StaticUsage);
var indices = this.indexBuffer.lock();
var _g1 = 0;
var _g = kgraphics4_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 kgraphics4_VertexBuffer(kgraphics4_ColoredShaderPainter.triangleBufferSize * 3,kgraphics4_ColoredShaderPainter.structure,kgraphics4_Usage.DynamicUsage);
this.triangleVertices = this.triangleVertexBuffer.lock();
this.triangleIndexBuffer = new kgraphics4_IndexBuffer(kgraphics4_ColoredShaderPainter.triangleBufferSize * 3,kgraphics4_Usage.StaticUsage);
var triIndices = this.triangleIndexBuffer.lock();
var _g11 = 0;
var _g2 = kgraphics4_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 ? kgraphics4_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 ? kgraphics4_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 >= kgraphics4_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 >= kgraphics4_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__: kgraphics4_ColoredShaderPainter
};
var kgraphics4_TextShaderPainter = function(g4) {
this.destinationBlend = kgraphics4_BlendingFactor.Undefined;
this.sourceBlend = kgraphics4_BlendingFactor.Undefined;
this.bilinear = false;
this.myPipeline = null;
this.g = g4;
this.bufferIndex = 0;
kgraphics4_TextShaderPainter.initShaders();
this.initBuffers();
this.projectionLocation = kgraphics4_TextShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix");
this.textureLocation = kgraphics4_TextShaderPainter.shaderPipeline.getTextureUnit("tex");
};
xClasses["kha.graphics4.TextShaderPainter"] = kgraphics4_TextShaderPainter;
kgraphics4_TextShaderPainter.nom = true;
kgraphics4_TextShaderPainter.initShaders = function() {
if(kgraphics4_TextShaderPainter.shaderPipeline != null) {
return;
}
kgraphics4_TextShaderPainter.shaderPipeline = new kgraphics4_PipelineState();
kgraphics4_TextShaderPainter.shaderPipeline.fragmentShader = kShaders.painter_text_frag;
kgraphics4_TextShaderPainter.shaderPipeline.vertexShader = kShaders.painter_text_vert;
kgraphics4_TextShaderPainter.structure = new kgraphics4_VertexStructure();
kgraphics4_TextShaderPainter.structure.add("vertexPosition",kgraphics4_VertexData.Float3);
kgraphics4_TextShaderPainter.structure.add("texPosition",kgraphics4_VertexData.Float2);
kgraphics4_TextShaderPainter.structure.add("vertexColor",kgraphics4_VertexData.Float4);
kgraphics4_TextShaderPainter.shaderPipeline.inputLayout = [kgraphics4_TextShaderPainter.structure];
kgraphics4_TextShaderPainter.shaderPipeline.blendSource = kgraphics4_BlendingFactor.SourceAlpha;
kgraphics4_TextShaderPainter.shaderPipeline.blendDestination = kgraphics4_BlendingFactor.InverseSourceAlpha;
kgraphics4_TextShaderPainter.shaderPipeline.alphaBlendSource = kgraphics4_BlendingFactor.SourceAlpha;
kgraphics4_TextShaderPainter.shaderPipeline.alphaBlendDestination = kgraphics4_BlendingFactor.InverseSourceAlpha;
kgraphics4_TextShaderPainter.shaderPipeline.compile();
};
kgraphics4_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;
};
kgraphics4_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 = kgraphics4_TextShaderPainter.shaderPipeline.getConstantLocation("projectionMatrix");
this.textureLocation = kgraphics4_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 kgraphics4_VertexBuffer(kgraphics4_TextShaderPainter.bufferSize * 4,kgraphics4_TextShaderPainter.structure,kgraphics4_Usage.DynamicUsage);
this.rectVertices = this.rectVertexBuffer.lock();
this.indexBuffer = new kgraphics4_IndexBuffer(kgraphics4_TextShaderPainter.bufferSize * 3 * 2,kgraphics4_Usage.StaticUsage);
var indices = this.indexBuffer.lock();
var _g1 = 0;
var _g = kgraphics4_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 ? kgraphics4_TextShaderPainter.shaderPipeline : this.get_pipeline());
this.g.setTexture(this.textureLocation,this.lastTexture);
this.g.setMatrix(this.projectionLocation,this.projectionMatrix);
this.g.setTextureParameters(this.textureLocation,kgraphics4_TextureAddressing.Clamp,kgraphics4_TextureAddressing.Clamp,this.bilinear ? kgraphics4_TextureFilter.LinearFilter : kgraphics4_TextureFilter.PointFilter,this.bilinear ? kgraphics4_TextureFilter.LinearFilter : kgraphics4_TextureFilter.PointFilter,kgraphics4_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 = jsBoot.__cast(font , kKravur);
}
,text: null
,startString: function(text) {
this.text = text;
}
,charCodeAt: function(position) {
return xOverrides.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(kgraphics4_TextShaderPainter.findIndex(this.charCodeAt(i),fontGlyphs),xpos,ypos);
if(q != null) {
if(this.bufferIndex + 1 >= kgraphics4_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__: kgraphics4_TextShaderPainter
};
var kgraphics4_Graphics2 = function(canvas) {
this.myMipmapScaleQuality = kgraphics2_ImageScaleQuality.High;
this.myImageScaleQuality = kgraphics2_ImageScaleQuality.High;
kgraphics2_Graphics.call(this);
this.set_color(-1);
this.canvas = canvas;
this.g = canvas.get_g4();
this.imagePainter = new kgraphics4_ImageShaderPainter(this.g);
this.coloredPainter = new kgraphics4_ColoredShaderPainter(this.g);
this.textPainter = new kgraphics4_TextShaderPainter(this.g);
this.textPainter.fontSize = this.get_fontSize();
this.setProjection();
if(kgraphics4_Graphics2.videoPipeline == null) {
kgraphics4_Graphics2.videoPipeline = new kgraphics4_PipelineState();
kgraphics4_Graphics2.videoPipeline.fragmentShader = kShaders.painter_video_frag;
kgraphics4_Graphics2.videoPipeline.vertexShader = kShaders.painter_video_vert;
var structure = new kgraphics4_VertexStructure();
structure.add("vertexPosition",kgraphics4_VertexData.Float3);
structure.add("texPosition",kgraphics4_VertexData.Float2);
structure.add("vertexColor",kgraphics4_VertexData.Float4);
kgraphics4_Graphics2.videoPipeline.inputLayout = [structure];
kgraphics4_Graphics2.videoPipeline.compile();
}
};
xClasses["kha.graphics4.Graphics2"] = kgraphics4_Graphics2;
kgraphics4_Graphics2.nom = true;
kgraphics4_Graphics2.upperPowerOfTwo = function(v) {
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return ++v;
};
kgraphics4_Graphics2.__super__ = kgraphics2_Graphics;
kgraphics4_Graphics2.prototype = $extend(kgraphics2_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(jsBoot.__instanceof(this.canvas,kFramebuffer)) {
this.projectionMatrix = kmath_FastMatrix4.orthogonalProjection(0,width,height,0,0.1,1000);
} else {
if(!kImage.get_nonPow2Supported()) {
width = kgraphics4_Graphics2.upperPowerOfTwo(width);
height = kgraphics4_Graphics2.upperPowerOfTwo(height);
}
if(this.g.renderTargetsInvertedY()) {
this.projectionMatrix = kmath_FastMatrix4.orthogonalProjection(0,width,0,height,0.1,1000);
} else {
this.projectionMatrix = kmath_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 >= kgraphics4_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 * kgraphics4_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 * kgraphics4_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 * kgraphics4_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 >= kgraphics4_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 * kgraphics4_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 * kgraphics4_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 * kgraphics4_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 kgraphics2_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 kmath_FastVector2(0,-1);
} else {
vec = new kmath_FastVector2(1,-(x2 - x1) / (y2 - y1));
}
vec.set_length(strength);
var p1 = new kmath_FastVector2(x1 + 0.5 * vec.x,y1 + 0.5 * vec.y);
var p2 = new kmath_FastVector2(x2 + 0.5 * vec.x,y2 + 0.5 * vec.y);
var p3 = new kmath_FastVector2(p1.x - vec.x,p1.y - vec.y);
var p4 = new kmath_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 kmath_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 kmath_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 kmath_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 kmath_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 == kgraphics2_ImageScaleQuality.High);
this.textPainter.setBilinearFilter(value == kgraphics2_ImageScaleQuality.High);
return this.myImageScaleQuality = value;
}
,myMipmapScaleQuality: null
,get_mipmapScaleQuality: function() {
return this.myMipmapScaleQuality;
}
,set_mipmapScaleQuality: function(value) {
this.imagePainter.setBilinearMipmapFilter(value == kgraphics2_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(kgraphics4_Graphics2.videoPipeline);
this.drawVideoInternal(video,x,y,width,height);
this.setPipeline(null);
}
,__class__: kgraphics4_Graphics2
});
var kgraphics4_IndexBuffer = function(indexCount,usage,canRead) {
if(canRead == null) {
canRead = false;
}
this.usage = usage;
this.mySize = indexCount;
this.buffer = kSystemImpl.gl.createBuffer();
var this1 = new Uint32Array(indexCount);
this._data = this1;
};
xClasses["kha.graphics4.IndexBuffer"] = kgraphics4_IndexBuffer;
kgraphics4_IndexBuffer.nom = true;
kgraphics4_IndexBuffer.prototype = {
buffer: null
,_data: null
,mySize: null
,usage: null
,'delete': function() {
this._data = null;
kSystemImpl.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() {
kSystemImpl.gl.bindBuffer(34963,this.buffer);
var glData = kSystemImpl.elementIndexUint == null ? new Uint16Array(this._data) : this._data;
kSystemImpl.gl.bufferData(34963,glData,this.usage == kgraphics4_Usage.DynamicUsage ? 35048 : 35044);
}
,set: function() {
kSystemImpl.gl.bindBuffer(34963,this.buffer);
}
,count: function() {
return this.mySize;
}
,__class__: kgraphics4_IndexBuffer
};
var kgraphics4_MipMapFilter = xClasses["kha.graphics4.MipMapFilter"] = { __ename__ : true, __constructs__ : ["NoMipFilter","PointMipFilter","LinearMipFilter"] };
kgraphics4_MipMapFilter.NoMipFilter = ["NoMipFilter",0];
kgraphics4_MipMapFilter.NoMipFilter.toString = $estr;
kgraphics4_MipMapFilter.NoMipFilter.__enum__ = kgraphics4_MipMapFilter;
kgraphics4_MipMapFilter.PointMipFilter = ["PointMipFilter",1];
kgraphics4_MipMapFilter.PointMipFilter.toString = $estr;
kgraphics4_MipMapFilter.PointMipFilter.__enum__ = kgraphics4_MipMapFilter;
kgraphics4_MipMapFilter.LinearMipFilter = ["LinearMipFilter",2];
kgraphics4_MipMapFilter.LinearMipFilter.toString = $estr;
kgraphics4_MipMapFilter.LinearMipFilter.__enum__ = kgraphics4_MipMapFilter;
var kgraphics4_PipelineStateBase = function() {
this.inputLayout = null;
this.vertexShader = null;
this.fragmentShader = null;
this.geometryShader = null;
this.tessellationControlShader = null;
this.tessellationEvaluationShader = null;
this.cullMode = kgraphics4_CullMode.None;
this.depthWrite = false;
this.depthMode = kgraphics4_CompareMode.Always;
this.stencilMode = kgraphics4_CompareMode.Always;
this.stencilBothPass = kgraphics4_StencilAction.Keep;
this.stencilDepthFail = kgraphics4_StencilAction.Keep;
this.stencilFail = kgraphics4_StencilAction.Keep;
this.stencilReferenceValue = 0;
this.stencilReadMask = 255;
this.stencilWriteMask = 255;
this.blendSource = kgraphics4_BlendingFactor.BlendOne;
this.blendDestination = kgraphics4_BlendingFactor.BlendZero;
this.blendOperation = kgraphics4_BlendingOperation.Add;
this.alphaBlendSource = kgraphics4_BlendingFactor.BlendOne;
this.alphaBlendDestination = kgraphics4_BlendingFactor.BlendZero;
this.alphaBlendOperation = kgraphics4_BlendingOperation.Add;
this.colorWriteMaskRed = this.colorWriteMaskBlue = this.colorWriteMaskGreen = this.colorWriteMaskAlpha = true;
this.conservativeRasterization = false;
};
xClasses["kha.graphics4.PipelineStateBase"] = kgraphics4_PipelineStateBase;
kgraphics4_PipelineStateBase.nom = true;
kgraphics4_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__: kgraphics4_PipelineStateBase
};
var kgraphics4_PipelineState = function() {
kgraphics4_PipelineStateBase.call(this);
this.program = kSystemImpl.gl.createProgram();
this.textures = [];
this.textureValues = [];
};
xClasses["kha.graphics4.PipelineState"] = kgraphics4_PipelineState;
kgraphics4_PipelineState.nom = true;
kgraphics4_PipelineState.__super__ = kgraphics4_PipelineStateBase;
kgraphics4_PipelineState.prototype = $extend(kgraphics4_PipelineStateBase.prototype,{
program: null
,textures: null
,textureValues: null
,'delete': function() {
kSystemImpl.gl.deleteProgram(this.program);
}
,compile: function() {
this.compileShader(this.vertexShader);
this.compileShader(this.fragmentShader);
kSystemImpl.gl.attachShader(this.program,this.vertexShader.shader);
kSystemImpl.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;
kSystemImpl.gl.bindAttribLocation(this.program,index,element.name);
if(element.data == kgraphics4_VertexData.Float4x4) {
index += 4;
} else {
++index;
}
}
}
kSystemImpl.gl.linkProgram(this.program);
if(!kSystemImpl.gl.getProgramParameter(this.program,35714)) {
throw new jsxBoot_HaxeError("Could not link the shader program:\n" + kSystemImpl.gl.getProgramInfoLog(this.program));
}
}
,set: function() {
kSystemImpl.gl.useProgram(this.program);
var _g1 = 0;
var _g = this.textureValues.length;
while(_g1 < _g) {
var index = _g1++;
kSystemImpl.gl.uniform1i(this.textureValues[index],index);
}
kSystemImpl.gl.colorMask(this.colorWriteMaskRed,this.colorWriteMaskGreen,this.colorWriteMaskBlue,this.colorWriteMaskAlpha);
}
,compileShader: function(shader) {
if(shader.shader != null) {
return;
}
var s = kSystemImpl.gl.createShader(shader.type);
var highp = kSystemImpl.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(kSystemImpl.gl2) {
if(files[i].indexOf("-webgl2") >= 0 || files[i].indexOf("runtime-string") >= 0) {
kSystemImpl.gl.shaderSource(s,shader.sources[i]);
break;
}
} else {
if(!highpSupported && files[i].indexOf("-relaxed") >= 0) {
kSystemImpl.gl.shaderSource(s,shader.sources[i]);
break;
}
if(highpSupported && files[i].indexOf("-relaxed") < 0) {
kSystemImpl.gl.shaderSource(s,shader.sources[i]);
break;
}
}
}
kSystemImpl.gl.compileShader(s);
if(!kSystemImpl.gl.getShaderParameter(s,35713)) {
throw new jsxBoot_HaxeError("Could not compile shader:\n" + kSystemImpl.gl.getShaderInfoLog(s));
}
shader.shader = s;
}
,getConstantLocation: function(name) {
var location = kSystemImpl.gl.getUniformLocation(this.program,name);
var type = 5126;
var count = kSystemImpl.gl.getProgramParameter(this.program,35718);
var _g1 = 0;
var _g = count;
while(_g1 < _g) {
var i = _g1++;
var info = kSystemImpl.gl.getActiveUniform(this.program,i);
if(info.name == name || info.name == name + "[0]") {
type = info.type;
break;
}
}
return new kjsgraphics4_ConstantLocation(location,type);
}
,getTextureUnit: function(name) {
var index = this.findTexture(name);
if(index < 0) {
var location = kSystemImpl.gl.getUniformLocation(this.program,name);
index = this.textures.length;
this.textureValues.push(location);
this.textures.push(name);
}
return new kjsgraphics4_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__: kgraphics4_PipelineState
});
var kgraphics4_StencilAction = xClasses["kha.graphics4.StencilAction"] = { __ename__ : true, __constructs__ : ["Keep","Zero","Replace","Increment","IncrementWrap","Decrement","DecrementWrap","Invert"] };
kgraphics4_StencilAction.Keep = ["Keep",0];
kgraphics4_StencilAction.Keep.toString = $estr;
kgraphics4_StencilAction.Keep.__enum__ = kgraphics4_StencilAction;
kgraphics4_StencilAction.Zero = ["Zero",1];
kgraphics4_StencilAction.Zero.toString = $estr;
kgraphics4_StencilAction.Zero.__enum__ = kgraphics4_StencilAction;
kgraphics4_StencilAction.Replace = ["Replace",2];
kgraphics4_StencilAction.Replace.toString = $estr;
kgraphics4_StencilAction.Replace.__enum__ = kgraphics4_StencilAction;
kgraphics4_StencilAction.Increment = ["Increment",3];
kgraphics4_StencilAction.Increment.toString = $estr;
kgraphics4_StencilAction.Increment.__enum__ = kgraphics4_StencilAction;
kgraphics4_StencilAction.IncrementWrap = ["IncrementWrap",4];
kgraphics4_StencilAction.IncrementWrap.toString = $estr;
kgraphics4_StencilAction.IncrementWrap.__enum__ = kgraphics4_StencilAction;
kgraphics4_StencilAction.Decrement = ["Decrement",5];
kgraphics4_StencilAction.Decrement.toString = $estr;
kgraphics4_StencilAction.Decrement.__enum__ = kgraphics4_StencilAction;
kgraphics4_StencilAction.DecrementWrap = ["DecrementWrap",6];
kgraphics4_StencilAction.DecrementWrap.toString = $estr;
kgraphics4_StencilAction.DecrementWrap.__enum__ = kgraphics4_StencilAction;
kgraphics4_StencilAction.Invert = ["Invert",7];
kgraphics4_StencilAction.Invert.toString = $estr;
kgraphics4_StencilAction.Invert.__enum__ = kgraphics4_StencilAction;
var kgraphics4_TessellationControlShader = function(source,file) {
};
xClasses["kha.graphics4.TessellationControlShader"] = kgraphics4_TessellationControlShader;
kgraphics4_TessellationControlShader.nom = true;
kgraphics4_TessellationControlShader.prototype = {
'delete': function() {
}
,__class__: kgraphics4_TessellationControlShader
};
var kgraphics4_TessellationEvaluationShader = function(source,file) {
};
xClasses["kha.graphics4.TessellationEvaluationShader"] = kgraphics4_TessellationEvaluationShader;
kgraphics4_TessellationEvaluationShader.nom = true;
kgraphics4_TessellationEvaluationShader.prototype = {
'delete': function() {
}
,__class__: kgraphics4_TessellationEvaluationShader
};
var kgraphics4_TexDir = xClasses["kha.graphics4.TexDir"] = { __ename__ : true, __constructs__ : ["U","V"] };
kgraphics4_TexDir.U = ["U",0];
kgraphics4_TexDir.U.toString = $estr;
kgraphics4_TexDir.U.__enum__ = kgraphics4_TexDir;
kgraphics4_TexDir.V = ["V",1];
kgraphics4_TexDir.V.toString = $estr;
kgraphics4_TexDir.V.__enum__ = kgraphics4_TexDir;
var kgraphics4_TextureAddressing = xClasses["kha.graphics4.TextureAddressing"] = { __ename__ : true, __constructs__ : ["Repeat","Mirror","Clamp"] };
kgraphics4_TextureAddressing.Repeat = ["Repeat",0];
kgraphics4_TextureAddressing.Repeat.toString = $estr;
kgraphics4_TextureAddressing.Repeat.__enum__ = kgraphics4_TextureAddressing;
kgraphics4_TextureAddressing.Mirror = ["Mirror",1];
kgraphics4_TextureAddressing.Mirror.toString = $estr;
kgraphics4_TextureAddressing.Mirror.__enum__ = kgraphics4_TextureAddressing;
kgraphics4_TextureAddressing.Clamp = ["Clamp",2];
kgraphics4_TextureAddressing.Clamp.toString = $estr;
kgraphics4_TextureAddressing.Clamp.__enum__ = kgraphics4_TextureAddressing;
var kgraphics4_TextureFilter = xClasses["kha.graphics4.TextureFilter"] = { __ename__ : true, __constructs__ : ["PointFilter","LinearFilter","AnisotropicFilter"] };
kgraphics4_TextureFilter.PointFilter = ["PointFilter",0];
kgraphics4_TextureFilter.PointFilter.toString = $estr;
kgraphics4_TextureFilter.PointFilter.__enum__ = kgraphics4_TextureFilter;
kgraphics4_TextureFilter.LinearFilter = ["LinearFilter",1];
kgraphics4_TextureFilter.LinearFilter.toString = $estr;
kgraphics4_TextureFilter.LinearFilter.__enum__ = kgraphics4_TextureFilter;
kgraphics4_TextureFilter.AnisotropicFilter = ["AnisotropicFilter",2];
kgraphics4_TextureFilter.AnisotropicFilter.toString = $estr;
kgraphics4_TextureFilter.AnisotropicFilter.__enum__ = kgraphics4_TextureFilter;
var kgraphics4_TextureFormat = xClasses["kha.graphics4.TextureFormat"] = { __ename__ : true, __constructs__ : ["RGBA32","L8","RGBA128","DEPTH16","RGBA64","A32","A16"] };
kgraphics4_TextureFormat.RGBA32 = ["RGBA32",0];
kgraphics4_TextureFormat.RGBA32.toString = $estr;
kgraphics4_TextureFormat.RGBA32.__enum__ = kgraphics4_TextureFormat;
kgraphics4_TextureFormat.L8 = ["L8",1];
kgraphics4_TextureFormat.L8.toString = $estr;
kgraphics4_TextureFormat.L8.__enum__ = kgraphics4_TextureFormat;
kgraphics4_TextureFormat.RGBA128 = ["RGBA128",2];
kgraphics4_TextureFormat.RGBA128.toString = $estr;
kgraphics4_TextureFormat.RGBA128.__enum__ = kgraphics4_TextureFormat;
kgraphics4_TextureFormat.DEPTH16 = ["DEPTH16",3];
kgraphics4_TextureFormat.DEPTH16.toString = $estr;
kgraphics4_TextureFormat.DEPTH16.__enum__ = kgraphics4_TextureFormat;
kgraphics4_TextureFormat.RGBA64 = ["RGBA64",4];
kgraphics4_TextureFormat.RGBA64.toString = $estr;
kgraphics4_TextureFormat.RGBA64.__enum__ = kgraphics4_TextureFormat;
kgraphics4_TextureFormat.A32 = ["A32",5];
kgraphics4_TextureFormat.A32.toString = $estr;
kgraphics4_TextureFormat.A32.__enum__ = kgraphics4_TextureFormat;
kgraphics4_TextureFormat.A16 = ["A16",6];
kgraphics4_TextureFormat.A16.toString = $estr;
kgraphics4_TextureFormat.A16.__enum__ = kgraphics4_TextureFormat;
var kgraphics4_TextureUnit = function() { };
xClasses["kha.graphics4.TextureUnit"] = kgraphics4_TextureUnit;
kgraphics4_TextureUnit.nom = true;
var kgraphics4_Usage = xClasses["kha.graphics4.Usage"] = { __ename__ : true, __constructs__ : ["StaticUsage","DynamicUsage","ReadableUsage"] };
kgraphics4_Usage.StaticUsage = ["StaticUsage",0];
kgraphics4_Usage.StaticUsage.toString = $estr;
kgraphics4_Usage.StaticUsage.__enum__ = kgraphics4_Usage;
kgraphics4_Usage.DynamicUsage = ["DynamicUsage",1];
kgraphics4_Usage.DynamicUsage.toString = $estr;
kgraphics4_Usage.DynamicUsage.__enum__ = kgraphics4_Usage;
kgraphics4_Usage.ReadableUsage = ["ReadableUsage",2];
kgraphics4_Usage.ReadableUsage.toString = $estr;
kgraphics4_Usage.ReadableUsage.__enum__ = kgraphics4_Usage;
var kgraphics4_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 = kSystemImpl.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;
}
};
xClasses["kha.graphics4.VertexBuffer"] = kgraphics4_VertexBuffer;
kgraphics4_VertexBuffer.nom = true;
kgraphics4_VertexBuffer.prototype = {
buffer: null
,_data: null
,mySize: null
,myStride: null
,sizes: null
,offsets: null
,usage: null
,instanceDataStepRate: null
,'delete': function() {
this._data = null;
kSystemImpl.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() {
kSystemImpl.gl.bindBuffer(34962,this.buffer);
kSystemImpl.gl.bufferData(34962,this._data,this.usage == kgraphics4_Usage.DynamicUsage ? 35048 : 35044);
}
,stride: function() {
return this.myStride;
}
,count: function() {
return this.mySize;
}
,set: function(offset) {
var ext = kSystemImpl.gl2 ? true : kSystemImpl.gl.getExtension("ANGLE_instanced_arrays");
kSystemImpl.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) {
kSystemImpl.gl.enableVertexAttribArray(offset + attributesOffset);
kSystemImpl.gl.vertexAttribPointer(offset + attributesOffset,4,5126,false,this.myStride,this.offsets[i] + addonOffset);
if(ext) {
if(kSystemImpl.gl2) {
kSystemImpl.gl.vertexAttribDivisor(offset + attributesOffset,this.instanceDataStepRate);
} else {
ext.vertexAttribDivisorANGLE(offset + attributesOffset,this.instanceDataStepRate);
}
}
size -= 4;
addonOffset += 16;
++attributesOffset;
}
} else {
kSystemImpl.gl.enableVertexAttribArray(offset + attributesOffset);
kSystemImpl.gl.vertexAttribPointer(offset + attributesOffset,this.sizes[i],5126,false,this.myStride,this.offsets[i]);
if(ext) {
if(kSystemImpl.gl2) {
kSystemImpl.gl.vertexAttribDivisor(offset + attributesOffset,this.instanceDataStepRate);
} else {
ext.vertexAttribDivisorANGLE(offset + attributesOffset,this.instanceDataStepRate);
}
}
++attributesOffset;
}
}
return attributesOffset;
}
,__class__: kgraphics4_VertexBuffer
};
var kgraphics4_VertexData = xClasses["kha.graphics4.VertexData"] = { __ename__ : true, __constructs__ : ["Float1","Float2","Float3","Float4","Float4x4"] };
kgraphics4_VertexData.Float1 = ["Float1",0];
kgraphics4_VertexData.Float1.toString = $estr;
kgraphics4_VertexData.Float1.__enum__ = kgraphics4_VertexData;
kgraphics4_VertexData.Float2 = ["Float2",1];
kgraphics4_VertexData.Float2.toString = $estr;
kgraphics4_VertexData.Float2.__enum__ = kgraphics4_VertexData;
kgraphics4_VertexData.Float3 = ["Float3",2];
kgraphics4_VertexData.Float3.toString = $estr;
kgraphics4_VertexData.Float3.__enum__ = kgraphics4_VertexData;
kgraphics4_VertexData.Float4 = ["Float4",3];
kgraphics4_VertexData.Float4.toString = $estr;
kgraphics4_VertexData.Float4.__enum__ = kgraphics4_VertexData;
kgraphics4_VertexData.Float4x4 = ["Float4x4",4];
kgraphics4_VertexData.Float4x4.toString = $estr;
kgraphics4_VertexData.Float4x4.__enum__ = kgraphics4_VertexData;
var kgraphics4_VertexElement = function(name,data) {
this.name = name;
this.data = data;
};
xClasses["kha.graphics4.VertexElement"] = kgraphics4_VertexElement;
kgraphics4_VertexElement.nom = true;
kgraphics4_VertexElement.prototype = {
name: null
,data: null
,__class__: kgraphics4_VertexElement
};
var kgraphics4_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;
};
xClasses["kha.graphics4.VertexShader"] = kgraphics4_VertexShader;
kgraphics4_VertexShader.nom = true;
kgraphics4_VertexShader.fromSource = function(source) {
var shader = new kgraphics4_VertexShader([],["runtime-string"]);
shader.sources.push(source);
return shader;
};
kgraphics4_VertexShader.prototype = {
sources: null
,type: null
,shader: null
,files: null
,'delete': function() {
kSystemImpl.gl.deleteShader(this.shader);
this.shader = null;
this.sources = null;
}
,__class__: kgraphics4_VertexShader
};
var kgraphics4_VertexStructure = function() {
this.elements = [];
};
xClasses["kha.graphics4.VertexStructure"] = kgraphics4_VertexStructure;
kgraphics4_VertexStructure.nom = true;
kgraphics4_VertexStructure.prototype = {
elements: null
,add: function(name,data) {
this.elements.push(new kgraphics4_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__: kgraphics4_VertexStructure
};
var kinput_Gamepad = xExport["kha"]["input"]["Gamepad"] = function(index,id) {
if(id == null) {
id = "unknown";
}
if(index == null) {
index = 0;
}
this.index = index;
this.axisListeners = [];
this.buttonListeners = [];
kinput_Gamepad.instances[index] = this;
};
xClasses["kha.input.Gamepad"] = kinput_Gamepad;
kinput_Gamepad.nom = true;
kinput_Gamepad.get = function(index) {
if(index == null) {
index = 0;
}
if(index >= kinput_Gamepad.instances.length) {
return null;
}
return kinput_Gamepad.instances[index];
};
kinput_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) {
xOverrides.remove(this.axisListeners,axisListener);
}
if(buttonListener != null) {
xOverrides.remove(this.buttonListeners,buttonListener);
}
}
,axisListeners: null
,buttonListeners: null
,id: null
,get_id: function() {
return kSystemImpl.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__: kinput_Gamepad
};
var kinput_KeyCode = function() { };
xClasses["kha.input.KeyCode"] = kinput_KeyCode;
kinput_KeyCode.nom = true;
var knetwork_Controller = function() {
this.__id = knetwork_ControllerBuilder.nextId++;
this._inputBuffer = new haxe_io_Bytes(new ArrayBuffer(1));
};
xClasses["kha.network.Controller"] = knetwork_Controller;
knetwork_Controller.nom = true;
knetwork_Controller.prototype = {
__id: null
,_inputBufferIndex: null
,_inputBuffer: null
,_id: function() {
return this.__id;
}
,_receive: function(bytes) {
}
,__class__: knetwork_Controller
};
var kinput_Keyboard = xExport["kha"]["input"]["Keyboard"] = function() {
knetwork_Controller.call(this);
this.downListeners = [];
this.upListeners = [];
this.pressListeners = [];
kinput_Keyboard.instance = this;
};
xClasses["kha.input.Keyboard"] = kinput_Keyboard;
kinput_Keyboard.nom = true;
kinput_Keyboard.get = function(num) {
if(num == null) {
num = 0;
}
return kSystemImpl.getKeyboard(num);
};
kinput_Keyboard.__super__ = knetwork_Controller;
kinput_Keyboard.prototype = $extend(knetwork_Controller.prototype,{
notify: function(downListener,upListener,pressListener) {
if(downListener != null) {
this.downListeners.push(downListener);
}
if(upListener != null) {
this.upListeners.push(upListener);
}
if(pressListener != null) {
this.pressListeners.push(pressListener);
}
}
,remove: function(downListener,upListener,pressListener) {
if(downListener != null) {
xOverrides.remove(this.downListeners,downListener);
}
if(upListener != null) {
xOverrides.remove(this.upListeners,upListener);
}
if(pressListener != null) {
xOverrides.remove(this.pressListeners,pressListener);
}
}
,show: function() {
}
,hide: function() {
}
,downListeners: null
,upListeners: null
,pressListeners: null
,sendDownEvent: function(code) {
if(knetwork_Session.the() != null) {
var bytes = new haxe_io_Bytes(new ArrayBuffer(8));
bytes.setInt32(0,0);
bytes.setInt32(4,code);
knetwork_Session.the().sendControllerUpdate(this._id(),bytes);
}
var _g = 0;
var _g1 = this.downListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener(code);
}
}
,sendUpEvent: function(code) {
if(knetwork_Session.the() != null) {
var bytes = new haxe_io_Bytes(new ArrayBuffer(8));
bytes.setInt32(0,1);
bytes.setInt32(4,code);
knetwork_Session.the().sendControllerUpdate(this._id(),bytes);
}
var _g = 0;
var _g1 = this.upListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener(code);
}
}
,sendPressEvent: function($char) {
if(knetwork_Session.the() != null) {
var bytes = new haxe_io_Bytes(new ArrayBuffer(5));
bytes.setInt32(0,2);
var v = xOverrides.cca($char,0);
bytes.b[4] = v & 255;
knetwork_Session.the().sendControllerUpdate(this._id(),bytes);
}
var _g = 0;
var _g1 = this.pressListeners;
while(_g < _g1.length) {
var listener = _g1[_g];
++_g;
listener($char);
}
}
,_receive: function(bytes) {
var funcindex = bytes.getInt32(0);
if(funcindex == 0) {
var input0 = bytes.getInt32(4);
this.sendDownEvent(input0);
return;
}
if(funcindex == 1) {
var input01 = bytes.getInt32(4);
this.sendUpEvent(input01);
return;
}
if(funcindex == 2) {
var input02 = String.fromCharCode(bytes.b[4]);
this.sendPressEvent(input02);
return;
}
}
,__class__: kinput_Keyboard
});
var kinput_Mouse = xExport["kha"]["input"]["Mouse"] = function() {
knetwork_Controller.call(this);
kinput_Mouse.instance = this;
};
xClasses["kha.input.Mouse"] = kinput_Mouse;
kinput_Mouse.nom = true;
kinput_Mouse.get = function(num) {
if(num == null) {
num = 0;
}
return kSystemImpl.getMouse(num);
};
kinput_Mouse.__super__ = knetwork_Controller;
kinput_Mouse.prototype = $extend(knetwork_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) {
xOverrides.remove(this.windowDownListeners[windowId],downListener);
} else {
haxe_Log.trace("no downListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.x", lineNumber : 88, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
} else {
haxe_Log.trace("no downListeners were ever registered",{ fileName : "Mouse.x", lineNumber : 91, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
}
if(upListener != null) {
if(this.windowUpListeners != null) {
if(windowId < this.windowUpListeners.length) {
xOverrides.remove(this.windowUpListeners[windowId],upListener);
} else {
haxe_Log.trace("no upListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.x", lineNumber : 100, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
} else {
haxe_Log.trace("no upListeners were ever registered",{ fileName : "Mouse.x", lineNumber : 103, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
}
if(moveListener != null) {
if(this.windowMoveListeners != null) {
if(windowId < this.windowMoveListeners.length) {
xOverrides.remove(this.windowMoveListeners[windowId],moveListener);
} else {
haxe_Log.trace("no moveListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.x", lineNumber : 112, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
} else {
haxe_Log.trace("no moveListeners were ever registered",{ fileName : "Mouse.x", lineNumber : 115, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
}
if(wheelListener != null) {
if(this.windowWheelListeners != null) {
if(windowId < this.windowWheelListeners.length) {
xOverrides.remove(this.windowWheelListeners[windowId],wheelListener);
} else {
haxe_Log.trace("no wheelListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.x", lineNumber : 124, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
} else {
haxe_Log.trace("no wheelListeners were ever registered",{ fileName : "Mouse.x", lineNumber : 127, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
}
if(leaveListener != null) {
if(this.windowLeaveListeners != null) {
if(windowId < this.windowLeaveListeners.length) {
xOverrides.remove(this.windowLeaveListeners[windowId],leaveListener);
} else {
haxe_Log.trace("no leaveListeners for window \"" + windowId + "\" are registered",{ fileName : "Mouse.x", lineNumber : 136, className : "kha.input.Mouse", methodName : "removeWindowed"});
}
} else {
haxe_Log.trace("no leaveListeners were ever registered",{ fileName : "Mouse.x", 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(knetwork_Session.the() != null) {
var bytes = new haxe_io_Bytes(new ArrayBuffer(8));
bytes.setInt32(0,0);
bytes.setInt32(4,windowId);
knetwork_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(knetwork_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);
knetwork_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(knetwork_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);
knetwork_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(knetwork_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);
knetwork_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(knetwork_Session.the() != null) {
var bytes = new haxe_io_Bytes(new ArrayBuffer(12));
bytes.setInt32(0,4);
bytes.setInt32(4,windowId);
bytes.setInt32(8,delta);
knetwork_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__: kinput_Mouse
});
var kinput_MouseImpl = function() {
kinput_Mouse.call(this);
};
xClasses["kha.input.MouseImpl"] = kinput_MouseImpl;
kinput_MouseImpl.nom = true;
kinput_MouseImpl.__super__ = kinput_Mouse;
kinput_MouseImpl.prototype = $extend(kinput_Mouse.prototype,{
hideSystemCursor: function() {
kSystemImpl.khanvas.style.cursor = "none";
}
,showSystemCursor: function() {
kSystemImpl.khanvas.style.cursor = "default";
}
,_receive: function(bytes) {
var funcindex = bytes.getInt32(0);
}
,__class__: kinput_MouseImpl
});
var kinput_Surface = xExport["kha"]["input"]["Surface"] = function() {
this.touchStartListeners = [];
this.touchEndListeners = [];
this.moveListeners = [];
kinput_Surface.instance = this;
};
xClasses["kha.input.Surface"] = kinput_Surface;
kinput_Surface.nom = true;
kinput_Surface.get = function(num) {
if(num == null) {
num = 0;
}
if(num != 0) {
return null;
}
return kinput_Surface.instance;
};
kinput_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) {
xOverrides.remove(this.touchStartListeners,touchStartListener);
}
if(touchEndListener != null) {
xOverrides.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__: kinput_Surface
};
var kinternal_BytesBlob = function(bytes) {
this.myFirstLine = true;
this.bytes = bytes;
this.buffer = [];
};
xClasses["kha.internal.BytesBlob"] = kinternal_BytesBlob;
kinternal_BytesBlob.nom = true;
kinternal_BytesBlob.__interfaces__ = [kResource];
kinternal_BytesBlob.fromBytes = function(bytes) {
return new kinternal_BytesBlob(bytes);
};
kinternal_BytesBlob.alloc = function(size) {
return new kinternal_BytesBlob(new haxe_io_Bytes(new ArrayBuffer(size)));
};
kinternal_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);
}
};
kinternal_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;
}
};
kinternal_BytesBlob.prototype = {
bytes: null
,buffer: null
,myFirstLine: null
,sub: function(start,length) {
return new kinternal_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 kinternal_BytesBlob.readF32(this.readS32LE(position));
}
,readF32BE: function(position) {
return kinternal_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(!kinternal_BytesBlob.bit(c,7)) {
value = c;
} else if(kinternal_BytesBlob.bit(c,7) && kinternal_BytesBlob.bit(c,6) && !kinternal_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(kinternal_BytesBlob.bit(c,7) && kinternal_BytesBlob.bit(c,6) && kinternal_BytesBlob.bit(c,5) && !kinternal_BytesBlob.bit(c,4)) {
position.value += 2;
} else if(kinternal_BytesBlob.bit(c,7) && kinternal_BytesBlob.bit(c,6) && kinternal_BytesBlob.bit(c,5) && kinternal_BytesBlob.bit(c,4) && !kinternal_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__: kinternal_BytesBlob
};
var kinternal_HdrFormat = function() {
};
xClasses["kha.internal.HdrFormat"] = kinternal_HdrFormat;
kinternal_HdrFormat.nom = true;
kinternal_HdrFormat.readBuf = function(buf) {
var bytesRead = 0;
while(true) {
buf[bytesRead++] = kinternal_HdrFormat.buffer[kinternal_HdrFormat.fileOffset] & 255;
if(!(++kinternal_HdrFormat.fileOffset < kinternal_HdrFormat.bufferLength && bytesRead < buf.length)) {
break;
}
}
return bytesRead;
};
kinternal_HdrFormat.readBufOffset = function(buf,offset,length) {
var bytesRead = 0;
while(true) {
buf[offset + bytesRead++] = kinternal_HdrFormat.buffer[kinternal_HdrFormat.fileOffset] & 255;
if(!(++kinternal_HdrFormat.fileOffset < kinternal_HdrFormat.bufferLength && bytesRead < length)) {
break;
}
}
return bytesRead;
};
kinternal_HdrFormat.readPixelsRaw = function(buffer,data,offset,numpixels) {
var numExpected = 4 * numpixels;
var numRead = kinternal_HdrFormat.readBufOffset(data,offset,numExpected);
if(numRead < numExpected) {
haxe_Log.trace("Error reading raw pixels: got " + numRead + " bytes, expected " + numExpected,{ fileName : "HdrFormat.x", lineNumber : 43, className : "kha.internal.HdrFormat", methodName : "readPixelsRaw"});
return;
}
};
kinternal_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(kinternal_HdrFormat.readBuf(rgbe) < rgbe.length) {
haxe_Log.trace("Error reading bytes: expected " + rgbe.length,{ fileName : "HdrFormat.x", 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;
kinternal_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.x", 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(kinternal_HdrFormat.readBuf(buf) < buf.length) {
haxe_Log.trace("Error reading 2-byte buffer",{ fileName : "HdrFormat.x", 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.x", 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.x", lineNumber : 106, className : "kha.internal.HdrFormat", methodName : "readPixelsRawRLE"});
return;
}
scanline_buffer[ptr++] = buf[1] & 255;
if(--count > 0) {
if(kinternal_HdrFormat.readBufOffset(scanline_buffer,ptr,count) < count) {
haxe_Log.trace("Error reading non-run data",{ fileName : "HdrFormat.x", 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;
}
};
kinternal_HdrFormat.readLine = function() {
var buf = "";
while(true) {
var b = kinternal_HdrFormat.buffer[kinternal_HdrFormat.fileOffset];
if(b == 10) {
++kinternal_HdrFormat.fileOffset;
break;
}
buf += String.fromCharCode(b);
if(!(++kinternal_HdrFormat.fileOffset < kinternal_HdrFormat.bufferLength)) {
break;
}
}
return buf;
};
kinternal_HdrFormat.parse = function(bytes) {
kinternal_HdrFormat.buffer = haxe_io_xUInt8Array_UInt8ArrayxImplx.fromBytes(bytes);
kinternal_HdrFormat.bufferLength = kinternal_HdrFormat.buffer.length;
kinternal_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 = kinternal_HdrFormat.readLine();
if(kinternal_HdrFormat.formatPattern.match(line)) {
rle = true;
} else if(kinternal_HdrFormat.exposurePattern.match(line)) {
exposure = parseFloat(kinternal_HdrFormat.exposurePattern.matched(1));
} else if(kinternal_HdrFormat.widthHeightPattern.match(line)) {
height = Std.parseInt(kinternal_HdrFormat.widthHeightPattern.matched(1));
width = Std.parseInt(kinternal_HdrFormat.widthHeightPattern.matched(2));
break;
}
}
if(!rle) {
haxe_Log.trace("File is not run length encoded!",{ fileName : "HdrFormat.x", 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;
kinternal_HdrFormat.readPixelsRawRLE(kinternal_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};
};
kinternal_HdrFormat.prototype = {
__class__: kinternal_HdrFormat
};
var kjsAEAudioChannel = function(element) {
this.stopped = false;
this.element = element;
};
xClasses["kha.js.AEAudioChannel"] = kjsAEAudioChannel;
kjsAEAudioChannel.nom = true;
kjsAEAudioChannel.__interfaces__ = [kaudio1_AudioChannel];
kjsAEAudioChannel.prototype = {
element: null
,stopped: null
,play: function() {
this.stopped = false;
if(kSystemImpl.mobile) {
if(kSystemImpl.insideInputEvent) {
this.element.play();
kSystemImpl.mobileAudioPlaying = true;
} else if(kSystemImpl.mobileAudioPlaying) {
this.element.play();
} else {
kjsAEAudioChannel.todo.push(this);
}
} else {
this.element.play();
}
}
,pause: function() {
try {
this.element.pause();
} catch( e ) {
if (e instanceof jsxBoot_HaxeError) e = e.val;
haxe_Log.trace(e,{ fileName : "AEAudioChannel.x", 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 jsxBoot_HaxeError) e = e.val;
haxe_Log.trace(e,{ fileName : "AEAudioChannel.x", 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__: kjsAEAudioChannel
};
var kjsAudioElementAudio = function() { };
xClasses["kha.js.AudioElementAudio"] = kjsAudioElementAudio;
kjsAudioElementAudio.nom = true;
kjsAudioElementAudio._compile = function() {
};
kjsAudioElementAudio.play = function(sound,loop) {
if(loop == null) {
loop = false;
}
return kjsAudioElementAudio.stream(sound,loop);
};
kjsAudioElementAudio.stream = function(sound,loop) {
if(loop == null) {
loop = false;
}
sound.element.loop = loop;
var channel = new kjsAEAudioChannel(sound.element);
channel.play();
return channel;
};
var kjsCanvasGraphics = function(canvas) {
kgraphics2_Graphics.call(this);
this.canvas = canvas;
kjsCanvasGraphics.instance = this;
this.myColor = kxColor_ColorxImplx.fromBytes(0,0,0);
canvas.save();
};
xClasses["kha.js.CanvasGraphics"] = kjsCanvasGraphics;
kjsCanvasGraphics.nom = true;
kjsCanvasGraphics.stringWidth = function(font,text) {
if(kjsCanvasGraphics.instance == null) {
return 5 * text.length;
} else {
kjsCanvasGraphics.instance.set_font(font);
return kjsCanvasGraphics.instance.canvas.measureText(text).width;
}
};
kjsCanvasGraphics.__super__ = kgraphics2_Graphics;
kjsCanvasGraphics.prototype = $extend(kgraphics2_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((jsBoot.__cast(img , kCanvasImage)).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((jsBoot.__cast(image , kCanvasImage)).image,sx,sy,sw,sh,x,y,dw,dh);
this.canvas.restore();
} else {
this.canvas.drawImage((jsBoot.__cast(image , kCanvasImage)).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 == kgraphics2_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(xOverrides.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 = jsBoot.__cast(font , kjsFont);
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((jsBoot.__cast(video , kjsVideo)).element,x,y,width,height);
}
,setTransformation: function(transformation) {
this.canvas.setTransform(transformation._00,transformation._01,transformation._10,transformation._11,transformation._20,transformation._21);
}
,__class__: kjsCanvasGraphics
});
var kjsURLParser = 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);
}
};
xClasses["kha.js.URLParser"] = kjsURLParser;
kjsURLParser.nom = true;
kjsURLParser.parse = function(url) {
return new kjsURLParser(url);
};
kjsURLParser.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__: kjsURLParser
};
var kjsEnvironmentVariables = function() {
kEnvironmentVariables.call(this);
};
xClasses["kha.js.EnvironmentVariables"] = kjsEnvironmentVariables;
kjsEnvironmentVariables.nom = true;
kjsEnvironmentVariables.__super__ = kEnvironmentVariables;
kjsEnvironmentVariables.prototype = $extend(kEnvironmentVariables.prototype,{
getVariable: function(name) {
var parser = new kjsURLParser(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.x", lineNumber : 90, className : "kha.js.EnvironmentVariables", methodName : "getVariable"});
return "";
}
,__class__: kjsEnvironmentVariables
});
var kjsFont = function(kravur) {
this.images = new haxe_ds_IntMap();
this.kravur = kravur;
};
xClasses["kha.js.Font"] = kjsFont;
kjsFont.nom = true;
kjsFont.__interfaces__ = [kFont];
kjsFont.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 = (jsBoot.__cast(kravur.getTexture() , kCanvasImage)).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__: kjsFont
};
var kjsMobileWebAudio = function() { };
xClasses["kha.js.MobileWebAudio"] = kjsMobileWebAudio;
kjsMobileWebAudio.nom = true;
kjsMobileWebAudio._init = function() {
try {
kjsMobileWebAudio._context = new AudioContext();
return;
} catch( e ) {
}
try {
this._context = new webkitAudioContext();
return;
} catch( e1 ) {
}
};
kjsMobileWebAudio.play = function(sound,loop) {
if(loop == null) {
loop = false;
}
var channel = new kjsMobileWebAudioChannel(sound,loop);
channel.play();
return channel;
};
kjsMobileWebAudio.stream = function(sound,loop) {
if(loop == null) {
loop = false;
}
return kjsMobileWebAudio.play(sound,loop);
};
var kjsMobileWebAudioChannel = function(sound,loop) {
this.stopped = false;
this.paused = false;
this.buffer = sound._buffer;
this.loop = loop;
this.createSource();
};
xClasses["kha.js.MobileWebAudioChannel"] = kjsMobileWebAudioChannel;
kjsMobileWebAudioChannel.nom = true;
kjsMobileWebAudioChannel.__interfaces__ = [kaudio1_AudioChannel];
kjsMobileWebAudioChannel.prototype = {
buffer: null
,loop: null
,source: null
,gain: null
,startTime: null
,pauseTime: null
,paused: null
,stopped: null
,createSource: function() {
var _gthis = this;
this.source = kjsMobileWebAudio._context.createBufferSource();
this.source.loop = this.loop;
this.source.buffer = this.buffer;
this.source.onended = function() {
_gthis.stopped = true;
};
this.gain = kjsMobileWebAudio._context.createGain();
this.source.connect(this.gain);
this.gain.connect(kjsMobileWebAudio._context.destination);
}
,play: function() {
if(this.paused || this.stopped) {
this.createSource();
}
this.stopped = false;
if(this.paused) {
this.paused = false;
this.startTime = kjsMobileWebAudio._context.currentTime - this.pauseTime;
this.source.start(0,this.pauseTime);
} else {
this.startTime = kjsMobileWebAudio._context.currentTime;
this.source.start();
}
}
,pause: function() {
this.pauseTime = kjsMobileWebAudio._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 kjsMobileWebAudio._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__: kjsMobileWebAudioChannel
};
var kjsMobileWebAudioSound = function(filename,done) {
var _gthis = this;
kSound.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.x", lineNumber : 25, className : "kha.js.MobileWebAudioSound", methodName : "new"});
};
request.onload = function() {
_gthis.compressedData = haxe_io_Bytes.ofData(request.response);
_gthis.uncompressedData = null;
kjsMobileWebAudio._context.decodeAudioData(_gthis.compressedData.b.bufferValue,function(buffer) {
_gthis._buffer = buffer;
done(_gthis);
},function() {
throw new jsxBoot_HaxeError("Audio format not supported");
});
};
request.send(null);
};
xClasses["kha.js.MobileWebAudioSound"] = kjsMobileWebAudioSound;
kjsMobileWebAudioSound.nom = true;
kjsMobileWebAudioSound.__super__ = kSound;
kjsMobileWebAudioSound.prototype = $extend(kSound.prototype,{
_buffer: null
,uncompress: function(done) {
done();
}
,__class__: kjsMobileWebAudioSound
});
var kjsSound = function(filenames,done) {
kSound.call(this);
this.done = done;
kjsSound.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();
};
xClasses["kha.js.Sound"] = kjsSound;
kjsSound.nom = true;
kjsSound.__super__ = kSound;
kjsSound.prototype = $extend(kSound.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.x", 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);
xOverrides.remove(kjsSound.loading,this);
}
,uncompress: function(done) {
done();
}
,__class__: kjsSound
});
var kjsVideo = function() {
kVideo.call(this);
};
xClasses["kha.js.Video"] = kjsVideo;
kjsVideo.nom = true;
kjsVideo.fromElement = function(element) {
var video = new kjsVideo();
video.element = element;
if(kSystemImpl.gl != null) {
video.texture = kImage.fromVideo(video);
}
return video;
};
kjsVideo.fromFile = function(filenames,done) {
var video = new kjsVideo();
video.done = done;
video.element = window.document.createElement("video");
video.filenames = [];
var _g = 0;
while(_g < filenames.length) {
var filename = filenames[_g];
++_g;
if(video.element.canPlayType("video/webm") != "" && StringTools.endsWith(filename,".webm")) {
video.filenames.push(filename);
}
if(video.element.canPlayType("video/mp4") != "" && StringTools.endsWith(filename,".mp4")) {
video.filenames.push(filename);
}
}
video.element.addEventListener("error",$bind(video,video.errorListener),false);
video.element.addEventListener("canplaythrough",$bind(video,video.canPlayThroughListener),false);
video.element.preload = "auto";
video.element.src = video.filenames[0];
};
kjsVideo.__super__ = kVideo;
kjsVideo.prototype = $extend(kVideo.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 jsxBoot_HaxeError) e = e.val;
haxe_Log.trace(e,{ fileName : "Video.x", lineNumber : 64, className : "kha.js.Video", methodName : "play"});
}
}
,pause: function() {
try {
this.element.pause();
} catch( e ) {
if (e instanceof jsxBoot_HaxeError) e = e.val;
haxe_Log.trace(e,{ fileName : "Video.x", lineNumber : 73, className : "kha.js.Video", methodName : "pause"});
}
}
,stop: function() {
try {
this.element.pause();
this.element.currentTime = 0;
} catch( e ) {
if (e instanceof jsxBoot_HaxeError) e = e.val;
haxe_Log.trace(e,{ fileName : "Video.x", lineNumber : 83, 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.x", lineNumber : 120, 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(kSystemImpl.gl != null) {
this.texture = kImage.fromVideo(this);
}
this.done(this);
}
,__class__: kjsVideo
});
var kjsWebAudioSound = function(filename,done) {
var _gthis = this;
kSound.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.x", 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);
};
xClasses["kha.js.WebAudioSound"] = kjsWebAudioSound;
kjsWebAudioSound.nom = true;
kjsWebAudioSound.__super__ = kSound;
kjsWebAudioSound.prototype = $extend(kSound.prototype,{
superUncompress: function(done) {
kSound.prototype.uncompress.call(this,done);
}
,uncompress: function(done) {
var _gthis = this;
kaudio2_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__: kjsWebAudioSound
});
var kjsgraphics4_ConstantLocation = function(value,type) {
this.value = value;
this.type = type;
};
xClasses["kha.js.graphics4.ConstantLocation"] = kjsgraphics4_ConstantLocation;
kjsgraphics4_ConstantLocation.nom = true;
kjsgraphics4_ConstantLocation.__interfaces__ = [kgraphics4_ConstantLocation];
kjsgraphics4_ConstantLocation.prototype = {
value: null
,type: null
,__class__: kjsgraphics4_ConstantLocation
};
var kjsgraphics4_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(kSystemImpl.gl2) {
this.instancedExtension = true;
} else {
this.instancedExtension = kSystemImpl.gl.getExtension("ANGLE_instanced_arrays");
this.blendMinMaxExtension = kSystemImpl.gl.getExtension("EXT_blend_minmax");
}
};
xClasses["kha.js.graphics4.Graphics"] = kjsgraphics4_Graphics;
kjsgraphics4_Graphics.nom = true;
kjsgraphics4_Graphics.__interfaces__ = [kgraphics4_Graphics];
kjsgraphics4_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;
}
};
kjsgraphics4_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;
}
};
kjsgraphics4_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 = jsBoot.__instanceof(this.renderTarget,kgraphics4_CubeMap);
if(this.isCubeMap) {
var cubeMap = jsBoot.__cast(this.renderTarget , kgraphics4_CubeMap);
this.renderTargetFrameBuffer = cubeMap.frameBuffer;
this.renderTargetTexture = cubeMap.texture;
this.isDepthAttachment = cubeMap.isDepthAttachment;
} else {
var image = jsBoot.__cast(this.renderTarget , kWebGLImage);
this.renderTargetFrameBuffer = image.frameBuffer;
this.renderTargetTexture = image.texture;
}
}
,begin: function(additionalRenderTargets) {
kSystemImpl.gl.enable(3042);
kSystemImpl.gl.blendFunc(770,771);
if(this.renderTarget == null) {
kSystemImpl.gl.bindFramebuffer(36160,null);
kSystemImpl.gl.viewport(0,0,kSystem.windowWidth(),kSystem.windowHeight());
} else {
kSystemImpl.gl.bindFramebuffer(36160,this.renderTargetFrameBuffer);
kSystemImpl.gl.viewport(0,0,this.renderTarget.get_width(),this.renderTarget.get_height());
if(additionalRenderTargets != null) {
kSystemImpl.gl.framebufferTexture2D(36160,kSystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL,3553,this.renderTargetTexture,0);
var _g1 = 0;
var _g = additionalRenderTargets.length;
while(_g1 < _g) {
var i = _g1++;
kSystemImpl.gl.framebufferTexture2D(36160,kSystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL + i + 1,3553,(jsBoot.__cast(additionalRenderTargets[i] , kWebGLImage)).texture,0);
}
var attachments = [kSystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL];
var _g11 = 0;
var _g2 = additionalRenderTargets.length;
while(_g11 < _g2) {
var i1 = _g11++;
attachments.push(kSystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL + i1 + 1);
}
if(kSystemImpl.gl2) {
kSystemImpl.gl.drawBuffers(attachments);
} else {
kSystemImpl.drawBuffers.drawBuffersWEBGL(attachments);
}
}
}
}
,beginFace: function(face) {
kSystemImpl.gl.enable(3042);
kSystemImpl.gl.blendFunc(770,771);
kSystemImpl.gl.bindFramebuffer(36160,this.renderTargetFrameBuffer);
kSystemImpl.gl.framebufferTexture2D(36160,this.isDepthAttachment ? 36096 : 36064,34069 + face,this.renderTargetTexture,0);
kSystemImpl.gl.viewport(0,0,this.renderTarget.get_width(),this.renderTarget.get_height());
}
,beginEye: function(eye) {
kSystemImpl.gl.enable(3042);
kSystemImpl.gl.blendFunc(770,771);
kSystemImpl.gl.bindFramebuffer(36160,null);
if(eye == 0) {
kSystemImpl.gl.viewport(0,0,kSystem.windowWidth() * 0.5 | 0,kSystem.windowHeight());
} else {
kSystemImpl.gl.viewport(kSystem.windowWidth() * 0.5 | 0,0,kSystem.windowWidth() * 0.5 | 0,kSystem.windowHeight());
}
}
,end: function() {
var error = kSystemImpl.gl.getError();
switch(error) {
case 0:
break;
case 1280:
haxe_Log.trace("WebGL error: Invalid enum",{ fileName : "Graphics.x", lineNumber : 130, className : "kha.js.graphics4.Graphics", methodName : "end"});
break;
case 1281:
haxe_Log.trace("WebGL error: Invalid value",{ fileName : "Graphics.x", lineNumber : 132, className : "kha.js.graphics4.Graphics", methodName : "end"});
break;
case 1282:
haxe_Log.trace("WebGL error: Invalid operation",{ fileName : "Graphics.x", lineNumber : 134, className : "kha.js.graphics4.Graphics", methodName : "end"});
break;
case 1285:
haxe_Log.trace("WebGL error: Out of memory",{ fileName : "Graphics.x", lineNumber : 138, className : "kha.js.graphics4.Graphics", methodName : "end"});
break;
case 1286:
haxe_Log.trace("WebGL error: Invalid framebuffer operation",{ fileName : "Graphics.x", lineNumber : 136, className : "kha.js.graphics4.Graphics", methodName : "end"});
break;
case 37442:
haxe_Log.trace("WebGL error: Context lost",{ fileName : "Graphics.x", lineNumber : 140, className : "kha.js.graphics4.Graphics", methodName : "end"});
break;
default:
haxe_Log.trace("Unknown WebGL error",{ fileName : "Graphics.x", 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;
kSystemImpl.gl.colorMask(true,true,true,true);
kSystemImpl.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;
kSystemImpl.gl.enable(2929);
kSystemImpl.gl.depthMask(true);
kSystemImpl.gl.clearDepth(depth);
}
if(stencil != null) {
clearMask |= 1024;
kSystemImpl.gl.enable(2960);
kSystemImpl.gl.stencilMask(255);
kSystemImpl.gl.clearStencil(stencil);
}
kSystemImpl.gl.clear(clearMask);
kSystemImpl.gl.colorMask(this.colorMaskRed,this.colorMaskGreen,this.colorMaskBlue,this.colorMaskAlpha);
if(this.depthTest) {
kSystemImpl.gl.enable(2929);
} else {
kSystemImpl.gl.disable(2929);
}
kSystemImpl.gl.depthMask(this.depthMask);
}
,viewport: function(x,y,width,height) {
var h = this.renderTarget == null ? kSystem.windowHeight(0) : this.renderTarget.get_height();
kSystemImpl.gl.viewport(x,h - y - height,width,height);
}
,setDepthMode: function(write,mode) {
switch(mode[1]) {
case 0:
if(write) {
kSystemImpl.gl.enable(2929);
} else {
kSystemImpl.gl.disable(2929);
}
this.depthTest = write;
kSystemImpl.gl.depthFunc(519);
break;
case 1:
kSystemImpl.gl.enable(2929);
this.depthTest = true;
kSystemImpl.gl.depthFunc(512);
break;
case 2:
kSystemImpl.gl.enable(2929);
this.depthTest = true;
kSystemImpl.gl.depthFunc(514);
break;
case 3:
kSystemImpl.gl.enable(2929);
this.depthTest = true;
kSystemImpl.gl.depthFunc(517);
break;
case 4:
kSystemImpl.gl.enable(2929);
this.depthTest = true;
kSystemImpl.gl.depthFunc(513);
break;
case 5:
kSystemImpl.gl.enable(2929);
this.depthTest = true;
kSystemImpl.gl.depthFunc(515);
break;
case 6:
kSystemImpl.gl.enable(2929);
this.depthTest = true;
kSystemImpl.gl.depthFunc(516);
break;
case 7:
kSystemImpl.gl.enable(2929);
this.depthTest = true;
kSystemImpl.gl.depthFunc(518);
break;
}
kSystemImpl.gl.depthMask(write);
this.depthMask = write;
}
,setBlendingMode: function(source,destination,operation,alphaSource,alphaDestination,alphaOperation) {
if(source == kgraphics4_BlendingFactor.BlendOne && destination == kgraphics4_BlendingFactor.BlendZero) {
kSystemImpl.gl.disable(3042);
} else {
kSystemImpl.gl.enable(3042);
kSystemImpl.gl.blendFuncSeparate(kjsgraphics4_Graphics.getBlendFunc(source),kjsgraphics4_Graphics.getBlendFunc(destination),kjsgraphics4_Graphics.getBlendFunc(alphaSource),kjsgraphics4_Graphics.getBlendFunc(alphaDestination));
kSystemImpl.gl.blendEquationSeparate(kjsgraphics4_Graphics.getBlendOp(operation),kjsgraphics4_Graphics.getBlendOp(alphaOperation));
}
}
,createVertexBuffer: function(vertexCount,structure,usage,canRead) {
if(canRead == null) {
canRead = false;
}
return new kgraphics4_VertexBuffer(vertexCount,structure,usage);
}
,setVertexBuffer: function(vertexBuffer) {
(jsBoot.__cast(vertexBuffer , kgraphics4_VertexBuffer)).set(0);
}
,setVertexBuffers: function(vertexBuffers) {
var offset = 0;
var _g = 0;
while(_g < vertexBuffers.length) {
var vertexBuffer = vertexBuffers[_g];
++_g;
offset += (jsBoot.__cast(vertexBuffer , kgraphics4_VertexBuffer)).set(offset);
}
}
,createIndexBuffer: function(indexCount,usage,canRead) {
if(canRead == null) {
canRead = false;
}
return new kgraphics4_IndexBuffer(indexCount,usage);
}
,setIndexBuffer: function(indexBuffer) {
this.indicesCount = indexBuffer.count();
(jsBoot.__cast(indexBuffer , kgraphics4_IndexBuffer)).set();
}
,setTexture: function(stage,texture) {
if(texture == null) {
kSystemImpl.gl.activeTexture(33984 + (jsBoot.__cast(stage , kjsgraphics4_TextureUnit)).value);
kSystemImpl.gl.bindTexture(3553,null);
} else {
(jsBoot.__cast(texture , kWebGLImage)).set((jsBoot.__cast(stage , kjsgraphics4_TextureUnit)).value);
}
}
,setTextureDepth: function(stage,texture) {
(jsBoot.__cast(texture , kWebGLImage)).setDepth((jsBoot.__cast(stage , kjsgraphics4_TextureUnit)).value);
}
,setVideoTexture: function(unit,texture) {
if(texture == null) {
kSystemImpl.gl.activeTexture(33984 + (jsBoot.__cast(unit , kjsgraphics4_TextureUnit)).value);
kSystemImpl.gl.bindTexture(3553,null);
} else {
(jsBoot.__cast((jsBoot.__cast(texture , kjsVideo)).texture , kWebGLImage)).set((jsBoot.__cast(unit , kjsgraphics4_TextureUnit)).value);
}
}
,setImageTexture: function(unit,texture) {
}
,setTextureParameters: function(texunit,uAddressing,vAddressing,minificationFilter,magnificationFilter,mipmapFilter) {
kSystemImpl.gl.activeTexture(33984 + (jsBoot.__cast(texunit , kjsgraphics4_TextureUnit)).value);
switch(uAddressing[1]) {
case 0:
kSystemImpl.gl.texParameteri(3553,10242,10497);
break;
case 1:
kSystemImpl.gl.texParameteri(3553,10242,33648);
break;
case 2:
kSystemImpl.gl.texParameteri(3553,10242,33071);
break;
}
switch(vAddressing[1]) {
case 0:
kSystemImpl.gl.texParameteri(3553,10243,10497);
break;
case 1:
kSystemImpl.gl.texParameteri(3553,10243,33648);
break;
case 2:
kSystemImpl.gl.texParameteri(3553,10243,33071);
break;
}
switch(minificationFilter[1]) {
case 0:
switch(mipmapFilter[1]) {
case 0:
kSystemImpl.gl.texParameteri(3553,10241,9728);
break;
case 1:
kSystemImpl.gl.texParameteri(3553,10241,9984);
break;
case 2:
kSystemImpl.gl.texParameteri(3553,10241,9986);
break;
}
break;
case 1:case 2:
switch(mipmapFilter[1]) {
case 0:
kSystemImpl.gl.texParameteri(3553,10241,9729);
break;
case 1:
kSystemImpl.gl.texParameteri(3553,10241,9985);
break;
case 2:
kSystemImpl.gl.texParameteri(3553,10241,9987);
break;
}
if(minificationFilter == kgraphics4_TextureFilter.AnisotropicFilter) {
kSystemImpl.gl.texParameteri(3553,kSystemImpl.anisotropicFilter.TEXTURE_MAX_ANISOTROPY_EXT,4);
}
break;
}
switch(magnificationFilter[1]) {
case 0:
kSystemImpl.gl.texParameteri(3553,10240,9728);
break;
case 1:case 2:
kSystemImpl.gl.texParameteri(3553,10240,9729);
break;
}
}
,setTexture3DParameters: function(texunit,uAddressing,vAddressing,wAddressing,minificationFilter,magnificationFilter,mipmapFilter) {
}
,setCubeMap: function(stage,cubeMap) {
if(cubeMap == null) {
kSystemImpl.gl.activeTexture(33984 + (jsBoot.__cast(stage , kjsgraphics4_TextureUnit)).value);
kSystemImpl.gl.bindTexture(34067,null);
} else {
cubeMap.set((jsBoot.__cast(stage , kjsgraphics4_TextureUnit)).value);
}
}
,setCubeMapDepth: function(stage,cubeMap) {
cubeMap.setDepth((jsBoot.__cast(stage , kjsgraphics4_TextureUnit)).value);
}
,setCullMode: function(mode) {
switch(mode[1]) {
case 0:
kSystemImpl.gl.enable(2884);
kSystemImpl.gl.cullFace(1029);
break;
case 1:
kSystemImpl.gl.enable(2884);
kSystemImpl.gl.cullFace(1028);
break;
case 2:
kSystemImpl.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) {
kSystemImpl.gl.uniform1i((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value ? 1 : 0);
}
,setInt: function(location,value) {
kSystemImpl.gl.uniform1i((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value);
}
,setFloat: function(location,value) {
kSystemImpl.gl.uniform1f((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value);
}
,setFloat2: function(location,value1,value2) {
kSystemImpl.gl.uniform2f((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value1,value2);
}
,setFloat3: function(location,value1,value2,value3) {
kSystemImpl.gl.uniform3f((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value1,value2,value3);
}
,setFloat4: function(location,value1,value2,value3,value4) {
kSystemImpl.gl.uniform4f((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value1,value2,value3,value4);
}
,setFloats: function(location,values) {
var webglLocation = jsBoot.__cast(location , kjsgraphics4_ConstantLocation);
var _g = webglLocation.type;
switch(_g) {
case 35664:
kSystemImpl.gl.uniform2fv(webglLocation.value,values);
break;
case 35665:
kSystemImpl.gl.uniform3fv(webglLocation.value,values);
break;
case 35666:
kSystemImpl.gl.uniform4fv(webglLocation.value,values);
break;
default:
kSystemImpl.gl.uniform1fv(webglLocation.value,values);
}
}
,setVector2: function(location,value) {
kSystemImpl.gl.uniform2f((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value.x,value.y);
}
,setVector3: function(location,value) {
kSystemImpl.gl.uniform3f((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,value.x,value.y,value.z);
}
,setVector4: function(location,value) {
kSystemImpl.gl.uniform4f((jsBoot.__cast(location , kjsgraphics4_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;
kSystemImpl.gl.uniformMatrix4fv((jsBoot.__cast(location , kjsgraphics4_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;
kSystemImpl.gl.uniformMatrix3fv((jsBoot.__cast(location , kjsgraphics4_ConstantLocation)).value,false,this.matrix3Cache);
}
,drawIndexedVertices: function(start,count) {
if(count == null) {
count = -1;
}
if(start == null) {
start = 0;
}
var type = kSystemImpl.elementIndexUint == null ? 5123 : 5125;
var size = type == 5123 ? 2 : 4;
kSystemImpl.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 == kgraphics4_CompareMode.Always && bothPass == kgraphics4_StencilAction.Keep && depthFail == kgraphics4_StencilAction.Keep && stencilFail == kgraphics4_StencilAction.Keep) {
kSystemImpl.gl.disable(2960);
} else {
kSystemImpl.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;
}
kSystemImpl.gl.stencilMask(writeMask);
kSystemImpl.gl.stencilOp(this.convertStencilAction(stencilFail),this.convertStencilAction(depthFail),this.convertStencilAction(bothPass));
kSystemImpl.gl.stencilFunc(stencilFunc,referenceValue,readMask);
}
}
,scissor: function(x,y,width,height) {
kSystemImpl.gl.enable(3089);
if(this.renderTarget == null) {
kSystemImpl.gl.scissor(x,kSystem.windowHeight(0) - y - height,width,height);
} else {
kSystemImpl.gl.scissor(x,y,width,height);
}
}
,disableScissor: function() {
kSystemImpl.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 = kSystemImpl.elementIndexUint == null ? 5123 : 5125;
var typeSize = kSystemImpl.elementIndexUint == null ? 2 : 4;
if(kSystemImpl.gl2) {
kSystemImpl.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__: kjsgraphics4_Graphics
};
var kjsgraphics4_Graphics2 = function(canvas) {
kgraphics4_Graphics2.call(this,canvas);
};
xClasses["kha.js.graphics4.Graphics2"] = kjsgraphics4_Graphics2;
kjsgraphics4_Graphics2.nom = true;
kjsgraphics4_Graphics2.__super__ = kgraphics4_Graphics2;
kjsgraphics4_Graphics2.prototype = $extend(kgraphics4_Graphics2.prototype,{
drawVideoInternal: function(video,x,y,width,height) {
var v = jsBoot.__cast(video , kjsVideo);
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;
}
kSystemImpl.gl.colorMask(true,true,true,true);
kSystemImpl.gl.disable(2929);
kSystemImpl.gl.depthFunc(519);
kgraphics4_Graphics2.prototype.begin.call(this,clear,clearColor);
}
,__class__: kjsgraphics4_Graphics2
});
var kjsgraphics4_TextureUnit = function(value) {
this.value = value;
};
xClasses["kha.js.graphics4.TextureUnit"] = kjsgraphics4_TextureUnit;
kjsgraphics4_TextureUnit.nom = true;
kjsgraphics4_TextureUnit.__interfaces__ = [kgraphics4_TextureUnit];
kjsgraphics4_TextureUnit.prototype = {
value: null
,__class__: kjsgraphics4_TextureUnit
};
var kvr_VrInterface = function() {
};
xClasses["kha.vr.VrInterface"] = kvr_VrInterface;
kvr_VrInterface.nom = true;
kvr_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__: kvr_VrInterface
};
var kjsvr_VrInterface = function() {
this.vrHeight = 0;
this.vrWidth = 0;
this.height = 0;
this.width = 0;
this.rightViewMatrix = new kmath_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
this.leftViewMatrix = new kmath_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
this.rightProjectionMatrix = new kmath_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
this.leftProjectionMatrix = new kmath_FastMatrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
this.vrEnabled = false;
kvr_VrInterface.call(this);
var displayEnabled = navigator.getVRDisplays;
if(displayEnabled) {
this.vrEnabled = true;
this.getVRDisplays();
haxe_Log.trace("Display enabled.",{ fileName : "VrInterface.x", lineNumber : 36, className : "kha.js.vr.VrInterface", methodName : "new"});
}
};
xClasses["kha.js.vr.VrInterface"] = kjsvr_VrInterface;
kjsvr_VrInterface.nom = true;
kjsvr_VrInterface.__super__ = kvr_VrInterface;
kjsvr_VrInterface.prototype = $extend(kvr_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 = kSystemImpl.khanvas.width;
_gthis.height = kSystemImpl.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.x", lineNumber : 56, className : "kha.js.vr.VrInterface", methodName : "getVRDisplays"});
}
});
}
,onVRRequestPresent: function() {
var _gthis = this;
try {
this.vrDisplay.requestPresent([{ source : kSystemImpl.khanvas}]).then(function() {
_gthis.onResize();
_gthis.vrDisplay.requestAnimationFrame($bind(_gthis,_gthis.onAnimationFrame));
});
} catch( err ) {
if (err instanceof jsxBoot_HaxeError) err = err.val;
haxe_Log.trace("Failed to requestPresent.",{ fileName : "VrInterface.x", lineNumber : 68, className : "kha.js.vr.VrInterface", methodName : "onVRRequestPresent"});
haxe_Log.trace(err,{ fileName : "VrInterface.x", lineNumber : 69, className : "kha.js.vr.VrInterface", methodName : "onVRRequestPresent"});
}
}
,onVRExitPresent: function() {
var _gthis = this;
try {
this.vrDisplay.exitPresent([{ source : kSystemImpl.khanvas}]).then(function() {
_gthis.onResize();
});
} catch( err ) {
if (err instanceof jsxBoot_HaxeError) err = err.val;
haxe_Log.trace("Failed to exitPresent.",{ fileName : "VrInterface.x", lineNumber : 79, className : "kha.js.vr.VrInterface", methodName : "onVRExitPresent"});
haxe_Log.trace(err,{ fileName : "VrInterface.x", lineNumber : 80, className : "kha.js.vr.VrInterface", methodName : "onVRExitPresent"});
}
}
,onResetPose: function() {
try {
this.vrDisplay.resetPose();
} catch( err ) {
if (err instanceof jsxBoot_HaxeError) err = err.val;
haxe_Log.trace("Failed to resetPose",{ fileName : "VrInterface.x", lineNumber : 88, className : "kha.js.vr.VrInterface", methodName : "onResetPose"});
haxe_Log.trace(err,{ fileName : "VrInterface.x", 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) {
kSystemImpl.khanvas.width = this.vrWidth;
kSystemImpl.khanvas.height = this.vrHeight;
} else {
kSystemImpl.khanvas.width = this.width;
kSystemImpl.khanvas.height = this.height;
}
}
,GetSensorState: function() {
return this.GetPredictedSensorState(0.0);
}
,GetPredictedSensorState: function(time) {
var result = new kvr_SensorState();
result.Predicted = new kvr_PoseState();
result.Recorded = result.Predicted;
result.Predicted.AngularAcceleration = new kmath_Vector3();
result.Predicted.AngularVelocity = new kmath_Vector3();
result.Predicted.LinearAcceleration = new kmath_Vector3();
result.Predicted.LinearVelocity = new kmath_Vector3();
result.Predicted.TimeInSeconds = time;
result.Predicted.Pose = new kvr_Pose();
result.Predicted.Pose.Orientation = new kmath_Quaternion();
result.Predicted.Pose.Position = new kmath_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 kScheduler.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 kmath_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 kmath_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 kmath_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__: kjsvr_VrInterface
});
var kmath_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;
};
xClasses["kha.math.FastMatrix3"] = kmath_FastMatrix3;
kmath_FastMatrix3.nom = true;
kmath_FastMatrix3.fromMatrix3 = function(m) {
return new kmath_FastMatrix3(m._00,m._10,m._20,m._01,m._11,m._21,m._02,m._12,m._22);
};
kmath_FastMatrix3.prototype = {
_00: null
,_10: null
,_20: null
,_01: null
,_11: null
,_21: null
,_02: null
,_12: null
,_22: null
,__class__: kmath_FastMatrix3
};
var kmath_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;
};
xClasses["kha.math.FastMatrix4"] = kmath_FastMatrix4;
kmath_FastMatrix4.nom = true;
kmath_FastMatrix4.fromMatrix4 = function(m) {
return new kmath_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);
};
kmath_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 kmath_FastMatrix4(2 / (right - left),0,0,tx,0,2 / (top - bottom),0,ty,0,0,-2 / (zf - zn),tz,0,0,0,1);
};
kmath_FastMatrix4.perspectiveProjection = function(fovY,aspect,zn,zf) {
var uh = 1.0 / Math.tan(fovY / 2);
var uw = uh / aspect;
return new kmath_FastMatrix4(uw,0,0,0,0,uh,0,0,0,0,(zf + zn) / (zn - zf),2 * zf * zn / (zn - zf),0,0,-1,0);
};
kmath_FastMatrix4.lookAt = function(eye,at,up) {
var zaxis = new kmath_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 kmath_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 kmath_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);
};
kmath_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__: kmath_FastMatrix4
};
var kmath_FastVector2 = function(x,y) {
if(y == null) {
y = 0;
}
if(x == null) {
x = 0;
}
this.x = x;
this.y = y;
};
xClasses["kha.math.FastVector2"] = kmath_FastVector2;
kmath_FastVector2.nom = true;
kmath_FastVector2.fromVector2 = function(v) {
return new kmath_FastVector2(v.x,v.y);
};
kmath_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__: kmath_FastVector2
};
var kmath_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;
};
xClasses["kha.math.FastVector3"] = kmath_FastVector3;
kmath_FastVector3.nom = true;
kmath_FastVector3.fromVector3 = function(v) {
return new kmath_FastVector3(v.x,v.y,v.z);
};
kmath_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__: kmath_FastVector3
};
var kmath_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;
};
xClasses["kha.math.FastVector4"] = kmath_FastVector4;
kmath_FastVector4.nom = true;
kmath_FastVector4.fromVector4 = function(v) {
return new kmath_FastVector4(v.x,v.y,v.z,v.w);
};
kmath_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__: kmath_FastVector4
};
var kmath_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;
};
xClasses["kha.math.Matrix3"] = kmath_Matrix3;
kmath_Matrix3.nom = true;
kmath_Matrix3.prototype = {
_00: null
,_10: null
,_20: null
,_01: null
,_11: null
,_21: null
,_02: null
,_12: null
,_22: null
,__class__: kmath_Matrix3
};
var kmath_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;
};
xClasses["kha.math.Matrix4"] = kmath_Matrix4;
kmath_Matrix4.nom = true;
kmath_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 kmath_Matrix4(2 / (right - left),0,0,tx,0,2 / (top - bottom),0,ty,0,0,-2 / (zf - zn),tz,0,0,0,1);
};
kmath_Matrix4.perspectiveProjection = function(fovY,aspect,zn,zf) {
var uh = 1.0 / Math.tan(fovY / 2);
var uw = uh / aspect;
return new kmath_Matrix4(uw,0,0,0,0,uh,0,0,0,0,(zf + zn) / (zn - zf),2 * zf * zn / (zn - zf),0,0,-1,0);
};
kmath_Matrix4.lookAt = function(eye,at,up) {
var zaxis = new kmath_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 kmath_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 kmath_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);
};
kmath_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__: kmath_Matrix4
};
var kmath_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);
};
xClasses["kha.math.Quaternion"] = kmath_Quaternion;
kmath_Quaternion.nom = true;
kmath_Quaternion.fromAxisAngle = function(axis,radians) {
var q = new kmath_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;
};
kmath_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 kmath_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 kmath_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 kmath_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 kmath_Quaternion(this.get_x(),this.get_y(),this.get_z(),this.get_w());
var q1 = new kmath_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 kmath_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 kmath_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 kmath_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 kmath_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__: kmath_Quaternion
};
var kmath_Vector2 = function(x,y) {
if(y == null) {
y = 0;
}
if(x == null) {
x = 0;
}
this.x = x;
this.y = y;
};
xClasses["kha.math.Vector2"] = kmath_Vector2;
kmath_Vector2.nom = true;
kmath_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__: kmath_Vector2
};
var kmath_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;
};
xClasses["kha.math.Vector3"] = kmath_Vector3;
kmath_Vector3.nom = true;
kmath_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__: kmath_Vector3
};
var kmath_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;
};
xClasses["kha.math.Vector4"] = kmath_Vector4;
kmath_Vector4.nom = true;
kmath_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__: kmath_Vector4
};
var knetwork_Client = function() { };
xClasses["kha.network.Client"] = knetwork_Client;
knetwork_Client.nom = true;
knetwork_Client.prototype = {
get_id: null
,id: null
,send: null
,receive: null
,onClose: null
,__class__: knetwork_Client
};
var knetwork_ControllerBuilder = function() { };
xClasses["kha.network.ControllerBuilder"] = knetwork_ControllerBuilder;
knetwork_ControllerBuilder.nom = true;
var knetwork_Entity = function() { };
xClasses["kha.network.Entity"] = knetwork_Entity;
knetwork_Entity.nom = true;
knetwork_Entity.prototype = {
_id: null
,_size: null
,_send: null
,_receive: null
,__class__: knetwork_Entity
};
var knetwork_LocalClient = function(id) {
this.myId = id;
};
xClasses["kha.network.LocalClient"] = knetwork_LocalClient;
knetwork_LocalClient.nom = true;
knetwork_LocalClient.__interfaces__ = [knetwork_Client];
knetwork_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__: knetwork_LocalClient
};
var knetwork_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.x", 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.x", lineNumber : 22, className : "kha.network.Network", methodName : "new"});
closeCallback();
};
};
xClasses["kha.network.Network"] = knetwork_Network;
knetwork_Network.nom = true;
knetwork_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__: knetwork_Network
};
var knetwork_State = function(time,data) {
this.time = time;
this.data = data;
};
xClasses["kha.network.State"] = knetwork_State;
knetwork_State.nom = true;
knetwork_State.prototype = {
time: null
,data: null
,__class__: knetwork_State
};
var knetwork_Session = function(maxPlayers,address,port) {
this.ping = 1;
this.currentPlayers = 0;
this.controllers = new haxe_ds_IntMap();
this.entities = new haxe_ds_IntMap();
knetwork_Session.instance = this;
this.maxPlayers = maxPlayers;
this.address = address;
this.port = port;
};
xClasses["kha.network.Session"] = knetwork_Session;
knetwork_Session.nom = true;
knetwork_Session.the = function() {
return knetwork_Session.instance;
};
knetwork_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.x", 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,kScheduler.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 knetwork_LocalClient(index);
kScheduler.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();
}
kScheduler.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 = kScheduler.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.x", 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.x", 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.x", 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.x", lineNumber : 308, className : "kha.network.Session", methodName : "executeRPC"});
args.push(str);
break;
default:
haxe_Log.trace("Unknown argument type.",{ fileName : "Session.x", lineNumber : 311, className : "kha.network.Session", methodName : "executeRPC"});
}
}
if(syncId == -1) {
Reflect.field(Type.resolveClass(classname),methodname + "_remotely").apply(null,args);
} else {
var o = knetwork_SyncBuilder.objects[syncId];
Reflect.field(knetwork_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 knetwork_Network(this.address,this.port,errorCallback,function() {
closeCallback();
_gthis.reset();
});
this.network.listen(function(bytes) {
_gthis.receive(bytes);
});
this.updateTaskId = kScheduler.addFrameTask($bind(this,this.update),0);
this.ping = 1;
this.pingTaskId = kScheduler.addTimeTask($bind(this,this.sendPing),0,1);
}
,reset: function() {
kScheduler.removeFrameTask(this.updateTaskId);
kScheduler.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,kScheduler.realTime());
bytes.setInt32(13,kSystem.windowWidth(0));
bytes.setInt32(17,kSystem.windowHeight(0));
var v = kSystem.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__: knetwork_Session
};
var knetwork_SyncBuilder = function() { };
xClasses["kha.network.SyncBuilder"] = knetwork_SyncBuilder;
knetwork_SyncBuilder.nom = true;
var ksimd_Float32x4 = function(_0,_1,_2,_3) {
this._0 = _0;
this._1 = _1;
this._2 = _2;
this._3 = _3;
};
xClasses["kha.simd.Float32x4"] = ksimd_Float32x4;
ksimd_Float32x4.nom = true;
ksimd_Float32x4.create = function() {
return new ksimd_Float32x4(0,0,0,0);
};
ksimd_Float32x4.loadAllFast = function(t) {
return new ksimd_Float32x4(t,t,t,t);
};
ksimd_Float32x4.load = function(a,b,c,d) {
return new ksimd_Float32x4(a,b,c,d);
};
ksimd_Float32x4.loadFast = function(a,b,c,d) {
return new ksimd_Float32x4(a,b,c,d);
};
ksimd_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;
};
ksimd_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;
};
ksimd_Float32x4.abs = function(t) {
return new ksimd_Float32x4(Math.abs(t._0),Math.abs(t._1),Math.abs(t._2),Math.abs(t._3));
};
ksimd_Float32x4.add = function(a,b) {
return new ksimd_Float32x4(a._0 + b._0,a._1 + b._1,a._2 + b._2,a._3 + b._3);
};
ksimd_Float32x4.div = function(a,b) {
return new ksimd_Float32x4(a._0 / b._0,a._1 / b._1,a._2 / b._2,a._3 / b._3);
};
ksimd_Float32x4.mul = function(a,b) {
return new ksimd_Float32x4(a._0 * b._0,a._1 * b._1,a._2 * b._2,a._3 * b._3);
};
ksimd_Float32x4.neg = function(t) {
return new ksimd_Float32x4(-t._0,-t._1,-t._2,-t._3);
};
ksimd_Float32x4.reciprocalApproximation = function(t) {
return new ksimd_Float32x4(0,0,0,0);
};
ksimd_Float32x4.reciprocalSqrtApproximation = function(t) {
return new ksimd_Float32x4(0,0,0,0);
};
ksimd_Float32x4.sub = function(a,b) {
return new ksimd_Float32x4(a._0 - b._0,a._1 - b._1,a._2 - b._2,a._3 - b._3);
};
ksimd_Float32x4.sqrt = function(t) {
return new ksimd_Float32x4(Math.sqrt(t._0),Math.sqrt(t._1),Math.sqrt(t._2),Math.sqrt(t._3));
};
ksimd_Float32x4.prototype = {
_0: null
,_1: null
,_2: null
,_3: null
,__class__: ksimd_Float32x4
};
var kvr_Pose = function() {
this.Orientation = new kmath_Quaternion();
this.Position = new kmath_Vector3();
};
xClasses["kha.vr.Pose"] = kvr_Pose;
kvr_Pose.nom = true;
kvr_Pose.prototype = {
Orientation: null
,Position: null
,__class__: kvr_Pose
};
var kvr_PoseState = function() {
};
xClasses["kha.vr.PoseState"] = kvr_PoseState;
kvr_PoseState.nom = true;
kvr_PoseState.prototype = {
Pose: null
,AngularVelocity: null
,LinearVelocity: null
,AngularAcceleration: null
,LinearAcceleration: null
,TimeInSeconds: null
,__class__: kvr_PoseState
};
var kvr_SensorState = function() {
};
xClasses["kha.vr.SensorState"] = kvr_SensorState;
kvr_SensorState.nom = true;
kvr_SensorState.prototype = {
Predicted: null
,Recorded: null
,Temperature: null
,Status: null
,__class__: kvr_SensorState
};
var kvr_TimeWarpImage = function() {
};
xClasses["kha.vr.TimeWarpImage"] = kvr_TimeWarpImage;
kvr_TimeWarpImage.nom = true;
kvr_TimeWarpImage.prototype = {
Image: null
,TexCoordsFromTanAngles: null
,Pose: null
,__class__: kvr_TimeWarpImage
};
var kvr_TimeWarpParms = function() {
};
xClasses["kha.vr.TimeWarpParms"] = kvr_TimeWarpParms;
kvr_TimeWarpParms.nom = true;
kvr_TimeWarpParms.prototype = {
LeftImage: null
,RightImage: null
,LeftOverlay: null
,RightOverlay: null
,__class__: kvr_TimeWarpParms
};
var wings_core_ISimpleDrawingContext = xExport["wings"]["core"]["ISimpleDrawingContext"] = function() { };
xClasses["wings.core.ISimpleDrawingContext"] = wings_core_ISimpleDrawingContext;
wings_core_ISimpleDrawingContext.nom = true;
wings_core_ISimpleDrawingContext.prototype = {
clear: null
,lineStyle: null
,beginFill: null
,endFill: null
,moveTo: null
,lineTo: null
,quadTo: null
,drawCircle: null
,drawRect: null
,drawEquilaterialTri: null
,drawTri: null
,__class__: wings_core_ISimpleDrawingContext
};
var wings_jsCanvas_BasicCanvas = xExport["wings"]["jsCanvas"]["BasicCanvas"] = function() {
this.canvas = window.document.createElement("canvas");
this.dom = this.canvas;
this.body = window.document.body;
this.surface = this.canvas.getContext("2d",null);
this.style = this.dom.style;
this.header = new wings_jsCanvas_CanvasHeader();
this.canvas.width = this.header.width;
this.canvas.height = this.header.height;
this.style.paddingLeft = "0px";
this.style.paddingTop = "0px";
this.style.left = Std.string(0 + "px");
this.style.top = Std.string(0 + "px");
this.style.position = "absolute";
this.style.backgroundColor = this.header.bgColor;
this.surface.fillStyle = this.header.bgColor;
this.image = this.dom;
var s = window.document.createElement("style");
s.innerHTML = "@keyframes spin { from { transform:rotate( 0deg ); } to { transform:rotate( 360deg ); } }";
window.document.getElementsByTagName("head")[0].appendChild(s);
s.animation = "spin 1s linear infinite";
this.loop(this.header.frameRate);
var body = window.document.body;
body.appendChild(this.dom);
};
xClasses["wings.jsCanvas.BasicCanvas"] = wings_jsCanvas_BasicCanvas;
wings_jsCanvas_BasicCanvas.nom = true;
wings_jsCanvas_BasicCanvas.prototype = {
surface: null
,dom: null
,image: null
,canvas: null
,style: null
,body: null
,onEnterFrame: null
,header: null
,loop: function(tim) {
window.requestAnimationFrame($bind(this,this.loop));
if(this.onEnterFrame != null) {
this.onEnterFrame();
}
return true;
}
,clear: function() {
this.surface.clearRect(0,0,this.header.width,this.header.height);
}
,drawCircle: function(x,y,radius) {
this.surface.beginPath();
this.surface.arc(x,y,radius,0,2 * Math.PI,false);
this.surface.stroke();
this.surface.closePath();
}
,drawRect: function(x,y,width,height) {
this.surface.beginPath();
this.surface.moveTo(x,y);
this.surface.lineTo(x + width,y);
this.surface.lineTo(x + width,y + height);
this.surface.lineTo(x,y + height);
this.surface.stroke();
this.surface.closePath();
}
,drawTri: function(points) {
this.surface.beginPath();
var i = 0;
while(i < points.length) {
if(i == 0) {
this.surface.moveTo(points[i],points[i + 1]);
} else {
this.surface.lineTo(points[i],points[i + 1]);
}
i += 2;
}
this.surface.stroke();
this.surface.closePath();
}
,lineStyle: function(wid,col,alpha) {
this.surface.lineWidth = wid;
if(alpha != null && alpha != 1.0) {
var r = col >> 16 & 255;
var g = col >> 8 & 255;
var b = col & 255;
this.surface.strokeStyle = "rgba(" + r + "," + g + "," + b + "," + alpha + ")";
} else {
var tmp = StringTools.hex(col,6);
this.surface.strokeStyle = "#" + tmp;
}
}
,moveTo: function(x,y) {
this.surface.beginPath();
this.surface.moveTo(x,y);
}
,lineTo: function(x,y) {
this.surface.lineTo(x,y);
this.surface.closePath();
this.surface.stroke();
}
,quadTo: function(cx,cy,ax,ay) {
this.surface.quadraticCurveTo(cx,cy,ax,ay);
this.surface.stroke();
}
,beginFill: function(col,alpha) {
if(alpha != null && alpha != 1.0) {
var r = col >> 16 & 255;
var g = col >> 8 & 255;
var b = col & 255;
this.surface.fillStyle = "rgba(" + r + "," + g + "," + b + "," + alpha + ")";
} else {
var tmp = StringTools.hex(col,6);
this.surface.fillStyle = "#" + tmp;
}
this.surface.beginPath();
}
,endFill: function() {
this.surface.stroke();
this.surface.closePath();
this.surface.fill();
}
,__class__: wings_jsCanvas_BasicCanvas
};
var wings_jsCanvas_CanvasHeader = function() {
var canvasHeader = null.split(":");
this.width = Std.parseInt(canvasHeader[0]);
this.height = Std.parseInt(canvasHeader[1]);
this.frameRate = Std.parseInt(canvasHeader[2]);
this.bgColor = "#" + canvasHeader[3];
};
xClasses["wings.jsCanvas.CanvasHeader"] = wings_jsCanvas_CanvasHeader;
wings_jsCanvas_CanvasHeader.nom = true;
wings_jsCanvas_CanvasHeader.prototype = {
width: null
,height: null
,frameRate: null
,bgColor: null
,parseInt: function(e) {
return Std.parseInt(e);
}
,toHashColor: function(e) {
return "#" + e;
}
,__class__: wings_jsCanvas_CanvasHeader
};
var wings_jsCanvas_SimpleDrawingContext = xExport["wings"]["jsCanvas"]["SimpleDrawingContext"] = function(graphics) {
this.graphics = graphics;
};
xClasses["wings.jsCanvas.SimpleDrawingContext"] = wings_jsCanvas_SimpleDrawingContext;
wings_jsCanvas_SimpleDrawingContext.nom = true;
wings_jsCanvas_SimpleDrawingContext.__interfaces__ = [wings_core_ISimpleDrawingContext];
wings_jsCanvas_SimpleDrawingContext.prototype = {
graphics: null
,clear: function() {
this.graphics.clear();
}
,lineStyle: function(thickness,color,alpha) {
if(alpha == null) {
alpha = 1;
}
this.graphics.lineStyle(thickness,color,alpha);
}
,beginFill: function(color,alpha) {
if(alpha == null) {
alpha = 1;
}
this.graphics.beginFill(color,alpha);
}
,endFill: function() {
this.graphics.endFill();
}
,moveTo: function(x,y) {
this.graphics.moveTo(x,y);
}
,lineTo: function(x,y) {
this.graphics.lineTo(x,y);
}
,quadTo: function(cx,cy,ax,ay) {
this.graphics.quadTo(cx,cy,ax,ay);
}
,drawCircle: function(cx,cy,radius) {
this.graphics.drawCircle(cx,cy,radius);
}
,drawRect: function(x,y,width,height) {
this.graphics.drawRect(x,y,width,height);
}
,drawEquilaterialTri: function(x,y,radius,direction) {
var third = Math.PI * 2 / 3;
var points = [];
var x1;
var y1;
var _g = 0;
while(_g < 3) {
var i = _g++;
x1 = x + radius * Math.cos(direction + i * third);
y1 = y + radius * Math.sin(direction + i * third);
points.push(x1);
points.push(y1);
}
this.graphics.drawTri(points);
}
,drawTri: function(points) {
this.graphics.drawTri(points);
}
,__class__: wings_jsCanvas_SimpleDrawingContext
};
function $iterator(o) { if( o instanceof Array ) return function() { return xOverrides.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.xid == null ) m.xid = $fid++; var f; if( o.x__closures__ == null ) o.x__closures__ = {}; else f = o.x__closures__[m.xid]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.x__closures__[m.xid] = f; } return f; }
xClasses["Math"] = Math;
String.prototype.__class__ = xClasses["String"] = String;
String.nom = true;
xClasses["Array"] = Array;
Array.nom = true;
Date.prototype.__class__ = xClasses["Date"] = Date;
Date.nom = ["Date"];
var Int = xClasses["Int"] = { nom : ["Int"]};
var Dynamic = xClasses["Dynamic"] = { nom : ["Dynamic"]};
var Float = xClasses["Float"] = Number;
Float.nom = ["Float"];
var Bool = xClasses["Bool"] = Boolean;
Bool.__ename__ = ["Bool"];
var Class = xClasses["Class"] = { nom : ["Class"]};
var Enum = { };
var __map_reserved = {}
xPixels_PixelFormat.ARGB = new xPixels_PixelFormat(0,1,2,3,"ARGB");
xPixels_PixelFormat.RGBA = new xPixels_PixelFormat(3,0,1,2,"RGBA");
xPixels_PixelFormat.BGRA = new xPixels_PixelFormat(3,2,1,0,"BGRA");
var ArrayBuffer = $global.ArrayBuffer || jshtml_compat_ArrayBuffer;
if(ArrayBuffer.prototype.slice == null) {
ArrayBuffer.prototype.slice = jshtml_compat_ArrayBuffer.sliceImpl;
}
var DataView = $global.DataView || jshtml_compat_DataView;
var Float32Array = $global.Float32Array || jshtml_compat_Float32Array._new;
var Uint8Array = $global.Uint8Array || jshtml_compat_Uint8Array._new;
DIR.N = 0;
DIR.E = 1;
DIR.S = 2;
DIR.W = 3;
haxe_Unserializer.DEFAULT_RESOLVER = new haxe_xUnserializer_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_xInt64_xxxInt64(0,0);
$r = this1;
return $r;
}(this));
xDaedalus_ai_EntityAI.NUM_SEGMENTS = 6;
xDaedalus_data_Constants.EPSILON = 0.01;
xDaedalus_data_Constants.EPSILON_SQUARED = 0.0001;
xDaedalus_data_ConstraintSegment.INC = 0;
xDaedalus_data_ConstraintShape.INC = 0;
xDaedalus_data_Edge.INC = 0;
xDaedalus_data_Face.INC = 0;
xDaedalus_data_Mesh.INC = 0;
xDaedalus_data_Object.INC = 0;
xDaedalus_data_Vertex.INC = 0;
xDaedalus_data_graph_Graph.INC = 0;
xDaedalus_data_graph_GraphEdge.INC = 0;
xDaedalus_data_graph_GraphNode.INC = 0;
xDaedalus_data_math_Geom2D.__samples = [];
xDaedalus_data_math_Geom2D.__circumcenter = new xDaedalus_data_math_Point2D();
xDaedalus_data_math_Potrace.MAX_INT = 2147483647;
xDaedalus_data_math_Potrace.maxDistance = 1;
xPixels_xPixels_PixelsxImplx.CHANNEL_MASK = 3;
xPixels_xPixels_PixelsData.BYTES_PER_PIXEL = 4;
jsBoot.__toStr = ({ }).toString;
jshtml_compat_Float32Array.BYTES_PER_ELEMENT = 4;
jshtml_compat_Uint8Array.BYTES_PER_ELEMENT = 1;
kAssets.images = new kxAssets_ImageList();
kAssets.sounds = new kxAssets_SoundList();
kAssets.blobs = new kxAssets_BlobList();
kAssets.fonts = new kxAssets_FontList();
kAssets.videos = new kxAssets_VideoList();
kxColor_ColorxImplx.Black = -16777216;
kxColor_ColorxImplx.White = -1;
kxColor_ColorxImplx.Red = -65536;
kxColor_ColorxImplx.Blue = -16776961;
kxColor_ColorxImplx.Green = -16711936;
kxColor_ColorxImplx.Magenta = -65281;
kxColor_ColorxImplx.Yellow = -256;
kxColor_ColorxImplx.Cyan = -16711681;
kxColor_ColorxImplx.Purple = -8388480;
kxColor_ColorxImplx.Pink = -16181;
kxColor_ColorxImplx.Orange = -23296;
kxColor_ColorxImplx.Transparent = 0;
kxColor_ColorxImplx.invMaxChannelValue = 0.00392156862745098;
kCompilerDefines.js = "1";
kCompilerDefines.ka1 = "1";
kCompilerDefines.kg3 = "1";
kCompilerDefines.kg4 = "1";
kCompilerDefines.khtml5_js = "1";
kCompilerDefines["source-header"] = "Generated by Haxe 3.4.2";
kCompilerDefines.sys_g3 = "1";
kCompilerDefines.kg1 = "1";
kCompilerDefines.sys_a1 = "1";
kCompilerDefines.haxe_ver = "3.402";
kCompilerDefines.jquery_ver = "11204";
kCompilerDefines.kjs = "1";
kCompilerDefines.sys_html5 = "1";
kCompilerDefines.canvas_id = "khanvas";
kCompilerDefines.kversion = "1611";
kCompilerDefines.sys_g4 = "1";
kCompilerDefines.jses = "5";
kCompilerDefines.khtml5 = "1";
kCompilerDefines["js-es5"] = "1";
kCompilerDefines.jses5 = "1";
kCompilerDefines.sys_a2 = "1";
kCompilerDefines.dce = "std";
kCompilerDefines.sys_g1 = "1";
kCompilerDefines["true"] = "1";
kCompilerDefines.sys_g2 = "1";
kCompilerDefines.kwebgl = "1";
kCompilerDefines.kha = "1";
kCompilerDefines.kg2 = "1";
kCompilerDefines.haxe3 = "1";
kCompilerDefines.ka2 = "1";
kCompilerDefines.script_name = "kha";
kFontStyle.Default = new kFontStyle(false,false,false);
kScheduler.timeWarpSaveTime = 1.0;
kScheduler.DIF_COUNT = 3;
kScheduler.maxframetime = 0.5;
kScheduler.startTime = 0;
kShaders.painter_colored_fragData0 = "s198:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdmFyeWluZyBoaWdocCB2ZWM0IGZyYWdtZW50Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9GcmFnRGF0YVswXSA9IGZyYWdtZW50Q29sb3I7Cn0KCg";
kShaders.painter_colored_fragData1 = "s192:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp2YXJ5aW5nIHZlYzQgZnJhZ21lbnRDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX0ZyYWdEYXRhWzBdID0gZnJhZ21lbnRDb2xvcjsKfQoK";
kShaders.painter_colored_fragData2 = "s210:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7CgpvdXQgdmVjNCBGcmFnQ29sb3I7CmluIHZlYzQgZnJhZ21lbnRDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIEZyYWdDb2xvciA9IGZyYWdtZW50Q29sb3I7Cn0KCg";
kShaders.painter_colored_vertData0 = "s331:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgZnJhZ21lbnRDb2xvcjsKYXR0cmlidXRlIHZlYzQgdmVydGV4Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9Qb3NpdGlvbiA9IHByb2plY3Rpb25NYXRyaXggKiB2ZWM0KHZlcnRleFBvc2l0aW9uLCAxLjApOwogICAgZnJhZ21lbnRDb2xvciA9IHZlcnRleENvbG9yOwp9Cgo";
kShaders.painter_colored_vertData1 = "s374:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzQgZnJhZ21lbnRDb2xvcjsKYXR0cmlidXRlIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICBmcmFnbWVudENvbG9yID0gdmVydGV4Q29sb3I7Cn0KCg";
kShaders.painter_colored_vertData2 = "s354:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWM0IGZyYWdtZW50Q29sb3I7CmluIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICBmcmFnbWVudENvbG9yID0gdmVydGV4Q29sb3I7Cn0KCg";
kShaders.painter_image_fragData0 = "s471:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdW5pZm9ybSBoaWdocCBzYW1wbGVyMkQgdGV4OwoKdmFyeWluZyBoaWdocCB2ZWMyIHRleENvb3JkOwp2YXJ5aW5nIGhpZ2hwIHZlYzQgY29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBoaWdocCB2ZWM0IHRleGNvbG9yID0gdGV4dHVyZTJEKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICBoaWdocCB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBnbF9GcmFnRGF0YVswXSA9IHRleGNvbG9yOwp9Cgo";
kShaders.painter_image_fragData1 = "s444:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCnZhcnlpbmcgdmVjMiB0ZXhDb29yZDsKdmFyeWluZyB2ZWM0IGNvbG9yOwoKdm9pZCBtYWluKCkKewogICAgdmVjNCB0ZXhjb2xvciA9IHRleHR1cmUyRCh0ZXgsIHRleENvb3JkKSAqIGNvbG9yOwogICAgdmVjMyBfMzIgPSB0ZXhjb2xvci54eXogKiBjb2xvci53OwogICAgdGV4Y29sb3IgPSB2ZWM0KF8zMi54LCBfMzIueSwgXzMyLnosIHRleGNvbG9yLncpOwogICAgZ2xfRnJhZ0RhdGFbMF0gPSB0ZXhjb2xvcjsKfQoK";
kShaders.painter_image_fragData2 = "s452:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCmluIHZlYzIgdGV4Q29vcmQ7CmluIHZlYzQgY29sb3I7Cm91dCB2ZWM0IEZyYWdDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIHZlYzQgdGV4Y29sb3IgPSB0ZXh0dXJlKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBGcmFnQ29sb3IgPSB0ZXhjb2xvcjsKfQoK";
kShaders.painter_image_vertData0 = "s415:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSB2ZWMyIHRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgY29sb3I7CmF0dHJpYnV0ZSB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo";
kShaders.painter_image_vertData1 = "s479:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247CnZhcnlpbmcgbWVkaXVtcCB2ZWM0IGNvbG9yOwphdHRyaWJ1dGUgbWVkaXVtcCB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo";
kShaders.painter_image_vertData2 = "s444:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWMyIHRleENvb3JkOwppbiBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247Cm91dCBtZWRpdW1wIHZlYzQgY29sb3I7CmluIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICB0ZXhDb29yZCA9IHRleFBvc2l0aW9uOwogICAgY29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK";
kShaders.painter_text_fragData0 = "s351:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdW5pZm9ybSBoaWdocCBzYW1wbGVyMkQgdGV4OwoKdmFyeWluZyBoaWdocCB2ZWM0IGZyYWdtZW50Q29sb3I7CnZhcnlpbmcgaGlnaHAgdmVjMiB0ZXhDb29yZDsKCnZvaWQgbWFpbigpCnsKICAgIGdsX0ZyYWdEYXRhWzBdID0gdmVjNChmcmFnbWVudENvbG9yLnh5eiwgdGV4dHVyZTJEKHRleCwgdGV4Q29vcmQpLnggKiBmcmFnbWVudENvbG9yLncpOwp9Cgo";
kShaders.painter_text_fragData1 = "s340:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCnZhcnlpbmcgdmVjNCBmcmFnbWVudENvbG9yOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9GcmFnRGF0YVswXSA9IHZlYzQoZnJhZ21lbnRDb2xvci54eXosIHRleHR1cmUyRCh0ZXgsIHRleENvb3JkKS54ICogZnJhZ21lbnRDb2xvci53KTsKfQoK";
kShaders.painter_text_fragData2 = "s348:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCm91dCB2ZWM0IEZyYWdDb2xvcjsKaW4gdmVjNCBmcmFnbWVudENvbG9yOwppbiB2ZWMyIHRleENvb3JkOwoKdm9pZCBtYWluKCkKewogICAgRnJhZ0NvbG9yID0gdmVjNChmcmFnbWVudENvbG9yLnh5eiwgdGV4dHVyZSh0ZXgsIHRleENvb3JkKS54ICogZnJhZ21lbnRDb2xvci53KTsKfQoK";
kShaders.painter_text_vertData0 = "s436:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSB2ZWMyIHRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgZnJhZ21lbnRDb2xvcjsKYXR0cmlidXRlIHZlYzQgdmVydGV4Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9Qb3NpdGlvbiA9IHByb2plY3Rpb25NYXRyaXggKiB2ZWM0KHZlcnRleFBvc2l0aW9uLCAxLjApOwogICAgdGV4Q29vcmQgPSB0ZXhQb3NpdGlvbjsKICAgIGZyYWdtZW50Q29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK";
kShaders.painter_text_vertData1 = "s500:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247CnZhcnlpbmcgbWVkaXVtcCB2ZWM0IGZyYWdtZW50Q29sb3I7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzQgdmVydGV4Q29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBnbF9Qb3NpdGlvbiA9IHByb2plY3Rpb25NYXRyaXggKiB2ZWM0KHZlcnRleFBvc2l0aW9uLCAxLjApOwogICAgdGV4Q29vcmQgPSB0ZXhQb3NpdGlvbjsKICAgIGZyYWdtZW50Q29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK";
kShaders.painter_text_vertData2 = "s466:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWMyIHRleENvb3JkOwppbiBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247Cm91dCBtZWRpdW1wIHZlYzQgZnJhZ21lbnRDb2xvcjsKaW4gbWVkaXVtcCB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBmcmFnbWVudENvbG9yID0gdmVydGV4Q29sb3I7Cn0KCg";
kShaders.painter_video_fragData0 = "s471:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gaGlnaHAgaW50OwoKdW5pZm9ybSBoaWdocCBzYW1wbGVyMkQgdGV4OwoKdmFyeWluZyBoaWdocCB2ZWMyIHRleENvb3JkOwp2YXJ5aW5nIGhpZ2hwIHZlYzQgY29sb3I7Cgp2b2lkIG1haW4oKQp7CiAgICBoaWdocCB2ZWM0IHRleGNvbG9yID0gdGV4dHVyZTJEKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICBoaWdocCB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBnbF9GcmFnRGF0YVswXSA9IHRleGNvbG9yOwp9Cgo";
kShaders.painter_video_fragData1 = "s444:I3ZlcnNpb24gMTAwCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCnZhcnlpbmcgdmVjMiB0ZXhDb29yZDsKdmFyeWluZyB2ZWM0IGNvbG9yOwoKdm9pZCBtYWluKCkKewogICAgdmVjNCB0ZXhjb2xvciA9IHRleHR1cmUyRCh0ZXgsIHRleENvb3JkKSAqIGNvbG9yOwogICAgdmVjMyBfMzIgPSB0ZXhjb2xvci54eXogKiBjb2xvci53OwogICAgdGV4Y29sb3IgPSB2ZWM0KF8zMi54LCBfMzIueSwgXzMyLnosIHRleGNvbG9yLncpOwogICAgZ2xfRnJhZ0RhdGFbMF0gPSB0ZXhjb2xvcjsKfQoK";
kShaders.painter_video_fragData2 = "s452:I3ZlcnNpb24gMzAwIGVzCnByZWNpc2lvbiBtZWRpdW1wIGZsb2F0OwpwcmVjaXNpb24gbWVkaXVtcCBpbnQ7Cgp1bmlmb3JtIG1lZGl1bXAgc2FtcGxlcjJEIHRleDsKCmluIHZlYzIgdGV4Q29vcmQ7CmluIHZlYzQgY29sb3I7Cm91dCB2ZWM0IEZyYWdDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIHZlYzQgdGV4Y29sb3IgPSB0ZXh0dXJlKHRleCwgdGV4Q29vcmQpICogY29sb3I7CiAgICB2ZWMzIF8zMiA9IHRleGNvbG9yLnh5eiAqIGNvbG9yLnc7CiAgICB0ZXhjb2xvciA9IHZlYzQoXzMyLngsIF8zMi55LCBfMzIueiwgdGV4Y29sb3Iudyk7CiAgICBGcmFnQ29sb3IgPSB0ZXhjb2xvcjsKfQoK";
kShaders.painter_video_vertData0 = "s415:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1hdDQgcHJvamVjdGlvbk1hdHJpeDsKCmF0dHJpYnV0ZSB2ZWMzIHZlcnRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSB2ZWMyIHRleFBvc2l0aW9uOwp2YXJ5aW5nIHZlYzQgY29sb3I7CmF0dHJpYnV0ZSB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo";
kShaders.painter_video_vertData1 = "s479:I3ZlcnNpb24gMTAwCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKYXR0cmlidXRlIG1lZGl1bXAgdmVjMyB2ZXJ0ZXhQb3NpdGlvbjsKdmFyeWluZyBtZWRpdW1wIHZlYzIgdGV4Q29vcmQ7CmF0dHJpYnV0ZSBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247CnZhcnlpbmcgbWVkaXVtcCB2ZWM0IGNvbG9yOwphdHRyaWJ1dGUgbWVkaXVtcCB2ZWM0IHZlcnRleENvbG9yOwoKdm9pZCBtYWluKCkKewogICAgZ2xfUG9zaXRpb24gPSBwcm9qZWN0aW9uTWF0cml4ICogdmVjNCh2ZXJ0ZXhQb3NpdGlvbiwgMS4wKTsKICAgIHRleENvb3JkID0gdGV4UG9zaXRpb247CiAgICBjb2xvciA9IHZlcnRleENvbG9yOwp9Cgo";
kShaders.painter_video_vertData2 = "s444:I3ZlcnNpb24gMzAwIGVzCgp1bmlmb3JtIG1lZGl1bXAgbWF0NCBwcm9qZWN0aW9uTWF0cml4OwoKaW4gbWVkaXVtcCB2ZWMzIHZlcnRleFBvc2l0aW9uOwpvdXQgbWVkaXVtcCB2ZWMyIHRleENvb3JkOwppbiBtZWRpdW1wIHZlYzIgdGV4UG9zaXRpb247Cm91dCBtZWRpdW1wIHZlYzQgY29sb3I7CmluIG1lZGl1bXAgdmVjNCB2ZXJ0ZXhDb2xvcjsKCnZvaWQgbWFpbigpCnsKICAgIGdsX1Bvc2l0aW9uID0gcHJvamVjdGlvbk1hdHJpeCAqIHZlYzQodmVydGV4UG9zaXRpb24sIDEuMCk7CiAgICB0ZXhDb29yZCA9IHRleFBvc2l0aW9uOwogICAgY29sb3IgPSB2ZXJ0ZXhDb2xvcjsKfQoK";
kSystem.renderListeners = [];
kSystem.foregroundListeners = [];
kSystem.resumeListeners = [];
kSystem.pauseListeners = [];
kSystem.backgroundListeners = [];
kSystem.shutdownListeners = [];
kSystem.dropFilesListeners = [];
kSystemImpl.mobile = false;
kSystemImpl.mobileAudioPlaying = false;
kSystemImpl.chrome = false;
kSystemImpl.insideInputEvent = false;
kSystemImpl.maxGamepads = 4;
kSystemImpl.leftMouseCtrlDown = false;
kSystemImpl.minimumScroll = 999;
kSystemImpl.lastFirstTouchX = 0;
kSystemImpl.lastFirstTouchY = 0;
kSystemImpl.iosSoundEnabled = false;
kWebGLImage.GL_RGBA16F = 34842;
kWebGLImage.GL_RGBA32F = 34836;
kWebGLImage.GL_R16F = 33325;
kWebGLImage.GL_R32F = 33326;
kWebGLImage.GL_RED = 6403;
kWebGLImage.GL_DEPTH_COMPONENT24 = 33190;
kWebGLImage.GL_DEPTH24_STENCIL8 = 35056;
kWebGLImage.GL_DEPTH32F_STENCIL8 = 36013;
kaudio2_Audio1.channelCount = 16;
kaudio2_ogg_tools_Crc32.POLY = 79764919;
kaudio2_ogg_vorbis_VorbisDecodeState.INVALID_BITS = -1;
kaudio2_ogg_vorbis_VorbisTools.EOP = -1;
kaudio2_ogg_vorbis_VorbisTools.M__PI = 3.14159265358979323846264;
kaudio2_ogg_vorbis_VorbisTools.DIVTAB_NUMER = 32;
kaudio2_ogg_vorbis_VorbisTools.DIVTAB_DENOM = 64;
kaudio2_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];
kaudio2_ogg_vorbis_data_Codebook.NO_CODE = 255;
kaudio2_ogg_vorbis_data_Codebook.delay = 0;
kaudio2_ogg_vorbis_data_Header.PACKET_ID = 1;
kaudio2_ogg_vorbis_data_Header.PACKET_COMMENT = 3;
kaudio2_ogg_vorbis_data_Header.PACKET_SETUP = 5;
kaudio2_ogg_vorbis_data_PageFlag.CONTINUED_PACKET = 1;
kaudio2_ogg_vorbis_data_PageFlag.FIRST_PAGE = 2;
kaudio2_ogg_vorbis_data_PageFlag.LAST_PAGE = 4;
kaudio2_ogg_vorbis_data_Setting.MAX_CHANNELS = 16;
kaudio2_ogg_vorbis_data_Setting.PUSHDATA_CRC_COUNT = 4;
kaudio2_ogg_vorbis_data_Setting.FAST_HUFFMAN_LENGTH = 10;
kaudio2_ogg_vorbis_data_Setting.FAST_HUFFMAN_TABLE_SIZE = 1024;
kaudio2_ogg_vorbis_data_Setting.FAST_HUFFMAN_TABLE_MASK = 1023;
kgraphics2_truetype_StbTruetype.STBTT_vmove = 1;
kgraphics2_truetype_StbTruetype.STBTT_vline = 2;
kgraphics2_truetype_StbTruetype.STBTT_vcurve = 3;
kgraphics2_truetype_StbTruetype.STBTT_MACSTYLE_DONTCARE = 0;
kgraphics2_truetype_StbTruetype.STBTT_MACSTYLE_BOLD = 1;
kgraphics2_truetype_StbTruetype.STBTT_MACSTYLE_ITALIC = 2;
kgraphics2_truetype_StbTruetype.STBTT_MACSTYLE_UNDERSCORE = 4;
kgraphics2_truetype_StbTruetype.STBTT_MACSTYLE_NONE = 8;
kgraphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_UNICODE = 0;
kgraphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_MAC = 1;
kgraphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_ISO = 2;
kgraphics2_truetype_StbTruetype.STBTT_PLATFORM_ID_MICROSOFT = 3;
kgraphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_1_0 = 0;
kgraphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_1_1 = 1;
kgraphics2_truetype_StbTruetype.STBTT_UNICODE_EID_ISO_10646 = 2;
kgraphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_2_0_BMP = 3;
kgraphics2_truetype_StbTruetype.STBTT_UNICODE_EID_UNICODE_2_0_FULL = 4;
kgraphics2_truetype_StbTruetype.STBTT_MS_EID_SYMBOL = 0;
kgraphics2_truetype_StbTruetype.STBTT_MS_EID_UNICODE_BMP = 1;
kgraphics2_truetype_StbTruetype.STBTT_MS_EID_SHIFTJIS = 2;
kgraphics2_truetype_StbTruetype.STBTT_MS_EID_UNICODE_FULL = 10;
kgraphics2_truetype_StbTruetype.STBTT_MAC_EID_ROMAN = 0;
kgraphics2_truetype_StbTruetype.STBTT_MAC_EID_ARABIC = 4;
kgraphics2_truetype_StbTruetype.STBTT_MAC_EID_JAPANESE = 1;
kgraphics2_truetype_StbTruetype.STBTT_MAC_EID_HEBREW =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment