我需要帮助,因为我在TURBO C++ 编译器中使用graphics.h绘制一些形状
我需要增加形状的边框宽度,因为它几乎不可见
请告诉我函数(如果存在)或其他方式。
1430 次
2 回答
1
我还没有到使用过 Turbo C++ 的年龄,但是如果形状绘制函数不接受参数或不提供任何其他方式来指定边框宽度,那么您将不得不以另一种方式实现它。
您可以编写自己的绘图函数来提供您想要的附加功能。这真的没有那么难,它可能会教你相当多的图形编程知识。多年前,当 Turbo C++ 真正被使用时,许多新兴的程序员编写了他们自己的 2D 图形引擎,这既是出于教育原因,也是为了加快 Borland 的实现速度。
如果您不想做那么多工作,您可以通过迭代地调用具有越来越小的边界的形状绘制函数来解决这个问题。基本上,如果默认情况下使用 1 像素的边框绘制形状,那么您只需重复绘制形状,每次将其边界减少 1 像素。
我完全不知道 Graphics.h API 是什么样的,所以我将举一个使用我自己发明的图形 API 的示例:
// Start with the initial bounds of the shape that you want to draw.
// Here, we'll do a 100x100-px rectangle.
RECTANGLE rc;
rc.left = 50;
rc.top = 50;
rc.right = 150;
rc.bottom = 150;
// Let's assume that the default is to draw the shape with a 1-px border,
// but that is too small and you want a 5-px thick border instead.
// Well, we can achieve that by drawing the 1-px border 5 times, each inset by 1 pixel!
for (int i = 1; i <= 5; ++i)
{
DrawRectangle(&rc);
rc.left += 1;
rc.top += 1;
rc.right -= 1;
rc.bottom -= 1;
}
于 2016-11-26T16:34:25.000 回答