askui
Version:
Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on
39 lines (38 loc) • 1.03 kB
JavaScript
/**
*
* @remarks
* The screen top left corner is the origin
*
* @param {number} xmin - The bounding box xmin coordinate in pixels
* @param {number} ymin - The bounding box ymin coordinate in pixels
* @param {number} xmax - The bounding box xmax coordinate in pixels
* @param {number} ymax - The bounding box ymax coordinate in pixels
*
*/
export class BoundingBox {
constructor(xmin, ymin, xmax, ymax) {
this.xmin = xmin;
this.ymin = ymin;
this.xmax = xmax;
this.ymax = ymax;
}
static fromJson(boundinBox, resizeRatio = 1) {
return new BoundingBox(boundinBox.xmin * resizeRatio, boundinBox.ymin * resizeRatio, boundinBox.xmax * resizeRatio, boundinBox.ymax * resizeRatio);
}
/**
*
* @returns {number} The bounding box height in pixels
*
*/
get_height() {
return this.ymax - this.ymin;
}
/**
*
* @returns {number} The bounding box width in pixels
*
*/
get_width() {
return this.xmax - this.xmin;
}
}