UNPKG

uicore-ts

Version:

UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework tha

86 lines (85 loc) 2.23 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var UIPoint_exports = {}; __export(UIPoint_exports, { UIPoint: () => UIPoint }); module.exports = __toCommonJS(UIPoint_exports); var import_UIObject = require("./UIObject"); class UIPoint extends import_UIObject.UIObject { constructor(x, y) { super(); this.x = x; this.y = y; } copy() { return new UIPoint(this.x, this.y); } isEqualTo(point) { return this.x == point.x && this.y == point.y; } scale(zoom) { const x = this.x; const y = this.y; this.x = x * zoom; this.y = y * zoom; return this; } add(point) { this.x = this.x + point.x; this.y = this.y + point.y; return this; } subtract(point) { this.x = this.x - point.x; this.y = this.y - point.y; return this; } to(targetPoint) { return targetPoint.copy().add(this.copy().scale(-1)); } pointWithX(x) { const result = this.copy(); result.x = x; return result; } pointWithY(y) { const result = this.copy(); result.y = y; return result; } pointByAddingX(x) { return this.pointWithX(this.x + x); } pointByAddingY(y) { return this.pointWithY(this.y + y); } get length() { let result = this.x * this.x + this.y * this.y; result = Math.sqrt(result); return result; } didChange(b) { } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { UIPoint }); //# sourceMappingURL=UIPoint.js.map