reformat code

This commit is contained in:
yhh
2020-07-28 16:25:20 +08:00
parent 5994f0bee3
commit 514572f291
103 changed files with 2896 additions and 2839 deletions

View File

@@ -2,6 +2,7 @@ module es {
export class Rectangle extends egret.Rectangle {
public _tempMat: Matrix2D;
public _transformMat: Matrix2D;
/**
* 获取矩形的最大点,即右下角
*/
@@ -18,6 +19,7 @@ module es {
public get location() {
return new Vector2(this.x, this.y);
}
/** 左上角的坐标 */
public set location(value: Vector2) {
this.x = value.x;
@@ -33,6 +35,41 @@ module es {
this.height = value.y;
}
/**
* 创建一个矩形的最小/最大点(左上角,右下角的点)
* @param minX
* @param minY
* @param maxX
* @param maxY
*/
public static fromMinMax(minX: number, minY: number, maxX: number, maxY: number) {
return new Rectangle(minX, minY, maxX - minX, maxY - minY);
}
/**
* 给定多边形的点,计算边界
* @param points
*/
public static rectEncompassingPoints(points: Vector2[]) {
// 我们需要求出x/y的最小值/最大值
let minX = Number.POSITIVE_INFINITY;
let minY = Number.POSITIVE_INFINITY;
let maxX = Number.NEGATIVE_INFINITY;
let maxY = Number.NEGATIVE_INFINITY;
for (let i = 0; i < points.length; i++) {
let pt = points[i];
if (pt.x < minX) minX = pt.x;
if (pt.x > maxX) maxX = pt.x;
if (pt.y < minY) minY = pt.y;
if (pt.y > maxY) maxY = pt.y;
}
return this.fromMinMax(minX, minY, maxX, maxY);
}
/**
* 是否与另一个矩形相交
* @param value
@@ -58,17 +95,6 @@ module es {
return new Vector2(this.width * 0.5, this.height * 0.5);
}
/**
* 创建一个矩形的最小/最大点(左上角,右下角的点)
* @param minX
* @param minY
* @param maxX
* @param maxY
*/
public static fromMinMax(minX: number, minY: number, maxX: number, maxY: number) {
return new Rectangle(minX, minY, maxX - minX, maxY - minY);
}
/**
* 获取矩形边界上与给定点最近的点
* @param point
@@ -142,8 +168,8 @@ module es {
return boundsPoint;
}
public calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, rotation: number, width: number, height: number){
if (rotation == 0){
public calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, rotation: number, width: number, height: number) {
if (rotation == 0) {
this.x = parentPosition.x + position.x - origin.x * scale.x;
this.y = parentPosition.y + position.y - origin.y * scale.y;
this.width = width * scale.x;
@@ -183,29 +209,5 @@ module es {
this.height = maxY - minY;
}
}
/**
* 给定多边形的点,计算边界
* @param points
*/
public static rectEncompassingPoints(points: Vector2[]) {
// 我们需要求出x/y的最小值/最大值
let minX = Number.POSITIVE_INFINITY;
let minY = Number.POSITIVE_INFINITY;
let maxX = Number.NEGATIVE_INFINITY;
let maxY = Number.NEGATIVE_INFINITY;
for (let i = 0; i < points.length; i++) {
let pt = points[i];
if (pt.x < minX) minX = pt.x;
if (pt.x > maxX) maxX = pt.x;
if (pt.y < minY) minY = pt.y;
if (pt.y > maxY) maxY = pt.y;
}
return this.fromMinMax(minX, minY, maxX, maxY);
}
}
}