           Proposal for Writing Modes in PostScript - PGH 10/4/96
           ------------------------------------------------------

Introduction
------------

As discussed at our recent meeting, Laser-Scan have customers who are impeded
by the 'last colour wins' model of PostScript. We feel that if Harlequin were
to put extensions into its RIP to support translucency and colour masking
effects, then this would be a strong selling point against other RIP providers.
The two related facilities needed are writing modes to support translucency,
and protected colours for masking.


Writing Modes
-------------
For mapping (and I'm sure in other application areas) it is quite common to
want to put down particular lines, areas, and texts in a merging mode rather
than an opaque mode. Within our mapping software, we support colour combination
rules for display of maps on workstation screens. It is used to allow areas or
thick lines to be shaded without obliterating the underlying features. For
instance a cartographer may want a built-up area to be shaded brown without
erasing the roads below it, or for all text and linework to show through a
translucent yellow county boundary line. Prioritised sequencing of opaque
colours cannot achieve this result.

We would like to support this ability for hardcopy through PostScript. To do
this, the RIP must look at the existing colour of each pixel that it is writing
(target), as well as the current writing colour (source) and writing mode, in
order to determine what colour the pixel should become.

We currently support 6 writing modes.

    OPAQUE      - The source colour replaces any target colour.
    ADD         - The target colour is combined with the source colour so as
                  to produce a lighter resultant colour.
    SUBTRACT    - The target colour is combined with the source colour so as
                  to produce a darker resultant colour.
    MERGE       - The resultant colour is an average of the target colour
                  and the source colour.
    INVERSE     - A colour complementary to the target colour is written.
                  The source colour is not relevant.
    TRANSPARENT - The target colour is unchanged. The source colour is not
                  relevant.

The exact behaviour of the different colour attributes is as follows (using RGB
definitions - similar rules are possible for CMYK). Assume that 'T' represents
the amount of red, green, or blue in the target pixel, in the range 0.0->1.0,
and 'S' represents the source colour being written. The way that 'T' is
modified is:

     OPAQUE           T = S
     ADD              T = T + S - T*S
     SUB              T = T*S
     MERGE            T = (T + S)/2
     INVERSE          T = 1 - T
     TRANSPARENT      T = T

The behaviour of TRANSPARENT and OPAQUE is fairly obvious. INVERSE produces a
complimentary colour, for instance black<->white, yellow<->blue. 

ADD behaves like additive colours (rays of light) so that for instance red +
green would give yellow. In ADD mode, the resulting colour is always brighter
and nearer to white than the two component colours so that adding black to a
colour leaves it unchanged, while adding white to a colour always produces
white. 

SUB behaves like subtractive colours (paint pigments) so that for instance red
+ green would give black, while yellow + cyan would give green. In SUB mode,
the resulting colour is always darker and nearer to black than the two
component colours so that adding black to a colour produces black, while adding
white to a colour leaves the colour unchanged. 

MERGE produces an effect intermediate to ADD and SUB - the two colours are
averaged producing something intermediate in colour and brightness to the
originals. 

We envisage that a new PostScript operator would be needed to set the current
writing mode to one of the 6 above, defaulting to OPAQUE for compatability.


Protected Colours
-----------------
While support for writing modes as described above would solve many problems,
and be sufficient for many customers, for some customers a further facility
would be needed to achieve the results they desire. This is an ability to
protect certain colours which have been previously written, to prevent them
being overwritten by new graphics. This would not be used often, but is vital
to achieve certain traditional representations. This mechanism is often called
masking, from the traditional photographic techniques used to achieve it.

An example is where a coloured box around a text label should erase minor
detail which would make it difficult to read the text, but shouldn't erase
important features such as primary roads. In many cases, this can be achieved
using opaque colours put down in a priority sequence, but unfortunately there
are cases which can't. A simple example is three lines crossing each other
(red, blue, and green), where red should win over blue, blue should win over
green, but green should win over red.

To provide this facility, again the RIP would have to look at the existing
colour of the target pixels, and if they were in a list of protected colours
previously set up, then treat the writing colour as transparent for those
pixels.

We envisage that a new PostScript operator would be needed to protect a
given colour, and to remove a given colour from the protected set.


Summary
-------
The 'last colour wins' model of PostScript is an impediment to use of
PostScript in the cartographic industry, and doubtless in other industries
needing similar graphic capabilities. Two extensions to PostScript are proposed
to overcome these limitations. If Harlequin were to put extensions into its RIP
to support translucency and colour protection effects, then this would be a
strong selling point against other RIP providers.


---
Paul Hardy (PGH), Product Manager (former Chief Programmer)
Laser-Scan Ltd, Science Park, Milton Rd, CAMBRIDGE, CB4 4FY, England.
Tel: (+44) (0)1223 420414; Fax: 420044, Email: PAUL@LSL.CO.UK
     Good judgement is the result of experience ...
     ... Experience is the result of bad judgement. (Fred Brooks)
