UNPKG

starling-framework

Version:

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

75 lines (57 loc) 2.04 kB
// Class: starling.geom.Rectangle 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; var $extend = require("./../../extend_stub").default; function starling_geom_ImmutablePolygon() {return require("./../../starling/geom/ImmutablePolygon");} function starling_rendering_IndexData() {return require("./../../starling/rendering/IndexData");} // Constructor var Rectangle = function(x,y,width,height) { this.__x = x; this.__y = y; this.__width = width; this.__height = height; (starling_geom_ImmutablePolygon().default).call(this,[x,y,x + width,y,x + width,y + height,x,y + height]); } // Meta Rectangle.__name__ = "starling.geom.Rectangle"; Rectangle.__isInterface__ = false; Rectangle.__super__ = (starling_geom_ImmutablePolygon().default); Rectangle.prototype = $extend((starling_geom_ImmutablePolygon().default).prototype, { triangulate: function(indexData,offset) { if(offset == null) { offset = 0; } if(indexData == null) { indexData = new (starling_rendering_IndexData().default)(6); } indexData.addTriangle(offset,offset + 1,offset + 3); indexData.addTriangle(offset + 1,offset + 2,offset + 3); return indexData; }, contains: function(x,y) { if(x >= this.__x && x <= this.__x + this.__width && y >= this.__y) { return y <= this.__y + this.__height; } else { return false; } }, get_area: function() { return this.__width * this.__height; }, get_isSimple: function() { return true; }, get_isConvex: function() { return true; } }); Rectangle.prototype.__class__ = Rectangle.prototype.constructor = $hxClasses["starling.geom.Rectangle"] = Rectangle; // Init // Statics // Export exports.default = Rectangle;