2016-11-26 44 views

回答

1

我几乎没有足够大了,用过的Turbo C++,但如果形状绘制函数不采取一个参数或提供任何其他方式来指定边框的宽度,那么你就必须实现它的另一个办法。

你可以编写自己的形状的绘图功能,以提供您想要的附加功能。这确实不是那么困难,它可能会教你一些关于图形编程的知识。多年前,当Turbo C++被实际使用时,许多兴奋的编程人员为了教育的原因编写了他们自己的2D图形引擎,并且也加快了Borland的实现速度。

如果你不想经历那么多工作,你可以用越来越小的范围反复调用形状绘制功能砍解决该问题。基本上,如果图形默认以1-px边框绘制,那么您只需重复绘制形状,每次将其边界减少1个像素。

我完全不知道是什么的API有Graphics.h的样子,所以我给它使用我自己发明的图形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; 
} 
1

我不使用BGI而是从快速看看它的功能我想尝试:

所以厚度设置为你所需要的...例如:

setlinestyle(SOLID_LINE,0xFFFF,10); 

10应该是边框的宽度

相关问题