简体   繁体   中英

How to set custom Border width of objects in Turbo C++ graphics?

I need help as i am drawing some shapes using graphics.h in
TURBO C++ compiler
I need to increase the border width of shapes as it is hardly visible
please tell me the function(if exists) OR another way around.

I'm not nearly old enough to have ever used Turbo C++, but if the shape-drawing functions don't take a parameter for or provide any other way to specify border width, then you will have to implement it another way.

You could write your own shape-drawing functions to provide the additional functionality that you desire. This really isn't that difficult, and it would probably teach you a fair amount about graphics programming. Years ago, when Turbo C++ was actually being used, lots of bourgeoning programmers wrote their own 2D graphics engines, both for educational reasons and also to gain speed over Borland's implementations.

If you don't want to go through that much work, you could hack around the problem by iteratively calling the shape-drawing functions with increasingly smaller bounds. Basically, if the shape gets drawn by default with a 1-px border, then you just repeatedly draw the shape, each time decreasing its bounds by 1 pixel.

I have absolutely no idea what the Graphics.h APIs look like, so I'll give an example that uses a graphics API of my own invention:

// 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;
}

I do not use BGI but from quick look at its functions I would try:

so set the thickness to what you need ... for example:

setlinestyle(SOLID_LINE,0xFFFF,10);

Where 10 should be the width of the border

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM