/
difight
/
ruEngine
Обзор
Документация
Войти
/
difight
/
ruEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
client/src/engine/core/ui/InteractiveElement.ts
42 строки
1 KB
Andrey Bashkirev
refactor and add readme
30 июл 2025, 19:33
30 июл 2025, 19:33
714c914
Код
Авторство
О чём код?
import type { IInteractable } from "./IInteractable"; /** * Абстрактный базовый класс для интерактивных UI-элементов */ export abstract class InteractiveElement implements IInteractable { protected x: number; protected y: number; protected width: number; protected height: number; /** * @param x Координата X * @param y Координата Y * @param width Ширина * @param height Высота */ constructor(x: number, y: number, width: number, height: number) { this.x = x; this.y = y; this.width = width; this.height = height; } /** * Проверяет, содержится ли точка в элементе * @param x X-координата точки * @param y Y-координата точки * @returns true, если точка внутри элемента */ contains(x: number, y: number): boolean { return ( x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height ); } /** Отрисовать элемент */ abstract render(ctx: CanvasRenderingContext2D): void; }