shithub: pico


clone: git:// gits://
push: hjgit://

Last commit

6160f689 – qwx – 2020-03-02T19:30:05-05:00
image name bug fixes


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.


[2] Found in plan9 contrib at /n/sources/contrib/rsc/pico/