Thanks for your information. I just trying to draw rectangle using rectangle function to openGL in visual stdio using C language. – Masud pervej Oct 28 '18 at 3:37 add a comment. Created by Atari, Asteroids was one of the first vector graphics games, which means that it relied solely on lines to draw graphics, as opposed to little square pixels. Asteroids demonstrated that a very simple concept, with even simpler graphics and a soundtrack that gradually builds tension, creates a. When you ask the user what width they want, the rectangle you draw includes the sides in the width (which makes sense, because the top and bottom sides are included in the height). So having said that, you have to divide the width into three pieces.
I'm trying to write a method that draws a rectangle. If the user enters height = 4, and width = 8, and the print of character ' * ', then the left rectangle is drawn on the left if the filled flag is true. If the flag is false, then version on the right is drawn which would be an empty rectangle.
* * * * * * * * ||||| * * * * * * * *
* * * * * * * * ||||| *e m p t y *
* * * * * * * * ||||| *e m p t y *
* * * * * * * * ||||| * * * * * * * *
I've written the below so far, where am I going wrong?:
rec()
{
if (filled true)
{
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
cout << '*';
}
cout << endl;
}
}
else // this is the empty rectangle
{
for (int row = 0 ; row < height; row++)
{
for (int col = 0; col < width; col++)
{
cout << '*' << setw(width-1) << '*';
}
cout << endl;
}
}
- 4 Contributors
- forum 12 Replies
- 1,988 Views
- 6 Days Discussion Span
- commentLatest Postby richiekingLatest Post
daviddoria334
Draw Rectangle In C++
Welcome to DaniWeb! To allow us to help most effectively, please use code tags when you post code. Also, you should always comment code as much as you can. When you post code that isn't working, you should also show the incorrect output (or any errors that occur). I also suggest that you make a fully compilable example that demonstrates the problem (i.e. include main(), and hardcode values rather than taking user input).
Good luck,
How To Draw Rectangle In Dev C Youtube
David