help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

awk and graphics


From: Miriam English
Subject: awk and graphics
Date: Sun, 5 Nov 2023 19:10:02 +1000

Does anybody know some simple, fast, screen display extension that awk
can use?

I've been fiddling around with some of my old cellular automata
programs and have translated them to a few languages, including awk. I
haven't found any way to output graphics to the screen directly from
awk, so I've made it write to a .pbm image file. The great advantage of
this is that pbm is an ascii format, and easy to write to from awk.
(I've attached a pbm file of a cellular automaton, and another converted
to png in case you can't view pbm. It is an old format.)

I previously made a small python program that wrote to the screen using
John Zelle's graphics.py library which sits on top of tkinter. (This
is all on Linux.) I was surprised to find it took 12 minutes to render
a 256x192 pixel image. That was more than twice as long as the 5
minutes my ancient Tandy Color Computer (CoCo) emulator running at full
speed. (At original speed the CoCo would take a bit more than an hour.)

What was even more surprising to me is that awk writing directly to a
pbm file took less than a tenth of a second to create the same image.

When I rewrote the python program to output to a pbm image file too, it
took a little more than a tenth of a second -- much faster than writing
to the screen, but awk is still faster. :)

I have found awkGL https://github.com/takubo/awkGL but it doesn't
compile on my machine and I don't know enough about C to fix it. Also
OpenGL feels like overkill. I really only need to set and query pixels.

I also found awk-glib https://github.com/patsie75/awk-glib which is a
cunning way to use ANSI graphics to generate pictures from awk, but the
results are of course very low resolution. I could run it from a
terminal set to a very small font size, but it's not really what I'm
looking for.

Unfortunately there are some other experiments I want to do in which
being able to see the image update in real time is a big advantage.

Anybody know of something I can use?

Thanks,

 - Miriam

-- 
There are two wolves and they're always fighting.
One is darkness and despair. The other is light and hope.
Which wolf wins?
Whichever one you feed.
  -- Casey in Brad Bird's movie "Tomorrowland"

Attachment: ca-rule30-pbm-converted-to-png.png
Description: PNG image

Attachment: ca-rule30.pbm
Description: Portable bitmap


reply via email to

[Prev in Thread] Current Thread [Next in Thread]