Zajcev666
Zajcev666

Reputation:

Drawing coloured boxes with ncurses

I want to draw a filled box in console and set colour for every single pixel.

Is it possible to achive this with ncurses?

If not - is there any other library that will do the trick?

Upvotes: 2

Views: 6851

Answers (2)

ChssPly76
ChssPly76

Reputation: 100706

Seeing as how we're talking about pseudo-graphics in console, setting color for individual pixels is impossible with ncurses or any other library :-) so I'm going assume you meant setting colors for each character. That is possible with ncurses as long as your terminal supports colors. You need to invoke attron() function to specify color before you print the character and call attroff() to "unset" the color after character is printed. Prior to that, colors have to be set up for use:

start_color();
init_pair(1, COLOR_RED, COLOR_GREEN); /* create foreground / background combination */
attron(COLOR_PAIR(1)); /* use the above combination */
printw("Some text");
attroff(COLOR_PAIR(1)); /* turn color off */

Details are here

Upvotes: 4

Pierre
Pierre

Reputation: 35246

No, Curses is only for drawing characters, not pixels. If you want another libary, it depends the kind of language you want (C ? XLib, GTK... Java ? AWT, Swing) or if you only want a static image (libpng, svg, postscript...)

Upvotes: 0

Related Questions