2016-11-26 38 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應該是邊框的寬度

相關問題