Drawing lines and shapes in a console window

Discussion in 'C++' started by john, Jan 16, 2004.

  1. john

    john Guest

    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
    john, Jan 16, 2004
    #1
    1. Advertising

  2. john

    gabriel Guest

    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
    gabriel, Jan 16, 2004
    #2
    1. Advertising

  3. john

    Heath McKay Guest

    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.
    Heath McKay, Jan 16, 2004
    #3
  4. > 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>
    Andras Tantos, Jan 16, 2004
    #4
  5. gabriel <> 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.
    Christopher Benson-Manica, Jan 16, 2004
    #5
  6. john

    john Guest

    OK, what is the simplest way of drawing lines, vertical and horizontal
    in Microsoft visual C++ or Dev C++
    john, Jan 17, 2004
    #6
  7. "john" <> 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
    Victor Bazarov, Jan 17, 2004
    #7
  8. john

    John Carson Guest

    "john" <> wrote in message
    news:
    > 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)
    John Carson, Jan 17, 2004
    #8
  9. john

    Roger Leigh Guest

    Christopher Benson-Manica <> writes:

    > gabriel <> 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! =-----
    Roger Leigh, Jan 19, 2004
    #9
  10. john

    jbtatro

    Joined:
    Oct 31, 2008
    Messages:
    1
    Location:
    LBC
    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. :)
    jbtatro, Oct 31, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    623
    Kevin Spencer
    Jan 9, 2006
  2. Gambit
    Replies:
    2
    Views:
    380
    Gambit
    Oct 25, 2003
  3. Miktor
    Replies:
    7
    Views:
    12,008
    Joe Bacigalupa
    Aug 9, 2005
  4. defn noob
    Replies:
    1
    Views:
    373
    Mark Space
    Jun 28, 2008
  5. Terry Reedy
    Replies:
    4
    Views:
    1,592
    Alf P. Steinbach
    Jan 27, 2010
Loading...

Share This Page