groff
[Top][All Lists]
Advanced

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

RE: [Groff] pic: "shaded" problem


From: Ted Harding
Subject: RE: [Groff] pic: "shaded" problem
Date: Tue, 13 Sep 2005 18:14:05 +0100 (BST)

On 13-Sep-05 Ole Schoening wrote:
> Dear all,
> 
> the following:
> 
> .PS
> .fam H
> boxrad=0.15
> box shaded "green" width 1.5  "test test" ;
> .PE
> 
> produces no shaded green box (with round corners) but a "normal" one
> without special colours. If I omit the "boxrad" command, then the
> box will be shaded correctly. Typing "box rad 0.15 shaded ..."
> delivers the unwanted result as well. I got these results with groff
> 18.1 under cygwin as well as with gr0ff 19.2 for windows. Does
> anybody have a solution for this problem, how to get round corners
> together with colours?
> 
> Thanks in advance,
> 
> Ole

This is a horrible tangle. To understand it, you need to look at the
output of pic.

If you feed to pic the commands

.PS
.fam H
boxrad=0.15
box fill 0.5 width 1.5  "test test" ;
.PE

(which does produce a filled box, but filled grey), you will see
that it is drawn as follows:

First, 4 separate filled circles of diameter 0.3 inches are drawn
with "\D'C0.300i'", these being the rounded corners of the box.
Then two filled boxes are drawn (with "\D'P ..."), one having
left and right sides being the straight left and right sides of
the final box, with corners at the leftmost and rightmost sides
of the four circles; the other having top and bottom sides being
the straight top and bottom sides of the final box, with corners
at the topmost and bottom-most sides of the four circles.

In this way, the final box with rounded corners is a superposition
of 6 filled objects: two boxes and four circles.

Finally, the border of this is drawn as follows:

a) four circular arcs are drawn with "\D'a...'", being the rounded
   corners;
b) four disjoint straight lines are drawn with "\D'l...'", being
   the straight sides.

So far so good. Now comes the crunch. This is in two parts.

A) The 'fill' attribute in pic generates PostScript code where
   the fill intensity is set using the PS 'setgray' command.
   This has the effect of setting the PS colour space to "gray",
   so you cannot get colour fill using 'fill'.

B) The above mechanism of drawing a filled object (e.g. 4 filled
   circles plus 2 filled boxes) is only invoked in pic with the
   "fill" attribute.

   If you feed pic your code

.PS
.fam H
boxrad=0.15
box shaded "green" width 1.5  "test test" ;
.PE

   it is not invoked; instead you simply get the outline drawn
   in 8 separate parts: arc-line-arc-line-arc-line-arc-line
   as when the outline of the filled box is drawn as above.

   The result is not a "closed path" in the PS sense, so it
   will not be filled anyway.

So, as things stand with pic at the moment, your commands will
not work as you want.

This is is contrast with what heppens if you draw a simple box
with square (not rounded) corners, since this is drawn as a
filled polygon with "\D'P...'".

You can, however, do it with your bare hands, along the same
lines as pic does it for the grey-filled box. You had better
makes this a macro!

For example:

.PS
.fam H
box invis
define colbox {
  boxrad=0;
  B: box invis width $1 height $2
  d = $3 ; h = $2 ; w = $1
  circle rad d at B.sw + (d,d) colored $4
  circle rad d at B.se + (-d,d) colored $4
  circle rad d at B.ne + (-d,-d) colored $4
  circle rad d at B.nw + (d,-d) colored $4
  box width w height h-2*d with .se at B.se + (0,d) colored $4
  box width w-2*d height h with .se at B.se + (-d,0) colored $4
  box invis with .se at B.se width 1.5 height 1.0 
}
.PE
.fam H
.PS
colbox(1.5, 1.0, 0.15, "green")
"test" "test" at B
.PE

Cumbersome, I know; but it works!

Hoping that this helps,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Sep-05                                       Time: 18:04:54
------------------------------ XFMail ------------------------------




reply via email to

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