101 lines
1.9 KiB
JavaScript
101 lines
1.9 KiB
JavaScript
/**
|
|
* R3.API.Image
|
|
* @param id
|
|
* @param name
|
|
* @param parentEntity
|
|
* @param parentTexture
|
|
* @param fileName
|
|
* @param extension
|
|
* @param path
|
|
* @param contentType
|
|
* @param size
|
|
* @param width
|
|
* @param height
|
|
* @constructor
|
|
*/
|
|
R3.API.Image = function(
|
|
id,
|
|
name,
|
|
parentEntity,
|
|
parentTexture,
|
|
fileName,
|
|
extension,
|
|
path,
|
|
contentType,
|
|
size,
|
|
width,
|
|
height
|
|
) {
|
|
if (R3.Utils.UndefinedOrNull(id)) {
|
|
id = R3.Utils.RandomId();
|
|
}
|
|
this.id = id;
|
|
|
|
if (R3.Utils.UndefinedOrNull(name)) {
|
|
name = 'Image ' + id;
|
|
}
|
|
this.name = name;
|
|
|
|
if (R3.Utils.UndefinedOrNull(parentTexture)) {
|
|
parentTexture = null;
|
|
}
|
|
this.parentTexture = parentTexture;
|
|
|
|
if (R3.Utils.UndefinedOrNull(fileName)) {
|
|
fileName = R3.Utils.LowerUnderscore(name);
|
|
}
|
|
this.fileName = fileName;
|
|
|
|
if (R3.Utils.UndefinedOrNull(extension)) {
|
|
extension = '.unknown';
|
|
}
|
|
this.extension = extension;
|
|
|
|
if (R3.Utils.UndefinedOrNull(path)) {
|
|
path = '/';
|
|
}
|
|
this.path = path;
|
|
|
|
if (R3.Utils.UndefinedOrNull(contentType)) {
|
|
|
|
contentType = 'application/octet-stream';
|
|
|
|
if (this.extension.match(/(png)$/i)) {
|
|
contentType = 'image/png';
|
|
}
|
|
|
|
if (this.extension.match(/(jpg|jpeg)$/i)) {
|
|
contentType = 'image/jpeg';
|
|
}
|
|
|
|
if (this.extension.match(/(gif)$/i)) {
|
|
contentType = 'image/gif';
|
|
}
|
|
}
|
|
this.contentType = contentType;
|
|
|
|
if (R3.Utils.UndefinedOrNull(size)) {
|
|
size = 0;
|
|
}
|
|
this.size = size;
|
|
|
|
if (R3.Utils.UndefinedOrNull(width)) {
|
|
width = 0;
|
|
}
|
|
this.width = width;
|
|
|
|
if (R3.Utils.UndefinedOrNull(height)) {
|
|
height = 0;
|
|
}
|
|
this.height = height;
|
|
|
|
R3.API.Component.call(
|
|
this,
|
|
R3.Component.IMAGE,
|
|
parentEntity
|
|
);
|
|
};
|
|
|
|
R3.API.Image.prototype = Object.create(R3.API.Component.prototype);
|
|
R3.API.Image.prototype.constructor = R3.API.Image;
|