@applitools/utils
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -6,2 +6,6 @@ # Changelog | ||
## 1.2.2 - 2021/8/7 | ||
- add `geometry.rotate` to rotate region and sizes to on certain number of degrees | ||
## 1.2.1 - 2021/8/3 | ||
@@ -8,0 +12,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.divide = exports.equals = exports.contains = exports.isIntersected = exports.subtraction = exports.intersect = exports.offsetNegative = exports.offset = exports.scale = exports.isEmpty = exports.region = exports.size = exports.location = void 0; | ||
exports.divide = exports.equals = exports.contains = exports.isIntersected = exports.subtraction = exports.intersect = exports.offsetNegative = exports.offset = exports.scale = exports.rotate = exports.round = exports.isEmpty = exports.region = exports.size = exports.location = void 0; | ||
const types = require("./types"); | ||
@@ -24,2 +24,25 @@ const guard = require("./guard"); | ||
exports.isEmpty = isEmpty; | ||
function round(target) { | ||
const result = Object.assign({}, target); | ||
if (types.has(target, ['x', 'y'])) { | ||
result.x = Math.round(target.x); | ||
result.y = Math.round(target.y); | ||
} | ||
if (types.has(target, ['width', 'height'])) { | ||
result.width = Math.round(target.width); | ||
result.height = Math.round(target.height); | ||
} | ||
return result; | ||
} | ||
exports.round = round; | ||
function rotate(target, degree) { | ||
const result = Object.assign({}, target); | ||
const rotate = Boolean(Math.floor(degree / 90) % 2); | ||
if (rotate) { | ||
result.width = target.height; | ||
result.height = target.width; | ||
} | ||
return result; | ||
} | ||
exports.rotate = rotate; | ||
function scale(target, scaleRatio) { | ||
@@ -138,4 +161,4 @@ const result = Object.assign({}, target); | ||
// last region | ||
else if (nextY + padding.bottom >= maxY) | ||
nextY += padding.bottom; | ||
else if (nextY < maxY && nextY + padding.top >= maxY) | ||
nextY = maxY; | ||
const currentHeight = nextY - currentY; | ||
@@ -142,0 +165,0 @@ let currentX = region.x; |
{ | ||
"name": "@applitools/utils", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "applitools", |
@@ -20,2 +20,7 @@ declare type Location = { | ||
export declare function isEmpty(region: Region): boolean; | ||
export declare function round(region: Region): Region; | ||
export declare function round(region: RectangleSize): RectangleSize; | ||
export declare function round(region: Location): Location; | ||
export declare function rotate(region: Region, degree: number): Region; | ||
export declare function rotate(size: RectangleSize, degree: number): RectangleSize; | ||
export declare function scale(region: Region, scaleRatio: number): Region; | ||
@@ -22,0 +27,0 @@ export declare function scale(size: RectangleSize, scaleRatio: number): RectangleSize; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
78026
676
1