[Top][All Lists]

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

Re: [Groff] A tip for arbitrary colours in PIC

From: Ted Harding
Subject: Re: [Groff] A tip for arbitrary colours in PIC
Date: Sun, 13 Sep 2009 14:39:02 +0100 (BST)

On 13-Sep-09 13:05:42, Ted Harding wrote:
> [...]
> The main problem I'm still trying to find a good solution for is how
> to fill an arbitrary closed contour with a chosen colour (this also
> applies to colours which are defined, like "red" etc.).
> The PIC objects which can be filled or coloured without special
> manoeuvres are limited to "box," "circle" and "ellipse", and things
> which can be constructed "Lego" style from these. Even a triangle
> is not an avaiable entity (which could be useable for filling a
> closed contour by triangulating its interior, working round from
> a fixed internal point).
> The line of solution I am thinking about just now involves using
> PIC to compute a troff "\D'P ...'" command, since this will draw
> a filled (in the ambient colour) closed polygon. However, there
> are issues in integrating this with the rest of a picture drawn
> using PIC!
> More later ...
> Ted.

... And, as something to contemplate meanwhile, here is an example
of how to use "D'P ...'" to draw a filled polygon (interpolated
in the previous drawing of red/green shading with box and circle):


.PS 5i
for i=0 to 1000 do {
  red = i/1000 ; green = 1-red ; blue = red*green
  sprintf("\Z\'\X\'ps: exec %.4f %.4f 0 setrgbcolor\'\'",red,green)
  line from (0,5*i/1000) to (5,5*i/1000) thick 0.5
"\Z'\X'ps: exec 0.15 1.00 0.45 setrgbcolor''"
"\D'P 1i -1i 3i 0 1i 1i -1i 1i -3i 0 -1i -1i'"  at (0,2.5)
"\Z'\X'ps: exec 1 0 1 setrgbcolor''"
box wid 1 ht 1 at (2.5,2.5) colour "wombat"
"\Z'\X'ps: exec 0.50 0.25 0.85 setrgbcolor''"
circle rad 0.25 at (2.5,2.5) colour "as-is"
line from (0,0) to (5,0) to (5,5) to (0,5) to (0,0) colour "black"
\X'ps: exec 1 1 1 setrgbcolor'\c
\fBExample of Colour Shading with Box, Circle and Polygon\fP


The problem here is that the displacements in the "\D'P ...'"
command are interpreted by troff in absolute units on the page,
and are not influenced by the rescaling of the PIC graphics
which is applied by the ".PS" request -- to see this, change
the ".PS 5i" to ".PS 4i".

Or insert the PIC commabd

  line from (-2,5) to (7,5)

below ".PS 5i"

So the coordinates of the polygon are not integrated with the
coordinates produced by PIC.

It is of course possible in any particular case to work round this
by ensuring that the coordinates being used in the PIC code are
exactly what will be required in the page. But this could turn out
to be hard work (e.g. if the polygon is being drawn on the basis
of a data file, computed by an external program, which was being
read by PIC).


E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Sep-09                                       Time: 14:38:59
------------------------------ XFMail ------------------------------

reply via email to

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