[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 16:28:02 +0100 (BST) |
And, finally (for the moment -- more to come when I've thought
about some aspects a bit more) here is an example for colouring
in nested polygons (such as might be used for a contour plot).
The trick here is defining a function "mkpoly" in PIC to construct,
within troff, a string variable \*[poly] which contains the
displacements vector for the "\D'P ...'" command to troff.
This is then invoked from PIC with
"\D'P \*[poly]'" at (<wherever>)
where <wherever> is the starting-point from which "\D'P ... '" draws.
The following example draws a series of four 8-sided approximations
to ellipses, nested within each other and with different colours.
8<-------------------------------------------------
.PS 5i
start=1
define mkpoly {
if start then {
command sprintf(".ds poly \"\" ")
start = 0
}
command sprintf(".ds poly \*[poly] %.3fi %.3fi",$1,$2)
}
line from (0,0) to (5,0) to (5,5) to (0,5) to (0,0)
start=1
copy thru mkpoly until "EOT"
-0.439 0.707
-1.061 0.293
-1.061 -0.293
-0.439 -0.707
0.439 -0.707
1.061 -0.293
1.061 0.293
0.439 0.707
EOT
"\X' ps: exec 0.0 1.0 0.0 setrgbcolor'"
"\D'P \*[poly]'" at (4.0,2.5)
start=1
copy thru mkpoly until "EOT"
-0.330 0.530
-0.795 0.220
-0.795 -0.220
-0.330 -0.530
0.330 -0.530
0.795 -0.220
0.795 0.220
0.330 0.530
EOT
"\X' ps: exec 0.7 0.3 0.0 setrgbcolor'"
"\D'P \*[poly]'" at (3.75,2.5)
start=1
copy thru mkpoly until "EOT"
-0.220 0.354
-0.530 0.146
-0.530 -0.146
-0.220 -0.354
0.220 -0.354
0.530 -0.146
0.530 0.146
0.220 0.354
EOT
"\X' ps: exec 0.85 0.2 0.0 setrgbcolor'"
"\D'P \*[poly]'" at (3.60,2.5)
start=1
copy thru mkpoly until "EOT"
-0.110 0.1768
-0.265 0.0732
-0.265 -0.0732
-0.110 -0.1768
0.110 -0.1768
0.265 -0.0732
0.265 0.0732
0.110 0.1768
EOT
"\X' ps: exec 1.00 0.0 0.75 setrgbcolor'"
"\D'P \*[poly]'" at (3.50,2.5)
.PE
8<-------------------------------------------------
For example, the value of "\*[poly]" in the last case is
"-0.110 0.1768 -0.265 0.0732 -0.265 -0.0732 -0.110 -0.1768 \
0.110 -0.1768 0.265 -0.0732 0.265 0.0732 0.110 0.1768"
--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Sep-09 Time: 16:27:56
------------------------------ XFMail ------------------------------