ncurses graphics in xterm

Linux specific questions.
Post Reply
d11031971
Posts: 2
Joined: Aug 10, 2017 1:51

ncurses graphics in xterm

Post by d11031971 »

I am trying to use freebasic in an xterm to create simple (blocky) graphics. I assume that in principle ncurses could provide this capability. I cannot figure out how to do this if it is possible. I am not interested in complicated programs. I am trying to re-create the look and feel (and simplicity) of an old Apple IIe BASIC for teaching programming to kids. Any help appreciated. When I use any graphics modes I get errors saying -lX11 etc cannot be found but I have no xserver running, I am using an xterm and/or console.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ncurses graphics in xterm

Post by MrSwiss »

Hi d11031971,

there is a contradiction in your post: xterm or graphics? It's different.
A better approach would be: post the code (you have) here, for all to see ...

Note: put it in between code tags (5th Button from left, above the edit window).
St_W
Posts: 1627
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: ncurses graphics in xterm

Post by St_W »

@d11031971: you don't need any graphics mode to display block elements. They are special (graphical) characters and you simply can use print to write them to the console (see also the links below). All commands you need are probably Print, Color and Locate.

@MrSwiss: it is called 'block graphics' or 'terminal graphics'

See https://en.wikipedia.org/wiki/Semigraph ... k_graphics and https://en.wikipedia.org/wiki/Block_Elements
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ncurses graphics in xterm

Post by MrSwiss »

St_W wrote:@MrSwiss: it is called 'block graphics' or 'terminal graphics'
Could you stop the "hair-splitting" on a reply, to a first time poster?
It's only one thing, digressing from main issue.
d11031971
Posts: 2
Joined: Aug 10, 2017 1:51

Re: ncurses graphics in xterm

Post by d11031971 »

Yes what I am trying to do is a contradiction in modern times and might not make much sense, but with an Apple IIe you could do low res graphics with plot command, etc., and the resolution was not very different from a modern xterm. I will follow the suggestions below with terminal graphics and experiment a bit, and then perhaps wrap the print/locate commands into a plot command with a few mods to freebasic. What I am trying to accomplish is not just to create graphics, but to have the same look and feel of the older systems which I think were great for teaching (simple interface, simple language, simple graphics to motivate kids to be creative). I am familiar with most modern teaching tools and find them lacking for some reason, e.g., the hour of code stuff tries too hard to make programming a game. Again, this is not for serious coding, just for teaching. Thank you for the quick response, and helping me know I am not just missing a library or command line flag. Freebasic looks like a great starting point for what I want to do, and I appreciate all the efforts that go into it.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ncurses graphics in xterm

Post by MrSwiss »

FreeBASIC has something similar to the "plot" you've mentioned, it's called "Draw" ... may be a starting point ...
However, you need a graphic's screen, to run it. (Terminal/Console is no good)
speedfixer
Posts: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: ncurses graphics in xterm

Post by speedfixer »

You probably haven't installed several libraries FB needs for linux.

Install libx11-dev

You probably will run into more libraries missing.
FB loads what it needs, and if graphics aren't used in your test program, you may think all is well.

Also, all terminal/console programs do not behave the same, especially for those graphic block charachters.


David
St_W
Posts: 1627
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: ncurses graphics in xterm

Post by St_W »

d11031971 wrote:[...] with an Apple IIe you could do low res graphics with plot command, etc., and the resolution was not very different from a modern xterm.
I do not know how that low-resolution mode worked on the Apple II (I only used DOS PCs), but according to the documentation the resolution is so low that you can just use graphical characters as mentioned above.

From http://www.calormen.com/jsbasic/reference.html :
PLOT aexpr, aexpr
Plot lores point (x = 0...39, y = 0...39/47)
However, if you need a higher resolution or graphics commands you'll have to install X11. Although FB's graphics library can use the framebuffer device on Linux the compiler wants to link the X11 libraries.
Post Reply