ds/ImageParams.js

/**
 * @fileoverview Exposed data type for use outside of DsClient.
 *               All properties should be exposed to allow use from uncompiled
 *               code.
 *
 * @author anders.rejdebrant@spark-vision.com (Anders Rejdebrant)
 */

goog.provide('spv.ds.ImageParams');




/**
 * This data structure holds all parameters used in image requests.
 * The default values initialized by the constructor are not recommended, 
 * the context should provide a factory function for default construction.
 * 
 * The image compose process goes as follows.
 * 
 * 1. Image is rendered to it's native resolution
 * 2. Image is scaled according to scaled_width and scaled_height
 * 3. Image is cropped according to cropped_width and cropped_height
 * 4. Image is auto cropped if auto_crop is set
 * 5. Image is saved
 * 
 * Note that a "0" in scaled_width, scaled_height, cropped_width or 
 * cropped_height means that it will use the "native/source" value for that 
 * dimension. If auto_crop is set however, and exactly one of scaled_width or 
 * scaled_height is set to "0", the "0" will be replaced with a value that
 * keeps the source aspect ratio.
 * 
 * @export
 * @struct
 * @constructor
 */
spv.ds.ImageParams = function()
{
	/**
	 * Width that the rendered image should be scaled to
	 *
	 * @nocollapse
	 * @type {number}
	 */
	this.scaled_width = 0;

	/**
	 * Height that the rendered image should be scaled to
	 *
	 * @nocollapse
	 * @type {number}
	 */
	this.scaled_height = 0;

	/**
	 * Name of the series to be used (EXTERIOR or INTERIOR in most cases)
	 *
	 * @nocollapse
	 * @type {string}
	 */
	this.serie_name = 'EXTERIOR';

	/**
	 * Index for the frame/angle
	 *
	 * @nocollapse
	 * @type {number}
	 */
	this.frame = 1;

	/**
	 * Distribution of the cropped pixels along the X axis (0 = Crop right, 0.5 = Equal, 1 = Crop left)
	 *
	 * @nocollapse
	 * @type {number}
	 */
	this.crop_x_ratio = 0.5;

	/**
	 * Distribution of the cropped pixels along the Y axis (0 = Crop bottom, 0.5 = Equal, 1 = Crop top)
	 *
	 * @nocollapse
	 * @type {number}
	 */
	this.crop_y_ratio = 0.5;

	/**
	 * Width of image after crop
	 *
	 * @nocollapse
	 * @type {number}
	 */
	this.cropped_width = 0;

	/**
	 * Height of image after crop
	 *
	 * @nocollapse
	 * @type {number}
	 */
	this.cropped_height = 0;

	/**
	 * Items that should not contribute to the image (S-TENT is often set here)
	 *
	 * @nocollapse
	 * @type {Array.<string>}
	 */
	this.skip = [];

	/**
	 * Itemgroups that should not contribute to the image
	 *
	 * @nocollapse
	 * @type {Array.<string>}
	 */
	this.skip_groups = [];

	/**
	 * The only items that should contribute to the image
	 *
	 * @nocollapse
	 * @type {Array.<string>}
	 */
	this.only_use = [];

	/**
	 * The only item groups that should contribute to the image
	 *
	 * @nocollapse
	 * @type {Array.<string>}
	 */
	this.only_use_groups = [];

	/**
	 * Type of image (png or jpg)
	 *
	 * @nocollapse
	 * @type {string}
	 */
	this.file_type = 'jpg';

	/**
	 * Use HD material
	 *
	 * @nocollapse
	 * @type {boolean}
	 */
	this.use_hd = false;

	/**
	 * Keep aspect ratio (set any of scaled_width or scaled_height in order for it 
	 * to have any effect)
	 *
	 * @nocollapse
	 * @type {boolean}
	 */
	this.keep_aspect_ratio = true;

	/**
	 * Automatically crops the image of all bordering "empty" pixels
	 *
	 * @nocollapse
	 * @type {boolean}
	 */
	this.auto_crop = false;

	/**
	 * Specifies the color of the background.
	 * Should be a hexadecimal string representing the color.
	 *
	 * @nocollapse
	 * @type {string}
	 */
	this.bg_color_hex = "FFFFFFFF";
};