UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

173 lines (156 loc) 4.36 kB
// Class: starling.utils.Pool var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../hxClasses_stub").default; var $hxEnums = require("./../../hxEnums_stub").default; var $import = require("./../../import_stub").default; function openfl__$Vector_Vector_$Impl_$() {return require("./../../openfl/_Vector/Vector_Impl_");} function openfl_geom_Point() {return $import(require("openfl/geom/Point"));} function openfl_geom_Vector3D() {return $import(require("openfl/geom/Vector3D"));} function openfl_geom_Matrix() {return $import(require("openfl/geom/Matrix"));} function openfl_geom_Matrix3D() {return $import(require("openfl/geom/Matrix3D"));} function openfl_geom_Rectangle() {return $import(require("openfl/geom/Rectangle"));} // Constructor var Pool = function() { } // Meta Pool.__name__ = "starling.utils.Pool"; Pool.__isInterface__ = false; Pool.prototype = { }; Pool.prototype.__class__ = Pool.prototype.constructor = $hxClasses["starling.utils.Pool"] = Pool; // Init // Statics Pool.getPoint = function(x,y) { if(y == null) { y = 0; } if(x == null) { x = 0; } if(Pool.sPoints.length == 0) { return new (openfl_geom_Point().default)(x,y); } else { var point = (openfl__$Vector_Vector_$Impl_$().default).pop(Pool.sPoints); point.x = x; point.y = y; return point; } } Pool.putPoint = function(point) { if(point != null) { (openfl__$Vector_Vector_$Impl_$().default).set(Pool.sPoints,Pool.sPoints.length,point); } } Pool.getPoint3D = function(x,y,z) { if(z == null) { z = 0; } if(y == null) { y = 0; } if(x == null) { x = 0; } if(Pool.sPoints3D.length == 0) { return new (openfl_geom_Vector3D().default)(x,y,z); } else { var point = (openfl__$Vector_Vector_$Impl_$().default).pop(Pool.sPoints3D); point.x = x; point.y = y; point.z = z; return point; } } Pool.putPoint3D = function(point) { if(point != null) { (openfl__$Vector_Vector_$Impl_$().default).set(Pool.sPoints3D,Pool.sPoints3D.length,point); } } Pool.getMatrix = function(a,b,c,d,tx,ty) { if(ty == null) { ty = 0; } if(tx == null) { tx = 0; } if(d == null) { d = 1; } if(c == null) { c = 0; } if(b == null) { b = 0; } if(a == null) { a = 1; } if(Pool.sMatrices.length == 0) { return new (openfl_geom_Matrix().default)(a,b,c,d,tx,ty); } else { var matrix = (openfl__$Vector_Vector_$Impl_$().default).pop(Pool.sMatrices); matrix.setTo(a,b,c,d,tx,ty); return matrix; } } Pool.putMatrix = function(matrix) { if(matrix != null) { (openfl__$Vector_Vector_$Impl_$().default).set(Pool.sMatrices,Pool.sMatrices.length,matrix); } } Pool.getMatrix3D = function(identity) { if(identity == null) { identity = true; } if(Pool.sMatrices3D.length == 0) { return new (openfl_geom_Matrix3D().default)(); } else { var matrix = (openfl__$Vector_Vector_$Impl_$().default).pop(Pool.sMatrices3D); if(identity) { matrix.identity(); } return matrix; } } Pool.putMatrix3D = function(matrix) { if(matrix != null) { (openfl__$Vector_Vector_$Impl_$().default).set(Pool.sMatrices3D,Pool.sMatrices3D.length,matrix); } } Pool.getRectangle = function(x,y,width,height) { if(height == null) { height = 0; } if(width == null) { width = 0; } if(y == null) { y = 0; } if(x == null) { x = 0; } if(Pool.sRectangles.length == 0) { return new (openfl_geom_Rectangle().default)(x,y,width,height); } else { var rectangle = (openfl__$Vector_Vector_$Impl_$().default).pop(Pool.sRectangles); rectangle.setTo(x,y,width,height); return rectangle; } } Pool.putRectangle = function(rectangle) { if(rectangle != null) { (openfl__$Vector_Vector_$Impl_$().default).set(Pool.sRectangles,Pool.sRectangles.length,rectangle); } } Pool.sPoints = (openfl__$Vector_Vector_$Impl_$().default)._new() Pool.sPoints3D = (openfl__$Vector_Vector_$Impl_$().default)._new() Pool.sMatrices = (openfl__$Vector_Vector_$Impl_$().default)._new() Pool.sMatrices3D = (openfl__$Vector_Vector_$Impl_$().default)._new() Pool.sRectangles = (openfl__$Vector_Vector_$Impl_$().default)._new() Pool.sArrays = (openfl__$Vector_Vector_$Impl_$().default)._new() // Export exports.default = Pool;