# Drawing

# 说明

Drawing命名空间提供了在游戏界面上绘制各种图形和文本的功能,用于可视化信息展示和调试。

# 如何使用

// 在屏幕上绘制文本
Drawing::DrawText(Vector2(100, 100), "Hello World", MAKE_COLOR(255, 255, 255, 255));

// 绘制一个圆形
Drawing::DrawCircle(myHero.GetPosition(), 300.0f, MAKE_COLOR(255, 0, 0, 255));

// 绘制一条线
Drawing::DrawLine(startPos, endPos, 2.0f, MAKE_COLOR(0, 255, 0, 255));

# DrawText

void DrawText(Vector2 const& pos, const char* text, int color, int fontSize = 14)

在屏幕上绘制文本。

参数名字 参数类型 描述
pos Vector2 const& 文本起始位置的屏幕坐标
text const char* 要显示的文本内容
color int 文本颜色 (RGBA格式)
fontSize int 字体大小,默认为14
// 在屏幕坐标(100,100)位置绘制白色文本
Drawing::DrawText(Vector2(100, 100), "Hello World", MAKE_COLOR(255, 255, 255, 255));

// 绘制较大的红色文本
Drawing::DrawText(Vector2(200, 200), "Warning!", MAKE_COLOR(255, 0, 0, 255), 20);

# DrawLine

void DrawLine(Vector3 const& start, Vector3 const& end, float thickness, int color)

在游戏世界中绘制一条线。

参数名字 参数类型 描述
start Vector3 const& 线的起点坐标
end Vector3 const& 线的终点坐标
thickness float 线的粗细
color int 线的颜色 (RGBA格式)
// 绘制一条从英雄位置到目标位置的红色线
Vector3 heroPos = myHero.GetPosition();
Vector3 targetPos = enemy.GetPosition();
Drawing::DrawLine(heroPos, targetPos, 2.0f, MAKE_COLOR(255, 0, 0, 255));

// 绘制一条蓝色粗线
Drawing::DrawLine(Vector3(0, 0, 0), Vector3(1000, 0, 1000), 5.0f, MAKE_COLOR(0, 0, 255, 255));

# DrawCircle

void DrawCircle(Vector3 const& center, float radius, int color, float thickness = 2.0f)

在游戏世界中绘制一个圆。

参数名字 参数类型 描述
center Vector3 const& 圆心坐标
radius float 圆的半径
color int 圆的颜色 (RGBA格式)
thickness float 圆边框的粗细,默认为2.0
// 绘制一个围绕英雄的绿色圆,表示技能范围
Vector3 heroPos = myHero.GetPosition();
Drawing::DrawCircle(heroPos, 300.0f, MAKE_COLOR(0, 255, 0, 255));

// 绘制一个粗边框的红色圆
Drawing::DrawCircle(heroPos, 500.0f, MAKE_COLOR(255, 0, 0, 255), 4.0f);

# DrawRectangle

void DrawRectangle(Vector2 const& start, Vector2 const& end, int color, float thickness = 1.0f)

在屏幕上绘制一个矩形。

参数名字 参数类型 描述
start Vector2 const& 矩形左上角的屏幕坐标
end Vector2 const& 矩形右下角的屏幕坐标
color int 矩形的颜色 (RGBA格式)
thickness float 矩形边框的粗细,默认为1.0
// 绘制一个蓝色矩形
Drawing::DrawRectangle(Vector2(100, 100), Vector2(300, 200), MAKE_COLOR(0, 0, 255, 255));

// 绘制一个粗边框的黄色矩形
Drawing::DrawRectangle(Vector2(400, 300), Vector2(600, 500), MAKE_COLOR(255, 255, 0, 255), 3.0f);

# DrawFilledRectangle

void DrawFilledRectangle(Vector2 const& start, Vector2 const& end, int color)

在屏幕上绘制一个填充的矩形。

参数名字 参数类型 描述
start Vector2 const& 矩形左上角的屏幕坐标
end Vector2 const& 矩形右下角的屏幕坐标
color int 矩形的填充颜色 (RGBA格式)
// 绘制一个半透明红色填充矩形
Drawing::DrawFilledRectangle(Vector2(200, 200), Vector2(400, 300), MAKE_COLOR(255, 0, 0, 128));

// 绘制一个不透明绿色填充矩形
Drawing::DrawFilledRectangle(Vector2(500, 400), Vector2(700, 500), MAKE_COLOR(0, 255, 0, 255));

# DrawImage

void DrawImage(const char* imagePath, Vector2 const& position, Vector2 const& size)

在屏幕上绘制一个图像。

参数名字 参数类型 描述
imagePath const char* 图像文件的路径
position Vector2 const& 图像左上角的屏幕坐标
size Vector2 const& 图像的宽高
// 绘制一个图标
Drawing::DrawImage("images/icon.png", Vector2(100, 100), Vector2(32, 32));

// 绘制一个较大的图像
Drawing::DrawImage("images/background.png", Vector2(0, 0), Vector2(1920, 1080));