groff
[Top][All Lists]
Advanced

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

Re: [Groff] A little Greetings card


From: Ted Harding
Subject: Re: [Groff] A little Greetings card
Date: Tue, 29 Dec 2009 18:00:02 -0000 (GMT)

On 29-Dec-09 16:27:32, Jan-Herbert Damm wrote:
> Thanks to both of you, now i see: it *is* beautiful!
> 
> Werner LEMBERG wrote on 29.12.09:
>> BTW, the necessary command line options for groff for
>> file `foo' can be guessed with the `grog foo' command.
> oh, good! it did show me the correct command.
> 
> jan

Well, that little picture provoked quite a discussion!
I have now revised the PIC code to make it more "respectable".
Also, it should now be immune to any trailing spaces that may
creep in (no "\" at end-of-line in this one). The final version
is below.

I should explain how this came about. Initially, I was playing
with methods for rotating geometrical objects in PIC (see below),
and drew a few rotated ellipses. Then I decided to try a full
sweep of 12 rotated ellipses, just for fun. Then I realised that
this could be extended to create a picture of a flower, so then
I did that, and then it became a good idea to send it to you all
as a Greetings Card.

So far so good. But what you got was an input file which had been
built incrementally, as described above. The new version below
encapsulates the repetitive code into a definition (with resulting
much more compact code and shorter lines).

Rotating Objects (Discussion)
There is no provision in PIC to give a geometrical object (e.g. box,
ellipse) a "rotated" attribute. The only thing that can be rotated
is a text string, which you attach to an object which has been
given the "aligned" attribute (the text then lines up on the line
from the start-point to the end-point of the object, and by default
is centred on the midpoint of the line).

However, any object which PIC can draw can be drawn using the groff
escape "\D' .... '" with suitable replaqement for "...." (this is
how groff does it). And the "\D..." can be incorporated into a
text string which can then be aligned in any direction (by first
drawing an invisible line, as is done in my code). Since the effect
of using the "aligned" attribute is to enclose the text inside a
PostScript rotation wrapper, if the text draws on object then that
object will be rotated so as to be aligned with the invisible line.

That was the theory behind the experiment, and you have seen the
result of the experiment!

However, to a large extent one has to hand-code positions and
dimensions -- PIC's built-in ability to keep track of positions
etc is slightly out of reach. Code like what I wrote can be
parametrised to some extent, but something like
  line from 2nd last ellipse .ne to last ellipse .sw
does not drop directly into your hand!

So I am pondering techniques for this kind of thing.

Just a few thoughts -- and comments would be welcome.

Ted.
Now for the revised code for the flower:


.ds RED \X'ps: exec 1    0   0   setrgbcolor'
.ds GR0 \X'ps: exec 0    0.5 0   setrgbcolor'
.ds YEL \X'ps: exec 0    0   1 0 setcmykcolor'
.ds CY0 \X'ps: exec 0.25 0   0 0 setcmykcolor'
.blm
.PS
### Groff command: groff -Tps -p input.tr > output.ps
define sweep {
  for i=0 to 11 do {
    t = 2*pi*i/24
    x0 = 2*cos(t) ; y0 = 2*sin(t)
    line invis from (-x0,-y0) to (x0,y0) $1 aligned
  }
}
pi = 4*atan2(1,1)
sweep("\*[RED]\v'-0.22m'\D'E 2.0i 0.5i'\v'0.22m'")
sweep("\*[CY0]\v'-0.22m'\D'e 2.0i 0.5i'\v'0.22m'")
"\v'-0.22m'\*[YEL]\D'C 0.50i'\v'0.22m'" at (0,0)
sweep("\*[GR0]\v'-0.22m'\D'e 0.5i 0.125i'\v'0.22m'")
.PE




--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 29-Dec-09                                       Time: 17:59:59
------------------------------ XFMail ------------------------------




reply via email to

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