Update API documentation and remove obsolete plan files

This commit is contained in:
2026-03-21 15:55:04 +08:00
parent 7a6cd412c8
commit 629455df07
75 changed files with 1075 additions and 1816 deletions

View File

@@ -1,47 +1,24 @@
# RectInt::Contains
```cpp
bool Contains(int32_t px, int32_t py) const;
bool Contains(int32_t px, int32_t py) const
```
判断整数坐标点是否在矩形内
矩形使用左上位坐标系内部定义为x >= left && x < right && y >= top && y < bottom。即左边界和上边界在内部右边界和下边界在外部。
检测整数坐标点是否在矩形内。
**参数:**
- `px` - 点的 x 坐标
- `py` - 点的 y 坐标
**返回:** 点在矩形内部返回 true否则返回 false
**线程安全:**
**返回:** `bool` - 点在矩形内(包含边界)返回 true
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(0, 0, 1920, 1080);
if (rect.Contains(960, 540)) {
std::cout << "Point (960, 540) is inside\n";
}
if (!rect.Contains(2000, 1000)) {
std::cout << "Point (2000, 1000) is outside\n";
}
return 0;
RectInt rect(0, 0, 1920, 1080);
if (rect.Contains(pixelX, pixelY)) {
// 像素在矩形内
}
```
## 相关文档
- [`RectInt::Intersects`](intersects.md) - 判断是否相交
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetBottom
```cpp
int32_t GetBottom() const;
int32_t GetBottom() const
```
获取矩形下边界 y 坐标
获取矩形下边界。
**返回:** 矩形下边界 y 坐标(等于 y + height
**线程安全:**
**返回:** `int32_t` - 下边界坐标 (y + height)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t bottom = rect.GetBottom();
std::cout << "Bottom: " << bottom << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t bottom = rect.GetBottom(); // 70
```
## 相关文档
- [`RectInt::GetLeft`](getleft.md) - 获取左边界
- [`RectInt::GetRight`](getright.md) - 获取右边界
- [`RectInt::GetTop`](gettop.md) - 获取上边界
- [RectInt 总览](rectint.md)

View File

@@ -1,35 +1,18 @@
# RectInt::GetCenter
```cpp
Vector2 GetCenter() const;
Vector2 GetCenter() const
```
获取矩形中心点坐标
获取矩形中心点(转换为浮点)
**返回:** 表示矩形中心点的 Vector2转换为浮点
**线程安全:**
**返回:** `Vector2` - 中心点坐标
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
Vector2 center = rect.GetCenter();
std::cout << "Center: (" << center.x << ", " << center.y << ")\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
Vector2 center = rect.GetCenter(); // (60.0f, 45.0f)
```
## 相关文档
- [`RectInt::GetPosition`](getposition.md) - 获取位置
- [`RectInt::GetSize`](getsize.md) - 获取尺寸
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetLeft
```cpp
int32_t GetLeft() const;
int32_t GetLeft() const
```
获取矩形左边界 x 坐标
获取矩形左边界。
**返回:** 矩形左边界 x 坐标(等于 x 成员变量)
**线程安全:**
**返回:** `int32_t` - 左边界坐标 (x)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t left = rect.GetLeft();
std::cout << "Left: " << left << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t left = rect.GetLeft(); // 10
```
## 相关文档
- [`RectInt::GetRight`](getright.md) - 获取右边界
- [`RectInt::GetTop`](gettop.md) - 获取上边界
- [`RectInt::GetBottom`](getbottom.md) - 获取下边界
- [RectInt 总览](rectint.md)

View File

@@ -1,35 +1,18 @@
# RectInt::GetPosition
```cpp
Vector2 GetPosition() const;
Vector2 GetPosition() const
```
获取矩形位置x, y 坐标)。
获取矩形左上角位置(转换为浮点)。
**返回:** 表示矩形位置的 Vector2转换为浮点
**线程安全:**
**返回:** `Vector2` - 位置向量
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
Vector2 pos = rect.GetPosition();
std::cout << "Position: (" << pos.x << ", " << pos.y << ")\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
Vector2 pos = rect.GetPosition(); // (10.0f, 20.0f)
```
## 相关文档
- [`RectInt::GetSize`](getsize.md) - 获取尺寸
- [`RectInt::GetCenter`](getcenter.md) - 获取中心点
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetRight
```cpp
int32_t GetRight() const;
int32_t GetRight() const
```
获取矩形右边界 x 坐标
获取矩形右边界。
**返回:** 矩形右边界 x 坐标(等于 x + width
**线程安全:**
**返回:** `int32_t` - 右边界坐标 (x + width)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t right = rect.GetRight();
std::cout << "Right: " << right << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t right = rect.GetRight(); // 110
```
## 相关文档
- [`RectInt::GetLeft`](getleft.md) - 获取左边界
- [`RectInt::GetTop`](gettop.md) - 获取上边界
- [`RectInt::GetBottom`](getbottom.md) - 获取下边界
- [RectInt 总览](rectint.md)

View File

@@ -1,35 +1,18 @@
# RectInt::GetSize
```cpp
Vector2 GetSize() const;
Vector2 GetSize() const
```
获取矩形尺寸(width, height)。
获取矩形尺寸(转换为浮点)。
**返回:** 表示矩形尺寸的 Vector2转换为浮点
**线程安全:**
**返回:** `Vector2` - 尺寸向量
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
Vector2 size = rect.GetSize();
std::cout << "Size: (" << size.x << ", " << size.y << ")\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
Vector2 size = rect.GetSize(); // (100.0f, 50.0f)
```
## 相关文档
- [`RectInt::GetPosition`](getposition.md) - 获取位置
- [`RectInt::GetCenter`](getcenter.md) - 获取中心点
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetTop
```cpp
int32_t GetTop() const;
int32_t GetTop() const
```
获取矩形上边界 y 坐标
获取矩形上边界。
**返回:** 矩形上边界 y 坐标(等于 y 成员变量)
**线程安全:**
**返回:** `int32_t` - 上边界坐标 (y)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t top = rect.GetTop();
std::cout << "Top: " << top << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t top = rect.GetTop(); // 20
```
## 相关文档
- [`RectInt::GetLeft`](getleft.md) - 获取左边界
- [`RectInt::GetRight`](getright.md) - 获取右边界
- [`RectInt::GetBottom`](getbottom.md) - 获取下边界
- [RectInt 总览](rectint.md)

View File

@@ -1,48 +1,24 @@
# RectInt::Intersects
```cpp
bool Intersects(const RectInt& other) const;
bool Intersects(const RectInt& other) const
```
判断此矩形是否与另一矩形相交。
使用 AABB轴对齐包围盒碰撞检测算法。如果两个矩形在 x 轴和 y 轴上都有重叠,则返回 true。
检测两整数矩形是否相交。
**参数:**
- `other` - 另一个矩形
- `other` - 另一个整数矩形
**返回:** 两矩形相交返回 true否则返回 false
**线程安全:**
**返回:** `bool` - 两矩形相交返回 true
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rectA(0, 0, 100, 100);
RectInt rectB(50, 50, 100, 100);
if (rectA.Intersects(rectB)) {
std::cout << "Rects intersect\n";
}
RectInt rectC(200, 200, 50, 50);
if (!rectA.Intersects(rectC)) {
std::cout << "Rects do not intersect\n";
}
return 0;
RectInt rectA(0, 0, 100, 100);
RectInt rectB(50, 50, 100, 100);
if (rectA.Intersects(rectB)) {
// 两矩形相交
}
```
## 相关文档
- [`RectInt::Contains`](contains.md) - 判断点是否在矩形内
- [RectInt 总览](rectint.md)

View File

@@ -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) - 渲染视口