Update API documentation and remove obsolete plan files
This commit is contained in:
@@ -1,63 +1,53 @@
|
||||
# RectInt
|
||||
|
||||
**命名空间**: `XCEngine::Math`
|
||||
整数矩形结构体,用于像素级 2D 区域表示。
|
||||
|
||||
**类型**: `struct`
|
||||
**头文件:** `#include <XCEngine/Math/Rect.h>`
|
||||
|
||||
**头文件**: `XCEngine/Math/Rect.h`
|
||||
**命名空间:** `XCEngine::Math`
|
||||
|
||||
**描述**: 二维整数矩形,用于表示像素级 2D 区域
|
||||
## 结构体定义
|
||||
|
||||
## 概述
|
||||
```cpp
|
||||
struct RectInt {
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
int32_t width = 0;
|
||||
int32_t height = 0;
|
||||
|
||||
RectInt 结构体表示一个二维整数矩形,由整数位置 `(x, y)` 和尺寸 `(width, height)` 组成。与 Rect 不同,它使用 `int32_t` 类型,适合像素级操作和坐标计算。
|
||||
RectInt() = default;
|
||||
RectInt(int32_t x, int32_t y, int32_t w, int32_t h);
|
||||
};
|
||||
```
|
||||
|
||||
## 公共方法
|
||||
## 构造函数
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`GetLeft`](getleft.md) | 获取矩形左边界 |
|
||||
| [`GetRight`](getright.md) | 获取矩形右边界 |
|
||||
| [`GetTop`](gettop.md) | 获取矩形上边界 |
|
||||
| [`GetBottom`](getbottom.md) | 获取矩形下边界 |
|
||||
| [`GetPosition`](getposition.md) | 获取矩形位置 |
|
||||
| [`GetSize`](getsize.md) | 获取矩形尺寸 |
|
||||
| [`GetCenter`](getcenter.md) | 获取矩形中心点 |
|
||||
| [`Contains`](contains.md) | 判断点是否在矩形内 |
|
||||
| [`Intersects`](intersects.md) | 判断是否与另一矩形相交 |
|
||||
| `RectInt()` | 默认构造 |
|
||||
| `RectInt(x, y, w, h)` | 从整数坐标和尺寸构造 |
|
||||
|
||||
## 使用示例
|
||||
## 边界访问
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Math/Rect.h"
|
||||
#include "XCEngine/Math/Vector2.h"
|
||||
#include <iostream>
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| [GetLeft()](rectint-getleft.md) | `int32_t` | 左边界 |
|
||||
| [GetRight()](rectint-getright.md) | `int32_t` | 右边界 |
|
||||
| [GetTop()](rectint-gettop.md) | `int32_t` | 上边界 |
|
||||
| [GetBottom()](rectint-getbottom.md) | `int32_t` | 下边界 |
|
||||
| [GetPosition()](rectint-getposition.md) | `Vector2` | 位置(转换为浮点) |
|
||||
| [GetSize()](rectint-getsize.md) | `Vector2` | 尺寸(转换为浮点) |
|
||||
| [GetCenter()](rectint-getcenter.md) | `Vector2` | 中心点 |
|
||||
|
||||
using namespace XCEngine::Math;
|
||||
## 检测方法
|
||||
|
||||
int main() {
|
||||
RectInt rect(10, 20, 100, 50);
|
||||
|
||||
std::cout << "Position: (" << rect.x << ", " << rect.y << ")\n";
|
||||
std::cout << "Size: " << rect.width << " x " << rect.height << "\n";
|
||||
std::cout << "Left: " << rect.GetLeft() << ", Right: " << rect.GetRight() << "\n";
|
||||
std::cout << "Top: " << rect.GetTop() << ", Bottom: " << rect.GetBottom() << "\n";
|
||||
|
||||
if (rect.Contains(50, 30)) {
|
||||
std::cout << "Point (50, 30) is inside rect\n";
|
||||
}
|
||||
|
||||
RectInt other(60, 40, 100, 50);
|
||||
if (rect.Intersects(other)) {
|
||||
std::cout << "Rects intersect\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| [Contains(px, py)](rectint-contains.md) | `bool` | 整数坐标点检测 |
|
||||
| [Intersects(other)](rectint-intersects.md) | `bool` | 与另一矩形相交 |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [`Rect`](../rect/rect.md) - 浮点矩形
|
||||
- [`Viewport`](../rect/viewport.md) - 视口
|
||||
- [`Vector2`](../vector2/vector2.md) - 二维向量
|
||||
- [Math 模块总览](../math.md) - 返回 Rect 模块总览
|
||||
- [Rect](rect-overview.md) - 浮点矩形版本
|
||||
- [Viewport](viewport.md) - 渲染视口
|
||||
|
||||
Reference in New Issue
Block a user