Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Drawing lines and shapes in a console window (http://www.velocityreviews.com/forums/t280692-drawing-lines-and-shapes-in-a-console-window.html)

john 01-16-2004 07:07 PM

Drawing lines and shapes in a console window
 
Hi I am a C++ newbie, I am looking to draw single lines and simple
boxes in a C++ console window. Is there a draw command with x and y
coordinates that can be used with my Dev C++ compiler. For simplicity
sake, I would be prepared to draw using characters such as _ or * if
proper line drawing is really complicated.

Thanks in advance.

Walt

gabriel 01-16-2004 07:13 PM

Re: Drawing lines and shapes in a console window
 
john wrote:

> Hi I am a C++ newbie, I am looking to draw single lines and simple
> boxes in a C++ console window. Is there a draw command with x and y
> coordinates that can be used with my Dev C++ compiler. For simplicity
> sake, I would be prepared to draw using characters such as _ or * if
> proper line drawing is really complicated.


Am I missing smoething, or is a console, by definition, incapable of
graphics handling?

I'd suggest posting this question in a group that deals with your operating
system, as in standard C++ there are no sophisticated facilities to do
fancy stuff. Not even clearing the screen (Someone please correct me if
I'm wrong).

--
gabriel

Heath McKay 01-16-2004 07:34 PM

Re: Drawing lines and shapes in a console window
 
from my time in C++ class in High school, i remember that we did use a
drawing library that allowed us to both create pictures and output
precreated pictures to the screen, but i cannot remember what it was called.
We were using Borland and Windows, but i don't think it was just for
Borland.

PS. i found the library, it was called GFXLIB8 (.h or .cpp, i cannot
remember) but i don't think it is easy to find on the internet. my teacher
gave it to us, but i don't know where you could obtain it now, or even if
there is a newer version.



Andras Tantos 01-16-2004 07:49 PM

Re: Drawing lines and shapes in a console window
 
> Hi I am a C++ newbie, I am looking to draw single lines and simple
> boxes in a C++ console window. Is there a draw command with x and y
> coordinates that can be used with my Dev C++ compiler. For simplicity
> sake, I would be prepared to draw using characters such as _ or * if
> proper line drawing is really complicated.
>
> Thanks in advance.


This is probably OT here since standard C++ has no notion of 'lines and
boxes on a C++ console window'. Without OS info (though DevC++ suggests a
MinGW GCC compiler under Windows) it's hard to answer. In the Unix world
NCurses and it's variants (PCurses) is one library capable of this and much
more. There's a windows port of that library too.

--
Regards,
Andras Tantos
<http://andras.tantos.homedns.org>



Christopher Benson-Manica 01-16-2004 09:19 PM

Re: Drawing lines and shapes in a console window
 
gabriel <no@no--spam.com> spoke thus:

> Am I missing smoething, or is a console, by definition, incapable of
> graphics handling?


<ot>
Not if you count things like the curses library as graphics
handling. Of course, the curses library isn't standard...
</ot>

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.

john 01-17-2004 01:46 AM

Re: Drawing lines and shapes in a console window
 
OK, what is the simplest way of drawing lines, vertical and horizontal
in Microsoft visual C++ or Dev C++

Victor Bazarov 01-17-2004 02:28 AM

Re: Drawing lines and shapes in a console window
 
"john" <eaglesdare@fastmail.fm> wrote...
> OK, what is the simplest way of drawing lines, vertical and horizontal
> in Microsoft visual C++ or Dev C++


The only way I know to draw single horizontal lines in C++ is to output
either character '-' (minus) or '_' (underscore). For double lines use
'=' (equal sign). For vertical lines use '|' (bar) if it's among the
available characters. For oblique lines use a slash or a backslash,
depending on the angle. For intersections use a plus or a pound. Also,
for intersections of oblique lines you could use the capital x...

What it has to do with the language I have no idea.

Victor



John Carson 01-17-2004 03:10 PM

Re: Drawing lines and shapes in a console window
 
"john" <eaglesdare@fastmail.fm> wrote in message
news:1dcfc0a1.0401161746.2ce4cf0c@posting.google.c om
> OK, what is the simplest way of drawing lines, vertical and horizontal
> in Microsoft visual C++ or Dev C++


I don't know why anyone would want to bother drawing lines in console mode,
but you need to look at the character set of the font that your console
uses. It probably incorporates some special characters for the purpose. For
example, under Windows the default font is 8514oem. Characters 0xB3 to 0xDF
are line drawing charactes. For example, 0xB3 is a vertical line, 0xC4 is a
horizontal line and 0xBF, 0xC0, 0xD9, 0xDA are corners. Thus you can draw a
square with:


cout << '\n';
// top line and corners
cout << (char)0xDa;
for(int i=0; i<10; ++i)
cout << (char)0xC4;
cout << (char)0xBF;
cout << '\n';
// vertical edges
for(int i=0; i<10; ++i)
{
cout << (char)0xB3;
for(int j=0; j<10; ++j)
cout << ' ';
cout << (char)0xB3;
cout << '\n';
}
// bottom line and corners
cout << (char)0xC0;
for(int i=0; i<10; ++i)
cout << (char)0xC4;
cout << (char)0xD9;
cout << '\n';


--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


Roger Leigh 01-19-2004 07:04 PM

Re: Drawing lines and shapes in a console window
 
Christopher Benson-Manica <ataru@nospam.cyberspace.org> writes:

> gabriel <no@no--spam.com> spoke thus:
>
>> Am I missing smoething, or is a console, by definition, incapable of
>> graphics handling?

>
> <ot>
> Not if you count things like the curses library as graphics
> handling. Of course, the curses library isn't standard...
> </ot>


curses is standardised by POSIX (now Single UNIX Specification version
3). It's not a C++ standard, but is standardised nonetheless.


--
Roger Leigh

Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

jbtatro 10-31-2008 10:11 PM

When in College I actually compiled a windows for consoles library, basically it can define window shapes with different background colors and borders for a console. Its capable of keeping text within its boundarys and holding it in memory to be re-drawn. If you want a sample of its use, you can go to jbtatro dot com go to the code link section and select the ConnectFour.zip (not the ConnectFour2.zip) and you can see how to manipulate your console in all the ways you ever wished and more. :)


All times are GMT. The time now is 06:46 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.