pico: a reimplementation of rsc's implementation of pico

A language for composing digital images

This does not really reimplement the pico[1] language, but builds on the same

rsc initially implemented a version in C and YACC[2], which parsed a simplified
language based on pico.
It essentially parses a simple syntax to output a C file which performed the
specified image manipulations in an expression embedded in a simple nested loop.

It was an elegant hack, and possibly worked on plan9port as well as on plan9,
but suffered from a number of bugs and limitations preventing its use in

This repository contains in its initial commit an improved version, which
fixed some of the bugs and added a number of features:

- removal of plan9port code and fixes on some bitrot
- numerous memory leaks fixed
- use of mk(1) instead of hardcoding CC and LD
- arbitrary image sizes, set from loaded images, or 248x248 by default as
- ABGR32 images instead of GREY8 images, with channels accessible via a third
  'z' coordinate
- some parser changes: addition of &&, || operators, integers in octal and
  hexadecimal notation, floating point numbers; accept digits and utf8 runes
  in image names
- always name all images to allow referencing them
- some simple optimizations in the execution, such as not writing images
  multiple times to disk, etc.

However, several problems remained unfixed.
In particular, due to the way it was specified, the parser allocated
an exponential number of strings while processing input.

This, and the need of a few other features, prompted a reimplementation,
this time without YACC, also in the repository, and which was also
unsatisfactory for a number of reasons.

Several reimplementations later, the current pico "implementation" is merely
an awk script, in less than half the size of the initial code.

It does everything the previous versions do, and some more:

- no more memory issues
- excepting image coordinate specifications, the syntax is straight C and
  almost any valid expression (and operator) is allowed; using libc functions
  and definitions such as sqrt(2) or PI is also allowed
- image coordinate specifications needn't always specify all channels
- images are displayed via plumb(1) and subsequently page(1) instead of a
  makeshift viewer
- image names may be any string not containing C operators, whitespace and
  not beginning with a digit
- add a command for specifying default image size when no other images are
- comments via #

Some other features are planned as well.
Manpage pending.


[1] http://doc.cat-v.org/unix/v10/10thEdMan/pico.pdf
[2] Found in plan9 contrib at /n/sources/contrib/rsc/pico/
Last 5 commits (shortlog)
Date Author Short message Commit hash
2020-03-03 qwx image name bug fixes 6160f68952923abe4a620d7fc1e5d2d9e6107448
2020-01-30 qwx reimplement in awk! cfbf70e39b53d3b7578c7e17b8b89b7fd24aa3f5
2020-01-22 qwx parse: use setrealloctag(2) for erealloc (thanks rodri) 630acc0e941f3463a99a4ced0f1611023a69c235
2020-01-22 qwx reimplement without yacc, only to understand that yacc remains a good idea f7cd83ffe6a65578a9f1c89646facbcbfd7179a1
2020-01-19 qwx fork our version of rsc's version of pico 75e473f518dc4a649638bf69fbfa1c48a16a7388
Files (browse)