UNPKG

laya-coreui-es

Version:

laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改

46 lines (45 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Point = void 0; const Pool_1 = require("../utils/Pool"); class Point { constructor(x = 0, y = 0) { this.x = x; this.y = y; } static create() { return Pool_1.Pool.getItemByClass("Point", Point); } setTo(x, y) { this.x = x; this.y = y; return this; } reset() { this.x = this.y = 0; return this; } recover() { Pool_1.Pool.recover("Point", this.reset()); } distance(x, y) { return Math.sqrt((this.x - x) * (this.x - x) + (this.y - y) * (this.y - y)); } toString() { return this.x + "," + this.y; } normalize() { var d = Math.sqrt(this.x * this.x + this.y * this.y); if (d > 0) { var id = 1.0 / d; this.x *= id; this.y *= id; } } copy(point) { return this.setTo(point.x, point.y); } } exports.Point = Point; Point.TEMP = new Point(); Point.EMPTY = new Point();