1/* 2 * Copyright (c) 2022-2023 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15export class XTools { 16 constructor() {} 17 static MOUSE_POS = { 18 x: 0, 19 y: 0, 20 }; 21 static InRect(xx, yy, x, y, w, h) { 22 if (xx < x) { 23 return false; 24 } 25 if (yy < y) { 26 return false; 27 } 28 if (xx > x + w) { 29 return false; 30 } 31 if (yy > y + h) { 32 return false; 33 } 34 return true; 35 } 36} 37export function fAngle(x, y) { 38 return (Math.atan2(-y, x) * 180) / Math.PI; 39} 40export function iDistance(x, y) { 41 return Math.sqrt(x * x + y * y); 42} 43 44export var timeMs = 0; 45export function freshTime() { 46 let t = new Date(); 47 timeMs = t.getTime(); 48} 49freshTime(); 50export function TimeMS() { 51 let t = new Date(); 52 return t.getTime(); 53} 54export function RandInt(min = 0, max = 100) { 55 return Math.floor(Math.random() * (max - min)) + min; 56} 57 58export function GetURL() { 59 if ('undefined' !== typeof wx) { 60 return 'https://7465-testegg-19e3c9-1301193145.tcb.qcloud.la/'; 61 } else { 62 return ''; 63 } 64} 65