/** * Image * @param id * @param name * @param path * @param contentType * @param size * @param data * @param parentEntity GameLib.Entity * @constructor */ GameLib.D3.API.Image = function( id, name, path, contentType, size, data, parentEntity ) { if (GameLib.Utils.UndefinedOrNull(id)) { id = GameLib.Utils.RandomId(); } this.id = id; if (GameLib.Utils.UndefinedOrNull(name)) { name = 'Image ' + GameLib.Utils.RandomId() + '.png'; } this.name = name; if (GameLib.Utils.UndefinedOrNull(path)) { path = '/' + this.name.toLowerCase().replace(' ', '_'); } this.path = path; if (GameLib.Utils.UndefinedOrNull(contentType)) { contentType = 'application/octet-stream'; if (this.name.match(/(png)$/i)) { contentType = 'image/png'; } if (this.name.match(/(jpg|jpeg)$/i)) { contentType = 'image/jpeg'; } if (this.name.match(/(gif)$/i)) { contentType = 'image/gif'; } } this.contentType = contentType; if (GameLib.Utils.UndefinedOrNull(size)) { size = 0; } this.size = size; if (GameLib.Utils.UndefinedOrNull(data)) { data = null; } this.data = data; if (GameLib.Utils.UndefinedOrNull(parentEntity)) { parentEntity = null; } this.parentEntity = parentEntity; }; GameLib.D3.API.Image.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Image.prototype.constructor = GameLib.D3.API.Image; /** * Returns an API light from an Object light * @constructor * @param objectImage */ GameLib.D3.API.Image.FromObject = function(objectImage) { return new GameLib.D3.API.Image( objectImage.id, objectImage.name, objectImage.path, objectImage.contentType, objectImage.size, objectImage.data, objectImage.parentEntity ); };