refactor: reorganize docs into plan/ and add skills/
This commit is contained in:
72
docs/api/math/math-color.md
Normal file
72
docs/api/math/math-color.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Color
|
||||
|
||||
颜色结构体,支持 RGBA 浮点分量。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Math/Color.h>
|
||||
```
|
||||
|
||||
## 命名空间
|
||||
|
||||
`XCEngine::Math`
|
||||
|
||||
## 结构体定义
|
||||
|
||||
```cpp
|
||||
struct Color {
|
||||
float r = 1.0f;
|
||||
float g = 1.0f;
|
||||
float b = 1.0f;
|
||||
float a = 1.0f;
|
||||
};
|
||||
```
|
||||
|
||||
分量范围: 0.0f ~ 1.0f
|
||||
|
||||
## 静态工厂方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| `White()` | `Color` | (1, 1, 1, 1) |
|
||||
| `Black()` | `Color` | (0, 0, 0, 1) |
|
||||
| `Red()` | `Color` | (1, 0, 0, 1) |
|
||||
| `Green()` | `Color` | (0, 1, 0, 1) |
|
||||
| `Blue()` | `Color` | (0, 0, 1, 1) |
|
||||
| `Yellow()` | `Color` | (1, 1, 0, 1) |
|
||||
| `Cyan()` | `Color` | (0, 1, 1, 1) |
|
||||
| `Magenta()` | `Color` | (1, 0, 1, 1) |
|
||||
| `Clear()` | `Color` | (0, 0, 0, 0),透明黑 |
|
||||
|
||||
## 静态方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| `Lerp(a, b, t)` | `Color` | 颜色线性插值 |
|
||||
|
||||
## 实例方法
|
||||
|
||||
| 方法 | 返回值 | 描述 |
|
||||
|------|--------|------|
|
||||
| `ToRGBA()` | `uint32_t` | 转换为 32-bit RGBA (0xAABBGGRR) |
|
||||
| `ToVector3()` | `Vector3` | 转换为 RGB (丢弃 alpha) |
|
||||
| `ToVector4()` | `Vector4` | 转换为 RGBA |
|
||||
|
||||
## 运算符
|
||||
|
||||
| 运算符 | 描述 |
|
||||
|--------|------|
|
||||
| `operator+(Color, Color)` | 颜色相加 |
|
||||
| `operator-(Color, Color)` | 颜色相减 |
|
||||
| `operator*(Color, float)` | 颜色乘以标量 |
|
||||
| `operator/(Color, float)` | 颜色除以标量 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
Color red = Color::Red();
|
||||
Color lerped = Color::Lerp(red, Color::Blue(), 0.5f);
|
||||
uint32_t rgba = lerped.ToRGBA();
|
||||
Vector4 v4 = lerped.ToVector4();
|
||||
```
|
||||
Reference in New Issue
Block a user